From 91fa7e358cb04936aa665928ae5e525a7bf05c87 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Thu, 23 Feb 2017 17:34:57 +0900 Subject: [PATCH] Started working on gutenberg again --- .gitignore | 2 + Cargo.lock | 489 +++++++++++++++++++++++++++++++++----------- Cargo.toml | 15 +- README.md | 8 +- src/cmd/build.rs | 25 +-- src/cmd/init.rs | 9 +- src/config.rs | 107 ++++++---- src/errors.rs | 13 +- src/front_matter.rs | 218 ++++++++++---------- src/main.rs | 25 ++- src/page.rs | 188 +++++++++-------- 11 files changed, 701 insertions(+), 398 deletions(-) diff --git a/.gitignore b/.gitignore index 187b750..99fac5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ target .idea/ +site +theme diff --git a/Cargo.lock b/Cargo.lock index 12ff837..78e0b8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,26 +2,27 @@ name = "gutenberg" version = "0.1.0" dependencies = [ - "clap 2.19.2 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.20.5 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tera 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syntect 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tera 0.7.2 (git+https://github.com/Keats/tera?branch=next)", + "toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aho-corasick" -version = "0.5.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -34,22 +35,33 @@ name = "backtrace" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.5" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bincode" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -62,26 +74,67 @@ name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cfg-if" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "chrono" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "chrono" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" -version = "2.19.2" +version = "2.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cmake" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dbghelp-sys" version = "0.2.0" @@ -93,20 +146,34 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.2.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "error-chain" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fnv" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "gcc" -version = "0.3.40" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -121,7 +188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "humansize" -version = "0.1.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -130,13 +197,13 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.1.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -155,7 +222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -165,10 +232,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "0.1.11" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz-sys" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-iter" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -176,11 +279,49 @@ name = "num-traits" version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "onig" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "onig_sys 61.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "onig_sys" +version = "61.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pest" -version = "0.4.0" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pkg-config" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "plist" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", + "xml-rs 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pulldown-cmark" version = "0.0.8" @@ -192,24 +333,29 @@ dependencies = [ [[package]] name = "quote" -version = "0.3.10" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_syscall" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "0.1.80" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.3.9" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -218,45 +364,56 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "serde" -version = "0.8.20" +name = "rustc-serialize" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "serde_codegen" -version = "0.8.20" +name = "same-file" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen_internals 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "serde_codegen_internals" -version = "0.11.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syn 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "0.8.20" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_codegen 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen_internals 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "0.8.4" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -269,73 +426,113 @@ dependencies = [ [[package]] name = "strsim" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.10.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "tera" -version = "0.5.0" +name = "synom" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syntect" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "onig 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "plist 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tera" +version = "0.7.2" +source = "git+https://github.com/Keats/tera?branch=next#cd13a801b61e8c11ef829943bd3f34ae7d9d4bab" +dependencies = [ + "chrono 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humansize 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "humansize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pest 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "term_size" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread-id" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" -version = "0.2.7" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "time" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "toml" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicode-bidi" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -343,22 +540,22 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-segmentation" -version = "0.1.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-xid" -version = "0.0.3" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -366,9 +563,17 @@ name = "unidecode" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unreachable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "url" -version = "1.2.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -377,7 +582,7 @@ dependencies = [ [[package]] name = "utf8-ranges" -version = "0.1.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -385,12 +590,18 @@ name = "vec_map" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "walkdir" -version = "1.0.3" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -404,58 +615,98 @@ name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "xml-rs" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "yaml-rust" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +"checksum aho-corasick 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0638fd549427caa90c499814196d1b9e3725eb4d15d7339d6de073a680ed0ca2" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum backtrace 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f551bc2ddd53aea015d453ef0b635af89444afa5ed2405dd0b2062ad5d600d80" -"checksum backtrace-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3602e8d8c43336088a8505fa55cae2b3884a9be29440863a11528a42f46f6bb7" +"checksum backtrace-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d192fd129132fbc97497c1f2ec2c2c5174e376b95f535199ef4fe0a293d33842" +"checksum bincode 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "55eb0b7fd108527b0c77860f75eca70214e11a8b4c6ef05148c54c05a25d48ad" "checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum bitflags 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e1ab483fc81a8143faa7203c4a3c02888ebd1a782e37e41fa34753ba9a162" +"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" +"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" -"checksum clap 2.19.2 (registry+https://github.com/rust-lang/crates.io-index)" = "305ad043f009db535a110200541d4567b63e172b1fe030313fbb92565da7ed24" +"checksum chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00" +"checksum chrono 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "158b0bd7d75cbb6bf9c25967a48a2e9f77da95876b858eadfabaa99cd069de6e" +"checksum clap 2.20.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7db281b0520e97fbd15cd615dcd8f8bcad0c26f5f7d5effe705f090f39e9a758" +"checksum cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a6805df695087e7c1bcd9a82e03ad6fb864c8e67ac41b1348229ce5b7f0407" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" -"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d" -"checksum error-chain 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1cd681735364a04cd5d69f01a4f6768e70473941f8d86d8c224faf6955a75799" -"checksum gcc 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "872db9e59486ef2b14f8e8c10e9ef02de2bccef6363d7f34835dedb386b3d950" +"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" +"checksum error-chain 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e92ecf0a508c8e074c0e6fa8fe0fa38414848ad4dfc4db6f74c5e9753330b248" +"checksum flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "d4e4d0c15ef829cbc1b7cda651746be19cceeb238be7b1049227b14891df9e25" +"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" +"checksum gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)" = "c07c758b972368e703a562686adb39125707cc1ef3399da8c019fc6c2498a75d" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" -"checksum humansize 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ec9e8cc78ff5f1f18be53b9a0295dce25c668c10cd60c4d3e535b8882a88f77" +"checksum humansize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b963e0c0a5149e12a9cab4d889404e4935e3484db7c4d9681e8bbdbcb9dfd80" "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" -"checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1" +"checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" -"checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" +"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5" "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" +"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" +"checksum miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "28eaee17666671fa872e567547e8428e83308ebe5808cdf6a0e28397dbe2c726" +"checksum num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "bde7c03b09e7c6a301ee81f6ddf66d7a28ec305699e3d3b056d2fc56470e3120" +"checksum num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "fb24d9bfb3f222010df27995441ded1e954f8f69cd35021f6bef02ca9552fb92" +"checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c" "checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" -"checksum pest 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f6666c81a6359af7a9dbc48f596d6f318a9dbaefdec248581ab836dc0c1f082" +"checksum onig 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5f586e53fa11ead18582956ea282c30baea1f25d3ee4c5fb85803f98727cb7" +"checksum onig_sys 61.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a35f2cca300f0945538564da6052a449db55e65870cf0e9d443c1bce3d5dda47" +"checksum pest 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e823a5967bb4cdc6d3e46f47baaf4ecfeae44413a642b74ad44e59e49c7f6" +"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" +"checksum plist 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c201fd99d98798fce524e3ea5dd91883c7def66d9ef6467ce014a05329de0799" "checksum pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1058d7bb927ca067656537eec4e02c2b4b70eaaa129664c5b90c111e20326f41" -"checksum quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6732e32663c9c271bfc7c1823486b471f18c47a2dbf87c066897b7b51afc83be" -"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum quote 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "08de3f12e670f83f61e450443cbae34496a35b665691fd8e99b24ec662f75865" +"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753" +"checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01" +"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" "checksum rustc-demangle 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1430d286cadb237c17c885e25447c982c97113926bb579f4379c0eca8d9586dc" -"checksum serde 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "793aa8d4a777e46a68bbf88998cd957e638427ba5bfb0de22c92ff277b65bd21" -"checksum serde_codegen 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "460354e47fffa7cf0c96fcf9a040fd170e957f43dd8032531083866eb4a51c11" -"checksum serde_codegen_internals 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55224f713f022184a1c332dc5c8b1ac634d25a355d54836386771947f12585e0" -"checksum serde_derive 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "18030bce88caabea7707ea4150557377f4b08df5ba3909b2c6a9cb34967c9f30" -"checksum serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3f7d3c184d35801fb8b32b46a7d58d57dbcc150b0eb2b46a1eb79645e8ecfd5b" +"checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b" +"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" +"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" +"checksum serde 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)" = "204db0f2a5335be7313fd4453132fd56d2085aed081c673140a256772903e116" +"checksum serde_codegen_internals 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a5113d5bd16471b183803b374f0fe4877ad9658b95e33b11f4a004d73aacc74a" +"checksum serde_derive 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)" = "e88ec062a02cbebfd6276044a305d665a9919b497aa6acb2e12c070d1a50d32d" +"checksum serde_json 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6501ac6f8b74f9b1033f7ddf79a08edfa0f58d6f8e3190cb8dc97736afa257a8" "checksum slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f5ff4b43cb07b86c5f9236c92714a22cdf9e5a27a7d85e398e2c9403328cb8" -"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c" -"checksum syn 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94e7d81ecd16d39f16193af05b8d5a0111b9d8d2f3f78f31760f327a247da777" -"checksum tera 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85033a49c2d956cd00f611a42196c4bd5868864b2a0da261cb278b3707409314" -"checksum term_size 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f7f5f3f71b0040cecc71af239414c23fd3c73570f5ff54cf50e03cef637f2a0" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" -"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" -"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" -"checksum unicode-segmentation 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c3bc443ded17b11305ffffe6b37e2076f328a5a8cb6aa877b1b98f77699e98b5" -"checksum unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6722facc10989f63ee0e20a83cd4e1714a9ae11529403ac7e0afd069abc39e" -"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" +"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" +"checksum syn 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0e28da8d02d75d1e58b89258e0741128f0b0d8a8309fb5c627be0fbd37a76c67" +"checksum synom 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8fece1853fb872b0acdc3ff88f37c474018e125ef81cd4cb8c0ca515746b62ed" +"checksum syntect 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f79be04af68d5fa09e71b3274159a955a25f25a5cbfba9a6ff64139b71d848a" +"checksum tera 0.7.2 (git+https://github.com/Keats/tera?branch=next)" = "" +"checksum term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "07b6c1ac5b3fffd75073276bca1ceed01f67a28537097a2a9539e116e50fb21a" +"checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a" +"checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7" +"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade" +"checksum toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08272367dd2e766db3fa38f068067d17aa6a9dfd7259af24b3927db92f1e0c2f" +"checksum unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a078ebdd62c0e71a709c3d53d2af693fe09fe93fbff8344aebe289b78f9032" +"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff" +"checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3" +"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unidecode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2adb95ee07cd579ed18131f2d9e7a17c25a4b76022935c7f2460d2bfae89fd2" -"checksum url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f024e241a55f5c88401595adc1d4af0c9649e91da82d0e190fe55950231ae575" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" +"checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" +"checksum url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5ba8a749fb4479b043733416c244fa9d1d3af3d7c23804944651c8a448cb87e" +"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cac5efe5cb0fa14ec2f84f83c701c562ee63f6dcc680861b21d65c682adfb05f" -"checksum walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd7c16466ecc507c7cb5988db03e6eab4aaeab89a5c37a29251fcfd3ac9b7afe" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum xml-rs 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "729264a98260c6469f7a7d7162baaf5869da5573f69ee08ccf3f3d9110cafe3b" +"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" diff --git a/Cargo.toml b/Cargo.toml index 4663299..8963a22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,20 +10,21 @@ repository = "https://github.com/Keats/gutenberg" keywords = ["static", "site", "generator", "blog"] [dependencies] -error-chain = "0.7" +error-chain = "0.9" clap = "2.19" walkdir = "1" pulldown-cmark = "0" -regex = "0.1" +regex = "0.2" lazy_static = "0.2" glob = "0.2" -serde = "0.8" -serde_json = "0.8" -serde_derive = "0.8" -tera = "0.5" +serde = "0.9" +serde_json = "0.9" +serde_derive = "0.9" +tera = { git = "https://github.com/Keats/tera", branch = "next" } +syntect = "1" [dependencies.toml] -version = "0.2" +version = "0.3" default-features = false features = ["serde"] diff --git a/README.md b/README.md index 9f59532..4656336 100644 --- a/README.md +++ b/README.md @@ -31,5 +31,9 @@ Get all .md files in content, remove the `content/` prefix to their path Split the file between front matter and content Parse the front matter markdown -> HTML for the content -TO THINK OF: create list pages for folders, can be done while globbing I guess? -Render templates + +# TODO: + +- syntax highlighting +- pass a --config arg to the CLI to change from `config.toml` +- have verbosity levels with a `verbosity` config variable with a default diff --git a/src/cmd/build.rs b/src/cmd/build.rs index e227208..85e6aad 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -18,7 +18,7 @@ pub fn build(config: Config) -> Result<()> { remove_dir_all("public").chain_err(|| "Couldn't delete `public` directory")?; } - let tera = Tera::new("layouts/**/*").chain_err(|| "Error parsing templates")?; + let tera = Tera::new("templates/**/*").chain_err(|| "Error parsing templates")?; // ok we got all the pages HTML, time to write them down to disk create_dir("public")?; @@ -32,7 +32,7 @@ pub fn build(config: Config) -> Result<()> { let path = entry.as_path(); let mut page = Page::from_file(&path)?; - let mut current_path = public.clone().to_path_buf(); + let mut current_path = public.to_path_buf(); for section in &page.sections { current_path.push(section); @@ -42,19 +42,17 @@ pub fn build(config: Config) -> Result<()> { } let str_path = current_path.as_path().to_string_lossy().to_string(); - if sections.contains_key(&str_path) { - sections.get_mut(&str_path).unwrap().push(page.clone()); - } else { - sections.insert(str_path, vec![page.clone()]); - } - + sections.entry(str_path).or_insert_with(|| vec![page.clone()]); } - if page.slug != "" { - current_path.push(&page.slug); + if let Some(ref url) = page.meta.url { + println!("URL: {:?}", url); + current_path.push(url); } else { - current_path.push(&page.url); + println!("REMOVE ME IF YOU DONT SEE ME"); + current_path.push(&page.get_slug()); } + create_dir(¤t_path)?; create_file(current_path.join("index.html"), &page.render_html(&tera, &config)?)?; pages.push(page); @@ -68,8 +66,7 @@ pub fn build(config: Config) -> Result<()> { let mut context = Context::new(); context.add("pages", &order_pages(pages)); context.add("config", &config); - create_file(public.join("index.html"), &tera.render("index.html", context)?)?; - + create_file(public.join("index.html"), &tera.render("index.html", &context)?)?; Ok(()) } @@ -86,5 +83,5 @@ fn render_section_index(section: String, pages: Vec, tera: &Tera, config: None => bail!("Couldn't find a section name in {:?}", path.display()) }; - create_file(path.join("index.html"), &tera.render(&format!("{}.html", section_name), context)?) + create_file(path.join("index.html"), &tera.render(&format!("{}.html", section_name), &context)?) } diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 87fe628..6b69133 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -8,12 +8,17 @@ use utils::create_file; const CONFIG: &'static str = r#" title = "My site" -base_url = "https://replace-this-with-your-url.com" +# replace the url below with yours +base_url = "https://example.com" + +[extra] +# Put all your custom variables here "#; pub fn create_new_project>(name: P) -> Result<()> { let path = name.as_ref(); + // Better error message than the rust default if path.exists() && path.is_dir() { bail!("Folder `{}` already exists", path.to_string_lossy().to_string()); @@ -27,7 +32,7 @@ pub fn create_new_project>(name: P) -> Result<()> { create_dir(path.join("content"))?; // layouts folder - create_dir(path.join("layouts"))?; + create_dir(path.join("templates"))?; create_dir(path.join("static"))?; diff --git a/src/config.rs b/src/config.rs index 5d8fcea..96696db 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,62 +1,52 @@ -use std::default::Default; use std::fs::File; use std::io::prelude::*; use std::path::Path; +use std::collections::HashMap; -use toml::Parser; - -use errors::{Result, ErrorKind, ResultExt}; +use toml::{Value as Toml, self}; +use errors::{Result, ResultExt}; +// TODO: disable tag(s)/category(ies) page generation #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Config { + /// Title of the site pub title: String, + /// Base URL of the site pub base_url: String, - - pub favicon: Option, -} - -impl Default for Config { - fn default() -> Config { - Config { - title: "".to_string(), - base_url: "".to_string(), - - favicon: None, - } - } + /// Description of the site + pub description: Option, + /// The language used in the site. Defaults to "en" + pub language_code: Option, + /// Whether to disable RSS generation, defaults to None (== generate RSS) + pub disable_rss: Option, + /// All user params set in [extra] in the config + pub extra: Option>, } impl Config { - pub fn from_str(content: &str) -> Result { - let mut parser = Parser::new(&content); - - if let Some(value) = parser.parse() { - let mut config = Config::default(); - - for (key, value) in value.iter() { - if key == "title" { - config.title = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string(); - } else if key == "base_url" { - config.base_url = value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string(); - } else if key == "favicon" { - config.favicon = Some(value.as_str().ok_or(ErrorKind::InvalidConfig)?.to_string()); - } - } - - return Ok(config); - } else { - bail!("Errors parsing front matter: {:?}", parser.errors); + /// Parses a string containing TOML to our Config struct + /// Any extra parameter will end up in the extra field + pub fn parse(content: &str) -> Result { + let mut config: Config = match toml::from_str(content) { + Ok(c) => c, + Err(e) => bail!(e) + }; + if config.language_code.is_none() { + config.language_code = Some("en".to_string()); } + + Ok(config) } + /// Parses a config file from the given path pub fn from_file>(path: P) -> Result { let mut content = String::new(); File::open(path) - .chain_err(|| "Failed to load config.toml. Are you in the right directory?")? + .chain_err(|| "No `config.toml` file found. Are you in the right directory?")? .read_to_string(&mut content)?; - Config::from_str(&content) + Config::parse(&content) } } @@ -72,7 +62,7 @@ title = "My site" base_url = "https://replace-this-with-your-url.com" "#; - let config = Config::from_str(config).unwrap(); + let config = Config::parse(config).unwrap(); assert_eq!(config.title, "My site".to_string()); } @@ -83,7 +73,44 @@ title = 1 base_url = "https://replace-this-with-your-url.com" "#; - let config = Config::from_str(config); + let config = Config::parse(config); + assert!(config.is_err()); + } + + #[test] + fn test_errors_when_missing_required_field() { + let config = r#" +title = "" + "#; + + let config = Config::parse(config); assert!(config.is_err()); } + + #[test] + fn test_can_add_extra_values() { + let config = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com" + +[extra] +hello = "world" + "#; + + let config = Config::parse(config); + assert!(config.is_ok()); + assert_eq!(config.unwrap().extra.unwrap().get("hello").unwrap().as_str().unwrap(), "world"); + } + + #[test] + fn test_language_defaults_to_en() { + let config = r#" +title = "My site" +base_url = "https://replace-this-with-your-url.com""#; + + let config = Config::parse(config); + assert!(config.is_ok()); + let config = config.unwrap(); + assert_eq!(config.language_code.unwrap(), "en"); + } } diff --git a/src/errors.rs b/src/errors.rs index 9f98a0e..5ff689c 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,19 +1,16 @@ use tera; - +use toml; error_chain! { + errors { + } + links { Tera(tera::Error, tera::ErrorKind); } foreign_links { Io(::std::io::Error); - } - - errors { - InvalidConfig { - description("invalid config") - display("The config.toml is invalid or is using the wrong type for an argument") - } + Toml(toml::de::Error); } } diff --git a/src/front_matter.rs b/src/front_matter.rs index 2528546..384d19c 100644 --- a/src/front_matter.rs +++ b/src/front_matter.rs @@ -1,150 +1,127 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; -use toml::{Parser, Value as TomlValue}; -use tera::{Value, to_value}; +use toml; +use tera::Value; use errors::{Result}; -use page::Page; - - -// Converts from one value (Toml) to another (Tera) -// Used to fill the Page::extra map -fn toml_to_tera(val: &TomlValue) -> Value { - match *val { - TomlValue::String(ref s) | TomlValue::Datetime(ref s) => to_value(s), - TomlValue::Boolean(ref b) => to_value(b), - TomlValue::Integer(ref n) => to_value(n), - TomlValue::Float(ref n) => to_value(n), - TomlValue::Array(ref arr) => to_value(&arr.into_iter().map(toml_to_tera).collect::>()), - TomlValue::Table(ref table) => { - to_value(&table.into_iter().map(|(k, v)| { - (k, toml_to_tera(v)) - }).collect::>()) - } - } + + +/// The front matter of every page +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct FrontMatter { + // of the page + pub title: String, + /// Description that appears when linked, e.g. on twitter + pub description: String, + + /// Date if we want to order pages (ie blog post) + pub date: Option<String>, + /// The page slug. Will be used instead of the filename if present + /// Can't be an empty string if present + pub slug: Option<String>, + /// The url the page appears at, overrides the slug if set in the front-matter + /// otherwise is set after parsing front matter and sections + /// Can't be an empty string if present + pub url: Option<String>, + /// Tags, not to be confused with categories + pub tags: Option<Vec<String>>, + /// Whether this page is a draft and should be published or not + pub draft: Option<bool>, + /// Only one category allowed + pub category: Option<String>, + /// Optional layout, if we want to specify which tpl to render for that page + #[serde(skip_serializing)] + pub layout: Option<String>, + /// Any extra parameter present in the front matter + pub extra: Option<HashMap<String, Value>>, } +impl FrontMatter { + pub fn parse(toml: &str) -> Result<FrontMatter> { + if toml.trim() == "" { + bail!("Front matter of file is missing"); + } -pub fn parse_front_matter(front_matter: &str, page: &mut Page) -> Result<()> { - if front_matter.trim() == "" { - bail!("Front matter of file is missing"); - } + let mut f: FrontMatter = match toml::from_str(toml) { + Ok(d) => d, + Err(e) => bail!(e), + }; - let mut parser = Parser::new(&front_matter); - - if let Some(value) = parser.parse() { - for (key, value) in value.iter() { - match key.as_str() { - "title" | "slug" | "url" | "category" | "layout" | "description" => match *value { - TomlValue::String(ref s) => { - if key == "title" { - page.title = s.to_string(); - } else if key == "slug" { - page.slug = s.to_string(); - } else if key == "url" { - page.url = s.to_string(); - } else if key == "category" { - page.category = Some(s.to_string()); - } else if key == "layout" { - page.layout = Some(s.to_string()); - } else if key == "description" { - page.description = Some(s.to_string()); - } - } - _ => bail!("Field {} should be a string", key) - }, - "draft" => match *value { - TomlValue::Boolean(b) => page.is_draft = b, - _ => bail!("Field {} should be a boolean", key) - }, - "date" => match *value { - TomlValue::Datetime(ref d) => page.date = Some(d.to_string()), - _ => bail!("Field {} should be a date", key) - }, - "tags" => match *value { - TomlValue::Array(ref a) => { - for elem in a { - if key == "tags" { - match *elem { - TomlValue::String(ref s) => page.tags.push(s.to_string()), - _ => bail!("Tag `{}` should be a string") - } - } - } - }, - _ => bail!("Field {} should be an array", key) - }, - // extra fields - _ => { - page.extra.insert(key.to_string(), toml_to_tera(value)); - } + if let Some(ref slug) = f.slug { + if slug == "" { + bail!("`slug` can't be empty if present") } } - } else { - bail!("Errors parsing front matter: {:?}", parser.errors); - } - if page.title == "" || (page.slug == "" && page.url == "") { - bail!("Front matter is missing required fields (title, slug/url or both)"); - } + if let Some(ref url) = f.url { + if url == "" { + bail!("`url` can't be empty if present") + } + } - Ok(()) + Ok(f) + } } + #[cfg(test)] mod tests { - use super::{parse_front_matter}; + use super::{FrontMatter}; use tera::to_value; - use page::Page; #[test] fn test_can_parse_a_valid_front_matter() { let content = r#" title = "Hello" -slug = "hello-world""#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); +description = "hey there""#; + let res = FrontMatter::parse(content); + println!("{:?}", res); assert!(res.is_ok()); - - assert_eq!(page.title, "Hello".to_string()); - assert_eq!(page.slug, "hello-world".to_string()); + let res = res.unwrap(); + assert_eq!(res.title, "Hello".to_string()); + assert_eq!(res.description, "hey there".to_string()); } #[test] fn test_can_parse_tags() { let content = r#" title = "Hello" +description = "hey there" slug = "hello-world" tags = ["rust", "html"]"#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); assert!(res.is_ok()); + let res = res.unwrap(); - assert_eq!(page.title, "Hello".to_string()); - assert_eq!(page.slug, "hello-world".to_string()); - assert_eq!(page.tags, ["rust".to_string(), "html".to_string()]); + assert_eq!(res.title, "Hello".to_string()); + assert_eq!(res.slug.unwrap(), "hello-world".to_string()); + assert_eq!(res.tags.unwrap(), ["rust".to_string(), "html".to_string()]); } #[test] fn test_can_parse_extra_attributes_in_frontmatter() { let content = r#" title = "Hello" +description = "hey there" slug = "hello-world" + +[extra] language = "en" authors = ["Bob", "Alice"]"#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); assert!(res.is_ok()); + let res = res.unwrap(); - assert_eq!(page.title, "Hello".to_string()); - assert_eq!(page.slug, "hello-world".to_string()); - assert_eq!(page.extra.get("language").unwrap(), &to_value("en")); + assert_eq!(res.title, "Hello".to_string()); + assert_eq!(res.slug.unwrap(), "hello-world".to_string()); + let extra = res.extra.unwrap(); + assert_eq!(extra.get("language").unwrap(), &to_value("en").unwrap()); assert_eq!( - page.extra.get("authors").unwrap(), - &to_value(["Bob".to_string(), "Alice".to_string()]) + extra.get("authors").unwrap(), + &to_value(["Bob".to_string(), "Alice".to_string()]).unwrap() ); } @@ -152,35 +129,33 @@ authors = ["Bob", "Alice"]"#; fn test_is_ok_with_url_instead_of_slug() { let content = r#" title = "Hello" +description = "hey there" url = "hello-world""#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); assert!(res.is_ok()); - assert_eq!(page.slug, "".to_string()); - assert_eq!(page.url, "hello-world".to_string()); + let res = res.unwrap(); + assert!(res.slug.is_none()); + assert_eq!(res.url.unwrap(), "hello-world".to_string()); } #[test] fn test_errors_with_empty_front_matter() { let content = r#" "#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); assert!(res.is_err()); } #[test] fn test_errors_with_invalid_front_matter() { let content = r#"title = 1\n"#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); assert!(res.is_err()); } #[test] fn test_errors_with_missing_required_value_front_matter() { let content = r#"title = """#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); assert!(res.is_err()); } @@ -188,10 +163,29 @@ url = "hello-world""#; fn test_errors_on_non_string_tag() { let content = r#" title = "Hello" +description = "hey there" slug = "hello-world" tags = ["rust", 1]"#; - let mut page = Page::default(); - let res = parse_front_matter(content, &mut page); + let res = FrontMatter::parse(content); + assert!(res.is_err()); + } + + #[test] + fn test_errors_on_present_but_empty_slug() { + let content = r#" +title = "Hello" +description = "hey there" +slug = """#; + let res = FrontMatter::parse(content); + assert!(res.is_err()); + } + #[test] + fn test_errors_on_present_but_empty_url() { + let content = r#" +title = "Hello" +description = "hey there" +url = """#; + let res = FrontMatter::parse(content); assert!(res.is_err()); } } diff --git a/src/main.rs b/src/main.rs index cf1de2a..b71b4c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,19 @@ -#![feature(proc_macro)] - - -#[macro_use] extern crate clap; -#[macro_use] extern crate error_chain; -#[macro_use] extern crate lazy_static; -#[macro_use] extern crate serde_derive; +#[macro_use] +extern crate clap; +#[macro_use] +extern crate error_chain; +#[macro_use] +extern crate lazy_static; +#[macro_use] +extern crate serde_derive; +extern crate serde; extern crate toml; extern crate walkdir; extern crate pulldown_cmark; extern crate regex; extern crate tera; extern crate glob; +extern crate syntect; mod utils; @@ -30,7 +33,11 @@ fn get_config() -> Config { match Config::from_file("config.toml") { Ok(c) => c, Err(e) => { + println!("Failed to load config.toml"); println!("Error: {}", e); + for e in e.iter().skip(1) { + println!("Reason: {}", e) + } ::std::process::exit(1); } } @@ -38,12 +45,12 @@ fn get_config() -> Config { fn main() { - let matches = clap_app!(myapp => + let matches = clap_app!(Gutenberg => (version: crate_version!()) (author: "Vincent Prouillet") (about: "Static site generator") (@setting SubcommandRequiredElseHelp) - (@subcommand new => + (@subcommand init => (about: "Create a new Gutenberg project") (@arg name: +required "Name of the project. Will create a directory with that name in the current directory") ) diff --git a/src/page.rs b/src/page.rs index 5153d2f..0efb269 100644 --- a/src/page.rs +++ b/src/page.rs @@ -1,119 +1,98 @@ /// A page, can be a blog post or a basic page -use std::collections::HashMap; -use std::default::Default; use std::fs::File; use std::io::prelude::*; use std::path::Path; +use std::result::Result as StdResult; use pulldown_cmark as cmark; use regex::Regex; -use tera::{Tera, Value, Context}; +use tera::{Tera, Context}; +use serde::ser::{SerializeStruct, self}; use errors::{Result, ResultExt}; use config::Config; -use front_matter::parse_front_matter; +use front_matter::{FrontMatter}; lazy_static! { - static ref DELIM_RE: Regex = Regex::new(r"\+\+\+\s*\r?\n").unwrap(); + static ref PAGE_RE: Regex = Regex::new(r"^\n?\+\+\+\n((?s).*(?-s))\+\+\+\n((?s).*(?-s))$").unwrap(); } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Deserialize)] pub struct Page { - // .md filepath, excluding the content/ bit + /// .md filepath, excluding the content/ bit #[serde(skip_serializing)] pub filepath: String, - // the name of the .md file + /// The name of the .md file #[serde(skip_serializing)] pub filename: String, - // the directories above our .md file are called sections - // for example a file at content/kb/solutions/blabla.md will have 2 sections: - // `kb` and `solutions` + /// The directories above our .md file are called sections + /// for example a file at content/kb/solutions/blabla.md will have 2 sections: + /// `kb` and `solutions` #[serde(skip_serializing)] pub sections: Vec<String>, - // the actual content of the page, in markdown + /// The actual content of the page, in markdown #[serde(skip_serializing)] pub raw_content: String, - - // <title> of the page - pub title: String, - // The page slug - pub slug: String, - // the url the page appears at, overrides the slug if set in the frontmatter - // otherwise is set after parsing front matter and sections - pub url: String, - // the HTML rendered of the page + /// The HTML rendered of the page pub content: String, - - // tags, not to be confused with categories - pub tags: Vec<String>, - // whether this page should be public or not - pub is_draft: bool, - // any extra parameter present in the front matter - // it will be passed to the template context - pub extra: HashMap<String, Value>, - - // only one category allowed - pub category: Option<String>, - // optional date if we want to order pages (ie blog post) - pub date: Option<String>, - // optional layout, if we want to specify which tpl to render for that page - #[serde(skip_serializing)] - pub layout: Option<String>, - // description that appears when linked, e.g. on twitter - pub description: Option<String>, + /// The front matter meta-data + pub meta: FrontMatter, + /// The previous page, by date + pub previous: Option<Box<Page>>, + /// The next page, by date + pub next: Option<Box<Page>>, } -impl Default for Page { - fn default() -> Page { +impl Page { + pub fn new(meta: FrontMatter) -> Page { Page { filepath: "".to_string(), filename: "".to_string(), sections: vec![], - - title: "".to_string(), - slug: "".to_string(), - url: "".to_string(), raw_content: "".to_string(), content: "".to_string(), - tags: vec![], - is_draft: false, - extra: HashMap::new(), - - category: None, - date: None, - layout: None, - description: None, + meta: meta, + previous: None, + next: None, } } -} + /// Get the slug for the page. + /// First tries to find the slug in the meta and defaults to filename otherwise + pub fn get_slug(&self) -> String { + if let Some(ref slug) = self.meta.slug { + slug.to_string() + } else { + self.filename.clone() + } + } -impl Page { // Parse a page given the content of the .md file // Files without front matter or with invalid front matter are considered // erroneous - pub fn from_str(filepath: &str, content: &str) -> Result<Page> { + pub fn parse(filepath: &str, content: &str) -> Result<Page> { // 1. separate front matter from content - if !DELIM_RE.is_match(content) { + if !PAGE_RE.is_match(content) { bail!("Couldn't find front matter in `{}`. Did you forget to add `+++`?", filepath); } // 2. extract the front matter and the content - let splits: Vec<&str> = DELIM_RE.splitn(content, 2).collect(); - let front_matter = splits[0]; - let content = splits[1]; + let caps = PAGE_RE.captures(content).unwrap(); + // caps[0] is the full match + let front_matter = &caps[1]; + let content = &caps[2]; - // 2. create our page, parse front matter and assign all of that - let mut page = Page::default(); - page.filepath = filepath.to_string(); - page.raw_content = content.to_string(); - parse_front_matter(front_matter, &mut page) + // 3. create our page, parse front matter and assign all of that + let meta = FrontMatter::parse(&front_matter) .chain_err(|| format!("Error when parsing front matter of file `{}`", filepath))?; + let mut page = Page::new(meta); + page.filepath = filepath.to_string(); + page.raw_content = content.to_string(); page.content = { let mut html = String::new(); let parser = cmark::Parser::new(&page.raw_content); @@ -121,11 +100,11 @@ impl Page { html }; - // next find sections + // 4. Find sections // Pages with custom urls exists outside of sections - if page.url == "" { + if page.meta.url.is_none() { let path = Path::new(filepath); - page.filename = path.file_stem().expect("Couldn't get file stem").to_string_lossy().to_string(); + page.filename = path.file_stem().expect("Couldn't get filename").to_string_lossy().to_string(); // find out if we have sections for section in path.parent().unwrap().components() { @@ -133,11 +112,11 @@ impl Page { } // now the url - // it's either set in the front matter OR we get it from a combination of sections + slug - if page.sections.len() > 0 { - page.url = format!("/{}/{}", page.sections.join("/"), page.slug); + // We get it from a combination of sections + slug + if !page.sections.is_empty() { + page.meta.url = Some(format!("/{}/{}", page.sections.join("/"), page.get_slug())); } else { - page.url = format!("/{}", page.slug); + page.meta.url = Some(format!("/{}", page.get_slug())); }; } @@ -154,13 +133,13 @@ impl Page { // Remove the content string from name // Maybe get a path as an arg instead and use strip_prefix? - Page::from_str(&path.strip_prefix("content").unwrap().to_string_lossy(), &content) + Page::parse(&path.strip_prefix("content").unwrap().to_string_lossy(), &content) } fn get_layout_name(&self) -> String { - match self.layout { + match self.meta.layout { Some(ref l) => l.to_string(), - None => "single.html".to_string() + None => "page.html".to_string() } } @@ -170,13 +149,30 @@ impl Page { context.add("site", config); context.add("page", self); - tera.render(&tpl, context) + tera.render(&tpl, &context) .chain_err(|| "Error while rendering template") } } +impl ser::Serialize for Page { + fn serialize<S>(&self, serializer: S) -> StdResult<S::Ok, S::Error> where S: ser::Serializer { + let mut state = serializer.serialize_struct("page", 10)?; + state.serialize_field("content", &self.content)?; + state.serialize_field("title", &self.meta.title)?; + state.serialize_field("description", &self.meta.description)?; + state.serialize_field("date", &self.meta.date)?; + state.serialize_field("slug", &self.meta.slug)?; + state.serialize_field("url", &self.meta.url)?; + state.serialize_field("tags", &self.meta.tags)?; + state.serialize_field("draft", &self.meta.draft)?; + state.serialize_field("category", &self.meta.category)?; + state.serialize_field("extra", &self.meta.extra)?; + state.end() + } +} // Order pages by date, no-op for now +// TODO: impl PartialOrd on Vec<Page> so we can use sort()? pub fn order_pages(pages: Vec<Page>) -> Vec<Page> { pages } @@ -190,16 +186,18 @@ mod tests { #[test] fn test_can_parse_a_valid_page() { let content = r#" ++++ title = "Hello" +description = "hey there" slug = "hello-world" +++ Hello world"#; - let res = Page::from_str("post.md", content); + let res = Page::parse("post.md", content); assert!(res.is_ok()); let page = res.unwrap(); - assert_eq!(page.title, "Hello".to_string()); - assert_eq!(page.slug, "hello-world".to_string()); + assert_eq!(page.meta.title, "Hello".to_string()); + assert_eq!(page.meta.slug.unwrap(), "hello-world".to_string()); assert_eq!(page.raw_content, "Hello world".to_string()); assert_eq!(page.content, "<p>Hello world</p>\n".to_string()); } @@ -207,11 +205,13 @@ Hello world"#; #[test] fn test_can_find_one_parent_directory() { let content = r#" ++++ title = "Hello" +description = "hey there" slug = "hello-world" +++ Hello world"#; - let res = Page::from_str("posts/intro.md", content); + let res = Page::parse("posts/intro.md", content); assert!(res.is_ok()); let page = res.unwrap(); assert_eq!(page.sections, vec!["posts".to_string()]); @@ -220,11 +220,13 @@ Hello world"#; #[test] fn test_can_find_multiple_parent_directories() { let content = r#" ++++ title = "Hello" +description = "hey there" slug = "hello-world" +++ Hello world"#; - let res = Page::from_str("posts/intro/start.md", content); + let res = Page::parse("posts/intro/start.md", content); assert!(res.is_ok()); let page = res.unwrap(); assert_eq!(page.sections, vec!["posts".to_string(), "intro".to_string()]); @@ -233,26 +235,42 @@ Hello world"#; #[test] fn test_can_make_url_from_sections_and_slug() { let content = r#" ++++ title = "Hello" +description = "hey there" slug = "hello-world" +++ Hello world"#; - let res = Page::from_str("posts/intro/start.md", content); + let res = Page::parse("posts/intro/start.md", content); assert!(res.is_ok()); let page = res.unwrap(); - assert_eq!(page.url, "/posts/intro/hello-world"); + assert_eq!(page.meta.url.unwrap(), "/posts/intro/hello-world"); } #[test] fn test_can_make_url_from_sections_and_slug_root() { let content = r#" ++++ title = "Hello" +description = "hey there" slug = "hello-world" +++ Hello world"#; - let res = Page::from_str("start.md", content); + let res = Page::parse("start.md", content); assert!(res.is_ok()); let page = res.unwrap(); - assert_eq!(page.url, "/hello-world"); + assert_eq!(page.meta.url.unwrap(), "/hello-world"); + } + + #[test] + fn test_errors_on_invalid_front_matter_format() { + let content = r#" +title = "Hello" +description = "hey there" +slug = "hello-world" ++++ +Hello world"#; + let res = Page::parse("start.md", content); + assert!(res.is_err()); } }