Skip to content

Commit da56a3c

Browse files
committed
Implement a pipeline approach for rendering.
Now all rendering is followed up with a pipeline which is aware of context. Minify and livereload are now middlewares in this pipeline. This infrastructure will easily support compression and encryption.
1 parent 4a1bc3b commit da56a3c

File tree

15 files changed

+875
-166
lines changed

15 files changed

+875
-166
lines changed

Cargo.lock

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/config/src/config/link_checker.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ use serde::{Deserialize, Serialize};
44
use errors::Result;
55
use utils::globs::build_ignore_glob_set;
66

7-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7+
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
88
pub enum LinkCheckerLevel {
99
#[serde(rename = "error")]
10+
#[default]
1011
Error,
1112
#[serde(rename = "warn")]
1213
Warn,
1314
}
1415

15-
impl Default for LinkCheckerLevel {
16-
fn default() -> Self {
17-
Self::Error
18-
}
19-
}
20-
2116
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
2217
#[serde(default)]
2318
pub struct LinkChecker {

components/content/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use file_info::FileInfo;
1515
pub use front_matter::{PageFrontMatter, SectionFrontMatter};
1616
pub use library::Library;
1717
pub use page::Page;
18-
pub use pagination::Paginator;
18+
pub use pagination::{Pager, Paginator};
1919
pub use section::Section;
2020
pub use taxonomies::{Taxonomy, TaxonomyTerm};
2121
pub use types::*;

components/content/src/page.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,11 @@ impl Page {
124124
};
125125

126126
if let Some(ref caps) = RFC3339_DATE.captures(&file_path_for_slug) {
127-
if caps.name("slug").is_some() {
128-
if !config.slugify.paths_keep_dates {
127+
if caps.name("slug").is_some()
128+
&& !config.slugify.paths_keep_dates {
129129
slug_from_dated_filename =
130130
Some(caps.name("slug").unwrap().as_str().to_string());
131131
}
132-
}
133132
if page.meta.date.is_none() {
134133
page.meta.date = Some(caps.name("datetime").unwrap().as_str().to_string());
135134
page.meta.date_to_datetime();

components/content/src/taxonomies.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ impl TaxonomyTerm {
7272
} else {
7373
format!("/{}/{}/{}/", lang, taxo_slug, item_slug)
7474
}
75+
} else if let Some(ref taxonomy_root) = config.taxonomy_root {
76+
format!("/{}/{}/{}/", taxonomy_root, taxo_slug, item_slug)
7577
} else {
76-
if let Some(ref taxonomy_root) = config.taxonomy_root {
77-
format!("/{}/{}/{}/", taxonomy_root, taxo_slug, item_slug)
78-
} else {
79-
format!("/{}/{}/", taxo_slug, item_slug)
80-
}
78+
format!("/{}/{}/", taxo_slug, item_slug)
8179
};
8280
let permalink = config.make_permalink(&path);
8381

@@ -179,12 +177,10 @@ impl Taxonomy {
179177
} else {
180178
format!("/{}/{}/", tax_found.lang, slug)
181179
}
180+
} else if let Some(ref taxonomy_root) = config.taxonomy_root {
181+
format!("/{}/{}/", taxonomy_root, slug)
182182
} else {
183-
if let Some(ref taxonomy_root) = config.taxonomy_root {
184-
format!("/{}/{}/", taxonomy_root, slug)
185-
} else {
186-
format!("/{}/", slug)
187-
}
183+
format!("/{}/", slug)
188184
};
189185
let permalink = config.make_permalink(&path);
190186

components/site/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include = ["src/**/*"]
77

88
[dependencies]
99
serde = { version = "1.0", features = ["derive"] }
10+
derive_builder = "0.20"
1011

1112
errors = { path = "../errors" }
1213
config = { path = "../config" }

components/site/benches/site.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn bench_render_paginated(b: &mut test::Bencher) {
7171
let section = library.sections.values().collect::<Vec<_>>()[0];
7272
let paginator = Paginator::from_section(section, &library);
7373

74-
b.iter(|| site.render_paginated(Vec::new(), &paginator));
74+
b.iter(|| site.render_paginated(&[], &paginator));
7575
}
7676

7777
#[bench]

0 commit comments

Comments
 (0)