Skip to content

Commit

Permalink
rotate the list of projects on a daily basis
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed Mar 5, 2019
1 parent d6c8adf commit 450a7d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ maplit = "1.0.1"
failure = "0.1.3"
exitfailure = "0.5.1"
fs_extra = "1.1.0"
chrono = "0.4.6"
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::{fs, path::Path};

use chrono::{Date, NaiveDate, Utc};
use exitfailure::ExitFailure;
use failure::{bail, SyncFailure};
use fs_extra::dir::{self, CopyOptions};
Expand Down Expand Up @@ -30,6 +31,12 @@ fn run() -> Result<(), failure::Error> {
let tera = Tera::new("templates/**/*.html").map_err(SyncFailure::new)?;
let mut projects: Vec<Project> = serde_yaml::from_str(&fs::read_to_string("data.yml")?)?;

// rotate the project list so that the first entry is not always shown at the top
// (we rebuild the site on a daily basis)
let start = Date::from_utc(NaiveDate::from_ymd(2019, 03, 04), Utc);
let nprojects = projects.len();
projects.rotate_left(((Utc::today() - start).num_days() as usize) % nprojects);

for project in &mut projects {
if project.description.len() > MAX_DESCRIPTION_SIZE {
bail!(
Expand Down

0 comments on commit 450a7d0

Please sign in to comment.