Skip to content

Commit

Permalink
Merge pull request getzola#567 from getzola/next
Browse files Browse the repository at this point in the history
v.0.6.0
  • Loading branch information
Keats authored Mar 25, 2019
2 parents bf95649 + 6822c08 commit 5d695d7
Show file tree
Hide file tree
Showing 138 changed files with 5,653 additions and 2,233 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
target
.idea/
test_site/public
test_site_i18n/public
docs/public

small-blog
medium-blog
big-blog
huge-blog
extra-huge-blog
small-kb
medium-kb
huge-kb

current.bench
now.bench
*.zst

# snapcraft artifacts
snap/.snapcraft
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ matrix:

# The earliest stable Rust version that works
- env: TARGET=x86_64-unknown-linux-gnu
rust: 1.30.0
rust: 1.31.0


before_install: set -e
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 0.6.0 (unreleased)

### Breaking
- `earlier/later` and `lighter/heavier` are not set anymore on pages when rendering
a section
- The table of content for a page/section is now only available as the `toc` variable when
rendering it and not anymore on the `page`/`section` variable
- Default directory for `load_data` is now the root of the site instead of the `content` directory
- Change variable sent to the sitemap template, see documentation for details

### Other
- Add support for content in multiple languages
- Lower latency on serve before rebuilding from 2 to 1 second
- Allow processing PNG and produced images are less blurry
- Add an id (`zola-continue-reading`) to the paragraph generated after a summary
- Add Dracula syntax highlighting theme
- Fix using inline styles in headers
- Fix sections with render=false being shown in sitemap
- Sitemap is now split when there are more than 30 000 links in it
- Add link to sitemap in robots.txt
- Markdown rendering is now fully CommonMark compliant
- `load_data` now defaults to loading file as plain text, unless `format` is passed
or the extension matches csv/toml/json
- Sitemap entries get an additional `extra` field for pages only
- Add a `base-path` command line option to `build` and `serve`


## 0.5.1 (2018-12-14)

