Browse Source

Use TOML dates in front-matter rather than strings

Closes #210
index-subcmd
Vincent Prouillet 6 years ago
parent
commit
1d1ff74d88
18 changed files with 121 additions and 87 deletions
  1. +3
    -0
      CHANGELOG.md
  2. +49
    -48
      Cargo.lock
  3. +1
    -0
      components/content/Cargo.toml
  4. +2
    -0
      components/content/src/lib.rs
  5. +6
    -2
      components/content/src/page.rs
  6. +7
    -4
      components/content/src/sorting.rs
  7. +4
    -4
      components/front_matter/src/lib.rs
  8. +31
    -18
      components/front_matter/src/page.rs
  9. +9
    -2
      components/site/src/lib.rs
  10. +1
    -1
      components/site/test_site/content/posts/draft.md
  11. +1
    -1
      components/site/test_site/content/posts/fixed-slug.md
  12. +1
    -1
      components/site/test_site/content/posts/fixed-url.md
  13. +1
    -1
      components/site/test_site/content/posts/python.md
  14. +1
    -1
      components/site/test_site/content/posts/simple.md
  15. +1
    -1
      components/site/test_site/content/posts/tutorials/devops/docker.md
  16. +1
    -1
      components/site/test_site/content/posts/tutorials/devops/nix.md
  17. +1
    -1
      components/site/test_site/content/posts/tutorials/programming/python.md
  18. +1
    -1
      components/site/test_site/content/posts/tutorials/programming/rust.md

+ 3
- 0
CHANGELOG.md View File

@@ -4,6 +4,8 @@


### Breaking ### Breaking
- Change names of individual taxonomies to be plural (ie `tags/my-tag` instead of `tag/my-tag`) - Change names of individual taxonomies to be plural (ie `tags/my-tag` instead of `tag/my-tag`)
- Front matter now uses TOML dates rather strings: remove quotes from your date value to fix it.
For example: `date = "2001-10-10"` becomes `date = 2001-10-10`


### Others ### Others
- Add `get_taxonomy_url` to retrieve the permalink of a tag/category - Add `get_taxonomy_url` to retrieve the permalink of a tag/category
@@ -13,6 +15,7 @@
- Add `output-dir` to `build` and `serve` to generate the site in a folder other than `public` - Add `output-dir` to `build` and `serve` to generate the site in a folder other than `public`
- Add Prolog syntax highlighting and update all current syntaxes - Add Prolog syntax highlighting and update all current syntaxes
- Live reloading now works on shortcode template changes - Live reloading now works on shortcode template changes
- `gutenberg serve` now reloads site on `config.toml` changes: you will need to F5 to see them though


## 0.2.2 (2017-11-01) ## 0.2.2 (2017-11-01)




+ 49
- 48
Cargo.lock View File

@@ -16,7 +16,7 @@ name = "atty"
version = "0.2.6" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -28,7 +28,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -39,7 +39,7 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -138,7 +138,7 @@ dependencies = [


[[package]] [[package]]
name = "clap" name = "clap"
version = "2.29.0"
version = "2.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -191,7 +191,8 @@ dependencies = [
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0", "utils 0.1.0",
] ]


@@ -206,7 +207,7 @@ version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"os_pipe 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "os_pipe 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shared_child 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "shared_child 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -229,7 +230,7 @@ name = "errors"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -239,7 +240,7 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -248,7 +249,7 @@ name = "flate2"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -267,7 +268,7 @@ dependencies = [
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -278,7 +279,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -286,7 +287,7 @@ name = "fsevent-sys"
version = "0.1.6" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -323,7 +324,7 @@ name = "gutenberg"
version = "0.2.2" version = "0.2.2"
dependencies = [ dependencies = [
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
"content 0.1.0", "content 0.1.0",
"errors 0.1.0", "errors 0.1.0",
"front_matter 0.1.0", "front_matter 0.1.0",
@@ -390,7 +391,7 @@ name = "inotify"
version = "0.3.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -398,7 +399,7 @@ name = "iovec"
version = "0.1.1" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -458,7 +459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.35"
version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]] [[package]]
@@ -492,7 +493,7 @@ name = "memchr"
version = "2.0.1" version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -520,7 +521,7 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -529,7 +530,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -549,7 +550,7 @@ dependencies = [
"iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -600,7 +601,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (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.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -611,7 +612,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -621,7 +622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -636,7 +637,7 @@ dependencies = [
"fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"inotify 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "inotify 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (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.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -679,7 +680,7 @@ name = "num_cpus"
version = "1.8.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -689,7 +690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"onig_sys 66.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "onig_sys 66.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -700,7 +701,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"duct 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -724,7 +725,7 @@ dependencies = [
"front_matter 0.1.0", "front_matter 0.1.0",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0", "utils 0.1.0",
] ]


