Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature flags to reduce dependencies #934

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f63cb6d
Start 0.10
Keats Oct 4, 2019
e0e1ace
Reset color after writing message in colorize
chrisvittal Sep 30, 2019
40699f5
Looks like it now requires 1.36
Keats Oct 8, 2019
7492496
Add zenburn theme
Keats Oct 8, 2019
5ed2366
rendering: Avoid prepending URL prefix to links that start with a sch…
zaeleus Oct 10, 2019
0ae0e5b
Let toc is visable through Page & Section variables in templates (#818)
nottxy Oct 14, 2019
2ec8921
Skip anchor checking for URL with prefix in config (#812)
TjeuKayim Oct 14, 2019
82ac173
Update tera
Keats Oct 20, 2019
b23c32d
Do not attempt to serve on "well-known" ports (#824)
homeworkprod Oct 24, 2019
b782f8c
Properly escape `&` in injected live-reload script tag (#825)
homeworkprod Oct 24, 2019
16dabd8
Paginator total pages (#829)
Geobert Oct 28, 2019
75ccfae
fix(init): handle already existing path (#815)
riginding Oct 28, 2019
0cd047b
Update base64
Keats Oct 28, 2019
83363d8
Add title and body to alias page (#830)
spk Oct 28, 2019
9839eac
Update changelog
Keats Oct 28, 2019
c83a53b
Update changelog
Keats Oct 30, 2019
450451b
fixes #844 duplicate entries in doc (#845)
SansGuidon Nov 19, 2019
6a2d2c8
Skip link checking for URL with prefix in config (#846)
TjeuKayim Nov 25, 2019
843c406
Simple clean up of documentation. (#849)
photong Nov 26, 2019
e0a05ef
Fix some doc changes
Keats Nov 26, 2019
8f669d3
Section extra -> SitemapEntry (#850)
stanistan Nov 26, 2019
7fe7c1b
Update deps
Keats Nov 26, 2019
53df9f1
Compute canonical path before adjusting parent path (#856)
phil-opp Nov 27, 2019
f42e819
Link to issues for regression tests
Keats Nov 27, 2019
dfd1885
Check for paths collisions
Keats Dec 1, 2019
80c3364
Finish path collision & fix paginate_path when empty
Keats Dec 1, 2019
f7955e4
Add path to `TranslatedContent` (#863)
phil-opp Dec 6, 2019
d61e3dd
Update Tera
Keats Dec 7, 2019
b83321f
Fix Clippy warnings (#886)
samford Dec 19, 2019
d1b2ada
Optionally do not slugify paths (#875)
Keats Dec 21, 2019
4edc299
Use Rust 2018 edition (#885)
samford Dec 21, 2019
cdd9928
Update livereload.js to v3.1.0 (#891)
samford Dec 22, 2019
c0ab32c
Bump minimum Rust version to 1.39.0 (#895)
samford Dec 23, 2019
1c5a66b
Format code using cargo fmt (#896)
samford Dec 23, 2019
80327c0
link_checker: Handle non-success status codes (#897)
samford Dec 23, 2019
d7a7fcd
Print remove_dir_all error on ctrl-c
Keats Dec 23, 2019
caaec21
Mock HTTP requests in tests (#898)
samford Dec 23, 2019
2773ca8
Treat 304 as valid, add mock tests, fix mock issue (#900)
samford Dec 24, 2019
f5dce64
Fix benchmarks (#901)
samford Dec 26, 2019
3f2252b
Update reqwest to v0.10 (#892)
samford Dec 31, 2019
e75ecd6
Serialize toc level
Keats Dec 31, 2019
9eefa02
Migrate serve command to hyper (#904)
samford Dec 31, 2019
610704c
Disable check_site test for now
Keats Jan 7, 2020
b5a47d8
fixed warning (#912)
djugei Jan 7, 2020
7de2544
Update tokio and re-enable check_site test (#915)
samford Jan 11, 2020
42b7a5b
Detect empty links on markdown rendering and issue an error (#884)
zbrox Jan 11, 2020
48ac2ee
Add Markdown strikethrough rendering (#924)
Jan 17, 2020
d96ddc7
Docs next (#858)
photong Jan 20, 2020
68ad8aa
Add --root global argument. Fixes #899. (#932)
etherealvisage Jan 21, 2020
e6a4181
Add feature flags to reduce dependencies
traviscross Jan 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ stage

# nixos dependencies snippet
shell.nix
# vim temporary files
**/.*.sw*
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 0.10.0 (unreleased)

### Breaking
- Remove `toc` variable in section/page context and pass it to `page.toc` and `section.toc` instead so they are
accessible everywhere
- [Slugification](https://en.wikipedia.org/wiki/Slug_(web_publishing)#Slug) of page paths is now optional. By default, every path will be slugified as it is happening right now.
To keep non-ASCII characters, set `slugify_paths = true` in your config.

### Other
- Add zenburn syntax highlighting theme
- Fix `zola init .`
- Add `total_pages` to paginator
- Do not prepend URL prefix to links that start with a scheme
- Allow skipping anchor checking in `zola check` for some URL prefixes
- Allow skipping prefixes in `zola check`
- Check for path collisions when building the site

## 0.9.0 (2019-09-28)

### Breaking
Expand Down
2,004 changes: 719 additions & 1,285 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 26 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "zola"
version = "0.9.0"
version = "0.10.0"
authors = ["Vincent Prouillet <[email protected]>"]
edition = "2018"
license = "MIT"
readme = "README.md"
description = "A fast static site generator with everything built-in"
Expand All @@ -16,6 +17,20 @@ clap = "2"
[[bin]]
name = "zola"

[features]
default = ["request", "serve"]
request = ["rebuild/request", "site/request"]
serve = [
"hyper",
"hyper-staticfile",
"tokio",
"notify",
"ws",
"ctrlc",
"open",
"globset",
]

[dependencies]
atty = "0.2.11"
clap = "2"
Expand All @@ -25,19 +40,20 @@ termcolor = "1.0.4"
# Used in init to ensure the url given as base_url is a valid one
url = "2"
# Below is for the serve cmd
actix-files = "0.1"
actix-web = { version = "1.0", default-features = false, features = [] }
notify = "4"
ws = "0.9"
ctrlc = "3"
open = "1.2"
globset = "0.4"
hyper = { version = "0.13", default-features = false, features = ["runtime"], optional = true }
hyper-staticfile = { version = "0.5", optional = true }
tokio = { version = "0.2", default-features = false, features = [], optional = true }
notify = { version = "4", optional = true }
ws = { version = "0.9", optional = true }
ctrlc = { version = "3", optional = true }
open = { version = "1.2", optional = true }
globset = { version = "0.4", optional = true }

site = { path = "components/site" }
site = { path = "components/site", default-features = false }
errors = { path = "components/errors" }
front_matter = { path = "components/front_matter" }
utils = { path = "components/utils" }
rebuild = { path = "components/rebuild" }
rebuild = { path = "components/rebuild", default-features = false }

[workspace]
members = [
Expand Down
1 change: 1 addition & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
| [maxdeviant.com](https://maxdeviant.com/) | |
| [Uwes Blog](https://uwe-arzt.de) | https://github.com/uwearzt/site-uwe-arzt |
| [ozkriff.games](https://ozkriff.games) | https://github.com/ozkriff/ozkriff.github.io-src |
| [Sylvain Kerkour](https://kerkour.fr) | https://gitlab.com/z0mbie42/kerkour.fr |
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ stages:
linux-stable:
imageName: 'ubuntu-16.04'
rustup_toolchain: stable
linux-1.35:
linux-1.39:
imageName: 'ubuntu-16.04'
rustup_toolchain: 1.35.0
rustup_toolchain: 1.39.0
pool:
vmImage: $(imageName)
steps:
Expand Down
3 changes: 0 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate clap;

// use clap::Shell;

include!("src/cli.rs");
Expand Down
1 change: 1 addition & 0 deletions components/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "config"
version = "0.1.0"
authors = ["Vincent Prouillet <[email protected]>"]
edition = "2018"

[dependencies]
toml = "0.5"
Expand Down
26 changes: 22 additions & 4 deletions components/config/examples/generate_sublime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
//! syntect, not as a helpful example for beginners.
//! Although it is a valid example for serializing syntaxes, you probably won't need
//! to do this yourself unless you want to cache your own compiled grammars.
extern crate syntect;

use std::collections::HashMap;
use std::collections::HashSet;
use std::env;
use std::iter::FromIterator;
use syntect::dumps::*;
use syntect::highlighting::ThemeSet;
use syntect::parsing::SyntaxSetBuilder;
Expand All @@ -26,10 +29,25 @@ fn main() {
builder.add_from_folder(package_dir, true).unwrap();
let ss = builder.build();
dump_to_file(&ss, packpath_newlines).unwrap();
let mut syntaxes: HashMap<String, HashSet<String>> = HashMap::new();

for s in ss.syntaxes() {
if !s.file_extensions.is_empty() {
println!("- {} -> {:?}", s.name, s.file_extensions);
for s in ss.syntaxes().iter() {
syntaxes
.entry(s.name.clone())
.and_modify(|e| {
for ext in &s.file_extensions {
e.insert(ext.clone());
}
})
.or_insert_with(|| HashSet::from_iter(s.file_extensions.iter().cloned()));
}
let mut keys = syntaxes.keys().collect::<Vec<_>>();
keys.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase()));
for k in keys {
if !syntaxes[k].is_empty() {
let mut extensions_sorted = syntaxes[k].iter().cloned().collect::<Vec<_>>();
extensions_sorted.sort();
println!("- {} -> {:?}", k, extensions_sorted);
}
}
}
Expand Down
84 changes: 76 additions & 8 deletions components/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::path::{Path, PathBuf};

use chrono::Utc;
use globset::{Glob, GlobSet, GlobSetBuilder};
use serde_derive::{Deserialize, Serialize};
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
use toml;
use toml::Value as Toml;

use errors::Result;
use errors::Error;
use highlighting::THEME_SET;
use theme::Theme;
use crate::highlighting::THEME_SET;
use crate::theme::Theme;
use errors::{bail, Error, Result};
use utils::fs::read_file_with_error;

// We want a default base url for tests
Expand Down Expand Up @@ -86,7 +86,22 @@ impl Default for Taxonomy {
}
}

type TranslateTerm = HashMap<String, String>;
type TranslateTerm = HashMap<String, String>;

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct LinkChecker {
/// Skip link checking for these URL prefixes
pub skip_prefixes: Vec<String>,
/// Skip anchor checking for these URL prefixes
pub skip_anchor_prefixes: Vec<String>,
}

impl Default for LinkChecker {
fn default() -> LinkChecker {
LinkChecker { skip_prefixes: Vec::new(), skip_anchor_prefixes: Vec::new() }
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
Expand Down Expand Up @@ -115,6 +130,8 @@ pub struct Config {
/// key into different language.
translations: HashMap<String, TranslateTerm>,

/// Whether to slugify page and taxonomy URLs (disable for UTF-8 URLs)
pub slugify_paths: bool,
/// Whether to highlight all code blocks found in markdown files. Defaults to false
pub highlight_code: bool,
/// Which themes to use for code highlighting. See Readme for supported themes
Expand Down Expand Up @@ -152,6 +169,8 @@ pub struct Config {
#[serde(skip_serializing, skip_deserializing)] // not a typo, 2 are need
pub extra_syntax_set: Option<SyntaxSet>,

pub link_checker: LinkChecker,

/// All user params set in [extra] in the config
pub extra: HashMap<String, Toml>,

Expand Down Expand Up @@ -317,9 +336,16 @@ impl Config {
Error::msg(format!("Translation for language '{}' is missing", lang.as_ref()))
})?;

terms.get(key.as_ref()).ok_or_else(|| {
Error::msg(format!("Translation key '{}' for language '{}' is missing", key.as_ref(), lang.as_ref()))
}).map(|term| term.to_string())
terms
.get(key.as_ref())
.ok_or_else(|| {
Error::msg(format!(
"Translation key '{}' for language '{}' is missing",
key.as_ref(),
lang.as_ref()
))
})
.map(|term| term.to_string())
}
}

Expand All @@ -330,6 +356,7 @@ impl Default for Config {
title: None,
description: None,
theme: None,
slugify_paths: true,
highlight_code: false,
highlight_theme: "base16-ocean-dark".to_string(),
default_language: "en".to_string(),
Expand All @@ -346,6 +373,7 @@ impl Default for Config {
translations: HashMap::new(),
extra_syntaxes: Vec::new(),
extra_syntax_set: None,
link_checker: LinkChecker::default(),
extra: HashMap::new(),
build_timestamp: Some(1),
}
Expand Down Expand Up @@ -551,4 +579,44 @@ ignored_content = ["*.{graphml,iso}", "*.py?"]
assert!(g.is_match("foo.py3"));
assert!(!g.is_match("foo.py"));
}

#[test]
fn link_checker_skip_anchor_prefixes() {
let config_str = r#"
title = "My site"
base_url = "example.com"

[link_checker]
skip_anchor_prefixes = [
"https://caniuse.com/#feat=",
"https://github.com/rust-lang/rust/blob/",
]
"#;

let config = Config::parse(config_str).unwrap();
assert_eq!(
config.link_checker.skip_anchor_prefixes,
vec!["https://caniuse.com/#feat=", "https://github.com/rust-lang/rust/blob/"]
);
}

#[test]
fn link_checker_skip_prefixes() {
let config_str = r#"
title = "My site"
base_url = "example.com"

[link_checker]
skip_prefixes = [
"http://[2001:db8::]/",
"https://www.example.com/path",
]
"#;

let config = Config::parse(config_str).unwrap();
assert_eq!(
config.link_checker.skip_prefixes,
vec!["http://[2001:db8::]/", "https://www.example.com/path",]
);
}
}
3 changes: 2 additions & 1 deletion components/config/src/highlighting.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use lazy_static::lazy_static;
use syntect::dumps::from_binary;
use syntect::easy::HighlightLines;
use syntect::highlighting::ThemeSet;
use syntect::parsing::SyntaxSet;

use Config;
use crate::config::Config;

lazy_static! {
pub static ref SYNTAX_SET: SyntaxSet = {
Expand Down
15 changes: 1 addition & 14 deletions components/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
#[macro_use]
extern crate serde_derive;
extern crate chrono;
extern crate globset;
extern crate toml;
#[macro_use]
extern crate lazy_static;
extern crate syntect;

#[macro_use]
extern crate errors;
extern crate utils;

mod config;
pub mod highlighting;
mod theme;
pub use config::{Config, Language, Taxonomy};
pub use crate::config::{Config, Language, LinkChecker, Taxonomy};

use std::path::Path;

Expand Down
3 changes: 2 additions & 1 deletion components/config/src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::HashMap;
use std::path::PathBuf;

use serde_derive::{Deserialize, Serialize};
use toml::Value as Toml;

use errors::Result;
use errors::{bail, Result};
use utils::fs::read_file_with_error;

/// Holds the data from a `theme.toml` file.
Expand Down
3 changes: 2 additions & 1 deletion components/errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name = "errors"
version = "0.1.0"
authors = ["Vincent Prouillet <[email protected]>"]
edition = "2018"

[dependencies]
tera = "1.0.0-beta.10"
tera = "1"
toml = "0.5"
image = "0.22"
syntect = "=3.2.0"
17 changes: 12 additions & 5 deletions components/errors/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
extern crate image;
extern crate syntect;
extern crate tera;
extern crate toml;

use std::convert::Into;
use std::error::Error as StdError;
use std::fmt;
Expand Down Expand Up @@ -63,6 +58,18 @@ impl Error {
pub fn chain(value: impl ToString, source: impl Into<Box<dyn StdError>>) -> Self {
Self { kind: ErrorKind::Msg(value.to_string()), source: Some(source.into()) }
}

/// Create an error from a list of path collisions, formatting the output
pub fn from_collisions(collisions: Vec<(&str, Vec<String>)>) -> Self {
let mut msg = String::from("Found path collisions:\n");

for (path, filepaths) in collisions {
let row = format!("- `{}` from files {:?}\n", path, filepaths);
msg.push_str(&row);
}

Self { kind: ErrorKind::Msg(msg), source: None }
}
}

impl From<&str> for Error {
Expand Down
Loading