Browse Source

Update deps and fix deprecrations

index-subcmd
Vincent Prouillet 6 years ago
parent
commit
38b30eb144
10 changed files with 278 additions and 246 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +239
    -208
      Cargo.lock
  3. +5
    -5
      components/content/src/page.rs
  4. +5
    -5
      components/content/src/section.rs
  5. +6
    -6
      components/pagination/src/lib.rs
  6. +1
    -1
      components/rendering/src/table_of_contents.rs
  7. +8
    -8
      components/site/src/lib.rs
  8. +10
    -10
      components/taxonomies/src/lib.rs
  9. +1
    -1
      components/templates/src/lib.rs
  10. +2
    -2
      components/utils/src/templates.rs

+ 1
- 0
CHANGELOG.md View File

@@ -3,6 +3,7 @@
## 0.4.3 (unreleased)

- Gutenberg has changed name to REPLACE_ME!
- Update dependencies, fixing a few bugs with templates


## 0.4.2 (2018-09-03)


+ 239
- 208
Cargo.lock
File diff suppressed because it is too large
View File


+ 5
- 5
components/content/src/page.rs View File

@@ -183,7 +183,7 @@ impl Page {
anchor_insert,
);

context.tera_context.add("page", self);
context.tera_context.insert("page", self);

let res = render_content(&self.raw_content, &context)
.chain_err(|| format!("Failed to render content of {}", self.file.path.display()))?;
@@ -203,10 +203,10 @@ impl Page {
};

let mut context = TeraContext::new();
context.add("config", config);
context.add("page", self);
context.add("current_url", &self.permalink);
context.add("current_path", &self.path);
context.insert("config", config);
context.insert("page", self);
context.insert("current_url", &self.permalink);
context.insert("current_path", &self.path);

render_template(&tpl_name, tera, &context, &config.theme)
.chain_err(|| format!("Failed to render page '{}'", self.file.path.display()))


+ 5
- 5
components/content/src/section.rs View File

@@ -133,7 +133,7 @@ impl Section {
self.meta.insert_anchor_links,
);

context.tera_context.add("section", self);
context.tera_context.insert("section", self);