@@ -828,7 +829,7 @@ version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -847,7 +848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -897,7 +898,7 @@ dependencies = [
"slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syntect 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"templates 0.1.0", "templates 0.1.0",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0", "utils 0.1.0",
] ]


@@ -913,7 +914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]] [[package]]
name = "same-file" name = "same-file"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -924,7 +925,7 @@ name = "sass-rs"
version = "0.2.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"sass-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "sass-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -934,7 +935,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -994,7 +995,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"kernel32-sys 0.2.2 (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.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


@@ -1020,7 +1021,7 @@ dependencies = [
"taxonomies 0.1.0", "taxonomies 0.1.0",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"templates 0.1.0", "templates 0.1.0",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0", "utils 0.1.0",
"walkdir 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -1117,7 +1118,7 @@ dependencies = [
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0", "utils 0.1.0",
] ]


@@ -1140,20 +1141,20 @@ dependencies = [
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"taxonomies 0.1.0", "taxonomies 0.1.0",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0", "utils 0.1.0",
] ]


[[package]] [[package]]
name = "tera" name = "tera"
version = "0.11.0-beta.1"
version = "0.11.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 1.0.0-beta.17 (registry+https://github.com/rust-lang/crates.io-index)", "pest 1.0.0-beta.17 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_derive 1.0.0-beta.17 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 1.0.0-beta.17 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1185,7 +1186,7 @@ name = "termion"
version = "1.5.1" version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -1212,7 +1213,7 @@ name = "time"
version = "0.1.39" version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@@ -1316,7 +1317,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"errors 0.1.0", "errors 0.1.0",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -1339,7 +1340,7 @@ name = "walkdir"
version = "2.0.1" version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"same-file 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]


