lehen commita
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use heck::ToUpperCamelCase;
|
||||
use crate::{
|
||||
instance::*, medias::Media, posts::Post, safe_string::SafeString, schema::blogs, users::User,
|
||||
Connection, Error, PlumeRocket, Result, CONFIG, ITEMS_PER_PAGE,
|
||||
@@ -102,9 +103,18 @@ impl Blog {
|
||||
find_by!(blogs, find_by_ap_url, ap_url as &str);
|
||||
find_by!(blogs, find_by_name, actor_id as &str, instance_id as i32);
|
||||
|
||||
/// Remove non alphanumeric characters and CamelCase a string
|
||||
pub fn slug(title: &str) -> String {
|
||||
title.to_upper_camel_case()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric())
|
||||
.collect()
|
||||
}
|
||||
/*
|
||||
pub fn slug(title: &str) -> &str {
|
||||
title
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn get_instance(&self, conn: &Connection) -> Result<Instance> {
|
||||
Instance::get(conn, self.instance_id)
|
||||
|
||||
Reference in New Issue
Block a user