Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add url_encode helper #102

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tokio = { version = "1.20.1", features = ["macros"] }

# To extract the base URI
url = "2.2.2"
urlencoding = "2.1.3"

# CLI
clap = { version = "4.4.12", features = ["derive", "env"] }
Expand Down
2 changes: 2 additions & 0 deletions src/gooseberry/knowledge_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
}

handlebars_helper!(date_format: |format: str, date: Json| format_date(format, date).map_err(|e| RenderError::from_error("serde_json", e))?);
handlebars_helper!(url_encode: |s: str| {urlencoding::encode(s).to_string()});

pub(crate) struct Templates<'a> {
pub(crate) annotation_template: &'a str,
Expand All @@ -110,6 +111,7 @@
handlebars_misc_helpers::register(&mut hbs);
hbs.register_escape_fn(handlebars::no_escape);
hbs.register_helper("date_format", Box::new(date_format));
hbs.register_helper("url_encode", Box::new(url_encode));
hbs.register_template_string("annotation", templates.annotation_template)?;
hbs.register_template_string("page", templates.page_template)?;
hbs.register_template_string("index_link", templates.index_link_template)?;
Expand Down Expand Up @@ -355,7 +357,7 @@
// Index file has links to each page
let mut index_links = vec![];
struct RecurseFolder<'s> {
f: &'s dyn Fn(

Check warning on line 360 in src/gooseberry/knowledge_base.rs

View workflow job for this annotation

GitHub Actions / Clippy

very complex type used. Consider factoring parts into `type` definitions

Check warning on line 360 in src/gooseberry/knowledge_base.rs

View workflow job for this annotation

GitHub Actions / Clippy

very complex type used. Consider factoring parts into `type` definitions
&RecurseFolder,
Vec<AnnotationTemplate>,
PathBuf,
Expand Down
Loading