let res = render_content(&self.raw_content, &context)
.chain_err(|| format!("Failed to render content of {}", self.file.path.display()))?;
@@ -147,10 +147,10 @@ impl Section {
let tpl_name = self.get_template_name();

let mut context = TeraContext::new();
context.add("config", config);
context.add("section", self);
context.add("current_url", &self.permalink);
context.add("current_path", &self.path);
context.insert("config", config);
context.insert("section", self);
context.insert("current_url", &self.permalink);
context.insert("current_path", &self.path);

render_template(&tpl_name, tera, &context, &config.theme)
.chain_err(|| format!("Failed to render section '{}'", self.file.path.display()))


+ 6
- 6
components/pagination/src/lib.rs View File

@@ -212,20 +212,20 @@ impl<'a> Paginator<'a> {

pub fn render_pager(&self, pager: &Pager, config: &Config, tera: &Tera) -> Result<String> {
let mut context = Context::new();
context.add("config", &config);
context.insert("config", &config);
let template_name = match self.root {
PaginationRoot::Section(s) => {
context.add("section", &s);
context.insert("section", &s);
s.get_template_name()
}
PaginationRoot::Taxonomy(t) => {
context.add("taxonomy", &t.kind);
context.insert("taxonomy", &t.kind);
format!("{}/single.html", t.kind.name)
}
};
context.add("current_url", &pager.permalink);
context.add("current_path", &pager.path);
context.add("paginator", &self.build_paginator_context(pager));
context.insert("current_url", &pager.permalink);
context.insert("current_path", &pager.path);
context.insert("paginator", &self.build_paginator_context(pager));

render_template(&template_name, tera, &context, &config.theme)
.chain_err(|| format!("Failed to render pager {}", pager.index))


+ 1
- 1
components/rendering/src/table_of_contents.rs View File

@@ -51,7 +51,7 @@ impl TempHeader {
pub fn to_string(&self, tera: &Tera, insert_anchor: InsertAnchor) -> String {
let anchor_link = if insert_anchor != InsertAnchor::None {
let mut c = TeraContext::new();
c.add("id", &self.id);
c.insert("id", &self.id);
tera.render("anchor-link.html", &c).unwrap()
} else {
String::new()


+ 8
- 8
components/site/src/lib.rs View File

@@ -739,14 +739,14 @@ impl Site {
})
.collect::<Vec<_>>();
pages.sort_by(|a, b| a.permalink.cmp(&b.permalink));
context.add("pages", &pages);
context.insert("pages", &pages);

let mut sections = self.sections
.values()
.map(|s| SitemapEntry::new(s.permalink.clone(), None))
.collect::<Vec<_>>();
sections.sort_by(|a, b| a.permalink.cmp(&b.permalink));
context.add("sections", &sections);
context.insert("sections", &sections);

let mut taxonomies = vec![];
for taxonomy in &self.taxonomies {
@@ -759,9 +759,9 @@ impl Site {
terms.sort_by(|a, b| a.permalink.cmp(&b.permalink));
taxonomies.push(terms);
}
context.add("taxonomies", &taxonomies);
context.insert("taxonomies", &taxonomies);

context.add("config", &self.config);
context.insert("config", &self.config);

let sitemap = &render_template("sitemap.xml", &self.tera, &context, &self.config.theme)?;

@@ -791,10 +791,10 @@ impl Site {
}

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

let rss_feed_url = if let Some(ref base) = base_path {
self.config.make_permalink(&base.join("rss.xml").to_string_lossy().replace('\\', "/"))
@@ -802,7 +802,7 @@ impl Site {
self.config.make_permalink("rss.xml")
};

context.add("feed_url", &rss_feed_url);
context.insert("feed_url", &rss_feed_url);

let feed = &render_template("rss.xml", &self.tera, &context, &self.config.theme)?;



+ 10
- 10
components/taxonomies/src/lib.rs View File

@@ -88,11 +88,11 @@ impl Taxonomy {

pub fn render_term(&self, item: &TaxonomyItem, tera: &Tera, config: &Config) -> Result<String> {
let mut context = Context::new();
context.add("config", config);
context.add("term", item);
context.add("taxonomy", &self.kind);
context.add("current_url", &config.make_permalink(&format!("{}/{}", self.kind.name, item.slug)));
context.add("current_path", &format!("/{}/{}", self.kind.name, item.slug));
context.insert("config", config);
context.insert("term", item);
context.insert("taxonomy", &self.kind);
context.insert("current_url", &config.make_permalink(&format!("{}/{}", self.kind.name, item.slug)));
context.insert("current_path", &format!("/{}/{}", self.kind.name, item.slug));

render_template(&format!("{}/single.html", self.kind.name), tera, &context, &config.theme)
.chain_err(|| format!("Failed to render single term {} page.", self.kind.name))
@@ -100,11 +100,11 @@ impl Taxonomy {

pub fn render_all_terms(&self, tera: &Tera, config: &Config) -> Result<String> {
let mut context = Context::new();
context.add("config", config);
context.add("terms", &self.items);
context.add("taxonomy", &self.kind);
context.add("current_url", &config.make_permalink(&self.kind.name));
context.add("current_path", &self.kind.name);
context.insert("config", config);
context.insert("terms", &self.items);
context.insert("taxonomy", &self.kind);
context.insert("current_url", &config.make_permalink(&self.kind.name));
context.insert("current_path", &self.kind.name);

render_template(&format!("{}/list.html", self.kind.name), tera, &context, &config.theme)
.chain_err(|| format!("Failed to render a list of {} page.", self.kind.name))


+ 1
- 1
components/templates/src/lib.rs View File

@@ -48,7 +48,7 @@ lazy_static! {
/// via refresh to the url given
pub fn render_redirect_template(url: &str, tera: &Tera) -> Result<String> {
let mut context = Context::new();
context.add("url", &url);
context.insert("url", &url);

tera.render("internal/alias.html", &context)
.chain_err(|| format!("Failed to render alias for '{}'", url))


+ 2
- 2
components/utils/src/templates.rs View File

@@ -9,8 +9,8 @@ macro_rules! render_default_tpl {
($filename: expr, $url: expr) => {
{
let mut context = Context::new();
context.add("filename", $filename);
context.add("url", $url);
context.insert("filename", $filename);
context.insert("url", $url);
Tera::one_off(DEFAULT_TPL, &context, true).map_err(|e| e.into())
}
};


Loading…
Cancel
Save