diff --git a/src/law.rs b/src/law.rs index 2975700..2afa837 100644 --- a/src/law.rs +++ b/src/law.rs @@ -2,6 +2,8 @@ use std::fs; use risp::law::{Content, Heading, HeadingContent, Law, Section}; +use crate::part::Parts; + fn print_content(content: Content) -> String { let mut ret = String::new(); @@ -114,6 +116,8 @@ pub(crate) fn create_law_files() -> String { .replace("{{content}}", &content) .replace("{{title}}", &lawname); + let site = Parts::new().perform(site); + li_of_files.push_str(&format!( "
  • {lawname}
  • " )); diff --git a/src/main.rs b/src/main.rs index f80a46c..18a2106 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ use std::{fs, path::Path}; +use part::Parts; + mod law; +mod part; fn main() { fs::create_dir_all("./output").unwrap(); @@ -15,6 +18,7 @@ fn main() { fn create_index(content: &str) { let mut index = fs::read_to_string("templates/index.html").unwrap(); index = index.replace("{{content}}", content); + let index = Parts::new().perform(index); fs::write("output/index.html", &index).expect("Unable to write file"); } diff --git a/src/part.rs b/src/part.rs new file mode 100644 index 0000000..2217b63 --- /dev/null +++ b/src/part.rs @@ -0,0 +1,32 @@ +use std::{collections::HashMap, fs, path::Path}; + +pub(crate) struct Parts { + parts: HashMap, +} + +impl Parts { + pub(crate) fn new() -> Self { + let mut parts = HashMap::new(); + let parts_path = Path::new("templates/parts"); + for part in fs::read_dir(parts_path).expect("No templates/parts folder") { + let part = part.unwrap(); + let filename = format!("{}", part.file_name().into_string().unwrap()); + let filename = filename.replace(".html", ""); + let path = format!("{}", part.path().display()); + + let template = fs::read_to_string(path).unwrap(); + + parts.insert(filename, template); + } + Self { parts } + } + + pub(crate) fn perform(&self, input: String) -> String { + let mut input = input; + for (key, value) in &self.parts { + let replace = format!("{{{{{}}}}}", key); + input = input.replace(&replace, value); + } + input + } +} diff --git a/templates/index.html b/templates/index.html index bb9e680..4027a86 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,58 +1,13 @@ - - - - RIS Parser - - - - - + {{head}} -
    - -
    + {{header}}
      {{content}}
    - + {{footer}} diff --git a/templates/law.html b/templates/law.html index 6ac2b89..9439a64 100644 --- a/templates/law.html +++ b/templates/law.html @@ -1,22 +1,7 @@ - - - - RIS Parser - - - - - + {{head}} -
    - -
    + {{header}}
    @@ -25,37 +10,7 @@

    {{title}}

    {{content}}
    - + {{footer}} diff --git a/templates/parts/footer.html b/templates/parts/footer.html new file mode 100644 index 0000000..e2cb8a4 --- /dev/null +++ b/templates/parts/footer.html @@ -0,0 +1,31 @@ + diff --git a/templates/parts/head.html b/templates/parts/head.html new file mode 100644 index 0000000..cf573db --- /dev/null +++ b/templates/parts/head.html @@ -0,0 +1,16 @@ + + + + RIS Parser + + + + + + + + + + + + diff --git a/templates/parts/header.html b/templates/parts/header.html new file mode 100644 index 0000000..2b6e049 --- /dev/null +++ b/templates/parts/header.html @@ -0,0 +1,8 @@ +
    + +
    diff --git a/templates/static/android-chrome-192x192.png b/templates/static/android-chrome-192x192.png new file mode 100644 index 0000000..a0bbfaa Binary files /dev/null and b/templates/static/android-chrome-192x192.png differ diff --git a/templates/static/android-chrome-512x512.png b/templates/static/android-chrome-512x512.png new file mode 100644 index 0000000..687fa80 Binary files /dev/null and b/templates/static/android-chrome-512x512.png differ diff --git a/templates/static/apple-touch-icon.png b/templates/static/apple-touch-icon.png new file mode 100644 index 0000000..934e78a Binary files /dev/null and b/templates/static/apple-touch-icon.png differ diff --git a/templates/static/browserconfig.xml b/templates/static/browserconfig.xml new file mode 100644 index 0000000..b3930d0 --- /dev/null +++ b/templates/static/browserconfig.xml @@ -0,0 +1,9 @@ + + + + + + #da532c + + + diff --git a/templates/static/favicon-16x16.png b/templates/static/favicon-16x16.png new file mode 100644 index 0000000..d7ee1ff Binary files /dev/null and b/templates/static/favicon-16x16.png differ diff --git a/templates/static/favicon-32x32.png b/templates/static/favicon-32x32.png new file mode 100644 index 0000000..8853f59 Binary files /dev/null and b/templates/static/favicon-32x32.png differ diff --git a/templates/static/favicon.ico b/templates/static/favicon.ico new file mode 100644 index 0000000..8977219 Binary files /dev/null and b/templates/static/favicon.ico differ diff --git a/templates/static/mstile-144x144.png b/templates/static/mstile-144x144.png new file mode 100644 index 0000000..b53ecde Binary files /dev/null and b/templates/static/mstile-144x144.png differ diff --git a/templates/static/mstile-150x150.png b/templates/static/mstile-150x150.png new file mode 100644 index 0000000..724d79c Binary files /dev/null and b/templates/static/mstile-150x150.png differ diff --git a/templates/static/mstile-310x150.png b/templates/static/mstile-310x150.png new file mode 100644 index 0000000..3828a22 Binary files /dev/null and b/templates/static/mstile-310x150.png differ diff --git a/templates/static/mstile-310x310.png b/templates/static/mstile-310x310.png new file mode 100644 index 0000000..1d6d537 Binary files /dev/null and b/templates/static/mstile-310x310.png differ diff --git a/templates/static/mstile-70x70.png b/templates/static/mstile-70x70.png new file mode 100644 index 0000000..90a7903 Binary files /dev/null and b/templates/static/mstile-70x70.png differ diff --git a/templates/static/safari-pinned-tab.svg b/templates/static/safari-pinned-tab.svg new file mode 100644 index 0000000..a56cd53 --- /dev/null +++ b/templates/static/safari-pinned-tab.svg @@ -0,0 +1,30 @@ + + + + +Created by potrace 1.14, written by Peter Selinger 2001-2017 + + + + + diff --git a/templates/static/site.webmanifest b/templates/static/site.webmanifest new file mode 100644 index 0000000..b20abb7 --- /dev/null +++ b/templates/static/site.webmanifest @@ -0,0 +1,19 @@ +{ + "name": "", + "short_name": "", + "icons": [ + { + "src": "/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +}