diff --git a/Cargo.lock b/Cargo.lock index f8b9613..010ee91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,7 +370,6 @@ dependencies = [ "errors 0.1.0", "front_matter 0.1.0", "globset 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "imageproc 0.1.0", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rendering 0.1.0", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -916,7 +915,7 @@ dependencies = [ "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", diff --git a/components/content/Cargo.toml b/components/content/Cargo.toml index e913873..ca8cffe 100644 --- a/components/content/Cargo.toml +++ b/components/content/Cargo.toml @@ -15,7 +15,6 @@ config = { path = "../config" } utils = { path = "../utils" } rendering = { path = "../rendering" } front_matter = { path = "../front_matter" } -imageproc = { path = "../imageproc" } [dev-dependencies] tempfile = "3" diff --git a/components/content/src/lib.rs b/components/content/src/lib.rs index 4cd93fa..5d111c4 100644 --- a/components/content/src/lib.rs +++ b/components/content/src/lib.rs @@ -8,7 +8,6 @@ extern crate errors; extern crate config; extern crate front_matter; extern crate rendering; -extern crate imageproc; extern crate utils; #[cfg(test)] diff --git a/components/content/src/page.rs b/components/content/src/page.rs index 704b068..b77a6db 100644 --- a/components/content/src/page.rs +++ b/components/content/src/page.rs @@ -15,7 +15,6 @@ use utils::site::get_reading_analytics; use utils::templates::render_template; use front_matter::{PageFrontMatter, InsertAnchor, split_page_content}; use rendering::{RenderContext, Header, render_content}; -use imageproc; use file_info::FileInfo; @@ -207,21 +206,13 @@ impl Page { .chain_err(|| format!("Failed to render page '{}'", self.file.path.display())) } - /// Creates two vectors of asset URLs. The first one contains all asset files, - /// the second one that which appear to be an image file. - fn serialize_assets(&self) -> (Vec, Vec) { - let mut assets = vec![]; - let mut images = vec![]; - for asset in self.assets.iter() { - if let Some(filename) = asset.file_name().and_then(|f| f.to_str()) { - let url = self.path.clone() + filename; - if imageproc::file_is_img(&asset) { - images.push(url.clone()); - } - assets.push(url); - } - } - (assets, images) + /// Creates a vectors of asset URLs. + fn serialize_assets(&self) -> Vec { + self.assets.iter() + .filter_map(|asset| asset.file_name()) + .filter_map(|filename| filename.to_str()) + .map(|filename| self.path.clone() + filename) + .collect() } } @@ -277,9 +268,8 @@ impl ser::Serialize for Page { state.serialize_field("next", &self.next)?; state.serialize_field("toc", &self.toc)?; state.serialize_field("draft", &self.is_draft())?; - let (assets, images) = self.serialize_assets(); + let assets = self.serialize_assets(); state.serialize_field("assets", &assets)?; - state.serialize_field("images", &images)?; state.end() } } diff --git a/components/imageproc/Cargo.toml b/components/imageproc/Cargo.toml index 647873f..7a85f1c 100644 --- a/components/imageproc/Cargo.toml +++ b/components/imageproc/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Vojtěch Král "] [dependencies] lazy_static = "1" -regex = "0.2" +regex = "1.0" tera = "0.11.0" image = "0.19.0" rayon = "0.9" diff --git a/components/imageproc/src/lib.rs b/components/imageproc/src/lib.rs index fde98af..810ebb3 100644 --- a/components/imageproc/src/lib.rs +++ b/components/imageproc/src/lib.rs @@ -213,7 +213,7 @@ pub struct Processor { resized_path: PathBuf, resized_url: String, /// A map of a ImageOps by their stored hash. - /// Note that this cannot be a HashSet, because hashest handles collisions and we don't want that, + /// Note that this cannot be a HashSet, because hashset handles collisions and we don't want that, /// we need to be aware of and handle collisions ourselves. img_ops: HashMap, /// Hash collisions go here: diff --git a/docs/templates/shortcodes/gallery.html b/docs/templates/shortcodes/gallery.html index fa1c84b..d2afc71 100644 --- a/docs/templates/shortcodes/gallery.html +++ b/docs/templates/shortcodes/gallery.html @@ -1,6 +1,8 @@ -{% for img in page.images %} - - - -   +{% for asset in page.assets %} + {% if asset is ending_with(".jpg") %} + + + +   + {% endif %} {% endfor %}