Update dependencies

This commit is contained in:
adnano 2020-05-08 03:33:24 -04:00
parent ff5f6ddaf2
commit fc79cc068b
7 changed files with 389 additions and 540 deletions

850
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,17 +4,15 @@ description = "A simple static site generator built in Rust."
version = "0.1.0"
authors = ["adnano <me@adnano.co>"]
edition = "2018"
license-file = "LICENSE.md" # BlueOak-1.0.0
license = "BlueOak-1.0.0"
[dependencies]
chrono = "0.4"
lazy_static = "1.3"
log = { version = "0.4", features = ["release_max_level_warn"] }
pulldown-cmark = { version = "0.5", default-features = false }
regex = "1.1"
rsass = "0.9"
lazy_static = "1.4"
pulldown-cmark = { version = "0.7", default-features = false }
regex = "1.3"
rsass = "0.13"
serde = "1.0"
serde_derive = "1.0"
tera = "1.0.0-beta.6"
toml = "0.4"
simple-log = { version = "0.1.0", git = "https://git.sr.ht/~adnano/simple-log" }
tera = "1.2"
toml = "0.5"

View file

@ -14,10 +14,6 @@ impl Index {
Ok(index)
}
pub fn len(&self) -> usize {
self.0.len()
}
pub fn insert(&mut self, key: PathBuf, val: Vec<u8>) {
self.0.push((key, val));
}

View file

@ -1,27 +0,0 @@
#[macro_use]
extern crate log;
use std::time::Instant;
mod index;
mod manipulate;
mod page;
mod result;
mod section;
use index::Index;
use manipulate::manipulate;
pub use result::{Exit, Result};
pub fn run() -> Result<()> {
let time = Instant::now();
let mut index = Index::from("src")?;
manipulate(&mut index)?;
index.write("public")?;
let elapsed = time.elapsed();
let elapsed = elapsed.as_secs() as f64 + f64::from(elapsed.subsec_nanos()) * 1e-9;
println!("Rendered {} files in {:.2} seconds", index.len(), elapsed);
Ok(())
}

View file

@ -1,7 +1,17 @@
#[macro_use]
extern crate log;
mod index;
mod manipulate;
mod page;
mod result;
mod section;
fn main() {
simple_log::init();
kiln::run().unwrap_or_else(|e| error!("{}", e));
use index::Index;
use manipulate::manipulate;
pub use result::{Exit, Result};
fn main() -> Result<()> {
let mut index = Index::from("src")?;
manipulate(&mut index)?;
index.write("public")?;
Ok(())
}

View file

@ -61,11 +61,11 @@ impl<'a> Manipulater<'a> {
}
Some("scss") => {
path.set_extension("css");
match rsass::compile_scss(&contents, rsass::OutputStyle::Compressed) {
match rsass::compile_scss(&contents, Default::default()) {
Ok(css) => *contents = css,
Err(e) => {
self.ignored.push(i);
warn!("failed to parse stylesheet `{}`: {}", path.display(), e)
eprintln!("Warning: Failed to parse stylesheet `{}`: {}", path.display(), e)
}
}
}
@ -80,7 +80,7 @@ impl<'a> Manipulater<'a> {
let entry = &mut self.index[i];
entry.1 = self
.tera
.render(&entry.0.to_string_lossy(), Context::new())?
.render(&entry.0.to_string_lossy(), &Context::new())?
.into_bytes();
entry.0.set_extension("html");
}
@ -99,7 +99,7 @@ impl<'a> Manipulater<'a> {
section.sort();
let mut context = Context::new();
context.insert("section", &section);
let contents = self.tera.render(&dir.to_string_lossy(), context)?;
let contents = self.tera.render(&dir.to_string_lossy(), &context)?;
entry.0.push("index.html");
entry.1 = contents.into_bytes();
}
@ -109,7 +109,7 @@ impl<'a> Manipulater<'a> {
if self.tera.templates.contains_key("_page") {
let mut context = Context::new();
context.insert("page", &page);
let content = self.tera.render("_page", context)?;
let content = self.tera.render("_page", &context)?;
let path = page.output.unwrap_or(page.input);
(*entry) = (path, content.into_bytes());
} else {

View file

@ -47,7 +47,7 @@ impl Page {
let mut page: Page = match toml::from_str(&captures[1]) {
Ok(page) => page,
Err(e) => {
warn!("failed to parse frontmatter in `{}`: {}", path.display(), e);
eprintln!("failed to parse frontmatter in `{}`: {}", path.display(), e);
Page::default()
}
};