From 2a601c0c6d5393ec91a86107c1d91ddbc5199bbc Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 24 Sep 2023 19:29:07 +0100 Subject: [PATCH 01/22] feat(ssg): v0.0.18 --- Cargo.lock | 71 ++++++++++++++----------------------------------- Cargo.toml | 8 +++--- README.md | 2 +- src/lib.rs | 2 +- src/term/cli.rs | 2 +- 5 files changed, 27 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c21579cf..c53502d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,9 +272,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.2" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", "clap_derive", @@ -282,9 +282,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", @@ -332,7 +332,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "482aa5695bca086022be453c700a40c02893f1ba7098a2c88351de55341ae894" dependencies = [ - "clap 4.4.2", + "clap 4.4.4", "entities", "memchr", "once_cell", @@ -398,7 +398,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.4.2", + "clap 4.4.4", "criterion-plot", "is-terminal", "itertools", @@ -969,17 +969,6 @@ dependencies = [ "hashbrown 0.14.0", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.2", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "ipnet" version = "2.8.0" @@ -993,7 +982,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.2", - "rustix 0.38.11", + "rustix", "windows-sys 0.48.0", ] @@ -1048,12 +1037,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.5" @@ -1592,20 +1575,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - [[package]] name = "rustix" version = "0.38.11" @@ -1615,7 +1584,7 @@ dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys", "windows-sys 0.48.0", ] @@ -1706,9 +1675,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -1805,10 +1774,10 @@ dependencies = [ [[package]] name = "ssg" -version = "0.0.17" +version = "0.0.18" dependencies = [ "assert_cmd", - "clap 4.4.2", + "clap 4.4.4", "comrak", "criterion", "dtt", @@ -1886,7 +1855,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix 0.38.11", + "rustix", "windows-sys 0.48.0", ] @@ -1901,11 +1870,11 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.23", + "rustix", "windows-sys 0.48.0", ] @@ -2036,9 +2005,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" dependencies = [ "serde", "serde_spanned", @@ -2057,9 +2026,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" dependencies = [ "indexmap 2.0.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 847dcf46..23234566 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ name = "ssg" readme = "README.md" repository = "https://github.com/sebastienrousseau/shokunin" rust-version = "1.71.1" -version = "0.0.17" +version = "0.0.18" include = [ "/CONTRIBUTING.md", "/LICENSE-APACHE", @@ -46,7 +46,7 @@ harness = false path = "benches/bench.rs" [dependencies] -clap = "4.4.2" +clap = "4.4.4" comrak = "0.18.0" dtt = "0.0.4" log = {version="0.4.20", features = ["std"] } @@ -56,10 +56,10 @@ quick-xml = "0.30.0" regex = "1.9.5" reqwest = { version = "0.11.20", features = ["blocking", "json"] } serde = { version = "1.0.188", features = ["derive"] } -serde_json = "1.0.106" +serde_json = "1.0.107" serde_yaml = "0.9.25" tempfile = "3.8.0" -toml = "0.7.8" +toml = "0.8.0" yaml-rust = "0.4.5" vrd = "0.0.4" diff --git a/README.md b/README.md index aac88079..a10b351f 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ To use the Shokunin Static Site Generator (SSG) library in your project, add the ```toml [dependencies] -shokunin = "0.0.17" +shokunin = "0.0.18" ``` Add the following to your `main.rs` file: diff --git a/src/lib.rs b/src/lib.rs index 20c6a60e..7d819f5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,7 +66,7 @@ //! //! ```toml //! [dependencies] -//! shokunin = "0.0.17" +//! shokunin = "0.0.18" //! ``` //! //! And in your `main.rs`: diff --git a/src/term/cli.rs b/src/term/cli.rs index 9593fae0..9f132d83 100644 --- a/src/term/cli.rs +++ b/src/term/cli.rs @@ -44,7 +44,7 @@ pub fn build() -> Result { .author("Sebastien Rousseau") .about("") .bin_name("ssg") - .version("0.0.17") + .version("0.0.18") .arg( Arg::new("new") .help("Create a new project.") From 2df174678e024500837d96a9ae54bb55471d9d56 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 25 Sep 2023 11:03:33 +0100 Subject: [PATCH 02/22] feat(ssg): extending template capacity --- content/features.md | 2 +- src/macros.rs | 43 +++++-- src/utilities/template.rs | 119 +++++++----------- template/feature.html | 259 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 343 insertions(+), 80 deletions(-) create mode 100644 template/feature.html diff --git a/content/features.md b/content/features.md index f98299fc..9a766970 100644 --- a/content/features.md +++ b/content/features.md @@ -24,7 +24,7 @@ image_width: "1200" ## The image width of the site. image: "https://kura.pro/kaishi/images/banners/banner-kaishi.webp" ## The main image of the site in SVG format. keywords: "kaishi starter templates, shokunin static site generator, static site generator, starter templates, bootstrap, bootstrap css, bootstrap javascript, content security policy, open graph meta tags, responsive navigation bar, schema.org meta tags" ## The keywords of the site. (max 160 characters) language: "en-GB" ## The language of the site. (default: en-GB) -layout: "page" ## The layout of the site. +layout: "feature" ## The layout of the site. locale: "en_GB" ## The locale of the site. logo_alt: "Logo of Kaishi, a starter template for static sites" ## The logo alt of the site. logo_height: "33" ## The logo height of the site. diff --git a/src/macros.rs b/src/macros.rs index 88680944..2d6123f3 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -287,23 +287,50 @@ macro_rules! macro_metadata_option { /// # `macro_render_layout` Macro /// -/// Selects the appropriate template for rendering based on the specified layout, -/// and uses this template to render a context into a string. +/// This macro selects and renders a specified layout with a given context. +/// +/// * `$layout`: The desired layout name (e.g., "contact", "index", "page"). +/// If a template file corresponding to `$layout.html` exists in the template directory, +/// it will be used. Otherwise, the macro falls back to predefined mappings. +/// +/// * `$template_path`: The path to the directory containing the template files. +/// +/// * `$context`: The context to be rendered into the template. +/// +/// ## Behaviour: +/// +/// 1. If a file named `$layout.html` exists in `$template_path`, it will be used as the template. +/// 2. If no such file exists, the macro checks for predefined layout names: +/// * "contact" maps to "contact.html" +/// * "index" maps to "index.html" +/// * "page" maps to "page.html" +/// 3. If `$layout` is unrecognized and doesn't correspond to a file in the template directory, +/// the macro defaults to using "index.html". +/// +/// ## Returns: +/// +/// The macro returns a rendered string using the selected template and provided context. /// #[macro_export] macro_rules! macro_render_layout { ($layout:expr, $template_path:expr, $context:expr) => {{ let layout_str: &str = &$layout; - let template_file = match layout_str { - "contact" => "contact.html", - "index" => "index.html", - "page" => "page.html", - _ => "index.html", + // Check if a file with the name of the layout exists in the template directory + let file_path = Path::new($template_path).join(format!("{}.html", layout_str)); + let template_file = if file_path.exists() { + format!("{}.html", layout_str) + } else { + match layout_str { + "contact" => "contact.html", + "index" => "index.html", + "page" => "page.html", + _ => "index.html", + }.to_string() }; let template_content = fs::read_to_string( - Path::new($template_path).join(template_file), + Path::new($template_path).join(&template_file), ) .unwrap(); render_template(&template_content, &$context) diff --git a/src/utilities/template.rs b/src/utilities/template.rs index 83c74e94..28a6e45b 100644 --- a/src/utilities/template.rs +++ b/src/utilities/template.rs @@ -6,7 +6,7 @@ use reqwest; use std::{ collections::HashMap, fs::{self, File}, - path::Path, + path::{Path, PathBuf}, }; #[derive(Debug, Default, PartialEq, Eq, Clone)] @@ -161,82 +161,59 @@ pub fn create_template_folder( // Get the current working directory let current_dir = std::env::current_dir()?; - // Determine the template directory path based on the provided argument or use the default path let template_dir_path = match template_path { + Some(path) if path.starts_with("http://") || path.starts_with("https://") => { + download_files_from_url(path)? + }, Some(path) => { - if path.starts_with("http://") - || path.starts_with("https://") - { - // If a URL is provided, download the template files to a temporary directory - let tempdir = tempfile::tempdir()?; - let template_dir_path = tempdir.into_path(); - println!( - "Creating temporary directory for template: {:?}", - template_dir_path - ); - - let url = path; - let files = [ - "contact.html", - "index.html", - "main.js", - "page.html", - "sw.js", - ]; - - for file in files.iter() { - let file_url = format!("{}/{}", url, file); - let file_path = template_dir_path.join(file); - let mut download = - reqwest::blocking::get(&file_url)?; - let mut file = File::create(&file_path)?; - download.copy_to(&mut file)?; - println!( - "Downloaded template file to: {:?}", - file_path - ); - } - - template_dir_path + let local_path = current_dir.join(path); + if local_path.exists() && local_path.is_dir() { + println!("Using local template directory: {}", path); + local_path } else { - // If a local path is provided, use it as the template - // directory path - // println!("Using local template directory: {}", path); - current_dir.join(path) + return Err(TemplateError::Io(std::io::Error::new( + std::io::ErrorKind::NotFound, + format!("Template directory not found: {}", path), + ))); } - } + }, None => { - // If no path is provided, download the default template files to a temporary directory - let tempdir = tempfile::tempdir()?; - let template_dir_path = tempdir.into_path(); - println!( - "Creating temporary directory for default template: {:?}", - template_dir_path - ); - - let url = "https://raw.githubusercontent.com/sebastienrousseau/shokunin/main/template/"; - let files = [ - "contact.html", - "index.html", - "main.js", - "page.html", - "sw.js", - ]; - - for file in files.iter() { - let file_url = format!("{}/{}", url, file); - let file_path = template_dir_path.join(file); - let mut download = reqwest::blocking::get(&file_url)?; - let mut file = File::create(&file_path)?; - download.copy_to(&mut file)?; - println!( - "Downloaded default template file to: {:?}", - file_path - ); - } - - template_dir_path + let default_url = "https://raw.githubusercontent.com/sebastienrousseau/shokunin/main/template/"; + download_files_from_url(default_url)? } }; + Ok(String::from(template_dir_path.to_str().unwrap())) } + +fn download_files_from_url(url: &str) -> Result { + let tempdir = tempfile::tempdir()?; + let template_dir_path = tempdir.into_path(); + println!( + "Creating temporary directory for template: {:?}", + template_dir_path + ); + + let files = [ + "contact.html", + "index.html", + "main.js", + "page.html", + "sw.js", + ]; + + for file in files.iter() { + let file_url = format!("{}/{}", url, file); + let file_path = template_dir_path.join(file); + let mut download = reqwest::blocking::get(&file_url)?; + let mut file = File::create(&file_path)?; + download.copy_to(&mut file)?; + println!( + "Downloaded template file to: {:?}", + file_path + ); + } + + Ok(template_dir_path) +} + diff --git a/template/feature.html b/template/feature.html new file mode 100644 index 00000000..edf514a8 --- /dev/null +++ b/template/feature.html @@ -0,0 +1,259 @@ + + + + + {{title}} + + + {{primary}} + + + + {{opengraph}} + + + + + + + + + + {{apple}} + + + + + + + + {{microsoft}} + + + + {{twitter}} + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+ {{content}} +
+
+ + + + + + + + From 30900492efba0bb98115cad7212a8f169bccf8f7 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 25 Sep 2023 18:11:45 +0100 Subject: [PATCH 03/22] fix(ssg): disabling openssl --- Cargo.lock | 11 ----------- Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c53502d7..37b2cc25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1242,15 +1242,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-src" -version = "300.1.3+3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd2c101a165fff9935e34def4669595ab1c7847943c42be86e21503e482be107" -dependencies = [ - "cc", -] - [[package]] name = "openssl-sys" version = "0.9.93" @@ -1259,7 +1250,6 @@ checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", - "openssl-src", "pkg-config", "vcpkg", ] @@ -1783,7 +1773,6 @@ dependencies = [ "dtt", "log", "minify-html", - "openssl", "quick-xml 0.30.0", "regex", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 23234566..4e33d1bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ comrak = "0.18.0" dtt = "0.0.4" log = {version="0.4.20", features = ["std"] } minify-html = "0.11.1" -openssl = { version = "0.10.57", features = ["vendored"] } +# openssl = { version = "0.10.57", features = ["vendored"] } quick-xml = "0.30.0" regex = "1.9.5" reqwest = { version = "0.11.20", features = ["blocking", "json"] } From 8b0a388c69ef1dfaf3266f61cd1b5e66db752193 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 25 Sep 2023 18:12:02 +0100 Subject: [PATCH 04/22] fix(ssg): content update --- content/features.md | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/content/features.md b/content/features.md index 9a766970..35cd886c 100644 --- a/content/features.md +++ b/content/features.md @@ -105,6 +105,45 @@ site_software: "Shokunin, Rust" ## The software of the site. --- + +
+
+
+
+ + +## Starter Templates + +All the starter templates, whether pages or websites are built from scratch +using the same principles and features. This means that you can easily mix and +match them together to create your own custom layouts and content. + +Get started with Shokunin using any of our Starter Templates for building +your website or web application. + +**Kaishi Starter Templates** has the following features enabled: + +- **Accessibility Meta-Tags:** These meta tags are designed to make the website more accessible to users with disabilities. By setting Accessible Rich Internet Applications (ARIA) roles and attributes, full keyboard control, and no flashing hazard, you can make sure your website is accessible to everyone. +- **Apple Meta-Tags:** These meta tags improve websites for Apple devices, like iPhones, iPads, and Apple devices. You can change web app capabilities, status bar style, title, application name, and author to improve Apple devices' appearance. +- **Bootstrap CSS:** Bootstrap is a popular CSS framework that provides you with a set of pre-designed styles and components. By using Bootstrap, you can quickly and easily create a professional-looking website without having to write CSS from scratch. +- **Bootstrap JavaScript:** Bootstrap JavaScript is a set of pre-built scripts that provide you with responsive navigation menus and modal dialogues. +- **Content Security Policy:** This meta tag is used to specify the sources of content allowed to load on the page. It is designed to prevent cross-site scripting (XSS) attacks and other security vulnerabilities. +- **Microsoft Meta Tags:** These meta tags are designed to optimise the website for Microsoft devices. You can set site verification, application configuration, tap highlight colour, tile colour, and tile image to look good on Windows devices. +- **Open Graph/Facebook Meta-Tags:** These meta tags allow you to control how your website appears when shared on Facebook and other social media platforms. By setting the title, description, and image, you can make sure that your website looks its best when shared online. +- **Responsive Navigation Bar:** The responsive navigation bar provides users with an intuitive and easy-to-use interface for navigating the website. It aims to adapt to the size of the screen, making it accessible to users on both desktop and mobile devices. +- **Schema.org Meta Tags:** These meta tags are used to provide structured data about the website's content. Setting the name, description, and image on a website helps search engines and others understand the content better. +- **Twitter Meta Tags:** These meta tags are designed to optimise the website for Twitter sharing. You can set the card type, creator, description, image, site, title, and URL to make their website look good on Twitter. + + +
+
+
+ +
+
+
+ + ## Starter Templates All the starter templates, whether pages or websites are built from scratch @@ -126,3 +165,10 @@ your website or web application. - **Responsive Navigation Bar:** The responsive navigation bar provides users with an intuitive and easy-to-use interface for navigating the website. It aims to adapt to the size of the screen, making it accessible to users on both desktop and mobile devices. - **Schema.org Meta Tags:** These meta tags are used to provide structured data about the website's content. Setting the name, description, and image on a website helps search engines and others understand the content better. - **Twitter Meta Tags:** These meta tags are designed to optimise the website for Twitter sharing. You can set the card type, creator, description, image, site, title, and URL to make their website look good on Twitter. + + +
+
+
+
+ \ No newline at end of file From 6f9ba92d08365bac72bb0d558dfd851a02794eb0 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 25 Sep 2023 18:13:00 +0100 Subject: [PATCH 05/22] fix(ssg): duplicate name --- content/features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/features.md b/content/features.md index 35cd886c..70c766e0 100644 --- a/content/features.md +++ b/content/features.md @@ -144,7 +144,7 @@ your website or web application.
-## Starter Templates +## Starter Templates 2 All the starter templates, whether pages or websites are built from scratch using the same principles and features. This means that you can easily mix and From 2edf3a845907a9375bcbd980ccd82da9ba638718 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 25 Sep 2023 19:35:15 +0100 Subject: [PATCH 06/22] fix(ssg): added missing changefreq --- content/404.md | 1 + content/contact.md | 1 + content/features.md | 3 +- content/index.md | 1 + content/offline.md | 1 + content/privacy.md | 1 + content/tags.md | 1 + content/terms.md | 1 + src/macros.rs | 1 + src/modules/sitemap.rs | 2 +- src/utilities/template.rs | 1 + template/post.html | 271 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 template/post.html diff --git a/content/404.md b/content/404.md index 972e41ff..4d800094 100644 --- a/content/404.md +++ b/content/404.md @@ -8,6 +8,7 @@ banner_height: "398" banner_width: "1440" banner: "https://kura.pro/unsplash/images/banners/ash-from-modern-afflatus-NQ6Lh81BTRs-unsplash.jpg" cdn: "https://kura.pro" +changefreq: "weekly" charset: "utf-8" cname: "kaishi.one" copyright: "© 2023 Kaishi. All rights reserved." diff --git a/content/contact.md b/content/contact.md index f4b064c1..30ec173f 100644 --- a/content/contact.md +++ b/content/contact.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/vishal-bansal-SC5sXeyjloE-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. diff --git a/content/features.md b/content/features.md index 70c766e0..de6a062a 100644 --- a/content/features.md +++ b/content/features.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/ryunosuke-kikuno-G5hYMUoJQf8-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. @@ -24,7 +25,7 @@ image_width: "1200" ## The image width of the site. image: "https://kura.pro/kaishi/images/banners/banner-kaishi.webp" ## The main image of the site in SVG format. keywords: "kaishi starter templates, shokunin static site generator, static site generator, starter templates, bootstrap, bootstrap css, bootstrap javascript, content security policy, open graph meta tags, responsive navigation bar, schema.org meta tags" ## The keywords of the site. (max 160 characters) language: "en-GB" ## The language of the site. (default: en-GB) -layout: "feature" ## The layout of the site. +layout: "post" ## The layout of the site. locale: "en_GB" ## The locale of the site. logo_alt: "Logo of Kaishi, a starter template for static sites" ## The logo alt of the site. logo_height: "33" ## The logo height of the site. diff --git a/content/index.md b/content/index.md index 0be96b29..550e3035 100644 --- a/content/index.md +++ b/content/index.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/bernardo-lorena-ponte-cEp2Tow6XKk-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. diff --git a/content/offline.md b/content/offline.md index c5325953..13232f1c 100644 --- a/content/offline.md +++ b/content/offline.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/tianyi-ma-WiONHd_zYI4-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. diff --git a/content/privacy.md b/content/privacy.md index cf7a769c..87dfc05a 100644 --- a/content/privacy.md +++ b/content/privacy.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/johannes-plenio-6XUA5KQ9-1k-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. diff --git a/content/tags.md b/content/tags.md index 8d98eab8..1041b5ae 100644 --- a/content/tags.md +++ b/content/tags.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/sean-stratton-ObpCE_X3j6U-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. diff --git a/content/terms.md b/content/terms.md index ea30ce25..8ed08e7d 100644 --- a/content/terms.md +++ b/content/terms.md @@ -8,6 +8,7 @@ banner_height: "398" ## The banner height of the site. banner_width: "1440" ## The banner width of the site. banner: "https://kura.pro/unsplash/images/banners/sean-stratton-ObpCE_X3j6U-unsplash.jpg" ## The banner of the site. cdn: "https://kura.pro" ## The CDN of the site. +changefreq: "weekly" ## The changefreq of the site. charset: "utf-8" ## The charset of the site. (default: utf-8) cname: "kaishi.one" ## The cname value of the site. (Only required for the index page.) copyright: "© 2023 Kaishi. All rights reserved." ## The copyright of the site. diff --git a/src/macros.rs b/src/macros.rs index 2d6123f3..5413a030 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -325,6 +325,7 @@ macro_rules! macro_render_layout { "contact" => "contact.html", "index" => "index.html", "page" => "page.html", + "post" => "post.html", _ => "index.html", }.to_string() }; diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs index 75af1d1d..64016eaf 100644 --- a/src/modules/sitemap.rs +++ b/src/modules/sitemap.rs @@ -9,7 +9,7 @@ pub fn create_site_map_data(metadata: &HashMap) -> SiteMapData { SiteMapData { loc: metadata.get("permalink").cloned().unwrap_or_default(), lastmod: metadata.get("last_build_date").cloned().unwrap_or_default(), - changefreq: metadata.get("weekly").cloned().unwrap_or_default(), + changefreq: metadata.get("changefreq").cloned().unwrap_or_default(), } } diff --git a/src/utilities/template.rs b/src/utilities/template.rs index 28a6e45b..942f2356 100644 --- a/src/utilities/template.rs +++ b/src/utilities/template.rs @@ -199,6 +199,7 @@ fn download_files_from_url(url: &str) -> Result { "index.html", "main.js", "page.html", + "post.html", "sw.js", ]; diff --git a/template/post.html b/template/post.html new file mode 100644 index 00000000..a0042f6e --- /dev/null +++ b/template/post.html @@ -0,0 +1,271 @@ + + + + + + {{title}} + + + {{primary}} + + + + {{opengraph}} + + + + + + + + + + {{apple}} + + + + + + + + {{microsoft}} + + + + {{twitter}} + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+ by + +

+

+

Tags: {{tags}}

+ {{content}} +
+
+ + + + + + + + + \ No newline at end of file From 5daf7545347554aecdaf9bdb6b511db638992b5d Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Mon, 25 Sep 2023 21:04:43 +0100 Subject: [PATCH 07/22] fix(ssg): added sitemap lastmod --- src/modules/json.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/modules/json.rs b/src/modules/json.rs index e4dfd03c..26ba231f 100644 --- a/src/modules/json.rs +++ b/src/modules/json.rs @@ -110,12 +110,13 @@ pub fn human(options: &HumansData) -> String { /// ## Function: `sitemap` - Generate a sitemap for a web app pub fn sitemap(options: SiteMapData, dir: &Path) -> String { + let lastmod = options.lastmod.clone(); let changefreq = options.changefreq.clone(); let base_url = options.loc.clone(); let base_dir = PathBuf::from(dir); let mut urls = vec![]; - visit_dirs(&base_dir, &base_dir, &base_url, &changefreq, &mut urls) + visit_dirs(&base_dir, &base_dir, &base_url, &changefreq, &lastmod, &mut urls) .unwrap(); let urls_str = urls.join("\n"); @@ -131,6 +132,7 @@ fn visit_dirs( dir: &Path, base_url: &str, changefreq: &str, + lastmod: &str, urls: &mut Vec, ) -> std::io::Result<()> { if dir.is_dir() { @@ -139,7 +141,7 @@ fn visit_dirs( let path = entry.path(); if path.is_dir() { visit_dirs( - base_dir, &path, base_url, changefreq, urls, + base_dir, &path, base_url, changefreq, lastmod, urls, )?; } else if path.file_name().unwrap() == "index.html" { let url = path @@ -149,12 +151,8 @@ fn visit_dirs( .unwrap() .replace("'\\'", "/"); urls.push(format!( - r#" - - {}/{} - {} - "#, - base_url, url, changefreq + r#"{}{}{}/{}"#, + changefreq, lastmod, base_url, url )); } } From f5cd16502346161e79329a936145dd6479de4e11 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 07:51:11 +0100 Subject: [PATCH 08/22] doc(ssg): code comment updates --- src/modules/cname.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/modules/cname.rs b/src/modules/cname.rs index 533c5668..48454d61 100644 --- a/src/modules/cname.rs +++ b/src/modules/cname.rs @@ -1,13 +1,38 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT +// Import the CnameData model from the `crate::models::data` module. use crate::models::data::CnameData; + +// Import the HashMap collection from the `std::collections` module. use std::collections::HashMap; -/// Function to create CnameData +/// Function to create a CnameData object from a HashMap of metadata. +/// +/// The `metadata` HashMap must contain a key named `cname` with the value +/// of the CNAME record. +/// +/// Returns a CnameData object with the CNAME record value. +/// +/// The `cname` value is the canonical name of the domain or subdomain. It is +/// the "true" name of the domain or subdomain, and it is what other DNS +/// records point to. For example, the `cname` value for the `www.example.com` +/// subdomain is typically `example.com`. +/// +/// The `cname` value is used to create aliases for domains and subdomains. +/// This can be useful for a variety of reasons, such as: +/// +/// * To make it easier for users to remember the domain name or subdomain. +/// * To distribute traffic across multiple servers. +/// * To use a domain name or subdomain with a service provider that does not +/// allow you to create your own DNS records. pub fn create_cname_data(metadata: &HashMap) -> CnameData { + // Get the value of the `cname` key from the `metadata` HashMap. + let cname = metadata.get("cname").cloned().unwrap_or_default(); + + // Create a new CnameData object with the CNAME record value. CnameData { - cname: metadata.get("cname").cloned().unwrap_or_default(), + cname, } } From a3b7e22972aa0dcdd93ad157846ba39c8ef4712a Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 08:08:35 +0100 Subject: [PATCH 09/22] doc(ssg): code comment updates --- src/modules/human.rs | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/modules/human.rs b/src/modules/human.rs index 2a74f809..9a40bcc3 100644 --- a/src/modules/human.rs +++ b/src/modules/human.rs @@ -1,21 +1,38 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT +// Import the HumansData struct from the data module. use crate::models::data::HumansData; + +// Import the HashMap struct from the collections module. use std::collections::HashMap; -/// Function to create HumansData +/// Function to create a HumansData object from a HashMap of metadata. +/// +/// The `metadata` HashMap must contain the following keys: +/// +/// * `author_location`: The location of the author. +/// * `author_twitter`: The Twitter handle of the author. +/// * `author_website`: The website of the author. +/// * `author`: The name of the author of the website or blog. +/// * `site_components`: The components that the website or blog uses. +/// * `site_last_updated`: The date on which the website or blog was last updated. +/// * `site_software`: The software that the website or blog uses. +/// * `site_standards`: The standards that the website or blog follows. +/// * `thanks`: A list of people or organizations to thank for their contributions to the website or blog. +/// +/// Returns a HumansData object with the metadata. pub fn create_human_data(metadata: &HashMap) -> HumansData { HumansData { - author: metadata.get("author").cloned().unwrap_or_default(), - author_website: metadata.get("author_website").cloned().unwrap_or_default(), - author_twitter: metadata.get("author_twitter").cloned().unwrap_or_default(), author_location: metadata.get("author_location").cloned().unwrap_or_default(), - thanks: metadata.get("thanks").cloned().unwrap_or_default(), - site_last_updated: metadata.get("site_last_updated").cloned().unwrap_or_default(), - site_standards: metadata.get("site_standards").cloned().unwrap_or_default(), + author_twitter: metadata.get("author_twitter").cloned().unwrap_or_default(), + author_website: metadata.get("author_website").cloned().unwrap_or_default(), + author: metadata.get("author").cloned().unwrap_or_default(), site_components: metadata.get("site_components").cloned().unwrap_or_default(), + site_last_updated: metadata.get("site_last_updated").cloned().unwrap_or_default(), site_software: metadata.get("site_software").cloned().unwrap_or_default(), + site_standards: metadata.get("site_standards").cloned().unwrap_or_default(), + thanks: metadata.get("thanks").cloned().unwrap_or_default(), } } From 94415c93ed962af979908b7c9a4a3a42a01cc08d Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 08:28:25 +0100 Subject: [PATCH 10/22] doc(ssg): code comment updates --- src/modules/json.rs | 90 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/src/modules/json.rs b/src/modules/json.rs index 26ba231f..b3ebb714 100644 --- a/src/modules/json.rs +++ b/src/modules/json.rs @@ -13,19 +13,26 @@ use crate::models::data::{ }; /// ## Function: `manifest` - Generate a JSON manifest for a web app +/// +/// The `ManifestData` object contains the following fields: +/// +/// * `background_color`: The background color of the web app. +/// * `description`: The description of the web app. +/// * `display`: The display mode of the web app. +/// * `icons`: A list of icons for the web app. +/// * `name`: The name of the web app. +/// * `orientation`: The orientation of the web app. +/// * `scope`: The scope of the web app. +/// * `short_name`: The short name of the web app. +/// * `start_url`: The start URL of the web app. +/// * `theme_color`: The theme color of the web app. +/// +/// Returns a JSON string containing the manifest. pub fn manifest(options: &ManifestData) -> String { let mut json_map = Map::new(); - json_map.insert("name".to_string(), json!(options.name)); - json_map - .insert("short_name".to_string(), json!(options.short_name)); - json_map.insert("start_url".to_string(), json!(options.start_url)); + json_map.insert("background_color".to_string(),json!(options.background_color),); + json_map.insert("description".to_string(), json!(options.description)); json_map.insert("display".to_string(), json!(options.display)); - json_map.insert( - "background_color".to_string(), - json!(options.background_color), - ); - json_map - .insert("description".to_string(), json!(options.description)); let mut icons_vec = vec![]; for icon in &options.icons { @@ -41,17 +48,23 @@ pub fn manifest(options: &ManifestData) -> String { icons_vec.push(json!(icon_map)); } json_map.insert("icons".to_string(), json!(icons_vec)); - - json_map - .insert("orientation".to_string(), json!(options.orientation)); + json_map.insert("name".to_string(), json!(options.name)); + json_map.insert("orientation".to_string(), json!(options.orientation)); json_map.insert("scope".to_string(), json!(options.scope)); - json_map - .insert("theme_color".to_string(), json!(options.theme_color)); + json_map.insert("short_name".to_string(), json!(options.short_name)); + json_map.insert("start_url".to_string(), json!(options.start_url)); + json_map.insert("theme_color".to_string(), json!(options.theme_color)); serde_json::to_string_pretty(&json_map).unwrap() } /// ## Function: `txt` - Generate a robots.txt for a web app +/// +/// The `TxtData` object contains the following fields: +/// +/// * `permalink`: The permalink of the web app. +/// +/// Returns a string containing the robots.txt file. pub fn txt(options: &TxtData) -> String { let permalink = options.permalink.clone(); let url = format!("{}/sitemap.xml", permalink); @@ -59,6 +72,12 @@ pub fn txt(options: &TxtData) -> String { } /// ## Function: `cname` - Generate a CNAME for a web app +/// +/// The `CnameData` object contains the following fields: +/// +/// * `cname`: The CNAME value of the web app. +/// +/// Returns a string containing the CNAME file. pub fn cname(options: &CnameData) -> String { let cname_value = options.cname.clone(); let full_domain = format!("www.{}", cname_value); @@ -67,6 +86,20 @@ pub fn cname(options: &CnameData) -> String { } /// ## Function: `human` - Generate a humans.txt for a web app +/// +/// The `HumansData` object contains the following fields: +/// +/// * `author_location`: The location of the author. +/// * `author_twitter`: The Twitter handle of the author. +/// * `author_website`: The website of the author. +/// * `author`: The author of the web app. +/// * `site_components`: The components that the web app uses. +/// * `site_last_updated`: The date on which the web app was last updated. +/// * `site_software`: The software that the web app uses. +/// * `site_standards`: The standards that the web app follows. +/// * `thanks`: A list of people or organizations to thank for their contributions to the web app. +/// +/// Returns a string containing the humans.txt file. pub fn human(options: &HumansData) -> String { let mut s = String::from("/* TEAM */\n"); @@ -109,6 +142,16 @@ pub fn human(options: &HumansData) -> String { } /// ## Function: `sitemap` - Generate a sitemap for a web app +/// +/// The `SiteMapData` object contains the following fields: +/// +/// * `changefreq`: The change frequency of the web app. +/// * `lastmod`: The last modified date of the web app. +/// * `loc`: The base URL of the web app. +/// +/// The `dir` parameter is the directory containing the web app. +/// +/// Returns a string containing the sitemap.xml file. pub fn sitemap(options: SiteMapData, dir: &Path) -> String { let lastmod = options.lastmod.clone(); let changefreq = options.changefreq.clone(); @@ -127,7 +170,22 @@ pub fn sitemap(options: SiteMapData, dir: &Path) -> String { ) } -fn visit_dirs( +/// ## Function: `visit_dirs` - Recursively visit all directories in a tree and add the URLs of all index.html files to the `urls` vector. +/// +/// The `base_dir` parameter is the root directory of the tree. +/// +/// The `dir` parameter is the current directory being visited. +/// +/// The `base_url` parameter is the base URL of the website. +/// +/// The `changefreq` parameter is the change frequency of the website. +/// +/// The `lastmod` parameter is the last modified date of the website. +/// +/// The `urls` parameter is a vector of URLs that will be populated by the function. +/// +/// Returns a `std::io::Result` value. +pub fn visit_dirs( base_dir: &Path, dir: &Path, base_url: &str, From 76574767f3184b2e1d45d2d36ac67e7a97f3be87 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 08:52:44 +0100 Subject: [PATCH 11/22] doc(ssg): code comment updates --- src/modules/manifest.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/manifest.rs b/src/modules/manifest.rs index d469ef69..e0daadcf 100644 --- a/src/modules/manifest.rs +++ b/src/modules/manifest.rs @@ -5,6 +5,10 @@ use crate::{models::data::{IconData, ManifestData}, macro_metadata_option}; use std::collections::HashMap; /// Function to create ManifestData +/// +/// The `metadata` parameter is a map of metadata strings. +/// +/// Returns a `ManifestData` object. pub fn create_manifest_data(metadata: &HashMap) -> ManifestData { ManifestData { name: metadata.get("name").cloned().unwrap_or_default(), From 2d57b2af88a14d4580330098e26c461316b5fd5a Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 08:55:34 +0100 Subject: [PATCH 12/22] doc(ssg): code comment updates --- src/modules/sitemap.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs index 64016eaf..bb238f34 100644 --- a/src/modules/sitemap.rs +++ b/src/modules/sitemap.rs @@ -1,15 +1,26 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT +// Import models::data::SiteMapData use crate::models::data::SiteMapData; + +// Import std::collections::HashMap use std::collections::HashMap; /// Function to create SiteMapData +/// +/// The `metadata` parameter is a map of metadata strings. +/// +/// Returns a `SiteMapData` object. pub fn create_site_map_data(metadata: &HashMap) -> SiteMapData { SiteMapData { - loc: metadata.get("permalink").cloned().unwrap_or_default(), - lastmod: metadata.get("last_build_date").cloned().unwrap_or_default(), + /// The change frequency of the website. changefreq: metadata.get("changefreq").cloned().unwrap_or_default(), + + /// The last modified date of the website. + lastmod: metadata.get("last_build_date").cloned().unwrap_or_default(), + + /// The base URL of the website. + loc: metadata.get("permalink").cloned().unwrap_or_default(), } } - From b0ec74801725b9e601ce8f54af89e2e23ddc5d77 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 08:57:35 +0100 Subject: [PATCH 13/22] doc(ssg): code comment updates --- src/modules/txt.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/txt.rs b/src/modules/txt.rs index 5397170f..7830ecec 100644 --- a/src/modules/txt.rs +++ b/src/modules/txt.rs @@ -1,10 +1,17 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT +// Import models::data::TxtData use crate::models::data::TxtData; + +// Import std::collections::HashMap use std::collections::HashMap; /// Function to create TxtData +/// +/// The `metadata` parameter is a map of metadata strings. +/// +/// Returns a `TxtData` object. pub fn create_txt_data(metadata: &HashMap) -> TxtData { TxtData { permalink: metadata.get("permalink").cloned().unwrap_or_default(), From 14a49270ef294de39d91e9fa6cbc5d1f99c180a6 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 09:54:28 +0100 Subject: [PATCH 14/22] ref(ssg): Improve code structure and readability --- src/compiler.rs | 4 +- src/utilities/backup.rs | 1 - src/utilities/write.rs | 130 +++++++++++++++++++++++++++++++--------- 3 files changed, 103 insertions(+), 32 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index a87d87d2..22517f3e 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -21,7 +21,7 @@ use crate::{ utilities::{ file::add, template::{render_page, PageOptions}, - write::write_files + write::write_files_to_build_directory }, }; use std::{error::Error, fs, path::Path, collections::HashMap}; @@ -286,7 +286,7 @@ pub fn compile( // Iterate over compiled files and write pages to output directory for file in &compiled_files { - write_files(build_dir_path, file, template_path)?; + write_files_to_build_directory(build_dir_path, file, template_path)?; } let tags_html_content = generate_tags_html(&global_tags_data); diff --git a/src/utilities/backup.rs b/src/utilities/backup.rs index 75d30508..8bbd75de 100644 --- a/src/utilities/backup.rs +++ b/src/utilities/backup.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT extern crate regex; -// use minify_html::{minify, Cfg}; use std::{ fs::{self}, io::{self}, diff --git a/src/utilities/write.rs b/src/utilities/write.rs index 7775a199..1795c718 100644 --- a/src/utilities/write.rs +++ b/src/utilities/write.rs @@ -1,26 +1,55 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT - +// Import the FileData object definition. use crate::models::data::FileData; + +// Import the minify_html function. use crate::utilities::minification::minify_html; + +// Import the Error trait. use std::error::Error; + +// Import the fs module. use std::fs; + +// Import the Path type. use std::path::Path; -/// Write the files to the build directory -pub fn write_files(build_dir_path: &Path, file: &FileData, template_path: &Path) -> Result<(), Box> { - let file_name = match Path::new(&file.name).extension() { - Some(ext) if ext == "js" => file.name.replace(".js", ""), - Some(ext) if ext == "json" => file.name.replace(".json", ""), - Some(ext) if ext == "md" => file.name.replace(".md", ""), - Some(ext) if ext == "toml" => file.name.replace(".toml", ""), - Some(ext) if ext == "txt" => file.name.replace(".txt", ""), - Some(ext) if ext == "xml" => file.name.replace(".xml", ""), +/// Write the files to the build directory. +/// +/// The `build_dir_path` parameter is the path to the build directory. +/// +/// The `file` parameter is the file data object to write. +/// +/// The `template_path` parameter is the path to the template directory. +/// +/// Returns a `Result` value, which is either `Ok(())` on success or +/// `Err(Box)` on failure. +pub fn write_files_to_build_directory( + build_dir_path: &Path, + file: &FileData, + template_path: &Path +) -> Result<(), Box> { + + // Determine the file name without extension and check if it's "index". + let file_name = match (Path::new(&file.name).extension().and_then( + |s| s.to_str() + ), &file.name) { + (Some(ext), name) if + ["js", "json", "md", "toml", "txt", "xml"].contains(&ext) => { + name.replace(&format!(".{}", ext), "") + }, _ => file.name.to_string(), }; + // Check if the file name is "index" to decide the directory structure. + let index_html_minified = file_name == "index"; + let dir_name = build_dir_path.join(&file_name); + if file_name == "index" { + // List of files that need special handling when the file name is + // "index". let file_paths = [ ("CNAME", &file.cname), ("humans.txt", &file.human), @@ -30,26 +59,34 @@ pub fn write_files(build_dir_path: &Path, file: &FileData, template_path: &Path) ("rss.xml", &file.rss), ("sitemap.xml", &file.sitemap), ]; - println!("\n {}", file_name.to_uppercase()); + + // Print the section header. + println!("\n{}", file_name.to_uppercase()); + + // Process each file in the list. for (file_name, content) in &file_paths { - let file_path = build_dir_path.join(file_name); - fs::write(&file_path, content)?; - if file_name == &"index.html" { - let minified_content = minify_html(&file_path)?; - fs::write(&file_path, &minified_content)?; - } - println!(" - {}", file_path.display()); + write_and_minify_file( + build_dir_path, + &file_name, + content, + index_html_minified + )?; } + // Copy other template files to the build directory. let other_files = ["main.js", "sw.js"]; for file_name in &other_files { - let dest_path = build_dir_path.join(file_name); - fs::copy(&template_path.join(file_name), &dest_path)?; + copy_template_file( + template_path, + build_dir_path, + file_name + )?; } } else { - let dir_name = build_dir_path.join(file_name.clone()); + // Create a subdirectory based on the file name. fs::create_dir_all(&dir_name)?; + // List of files that don't require special handling. let file_paths = [ ("index.html", &file.content), ("manifest.json", &file.json), @@ -58,17 +95,52 @@ pub fn write_files(build_dir_path: &Path, file: &FileData, template_path: &Path) ("sitemap.xml", &file.sitemap), ]; - println!("\n {}", file_name.to_uppercase()); + // Print the section header. + println!("\n{}", file_name.to_uppercase()); + + // Process each file in the list. for (file_name, content) in &file_paths { - let file_path = dir_name.join(file_name); - fs::write(&file_path, content)?; - if file_name == &"index.html" { - let minified_content = minify_html(&file_path)?; - fs::write(&file_path, &minified_content)?; - } - println!(" - {}", file_path.display()); + write_and_minify_file( + &dir_name, + &file_name, + content, + index_html_minified + )?; } } + Ok(()) +} + +// Function to write a file and optionally minify its content. +fn write_and_minify_file( + dir_path: &Path, + file_name: &str, + content: &str, + minify: bool, +) -> Result<(), Box> { + let file_path = dir_path.join(file_name); + fs::write(&file_path, content)?; + + // Minify "index.html" content if required. + if minify && file_name == "index.html" { + let minified_content = minify_html(&file_path)?; + fs::write(&file_path, &minified_content)?; + } + + // Print the file path. + println!(" - {}", file_path.display()); + Ok(()) +} + +// Function to copy a template file to the build directory. +fn copy_template_file( + template_path: &Path, + dest_dir: &Path, + file_name: &str +) -> Result<(), Box> { + let dest_path = dest_dir.join(file_name); + fs::copy(template_path.join(file_name), &dest_path)?; + Ok(()) } \ No newline at end of file From fe119ca741faae8a1ee9751a6f6bf2af235afe7a Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 10:07:05 +0100 Subject: [PATCH 15/22] fix(ssg): corrected variable name to theme-color --- content/404.md | 2 +- content/contact.md | 2 +- content/features.md | 2 +- content/index.md | 2 +- content/offline.md | 2 +- content/privacy.md | 2 +- content/tags.md | 2 +- content/terms.md | 2 +- src/modules/manifest.rs | 2 +- src/modules/metatags.rs | 2 +- template/contact.html | 2 +- template/feature.html | 2 +- template/index.html | 2 +- template/page.html | 2 +- template/post.html | 2 +- template/template.html | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/content/404.md b/content/404.md index 4d800094..5f42156b 100644 --- a/content/404.md +++ b/content/404.md @@ -39,7 +39,7 @@ revisit-after: "7 days" robots: "index, follow" short_name: "404" subtitle: "Sorry we can't find that page." -theme_color: "rgb(143, 250, 111)" +theme-color: "rgb(143, 250, 111)" tags: "404, page not found, not available" title: "404" url: "https://kaishi.one/404/" diff --git a/content/contact.md b/content/contact.md index 30ec173f..47bde5b2 100644 --- a/content/contact.md +++ b/content/contact.md @@ -41,7 +41,7 @@ robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "How can we help you today?" ## The subtitle of the page. (max 64 characters) tags: "contact us, contact form, get in touch, contact page, contact information, customer service, support, feedback, questions, inquiries, help" ## The tags of the site. (max 160 characters) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. title: "Contact Us" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. diff --git a/content/features.md b/content/features.md index de6a062a..dbc734a3 100644 --- a/content/features.md +++ b/content/features.md @@ -40,7 +40,7 @@ robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) tags: "kaishi starter templates, shokunin static site generator, static site generator, starter templates, bootstrap, bootstrap css, bootstrap javascript, content security policy, open graph meta tags, responsive navigation bar, schema.org meta tags" ## The tags of the site. (max 160 characters) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. title: "Features" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. diff --git a/content/index.md b/content/index.md index 550e3035..539c1c0d 100644 --- a/content/index.md +++ b/content/index.md @@ -39,7 +39,7 @@ revisit-after: "7 days" ## The revisit after of the site. robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. tags: "kaishi, shokunin static site generator, static site generator, minimalist website template, modern website template, responsive website template, website starter template, freelance creative, startup founder, small business owner, online presence" ## The tags of the site. (comma separated, max 10 tags) title: "Kaishi, a Shokunin Static Site Generator Starter Template" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. diff --git a/content/offline.md b/content/offline.md index 13232f1c..4a2dae4e 100644 --- a/content/offline.md +++ b/content/offline.md @@ -40,7 +40,7 @@ robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) tags: "offline, starter, templates, static, site, generator, rust, shokunin, kaishi" ## The tags of the site. (comma separated, max 10 tags) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. title: "Kaishi, a Shokunin Static Site Generator Starter Template" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. diff --git a/content/privacy.md b/content/privacy.md index 87dfc05a..56ca4c04 100644 --- a/content/privacy.md +++ b/content/privacy.md @@ -40,7 +40,7 @@ robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) tags: "privacy policy, kaishi, shokunin static site generator, static site generator, user data, google analytics, microsoft clarity, tracking tools, personal information, rights, changes" ## The tags of the site. (max 160 characters) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. title: "Kaishi, a Shokunin Static Site Generator Starter Template" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. diff --git a/content/tags.md b/content/tags.md index 1041b5ae..04f40ea8 100644 --- a/content/tags.md +++ b/content/tags.md @@ -40,7 +40,7 @@ robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) tags: "terms of use, kaishi, shokunin static site generator, static site generator, intellectual property, linked sites, liability, privacy, governing law, changes, contact us" ## The tags of the site. (max 160 characters) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. title: "Explore by tag" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. diff --git a/content/terms.md b/content/terms.md index 8ed08e7d..33655338 100644 --- a/content/terms.md +++ b/content/terms.md @@ -40,7 +40,7 @@ robots: "index, follow" ## The robots of the site. short_name: "kaishi" ## The short name of the site. (max 12 characters) subtitle: "Build Amazing Websites with Minimal Effort using Kaishi Starter Templates" ## The subtitle of the page. (max 64 characters) tags: "terms of use, kaishi, shokunin static site generator, static site generator, intellectual property, linked sites, liability, privacy, governing law, changes, contact us" ## The tags of the site. (max 160 characters) -theme_color: "rgb(143, 250, 111)" ## The theme color of the site. +theme-color: "rgb(143, 250, 111)" ## The theme color of the site. title: "Terms of Use" ## The title of the page. (max 64 characters) url: "https://kaishi.one" ## The url of the site. viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewport of the site. diff --git a/src/modules/manifest.rs b/src/modules/manifest.rs index e0daadcf..7c147b32 100644 --- a/src/modules/manifest.rs +++ b/src/modules/manifest.rs @@ -29,7 +29,7 @@ pub fn create_manifest_data(metadata: &HashMap) -> ManifestData .unwrap_or_else(Vec::new), orientation: "portrait-primary".to_string(), scope: "/".to_string(), - theme_color: macro_metadata_option!(metadata, "theme_color"), + theme_color: macro_metadata_option!(metadata, "theme-color"), } } diff --git a/src/modules/metatags.rs b/src/modules/metatags.rs index 2ba3d5ab..7a45f8af 100644 --- a/src/modules/metatags.rs +++ b/src/modules/metatags.rs @@ -96,7 +96,7 @@ pub fn generate_primary_meta_tags(metadata: &MetaDataMap) -> String { let tag_names = [ "author", "description", "format-detection", "generator", "keywords", "language", "permalink", "rating", "referrer", "revisit-after", - "robots", "theme_color", "title", "viewport", + "robots", "theme-color", "title", "viewport", ]; macro_generate_tags_from_list!(&tag_names, metadata) } diff --git a/template/contact.html b/template/contact.html index 5b6577df..7f539482 100644 --- a/template/contact.html +++ b/template/contact.html @@ -82,7 +82,7 @@ - + - + - + diff --git a/template/page.html b/template/page.html index edf514a8..b0bae9a3 100644 --- a/template/page.html +++ b/template/page.html @@ -82,7 +82,7 @@ - + - + Date: Tue, 26 Sep 2023 10:21:58 +0100 Subject: [PATCH 16/22] fix(ssg): lint issues resolved --- src/utilities/write.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utilities/write.rs b/src/utilities/write.rs index 1795c718..fbbebd1e 100644 --- a/src/utilities/write.rs +++ b/src/utilities/write.rs @@ -67,7 +67,7 @@ pub fn write_files_to_build_directory( for (file_name, content) in &file_paths { write_and_minify_file( build_dir_path, - &file_name, + file_name, content, index_html_minified )?; @@ -102,7 +102,7 @@ pub fn write_files_to_build_directory( for (file_name, content) in &file_paths { write_and_minify_file( &dir_name, - &file_name, + file_name, content, index_html_minified )?; @@ -125,7 +125,7 @@ fn write_and_minify_file( // Minify "index.html" content if required. if minify && file_name == "index.html" { let minified_content = minify_html(&file_path)?; - fs::write(&file_path, &minified_content)?; + fs::write(&file_path, minified_content)?; } // Print the file path. @@ -140,7 +140,7 @@ fn copy_template_file( file_name: &str ) -> Result<(), Box> { let dest_path = dest_dir.join(file_name); - fs::copy(template_path.join(file_name), &dest_path)?; + fs::copy(template_path.join(file_name), dest_path)?; Ok(()) } \ No newline at end of file From 385ea21f0ed1bf528ff9737aa17b8bfae1e90991 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 10:41:56 +0100 Subject: [PATCH 17/22] fix(ssg): html and content updates --- content/features.md | 35 +++++++---------------------------- template/contact.html | 2 +- template/index.html | 2 +- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/content/features.md b/content/features.md index dbc734a3..cedc6d05 100644 --- a/content/features.md +++ b/content/features.md @@ -106,12 +106,6 @@ site_software: "Shokunin, Rust" ## The software of the site. --- - -
-
-
-
- ## Starter Templates @@ -124,17 +118,17 @@ your website or web application. **Kaishi Starter Templates** has the following features enabled: + +
+
+
+
+ + - **Accessibility Meta-Tags:** These meta tags are designed to make the website more accessible to users with disabilities. By setting Accessible Rich Internet Applications (ARIA) roles and attributes, full keyboard control, and no flashing hazard, you can make sure your website is accessible to everyone. - **Apple Meta-Tags:** These meta tags improve websites for Apple devices, like iPhones, iPads, and Apple devices. You can change web app capabilities, status bar style, title, application name, and author to improve Apple devices' appearance. - **Bootstrap CSS:** Bootstrap is a popular CSS framework that provides you with a set of pre-designed styles and components. By using Bootstrap, you can quickly and easily create a professional-looking website without having to write CSS from scratch. - **Bootstrap JavaScript:** Bootstrap JavaScript is a set of pre-built scripts that provide you with responsive navigation menus and modal dialogues. -- **Content Security Policy:** This meta tag is used to specify the sources of content allowed to load on the page. It is designed to prevent cross-site scripting (XSS) attacks and other security vulnerabilities. -- **Microsoft Meta Tags:** These meta tags are designed to optimise the website for Microsoft devices. You can set site verification, application configuration, tap highlight colour, tile colour, and tile image to look good on Windows devices. -- **Open Graph/Facebook Meta-Tags:** These meta tags allow you to control how your website appears when shared on Facebook and other social media platforms. By setting the title, description, and image, you can make sure that your website looks its best when shared online. -- **Responsive Navigation Bar:** The responsive navigation bar provides users with an intuitive and easy-to-use interface for navigating the website. It aims to adapt to the size of the screen, making it accessible to users on both desktop and mobile devices. -- **Schema.org Meta Tags:** These meta tags are used to provide structured data about the website's content. Setting the name, description, and image on a website helps search engines and others understand the content better. -- **Twitter Meta Tags:** These meta tags are designed to optimise the website for Twitter sharing. You can set the card type, creator, description, image, site, title, and URL to make their website look good on Twitter. -
@@ -145,21 +139,6 @@ your website or web application.
-## Starter Templates 2 - -All the starter templates, whether pages or websites are built from scratch -using the same principles and features. This means that you can easily mix and -match them together to create your own custom layouts and content. - -Get started with Shokunin using any of our Starter Templates for building -your website or web application. - -**Kaishi Starter Templates** has the following features enabled: - -- **Accessibility Meta-Tags:** These meta tags are designed to make the website more accessible to users with disabilities. By setting Accessible Rich Internet Applications (ARIA) roles and attributes, full keyboard control, and no flashing hazard, you can make sure your website is accessible to everyone. -- **Apple Meta-Tags:** These meta tags improve websites for Apple devices, like iPhones, iPads, and Apple devices. You can change web app capabilities, status bar style, title, application name, and author to improve Apple devices' appearance. -- **Bootstrap CSS:** Bootstrap is a popular CSS framework that provides you with a set of pre-designed styles and components. By using Bootstrap, you can quickly and easily create a professional-looking website without having to write CSS from scratch. -- **Bootstrap JavaScript:** Bootstrap JavaScript is a set of pre-built scripts that provide you with responsive navigation menus and modal dialogues. - **Content Security Policy:** This meta tag is used to specify the sources of content allowed to load on the page. It is designed to prevent cross-site scripting (XSS) attacks and other security vulnerabilities. - **Microsoft Meta Tags:** These meta tags are designed to optimise the website for Microsoft devices. You can set site verification, application configuration, tap highlight colour, tile colour, and tile image to look good on Windows devices. - **Open Graph/Facebook Meta-Tags:** These meta tags allow you to control how your website appears when shared on Facebook and other social media platforms. By setting the title, description, and image, you can make sure that your website looks its best when shared online. diff --git a/template/contact.html b/template/contact.html index 7f539482..edb717dc 100644 --- a/template/contact.html +++ b/template/contact.html @@ -82,7 +82,7 @@ - + - + From fd43c172a1ab22d4e5fc917410dd56ba8bf96a95 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 10:45:36 +0100 Subject: [PATCH 18/22] fix(ssg):minified JSON --- template/contact.html | 33 +-------------------------------- template/feature.html | 33 +-------------------------------- template/index.html | 33 +-------------------------------- template/page.html | 33 +-------------------------------- template/post.html | 33 +-------------------------------- template/template.html | 33 +-------------------------------- 6 files changed, 6 insertions(+), 192 deletions(-) diff --git a/template/contact.html b/template/contact.html index edb717dc..17b88782 100644 --- a/template/contact.html +++ b/template/contact.html @@ -273,38 +273,7 @@ src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"> - + From 8f74496951da14c90636a638ac96b8e80f374e3b Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Tue, 26 Sep 2023 19:57:38 +0100 Subject: [PATCH 21/22] fix(ssg): updated unit tests --- src/modules/html.rs | 2 +- template/post.html | 2 -- tests/test_compiler.rs | 2 +- tests/test_html.rs | 18 +++++++++--------- tests/test_utilities.rs | 12 ++++++------ 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/modules/html.rs b/src/modules/html.rs index 3874e862..c9e92dd5 100644 --- a/src/modules/html.rs +++ b/src/modules/html.rs @@ -41,7 +41,7 @@ use crate::utilities::directory::{ /// let html = generate_html(content, title, description, None); /// let html_str = html.unwrap_or_else(|e| panic!("Error: {:?}", e)); /// -/// assert_eq!(html_str, "

My Page

This is a test page

Hello, world!

\n

This is a test.

\n"); +/// assert_eq!(html_str, "

My Page

This is a test page

Hello, world!

\n

This is a test.

\n"); /// /// ``` // diff --git a/template/post.html b/template/post.html index 7e140616..59b3086f 100644 --- a/template/post.html +++ b/template/post.html @@ -166,8 +166,6 @@
- - {{content}}
diff --git a/tests/test_compiler.rs b/tests/test_compiler.rs index d71aedf7..0d92c915 100644 --- a/tests/test_compiler.rs +++ b/tests/test_compiler.rs @@ -37,7 +37,7 @@ description: My Description Ok(html) => { assert_eq!( html, - "

My Page

This is a test page

Hello, world!

\n

This is a test.

\n" + "

My Page

This is a test page

Hello, world!

\n

This is a test.

\n" ); }, Err(err) => { diff --git a/tests/test_html.rs b/tests/test_html.rs index d352c37a..6667e88d 100644 --- a/tests/test_html.rs +++ b/tests/test_html.rs @@ -12,7 +12,7 @@ mod tests { let title = "Welcome"; let description = "Say hi to the world!"; let result = generate_html(content, title, description, None); - let expected = "

Welcome

Say hi to the world!

Welcome

"; + let expected = "

Welcome

Say hi to the world!

Welcome

"; match result { Ok(res) => assert_eq!(res.trim(), expected), Err(e) => panic!("Error: {:?}", e), @@ -25,7 +25,7 @@ mod tests { let title = "Welcome"; let description = "Say hi to the world!"; let result = generate_html(content, title, description, None); - let expected = "

Welcome

Say hi to the world!

Welcome

"; + let expected = "

Welcome

Say hi to the world!

Welcome

"; match result { Ok(res) => assert_eq!(res.trim(), expected), Err(e) => panic!("Error: {:?}", e), @@ -39,7 +39,7 @@ mod tests { let title = ""; let description = "Say hi to the world!"; let result = generate_html(content, title, description, None); - let expected = "

Say hi to the world!

Welcome

"; + let expected = "

Say hi to the world!

Welcome

"; match result { Ok(res) => assert_eq!(res.trim(), expected), Err(e) => panic!("Error: {:?}", e), @@ -52,7 +52,7 @@ mod tests { let title = "Welcome"; let description = ""; let result = generate_html(content, title, description, None); - let expected = "

Welcome

Welcome

"; + let expected = "

Welcome

Welcome

"; match result { Ok(res) => assert_eq!(res.trim(), expected), Err(e) => panic!("Error: {:?}", e), @@ -65,7 +65,7 @@ mod tests { let title = "Welcome"; let description = "Say hi to the world!"; let result = generate_html(content, title, description, None); - let expected = "

Welcome

Say hi to the world!

Welcome

"; + let expected = "

Welcome

Say hi to the world!

Welcome

"; match result { Ok(res) => assert_eq!(res.trim(), expected), Err(e) => panic!("Error: {:?}", e), @@ -78,7 +78,7 @@ mod tests { let title = "Welcome"; let description = "Say hi to the world!"; let result = generate_html(content, title, description, None); - let expected = "

Welcome

Say hi to the world!

"; + let expected = "

Welcome

Say hi to the world!

"; match result { Ok(res) => assert_eq!(res.trim(), expected), Err(e) => panic!("Error: {:?}", e), @@ -90,7 +90,7 @@ mod tests { let header_str = "

Hello, world!

"; let id_regex = Regex::new(r"[^a-z0-9]+").unwrap(); let result = format_header_with_id_class(header_str, &id_regex); - let expected = "

Hello, world!

"; + let expected = "

Hello, world!

"; assert_eq!(result, expected); } @@ -99,7 +99,7 @@ mod tests { let header_str = "

Welcome to the world

"; let id_regex = Regex::new(r"[^a-z0-9]+").unwrap(); let result = format_header_with_id_class(header_str, &id_regex); - let expected = "

Welcome to the world

"; + let expected = "

Welcome to the world

"; assert_eq!(result, expected); } @@ -108,7 +108,7 @@ mod tests { let header_str = "

Hello, world! #$%^&*()

"; let id_regex = Regex::new(r"[^a-z0-9]+").unwrap(); let result = format_header_with_id_class(header_str, &id_regex); - let expected = "

Hello, world! #$%^&*()

"; + let expected = "

Hello, world! #$%^&*()

"; assert_eq!(result, expected); } diff --git a/tests/test_utilities.rs b/tests/test_utilities.rs index 4ee21de6..b96f2a95 100644 --- a/tests/test_utilities.rs +++ b/tests/test_utilities.rs @@ -429,27 +429,27 @@ mod tests { let test_cases = vec![ ( "

This is a test

", - "

This is a test

" + "

This is a test

" ), ( "

Another Test

", - "

Another Test

" + "

Another Test

" ), ( "

Test with special characters!@#$%^&*

", - "

Test with special characters!@#$%^&*

" + "

Test with special characters!@#$%^&*

" ), ( "

Test with multiple spaces

", - "

Test with multiple spaces

" + "

Test with multiple spaces

" ), ( "

Test_with_underscores

", - "

Test_with_underscores

" + "

Test_with_underscores

" ), ( "

Test-with-dashes

", - "

Test-with-dashes

" + "

Test-with-dashes

" ), ]; From 3b59df9e87c09cbf2be026104d6406a8f329fc40 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Wed, 27 Sep 2023 09:07:56 +0100 Subject: [PATCH 22/22] fix(ssg): dependency updates --- Cargo.lock | 33 ++++++++++++++++++++++----------- Cargo.toml | 6 +++--- README.md | 2 +- TEMPLATE.md | 4 ++-- src/lib.rs | 2 +- src/term/cli.rs | 2 +- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37b2cc25..b58b740d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,9 +272,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.4" +version = "4.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" +checksum = "824956d0dca8334758a5b7f7e50518d66ea319330cbceedcf76905c2f6ab30e3" dependencies = [ "clap_builder", "clap_derive", @@ -282,9 +282,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.4" +version = "4.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" +checksum = "122ec64120a49b4563ccaedcbea7818d069ed8e9aa6d829b82d8a4128936b2ab" dependencies = [ "anstream", "anstyle", @@ -332,7 +332,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "482aa5695bca086022be453c700a40c02893f1ba7098a2c88351de55341ae894" dependencies = [ - "clap 4.4.4", + "clap 4.4.5", "entities", "memchr", "once_cell", @@ -398,7 +398,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.4.4", + "clap 4.4.5", "criterion-plot", "is-terminal", "itertools", @@ -1242,6 +1242,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.1.5+3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "559068e4c12950d7dcaa1857a61725c0d38d4fc03ff8e070ab31a75d6e316491" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.93" @@ -1250,6 +1259,7 @@ checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -1767,12 +1777,13 @@ name = "ssg" version = "0.0.18" dependencies = [ "assert_cmd", - "clap 4.4.4", + "clap 4.4.5", "comrak", "criterion", "dtt", "log", "minify-html", + "openssl", "quick-xml 0.30.0", "regex", "reqwest", @@ -1994,9 +2005,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +checksum = "1bc1433177506450fe920e46a4f9812d0c211f5dd556da10e731a0a3dfa151f0" dependencies = [ "serde", "serde_spanned", @@ -2015,9 +2026,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +checksum = "ca676d9ba1a322c1b64eb8045a5ec5c0cfb0c9d08e15e9ff622589ad5221c8fe" dependencies = [ "indexmap 2.0.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 4e33d1bd..a68da76f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,12 +46,12 @@ harness = false path = "benches/bench.rs" [dependencies] -clap = "4.4.4" +clap = "4.4.5" comrak = "0.18.0" dtt = "0.0.4" log = {version="0.4.20", features = ["std"] } minify-html = "0.11.1" -# openssl = { version = "0.10.57", features = ["vendored"] } +openssl = { version = "0.10.57", features = ["vendored"] } quick-xml = "0.30.0" regex = "1.9.5" reqwest = { version = "0.11.20", features = ["blocking", "json"] } @@ -59,7 +59,7 @@ serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" serde_yaml = "0.9.25" tempfile = "3.8.0" -toml = "0.8.0" +toml = "0.8.1" yaml-rust = "0.4.5" vrd = "0.0.4" diff --git a/README.md b/README.md index a10b351f..34d4aaf7 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,6 @@ A special thank you goes to the [Rust Reddit][13] community for providing a lot [crates-badge]: https://img.shields.io/crates/v/ssg.svg?style=for-the-badge 'Crates.io badge' [divider]: https://kura.pro/common/images/elements/divider.svg "divider" [docs-badge]: https://img.shields.io/docsrs/ssg.svg?style=for-the-badge 'Docs.rs badge' -[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.17-orange.svg?style=for-the-badge 'Lib.rs badge' +[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.18-orange.svg?style=for-the-badge 'Lib.rs badge' [license-badge]: https://img.shields.io/crates/l/ssg.svg?style=for-the-badge 'License badge' [made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' diff --git a/TEMPLATE.md b/TEMPLATE.md index 831a2350..4ab1c1a2 100644 --- a/TEMPLATE.md +++ b/TEMPLATE.md @@ -10,7 +10,7 @@ -# Shokunin Static Site Generator v0.0.17 🦀 +# Shokunin Static Site Generator v0.0.18 🦀 A Content-First Open Source Static Site Generator (SSG) written in Rust @@ -70,7 +70,7 @@ Shokunin Static Site Generator (SSG) feature highlights include: [crates-badge]: https://img.shields.io/crates/v/ssg.svg?style=for-the-badge 'Crates.io badge' [divider]: https://kura.pro/common/images/elements/divider.svg "divider" [docs-badge]: https://img.shields.io/docsrs/ssg.svg?style=for-the-badge 'Docs.rs badge' -[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.17-orange.svg?style=for-the-badge 'Lib.rs badge' +[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.18-orange.svg?style=for-the-badge 'Lib.rs badge' [license-badge]: https://img.shields.io/crates/l/ssg.svg?style=for-the-badge 'License badge' [made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge' diff --git a/src/lib.rs b/src/lib.rs index 7d819f5a..cf159fd2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! *Part of the [Mini Functions][0] family of Rust libraries.* //! //! [![Crates.io](https://img.shields.io/crates/v/ssg.svg?style=for-the-badge&color=success&labelColor=27A006)](https://crates.io/crates/ssg "Crates.io") -//! [![Lib.rs](https://img.shields.io/badge/lib.rs-v0.0.17-success.svg?style=for-the-badge&color=8A48FF&labelColor=6F36E4)](https://lib.rs/crates/ssg "Lib.rs") +//! [![Lib.rs](https://img.shields.io/badge/lib.rs-v0.0.18-success.svg?style=for-the-badge&color=8A48FF&labelColor=6F36E4)](https://lib.rs/crates/ssg "Lib.rs") //! [![License](https://img.shields.io/crates/l/ssg.svg?style=for-the-badge&color=007EC6&labelColor=03589B)](https://opensource.org/license/apache-2-0/ "MIT or Apache License, Version 2.0") //! [![Rust](https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust)](https://www.rust-lang.org "Rust") //! diff --git a/src/term/cli.rs b/src/term/cli.rs index 9f132d83..3bab47ba 100644 --- a/src/term/cli.rs +++ b/src/term/cli.rs @@ -109,7 +109,7 @@ pub fn build() -> Result { /// ``` pub fn print_banner() { // Set the title and description for the CLI - let title = "Shokunin 🦀 (v0.0.17)"; + let title = "Shokunin 🦀 (v0.0.18)"; let description = "A Fast and Flexible Static Site Generator written in Rust";