add: community settings ui
TODO: add community read/write access settings TODO: add profile settings TODO: profile following in ui TODO: community joining and membership management in ui
This commit is contained in:
parent
eecf357325
commit
6413ed09fb
20 changed files with 855 additions and 46 deletions
|
@ -1,4 +1,5 @@
|
|||
pub mod hash;
|
||||
pub mod markdown;
|
||||
pub mod snow;
|
||||
pub mod time;
|
||||
|
||||
|
|
44
crates/shared/src/markdown.rs
Normal file
44
crates/shared/src/markdown.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
use ammonia::Builder;
|
||||
use comrak::{Options, markdown_to_html};
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// Render markdown input into HTML
|
||||
pub fn render_markdown(input: &str) -> String {
|
||||
let mut options = Options::default();
|
||||
|
||||
options.extension.table = true;
|
||||
options.extension.superscript = true;
|
||||
options.extension.strikethrough = true;
|
||||
options.extension.autolink = true;
|
||||
options.extension.header_ids = Option::Some(String::new());
|
||||
options.extension.tagfilter = true;
|
||||
options.render.unsafe_ = true;
|
||||
// options.render.escape = true;
|
||||
options.parse.smart = false;
|
||||
|
||||
let html = markdown_to_html(input, &options);
|
||||
|
||||
let mut allowed_attributes = HashSet::new();
|
||||
allowed_attributes.insert("id");
|
||||
allowed_attributes.insert("class");
|
||||
allowed_attributes.insert("ref");
|
||||
allowed_attributes.insert("aria-label");
|
||||
allowed_attributes.insert("lang");
|
||||
allowed_attributes.insert("title");
|
||||
allowed_attributes.insert("align");
|
||||
|
||||
allowed_attributes.insert("data-color");
|
||||
allowed_attributes.insert("data-font-family");
|
||||
|
||||
Builder::default()
|
||||
.generic_attributes(allowed_attributes)
|
||||
.clean(&html)
|
||||
.to_string()
|
||||
.replace(
|
||||
"src=\"",
|
||||
"loading=\"lazy\" src=\"/api/v1/util/ext/image?img=",
|
||||
)
|
||||
.replace("-->", "<align class=\"right\">")
|
||||
.replace("->", "<align class=\"center\">")
|
||||
.replace("<-", "</align>")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue