Merge commit 'c415667263386faceadb8246e2ec370803846aff'
All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 1m13s

# Conflicts:
#	src/law.rs
This commit is contained in:
Marie Birner 2024-02-21 14:42:03 +01:00
commit 6cba130bc1
3 changed files with 13 additions and 15 deletions

8
Cargo.lock generated
View File

@ -97,12 +97,9 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
[[package]]
name = "cc"
version = "1.0.83"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730"
[[package]]
name = "cfg-if"
@ -527,6 +524,7 @@ dependencies = [
[[package]]
name = "risp"
version = "0.1.0"
source = "git+https://git.hofer.link/philipp/risp.git#ad8d5d828e508bd2186e3b6a8ad6f92c6e1baf67"
dependencies = [
"clap",
"directories",

View File

@ -39,10 +39,10 @@ fn print_paragraph(section: Section) -> String {
ret.push_str("<div class='par'>");
ret.push_str(&format!("<span class='symb'>{}</span>", section.symb));
if let Some(par_header) = section.par_header {
ret.push_str(&format!("<span class='header'>{}</span>", par_header));
ret.push_str(&format!("<span class='header'>{par_header}</span>"));
}
if let Some(note) = section.par_note {
ret.push_str(&format!("<span class='note'>Beachte: {}</span>", note));
ret.push_str(&format!("<span class='note'>Beachte: {note}</span>"));
}
ret.push_str(&print_content(section.content));
@ -54,7 +54,7 @@ fn print_header(header: Heading, level: usize) -> String {
let mut ret = String::new();
let mut header_title = header.name.clone();
if let Some(desc) = header.desc {
header_title.push_str(&format!(" ({desc})"))
header_title.push_str(&format!(" ({desc})"));
}
ret.push_str(&format!(
@ -96,15 +96,15 @@ fn get_content(config_path: &str) -> (String, String) {
pub(crate) fn create_law_files() -> String {
let mut configs: Vec<_> = fs::read_dir("./laws")
.unwrap()
.map(|r| r.unwrap())
.map(std::result::Result::unwrap)
.collect();
configs.sort_by_key(|dir| dir.path()); // Order by name
//
configs.sort_by_key(std::fs::DirEntry::path); // Order by name
let mut li_of_files = String::new();
for config in configs {
let filename = config.file_name().into_string().unwrap();
//TODO: use proper logic...
let law_name = filename.replace(".toml", "");
let law_filename = filename.replace(".toml", "");
let path = format!("{}", config.path().display());
let (lawname, content) = get_content(&path);
@ -117,9 +117,9 @@ pub(crate) fn create_law_files() -> String {
let site = Parts::new().perform(site);
li_of_files.push_str(&format!(
"<li data-filterable='true' data-filter='{lawname} {law_name}'><a href='./{law_name}' title='{law_name}' class='contrast'>{lawname}</a></li>"
"<li data-filterable='true' data-filter='{lawname} {law_filename}'><a href='./{law_filename}' title='{law_filename}' class='contrast'>{lawname}</a></li>"
));
fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
fs::write(&format!("output/{law_filename}.html"), &site).expect("Unable to write file");
}
li_of_files

View File

@ -24,7 +24,7 @@ impl Parts {
pub(crate) fn perform(&self, input: String) -> String {
let mut input = input;
for (key, value) in &self.parts {
let replace = format!("{{{{{}}}}}", key);
let replace = format!("{{{{{key}}}}}");
input = input.replace(&replace, value);
}
input