[[package]] [[package]]
@@ -1432,7 +1433,7 @@ dependencies = [
"checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" "checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0"
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9"
"checksum clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "110d43e343eb29f4f51c1db31beb879d546db27998577e5715270a54bcf41d3f"
"checksum clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f4a2b3bb7ef3c672d7c13d15613211d5a6976b6892c598b0fcb5d40765f19c2"
"checksum cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "56d741ea7a69e577f6d06b36b7dff4738f680593dc27a701ffa8506b73ce28bb" "checksum cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "56d741ea7a69e577f6d06b36b7dff4738f680593dc27a701ffa8506b73ce28bb"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd" "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
@@ -1463,7 +1464,7 @@ dependencies = [
"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
"checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" "checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b"
"checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef"
"checksum libc 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)" = "96264e9b293e95d25bfcbbf8a88ffd1aedc85b754eba8b7d78012f638ba220eb"
"checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121"
"checksum linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2aab0478615bb586559b0114d94dd8eca4fdbb73b443adcb0d00b61692b4bf" "checksum linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2aab0478615bb586559b0114d94dd8eca4fdbb73b443adcb0d00b61692b4bf"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
@@ -1511,7 +1512,7 @@ dependencies = [
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e" "checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f"
"checksum same-file 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3257af0472da4b8b8902102a57bafffd9991f0f43772a8af6153d597e6e4ae2"
"checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637"
"checksum sass-rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90f8cf6e645aa843ffffcbdc1e8752b1f221dfa314c81895aeb229a77aea7e05" "checksum sass-rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90f8cf6e645aa843ffffcbdc1e8752b1f221dfa314c81895aeb229a77aea7e05"
"checksum sass-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8bc8cb11c6906ced0e62751f93fa1f30216612a182d4e9a7d8ace302834b1742" "checksum sass-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8bc8cb11c6906ced0e62751f93fa1f30216612a182d4e9a7d8ace302834b1742"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
@@ -1533,7 +1534,7 @@ dependencies = [
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum syntect 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db9fffcb25a761118df53811bd1cfcd54cf57fcbc51e1ea3167ae263477129ad" "checksum syntect 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db9fffcb25a761118df53811bd1cfcd54cf57fcbc51e1ea3167ae263477129ad"
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
"checksum tera 0.11.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be9012fd155ae1d0bebc4eb58db8847b516be042b2b779821768def1560a037e"
"checksum tera 0.11.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4035bf251d9ba49ec5e2ae68f862be60b221c0fcead5d21df6fd72bdc90b81f"
"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
"checksum term-painter 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dcaa948f0e3e38470cd8dc8dcfe561a75c9e43f28075bb183845be2b9b3c08cf" "checksum term-painter 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dcaa948f0e3e38470cd8dc8dcfe561a75c9e43f28075bb183845be2b9b3c08cf"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"


+ 1
- 0
components/content/Cargo.toml View File

@@ -17,3 +17,4 @@ front_matter = { path = "../front_matter" }


[dev-dependencies] [dev-dependencies]
tempdir = "0.3" tempdir = "0.3"
toml = "0.4"

+ 2
- 0
components/content/src/lib.rs View File

@@ -11,6 +11,8 @@ extern crate utils;


#[cfg(test)] #[cfg(test)]
extern crate tempdir; extern crate tempdir;
#[cfg(test)]
extern crate toml;


mod file_info; mod file_info;
mod page; mod page;


+ 6
- 2
components/content/src/page.rs View File

@@ -103,7 +103,6 @@ impl Page {


if let Some(ref p) = page.meta.path { if let Some(ref p) = page.meta.path {
page.path = p.trim().trim_left_matches('/').to_string(); page.path = p.trim().trim_left_matches('/').to_string();

} else { } else {
page.path = if page.file.components.is_empty() { page.path = if page.file.components.is_empty() {
page.slug.clone() page.slug.clone()
@@ -207,7 +206,12 @@ impl ser::Serialize for Page {
state.serialize_field("content", &self.content)?; state.serialize_field("content", &self.content)?;
state.serialize_field("title", &self.meta.title)?; state.serialize_field("title", &self.meta.title)?;
state.serialize_field("description", &self.meta.description)?; state.serialize_field("description", &self.meta.description)?;
state.serialize_field("date", &self.meta.date)?;
// From a TOML datetime to a String first
let date = match self.meta.date {
Some(ref d) => Some(d.to_string()),
None => None,
};
state.serialize_field("date", &date)?;
state.serialize_field("slug", &self.slug)?; state.serialize_field("slug", &self.slug)?;
state.serialize_field("path", &self.path)?; state.serialize_field("path", &self.path)?;
state.serialize_field("components", &self.components)?; state.serialize_field("components", &self.components)?;


+ 7
- 4
components/content/src/sorting.rs View File

@@ -98,13 +98,16 @@ pub fn populate_previous_and_next_pages(input: &[Page]) -> Vec<Page> {


#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::str::FromStr;
use toml::value::Datetime;

use front_matter::{PageFrontMatter, SortBy}; use front_matter::{PageFrontMatter, SortBy};
use page::Page; use page::Page;
use super::{sort_pages, populate_previous_and_next_pages}; use super::{sort_pages, populate_previous_and_next_pages};


fn create_page_with_date(date: &str) -> Page { fn create_page_with_date(date: &str) -> Page {
let mut front_matter = PageFrontMatter::default(); let mut front_matter = PageFrontMatter::default();
front_matter.date = Some(date.to_string());
front_matter.date = Some(Datetime::from_str(date).unwrap());
Page::new("content/hello.md", front_matter) Page::new("content/hello.md", front_matter)
} }


@@ -136,9 +139,9 @@ mod tests {
]; ];
let (pages, _) = sort_pages(input, SortBy::Date); let (pages, _) = sort_pages(input, SortBy::Date);
// Should be sorted by date // Should be sorted by date
assert_eq!(pages[0].clone().meta.date.unwrap(), "2019-01-01");
assert_eq!(pages[1].clone().meta.date.unwrap(), "2018-01-01");
assert_eq!(pages[2].clone().meta.date.unwrap(), "2017-01-01");
assert_eq!(pages[0].clone().meta.date.unwrap().to_string(), "2019-01-01");
assert_eq!(pages[1].clone().meta.date.unwrap().to_string(), "2018-01-01");
assert_eq!(pages[2].clone().meta.date.unwrap().to_string(), "2017-01-01");
} }


#[test] #[test]


+ 4
- 4
components/front_matter/src/lib.rs View File

@@ -92,7 +92,7 @@ mod tests {
+++ +++
title = "Title" title = "Title"
description = "hey there" description = "hey there"
date = "2002/10/12"
date = 2002-10-12
+++ +++
Hello Hello
"#; "#;
@@ -120,7 +120,7 @@ Hello
+++ +++
title = "Title" title = "Title"
description = "hey there" description = "hey there"
date = "2002/10/12"
date = 2002-10-12
+++"#; +++"#;
let (front_matter, content) = split_page_content(Path::new(""), content).unwrap(); let (front_matter, content) = split_page_content(Path::new(""), content).unwrap();
assert_eq!(content, ""); assert_eq!(content, "");
@@ -133,7 +133,7 @@ date = "2002/10/12"
+++ +++
title = "Title" title = "Title"
description = "hey there" description = "hey there"
date = "2002-10-02T15:00:00Z"
date = 2002-10-02T15:00:00Z
+++ +++
+++"#; +++"#;
let (front_matter, content) = split_page_content(Path::new(""), content).unwrap(); let (front_matter, content) = split_page_content(Path::new(""), content).unwrap();
@@ -147,7 +147,7 @@ date = "2002-10-02T15:00:00Z"
+++ +++
title = "Title" title = "Title"
description = "hey there" description = "hey there"
date = "2002/10/12""#;
date = 2002-10-12"#;
let res = split_page_content(Path::new(""), content); let res = split_page_content(Path::new(""), content);
assert!(res.is_err()); assert!(res.is_err());
} }


+ 31
- 18
components/front_matter/src/page.rs View File

@@ -6,6 +6,7 @@ use toml;


use errors::Result; use errors::Result;



/// The front matter of every page /// The front matter of every page
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PageFrontMatter { pub struct PageFrontMatter {
@@ -14,7 +15,7 @@ pub struct PageFrontMatter {
/// Description in <meta> that appears when linked, e.g. on twitter /// Description in <meta> that appears when linked, e.g. on twitter
pub description: Option<String>, pub description: Option<String>,
/// Date if we want to order pages (ie blog post) /// Date if we want to order pages (ie blog post)
pub date: Option<String>,
pub date: Option<toml::value::Datetime>,
/// Whether this page is a draft and should be ignored for pagination etc /// Whether this page is a draft and should be ignored for pagination etc
pub draft: Option<bool>, pub draft: Option<bool>,
/// The page slug. Will be used instead of the filename if present /// The page slug. Will be used instead of the filename if present
@@ -71,17 +72,17 @@ impl PageFrontMatter {
Ok(f) Ok(f)
} }


/// Converts the date in the front matter, which can be in 2 formats, into a NaiveDateTime
/// Converts the TOML datetime to a Chrono naive datetime
pub fn date(&self) -> Option<NaiveDateTime> { pub fn date(&self) -> Option<NaiveDateTime> {
match self.date {
Some(ref d) => {
if d.contains('T') {
DateTime::parse_from_rfc3339(d).ok().and_then(|s| Some(s.naive_local()))
} else {
NaiveDate::parse_from_str(d, "%Y-%m-%d").ok().and_then(|s| Some(s.and_hms(0,0,0)))
}
},
None => None,
if let Some(ref d) = self.date {
let d2 = d.to_string();
if d2.contains('T') {
DateTime::parse_from_rfc3339(&d2).ok().and_then(|s| Some(s.naive_local()))
} else {
NaiveDate::parse_from_str(&d2, "%Y-%m-%d").ok().and_then(|s| Some(s.and_hms(0, 0, 0)))
}
} else {
None
} }
} }


@@ -121,6 +122,7 @@ impl Default for PageFrontMatter {
} }
} }



#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::PageFrontMatter; use super::PageFrontMatter;
@@ -203,9 +205,10 @@ mod tests {
let content = r#" let content = r#"
title = "Hello" title = "Hello"
description = "hey there" description = "hey there"
date = "2016-10-10""#;
date = 2016-10-10
"#;
let res = PageFrontMatter::parse(content).unwrap(); let res = PageFrontMatter::parse(content).unwrap();
assert!(res.date().is_some());
assert!(res.date.is_some());
} }


#[test] #[test]
@@ -213,9 +216,10 @@ mod tests {
let content = r#" let content = r#"
title = "Hello" title = "Hello"
description = "hey there" description = "hey there"
date = "2002-10-02T15:00:00Z""#;
date = 2002-10-02T15:00:00Z
"#;
let res = PageFrontMatter::parse(content).unwrap(); let res = PageFrontMatter::parse(content).unwrap();
assert!(res.date().is_some());
assert!(res.date.is_some());
} }


#[test] #[test]
@@ -223,9 +227,18 @@ mod tests {
let content = r#" let content = r#"
title = "Hello" title = "Hello"
description = "hey there" description = "hey there"
date = "2002/10/12""#;
let res = PageFrontMatter::parse(content).unwrap();
assert!(res.date().is_none());
date = 2002/10/12"#;
let res = PageFrontMatter::parse(content);
assert!(res.is_err());
} }


#[test]
fn cannot_parse_invalid_date_format() {
let content = r#"
title = "Hello"
description = "hey there"
date = 2002-14-01"#;
let res = PageFrontMatter::parse(content);
assert!(res.is_err());
}
} }

+ 9
- 2
components/site/src/lib.rs View File

@@ -636,7 +636,13 @@ impl Site {
&self.pages &self.pages
.values() .values()
.filter(|p| !p.is_draft()) .filter(|p| !p.is_draft())
.map(|p| SitemapEntry::new(p.permalink.clone(), p.meta.date.clone()))
.map(|p| {
let date = match p.meta.date {
Some(ref d) => Some(d.to_string()),
None => None,
};
SitemapEntry::new(p.permalink.clone(), date)
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
); );
context.add( context.add(
@@ -694,9 +700,10 @@ impl Site {
} }


let (sorted_pages, _) = sort_pages(pages, SortBy::Date); let (sorted_pages, _) = sort_pages(pages, SortBy::Date);
context.add("last_build_date", &sorted_pages[0].meta.date);
context.add("last_build_date", &sorted_pages[0].meta.date.clone().map(|d| d.to_string()));
// limit to the last n elements) // limit to the last n elements)
context.add("pages", &sorted_pages.iter().take(self.config.rss_limit.unwrap()).collect::<Vec<_>>()); context.add("pages", &sorted_pages.iter().take(self.config.rss_limit.unwrap()).collect::<Vec<_>>());
println!("{:?}", context.as_json());
context.add("config", &self.config); context.add("config", &self.config);


let rss_feed_url = if self.config.base_url.ends_with('/') { let rss_feed_url = if self.config.base_url.ends_with('/') {


+ 1
- 1
components/site/test_site/content/posts/draft.md View File

@@ -1,6 +1,6 @@
+++ +++
title = "A draft" title = "A draft"
draft = true draft = true
date = "2016-03-01"
date = 2016-03-01
+++ +++



+ 1
- 1
components/site/test_site/content/posts/fixed-slug.md View File

@@ -2,7 +2,7 @@
title = "Fixed slug" title = "Fixed slug"
description = "" description = ""
slug = "something-else" slug = "something-else"
date = "2017-01-01"
date = 2017-01-01
aliases = ["/an-old-url/old-page"] aliases = ["/an-old-url/old-page"]
+++ +++




+ 1
- 1
components/site/test_site/content/posts/fixed-url.md View File

@@ -2,7 +2,7 @@
title = "Fixed URL" title = "Fixed URL"
description = "" description = ""
path = "a-fixed-url" path = "a-fixed-url"
date = "2017-02-01"
date = 2017-02-01
+++ +++


A simple page with fixed url A simple page with fixed url

+ 1
- 1
components/site/test_site/content/posts/python.md View File

@@ -1,7 +1,7 @@
+++ +++
title = "Python in posts" title = "Python in posts"
description = "" description = ""
date = "2017-03-01"
date = 2017-03-01
+++ +++


Same filename but different path Same filename but different path


+ 1
- 1
components/site/test_site/content/posts/simple.md View File

@@ -1,7 +1,7 @@
+++ +++
title = "Simple article with shortcodes" title = "Simple article with shortcodes"
description = "" description = ""
date = "2017-04-01"
date = 2017-04-01
+++ +++


A simple page A simple page


+ 1
- 1
components/site/test_site/content/posts/tutorials/devops/docker.md View File

@@ -1,7 +1,7 @@
+++ +++
title = "Docker" title = "Docker"
order = 1 order = 1
date = "2017-01-01"
date = 2017-01-01
+++ +++


A simple page A simple page

+ 1
- 1
components/site/test_site/content/posts/tutorials/devops/nix.md View File

@@ -1,7 +1,7 @@
+++ +++
title = "Nix" title = "Nix"
order = 2 order = 2
date = "2017-01-01"
date = 2017-01-01
+++ +++


A simple page A simple page

+ 1
- 1
components/site/test_site/content/posts/tutorials/programming/python.md View File

@@ -1,7 +1,7 @@
+++ +++
title = "Python tutorial" title = "Python tutorial"
order = 1 order = 1
date = "2017-01-01"
date = 2017-01-01
+++ +++


A simple page A simple page

+ 1
- 1
components/site/test_site/content/posts/tutorials/programming/rust.md View File

@@ -1,7 +1,7 @@
+++ +++
title = "Rust" title = "Rust"
order = 2 order = 2
date = "2017-01-01"
date = 2017-01-01
+++ +++


A simple page A simple page

Loading…
Cancel
Save