- Fix deleting markdown file in `zola serve`
Expand Down
1,767 changes: 961 additions & 806 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zola"
version = "0.5.1"
version = "0.6.0"
authors = ["Vincent Prouillet <[email protected]>"]
license = "MIT"
readme = "README.md"
Expand Down
2 changes: 2 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
| [Daniel Sockwell's codesections.com](https://www.codesections.com) | https://gitlab.com/codesections/codesections-website |
| [Jens Getreu's blog](https://blog.getreu.net) | |
| [Matthias Endler](https://matthias-endler.de) | https://github.com/mre/mre.github.io |
| [Michael Plotke](https://michael.plotke.me) | https://gitlab.com/bdjnk/michael |
| [shaleenjain.com](https://shaleenjain.com) | https://github.com/shalzz/shalzz.github.io |
| [Hello, Rust!](https://hello-rust.show) | https://github.com/hello-rust/hello-rust.github.io |
| [maxdeviant.com](https://maxdeviant.com/) | |
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ in the `docs/content` folder of the repository and the community can use [its fo
| Syntax highlighting |||||
| Sass compilation |||||
| Assets co-location |||||
| i18n | ||||
| Multilingual site | ||||
| Image processing |||||
| Sane & powerful template engine || ~ | ~ ||
| Themes |||||
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:

matrix:
- target: x86_64-pc-windows-msvc
RUST_VERSION: 1.29.0
RUST_VERSION: 1.31.0
- target: x86_64-pc-windows-msvc
RUST_VERSION: stable

Expand Down
1 change: 1 addition & 0 deletions components/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ lazy_static = "1"
syntect = "3"

errors = { path = "../errors" }
utils = { path = "../utils" }
61 changes: 50 additions & 11 deletions components/config/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};

use chrono::Utc;
Expand All @@ -9,13 +7,29 @@ use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
use toml;
use toml::Value as Toml;

use errors::{Result, ResultExt};
use errors::Result;
use highlighting::THEME_SET;
use theme::Theme;
use utils::fs::read_file_with_error;

// We want a default base url for tests
static DEFAULT_BASE_URL: &'static str = "http://a-website.com";

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct Language {
/// The language code
pub code: String,
/// Whether to generate a RSS feed for that language, defaults to `false`
pub rss: bool,
}

impl Default for Language {
fn default() -> Language {
Language { code: String::new(), rss: false }
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct Taxonomy {
Expand All @@ -27,6 +41,9 @@ pub struct Taxonomy {
pub paginate_path: Option<String>,
/// Whether to generate a RSS feed only for each taxonomy term, defaults to false
pub rss: bool,
/// The language for that taxonomy, only used in multilingual sites.
/// Defaults to the config `default_language` if not set
pub lang: String,
}

impl Taxonomy {
Expand All @@ -49,7 +66,13 @@ impl Taxonomy {

impl Default for Taxonomy {
fn default() -> Taxonomy {
Taxonomy { name: String::new(), paginate_by: None, paginate_path: None, rss: false }
Taxonomy {
name: String::new(),
paginate_by: None,
paginate_path: None,
rss: false,
lang: String::new(),
}
}
}

Expand All @@ -68,6 +91,8 @@ pub struct Config {

/// The language used in the site. Defaults to "en"
pub default_language: String,
/// The list of supported languages outside of the default one
pub languages: Vec<Language>,
/// Languages list and translated strings
pub translations: HashMap<String, Toml>,

Expand Down Expand Up @@ -148,20 +173,23 @@ impl Config {
Some(glob_set_builder.build().expect("Bad ignored_content in config file."));
}

for taxonomy in config.taxonomies.iter_mut() {
if taxonomy.lang.is_empty() {
taxonomy.lang = config.default_language.clone();
}
}

Ok(config)
}

/// Parses a config file from the given path
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Config> {
let mut content = String::new();
let path = path.as_ref();
let file_name = path.file_name().unwrap();
File::open(path)
.chain_err(|| {
format!("No `{:?}` file found. Are you in the right directory?", file_name)
})?
.read_to_string(&mut content)?;

let content = read_file_with_error(
path,
&format!("No `{:?}` file found. Are you in the right directory?", file_name),
)?;
Config::parse(&content)
}

Expand Down Expand Up @@ -227,6 +255,16 @@ impl Config {
let theme = Theme::from_file(path)?;
self.add_theme_extra(&theme)
}

/// Is this site using i18n?
pub fn is_multilingual(&self) -> bool {
!self.languages.is_empty()
}

/// Returns the codes of all additional languages
pub fn languages_codes(&self) -> Vec<&str> {
self.languages.iter().map(|l| l.code.as_ref()).collect()
}
}

impl Default for Config {
Expand All @@ -239,6 +277,7 @@ impl Default for Config {
highlight_code: false,
highlight_theme: "base16-ocean-dark".to_string(),
default_language: "en".to_string(),
languages: Vec::new(),
generate_rss: false,
rss_limit: None,
taxonomies: Vec::new(),
Expand Down
10 changes: 6 additions & 4 deletions components/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#[macro_use]
extern crate serde_derive;
extern crate toml;
#[macro_use]
extern crate errors;
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, Taxonomy};
pub use config::{Config, Language, Taxonomy};

use std::path::Path;

Expand Down
20 changes: 8 additions & 12 deletions components/config/src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;

use toml::Value as Toml;

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

/// Holds the data from a `theme.toml` file.
/// There are other fields than `extra` in it but Zola
Expand Down Expand Up @@ -40,15 +39,12 @@ impl Theme {

/// Parses a theme file from the given path
pub fn from_file(path: &PathBuf) -> Result<Theme> {
let mut content = String::new();
File::open(path)
.chain_err(|| {
"No `theme.toml` file found. \
Is the `theme` defined in your `config.toml present in the `themes` directory \
and does it have a `theme.toml` inside?"
})?
.read_to_string(&mut content)?;

let content = read_file_with_error(
path,
"No `theme.toml` file found. \
Is the `theme` defined in your `config.toml present in the `themes` directory \
and does it have a `theme.toml` inside?",
)?;
Theme::parse(&content)
}
}
5 changes: 2 additions & 3 deletions components/errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <[email protected]>"]

[dependencies]
error-chain = "0.12"
tera = "0.11"
tera = "1.0.0-alpha.3"
toml = "0.4"
image = "0.20"
image = "0.21"
syntect = "3"
Loading

0 comments on commit 5d695d7

Please sign in to comment.