Merge branch 'main' into main
This commit is contained in:
commit
8f5a86206a
53
Cargo.lock
generated
53
Cargo.lock
generated
@ -992,9 +992,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "devise"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74e04ba2d03c5fa0d954c061fc8c9c288badadffc272ebb87679a89846de3ed3"
|
||||
checksum = "dd716c4a507adc5a2aa7c2a372d06c7497727e0892b243d3036bc7478a13e526"
|
||||
dependencies = [
|
||||
"devise_codegen",
|
||||
"devise_core",
|
||||
@ -1002,9 +1002,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "devise_codegen"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "066ceb7928ca93a9bedc6d0e612a8a0424048b0ab1f75971b203d01420c055d7"
|
||||
checksum = "ea7b8290d118127c08e3669da20b331bed56b09f20be5945b7da6c116d8fab53"
|
||||
dependencies = [
|
||||
"devise_core",
|
||||
"quote 0.6.13",
|
||||
@ -1012,9 +1012,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "devise_core"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf41c59b22b5e3ec0ea55c7847e5f358d340f3a8d6d53a5cf4f1564967f96487"
|
||||
checksum = "d1053e9d5d5aade9bcedb5ab53b78df2b56ff9408a3138ce77eaaef87f932373"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"proc-macro2 0.4.30",
|
||||
@ -1703,12 +1703,6 @@ dependencies = [
|
||||
"ahash 0.7.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
@ -2896,9 +2890,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.10.0"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
|
||||
|
||||
[[package]]
|
||||
name = "onig"
|
||||
@ -3067,9 +3061,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pear"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5320f212db967792b67cfe12bd469d08afd6318a249bd917d5c19bc92200ab8a"
|
||||
checksum = "32dfa7458144c6af7f9ce6a137ef975466aa68ffa44d4d816ee5934018ba960a"
|
||||
dependencies = [
|
||||
"pear_codegen",
|
||||
]
|
||||
@ -3265,12 +3259,11 @@ dependencies = [
|
||||
"chrono",
|
||||
"flume",
|
||||
"futures 0.3.21",
|
||||
"heck",
|
||||
"hex",
|
||||
"once_cell",
|
||||
"openssl",
|
||||
"pulldown-cmark",
|
||||
"regex-syntax 0.6.25",
|
||||
"regex-syntax 0.6.26",
|
||||
"reqwest 0.11.10",
|
||||
"rocket",
|
||||
"serde 1.0.137",
|
||||
@ -3776,7 +3769,7 @@ checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax 0.6.25",
|
||||
"regex-syntax 0.6.26",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3787,9 +3780,9 @@ checksum = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.25"
|
||||
version = "0.6.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
@ -3952,9 +3945,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket"
|
||||
version = "0.4.10"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a7ab1dfdc75bb8bd2be381f37796b1b300c45a3c9145b34d86715e8dd90bf28"
|
||||
checksum = "83b9d9dc08c5dcc1d8126a9dd615545e6a358f8c13c883c8dfed8c0376fa355e"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"base64 0.13.0",
|
||||
@ -3973,9 +3966,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_codegen"
|
||||
version = "0.4.10"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1729e687d6d2cf434d174da84fb948f7fef4fac22d20ce94ca61c28b72dbcf9f"
|
||||
checksum = "2810037b5820098af97bd4fdd309e76a8101ceb178147de775c835a2537284fe"
|
||||
dependencies = [
|
||||
"devise",
|
||||
"glob",
|
||||
@ -3988,9 +3981,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_contrib"
|
||||
version = "0.4.10"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b6303dccab46dce6c7ac26c9b9d8d8cde1b19614b027c3f913be6611bff6d9b"
|
||||
checksum = "e20efbc6a211cb3df5375accf532d4186f224b623f39eca650b19b96240c596b"
|
||||
dependencies = [
|
||||
"log 0.4.17",
|
||||
"notify",
|
||||
@ -4013,9 +4006,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_http"
|
||||
version = "0.4.10"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6131e6e6d38a9817f4a494ff5da95971451c2eb56a53915579fc9c80f6ef0117"
|
||||
checksum = "2bf9cbd128e1f321a2d0bebd2b7cf0aafd89ca43edf69e49b56a5c46e48eb19f"
|
||||
dependencies = [
|
||||
"cookie 0.11.4",
|
||||
"hyper 0.10.16",
|
||||
@ -4554,7 +4547,7 @@ dependencies = [
|
||||
"lazycell",
|
||||
"onig",
|
||||
"plist",
|
||||
"regex-syntax 0.6.25",
|
||||
"regex-syntax 0.6.26",
|
||||
"serde 1.0.137",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
|
@ -15,8 +15,8 @@ gettext-utils = "0.1.0"
|
||||
guid-create = "0.2"
|
||||
lettre_email = "0.9.2"
|
||||
num_cpus = "1.10"
|
||||
rocket = "0.4.6"
|
||||
rocket_contrib = { version = "0.4.5", features = ["json"] }
|
||||
rocket = "0.4.11"
|
||||
rocket_contrib = { version = "0.4.11", features = ["json"] }
|
||||
rocket_i18n = "0.4.1"
|
||||
scheduled-thread-pool = "0.2.2"
|
||||
serde = "1.0"
|
||||
|
@ -7,17 +7,16 @@ edition = "2018"
|
||||
[dependencies]
|
||||
array_tool = "1.0"
|
||||
base64 = "0.13"
|
||||
heck = "0.4.0"
|
||||
hex = "0.4"
|
||||
openssl = "0.10.40"
|
||||
rocket = "0.4.6"
|
||||
rocket = "0.4.11"
|
||||
reqwest = { version = "0.11.10", features = ["blocking", "json", "socks"] }
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0.81"
|
||||
shrinkwraprs = "0.3.0"
|
||||
syntect = "4.5.0"
|
||||
regex-syntax = { version = "0.6.17", default-features = false, features = ["unicode-perl"] }
|
||||
regex-syntax = { version = "0.6.26", default-features = false, features = ["unicode-perl"] }
|
||||
tracing = "0.1.34"
|
||||
askama_escape = "0.10.3"
|
||||
activitystreams = "0.7.0-alpha.18"
|
||||
@ -38,6 +37,6 @@ branch = "bidi-plume"
|
||||
|
||||
[dev-dependencies]
|
||||
assert-json-diff = "2.0.1"
|
||||
once_cell = "1.10.0"
|
||||
once_cell = "1.12.0"
|
||||
|
||||
[features]
|
||||
|
@ -1,4 +1,3 @@
|
||||
use heck::ToUpperCamelCase;
|
||||
use openssl::rand::rand_bytes;
|
||||
use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag};
|
||||
use regex_syntax::is_word_character;
|
||||
@ -16,14 +15,6 @@ pub fn random_hex() -> String {
|
||||
.fold(String::new(), |res, byte| format!("{}{:x}", res, byte))
|
||||
}
|
||||
|
||||
/// Remove non alphanumeric characters and CamelCase a string
|
||||
pub fn make_actor_id(name: &str) -> String {
|
||||
name.to_upper_camel_case()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent-encode characters which are not allowed in IRI path segments.
|
||||
*
|
||||
|
@ -13,7 +13,7 @@ lazy_static = "1.0"
|
||||
ldap3 = "0.10.5"
|
||||
migrations_internals= "1.4.0"
|
||||
openssl = "0.10.40"
|
||||
rocket = "0.4.6"
|
||||
rocket = "0.4.11"
|
||||
rocket_i18n = "0.4.1"
|
||||
reqwest = "0.11.10"
|
||||
scheduled-thread-pool = "0.2.2"
|
||||
@ -31,7 +31,7 @@ glob = "0.3.0"
|
||||
lindera-tantivy = { version = "0.7.1", optional = true }
|
||||
tracing = "0.1.34"
|
||||
riker = "0.4.2"
|
||||
once_cell = "1.10.0"
|
||||
once_cell = "1.12.0"
|
||||
lettre = "0.9.6"
|
||||
native-tls = "0.2.10"
|
||||
activitystreams = "0.7.0-alpha.18"
|
||||
|
@ -95,6 +95,10 @@ 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);
|
||||
|
||||
pub fn slug(title: &str) -> &str {
|
||||
title
|
||||
}
|
||||
|
||||
pub fn get_instance(&self, conn: &Connection) -> Result<Instance> {
|
||||
Instance::get(conn, self.instance_id)
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ pub struct NewBlogForm {
|
||||
}
|
||||
|
||||
fn valid_slug(title: &str) -> Result<(), ValidationError> {
|
||||
let slug = utils::make_actor_id(title);
|
||||
let slug = Blog::slug(title);
|
||||
if slug.is_empty() {
|
||||
Err(ValidationError::new("empty_slug"))
|
||||
} else {
|
||||
@ -93,7 +93,7 @@ pub fn create(
|
||||
conn: DbConn,
|
||||
rockets: PlumeRocket,
|
||||
) -> RespondOrRedirect {
|
||||
let slug = utils::make_actor_id(&form.title);
|
||||
let slug = Blog::slug(&form.title);
|
||||
let intl = &rockets.intl.catalog;
|
||||
let user = rockets.user.clone().unwrap();
|
||||
|
||||
@ -101,7 +101,7 @@ pub fn create(
|
||||
Ok(_) => ValidationErrors::new(),
|
||||
Err(e) => e,
|
||||
};
|
||||
if Blog::find_by_fqn(&conn, &slug).is_ok() {
|
||||
if Blog::find_by_fqn(&conn, slug).is_ok() {
|
||||
errors.add(
|
||||
"title",
|
||||
ValidationError {
|
||||
@ -122,7 +122,7 @@ pub fn create(
|
||||
let blog = Blog::insert(
|
||||
&conn,
|
||||
NewBlog::new_local(
|
||||
slug.clone(),
|
||||
slug.into(),
|
||||
form.title.to_string(),
|
||||
String::from(""),
|
||||
Instance::get_local()
|
||||
@ -379,6 +379,7 @@ pub fn atom_feed(name: String, conn: DbConn) -> Option<Content<String>> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::valid_slug;
|
||||
use crate::init_rocket;
|
||||
use diesel::Connection;
|
||||
use plume_common::utils::random_hex;
|
||||
@ -524,4 +525,10 @@ mod tests {
|
||||
.finish(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_valid_slug() {
|
||||
assert!(valid_slug("Blog Title").is_ok());
|
||||
assert!(valid_slug("ブログ タイトル").is_ok());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user