Browse Source

Put back a limit on rss feed number of pages

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
015f146792
4 changed files with 15 additions and 3 deletions
  1. +1
    -1
      CHANGELOG.md
  2. +1
    -1
      components/config/src/lib.rs
  3. +9
    -0
      components/site/benches/site.rs
  4. +4
    -1
      components/site/src/lib.rs

+ 1
- 1
CHANGELOG.md View File

@@ -6,7 +6,7 @@
- Add weight sorting - Add weight sorting
- Remove `section` from the `page` rendering context: this is too expensive. Use - Remove `section` from the `page` rendering context: this is too expensive. Use
the global function `get_section` if you need to get it the global function `get_section` if you need to get it
- Fix next/previous in pagination being incorrect
- Put back a 20 page limit on rss feed by default (configurable)


## 0.0.7 (2017-06-19) ## 0.0.7 (2017-06-19)




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

@@ -68,7 +68,7 @@ impl Config {
set_default!(config.language_code, "en".to_string()); set_default!(config.language_code, "en".to_string());
set_default!(config.highlight_code, false); set_default!(config.highlight_code, false);
set_default!(config.generate_rss, false); set_default!(config.generate_rss, false);
set_default!(config.rss_limit, <usize>::max_value());
set_default!(config.rss_limit, 20);
set_default!(config.generate_tags_pages, false); set_default!(config.generate_tags_pages, false);
set_default!(config.generate_categories_pages, false); set_default!(config.generate_categories_pages, false);
set_default!(config.insert_anchor_links, false); set_default!(config.insert_anchor_links, false);


+ 9
- 0
components/site/benches/site.rs View File

@@ -35,3 +35,12 @@ fn bench_render_sitemap(b: &mut test::Bencher) {
site.set_output_path(&public); site.set_output_path(&public);
b.iter(|| site.render_sitemap().unwrap()); b.iter(|| site.render_sitemap().unwrap());
} }

#[bench]
fn bench_render_rss_feed(b: &mut test::Bencher) {
let mut site = setup_site("huge-blog");
let tmp_dir = TempDir::new("benches").expect("create temp dir");
let public = &tmp_dir.path().join("public");
site.set_output_path(&public);
b.iter(|| site.render_rss_feed().unwrap());
}

+ 4
- 1
components/site/src/lib.rs View File

@@ -39,6 +39,8 @@ use pagination::Paginator;
use rayon::prelude::*; use rayon::prelude::*;




/// The sitemap only needs links and potentially date so we trim down
/// all pages to only that
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
struct SitemapEntry { struct SitemapEntry {
permalink: String, permalink: String,
@@ -566,8 +568,9 @@ impl Site {
if pages.is_empty() { if pages.is_empty() {
return Ok(()); return Ok(());
} }
context.add("last_build_date", &pages[0].meta.date);
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("pages", &sorted_pages); context.add("pages", &sorted_pages);
context.add("config", &self.config); context.add("config", &self.config);




Loading…
Cancel
Save