mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
Clippy
This commit is contained in:
parent
fd17684882
commit
ba0ffa0fc7
3 changed files with 11 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -39,6 +39,9 @@ npm-debug.log
|
||||||
# Intellij IDEA
|
# Intellij IDEA
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode
|
||||||
|
|
||||||
# ElixirLS
|
# ElixirLS
|
||||||
.elixir_ls
|
.elixir_ls
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,12 @@ rustler::init! {
|
||||||
// Markdown NIF wrappers.
|
// Markdown NIF wrappers.
|
||||||
|
|
||||||
#[rustler::nif(schedule = "DirtyCpu")]
|
#[rustler::nif(schedule = "DirtyCpu")]
|
||||||
fn markdown_to_html<'a>(input: String, reps: Term<'a>) -> String {
|
fn markdown_to_html(input: String, reps: Term) -> String {
|
||||||
markdown::to_html(input, reps)
|
markdown::to_html(input, reps)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustler::nif(schedule = "DirtyCpu")]
|
#[rustler::nif(schedule = "DirtyCpu")]
|
||||||
fn markdown_to_html_unsafe<'a>(input: String, reps: Term<'a>) -> String {
|
fn markdown_to_html_unsafe(input: String, reps: Term) -> String {
|
||||||
markdown::to_html_unsafe(input, reps)
|
markdown::to_html_unsafe(input, reps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ fn common_options() -> ComrakOptions {
|
||||||
|
|
||||||
options.extension.camoifier = Some(|s| camo::image_url(s).unwrap_or_else(|| String::from("")));
|
options.extension.camoifier = Some(|s| camo::image_url(s).unwrap_or_else(|| String::from("")));
|
||||||
|
|
||||||
if let Some(domains) = env::var("SITE_DOMAINS").ok() {
|
if let Ok(domains) = env::var("SITE_DOMAINS") {
|
||||||
options.extension.philomena_domains = Some(domains.split(",").map(|s| s.to_string()).collect::<Vec<String>>());
|
options.extension.philomena_domains = Some(domains.split(',').map(|s| s.to_string()).collect::<Vec<String>>());
|
||||||
};
|
}
|
||||||
|
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_to_hashmap<'a>(map: Term<'a>) -> Option<HashMap<String, String>> {
|
fn map_to_hashmap(map: Term) -> Option<HashMap<String, String>> {
|
||||||
Some(MapIterator::new(map)?.map(|(key, value)| {
|
Some(MapIterator::new(map)?.map(|(key, value)| {
|
||||||
let key: String = key.decode().unwrap_or_else(|_| String::from(""));
|
let key: String = key.decode().unwrap_or_else(|_| String::from(""));
|
||||||
let value: String = value.decode().unwrap_or_else(|_| String::from(""));
|
let value: String = value.decode().unwrap_or_else(|_| String::from(""));
|
||||||
|
@ -34,7 +34,7 @@ fn map_to_hashmap<'a>(map: Term<'a>) -> Option<HashMap<String, String>> {
|
||||||
}).collect())
|
}).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_html<'a>(input: String, reps: Term<'a>) -> String {
|
pub fn to_html(input: String, reps: Term) -> String {
|
||||||
let mut options = common_options();
|
let mut options = common_options();
|
||||||
options.render.escape = true;
|
options.render.escape = true;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ pub fn to_html<'a>(input: String, reps: Term<'a>) -> String {
|
||||||
comrak::markdown_to_html(&input, &options)
|
comrak::markdown_to_html(&input, &options)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_html_unsafe<'a>(input: String, reps: Term<'a>) -> String {
|
pub fn to_html_unsafe(input: String, reps: Term) -> String {
|
||||||
let mut options = common_options();
|
let mut options = common_options();
|
||||||
options.render.unsafe_ = true;
|
options.render.unsafe_ = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue