Skip to content

Commit 450a7d0

Browse files
committed
rotate the list of projects on a daily basis
1 parent d6c8adf commit 450a7d0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ maplit = "1.0.1"
1313
failure = "0.1.3"
1414
exitfailure = "0.5.1"
1515
fs_extra = "1.1.0"
16+
chrono = "0.4.6"

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

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

34+
// rotate the project list so that the first entry is not always shown at the top
35+
// (we rebuild the site on a daily basis)
36+
let start = Date::from_utc(NaiveDate::from_ymd(2019, 03, 04), Utc);
37+
let nprojects = projects.len();
38+
projects.rotate_left(((Utc::today() - start).num_days() as usize) % nprojects);
39+
3340
for project in &mut projects {
3441
if project.description.len() > MAX_DESCRIPTION_SIZE {
3542
bail!(

0 commit comments

Comments
 (0)