22
33use std:: { fs, path:: Path } ;
44
5- use chrono:: { Date , NaiveDate , Utc } ;
5+ use chrono:: { TimeZone , Utc } ;
66use exitfailure:: ExitFailure ;
77use failure:: { bail, SyncFailure } ;
88use fs_extra:: dir:: { self , CopyOptions } ;
9- use maplit:: hashmap;
109use serde_derive:: { Deserialize , Serialize } ;
11- use tera:: Tera ;
10+ use tera:: { Context , Tera } ;
1211
1312const MAX_DESCRIPTION_SIZE : usize = 280 ; // characters (assuming ASCII)
1413
@@ -33,9 +32,9 @@ fn run() -> Result<(), failure::Error> {
3332
3433 // rotate the project list so that the first entry is not always shown at the top
3534 // (we rebuild the site on a daily basis)
36- let start = Date :: from_utc ( NaiveDate :: from_ymd ( 2019 , 03 , 04 ) , Utc ) ;
35+ let start = Utc . with_ymd_and_hms ( 2019 , 03 , 04 , 0 , 0 , 0 ) . unwrap ( ) ;
3736 let nprojects = projects. len ( ) ;
38- projects. rotate_left ( ( ( Utc :: today ( ) - start) . num_days ( ) as usize ) % nprojects) ;
37+ projects. rotate_left ( ( ( Utc :: now ( ) - start) . num_days ( ) as usize ) % nprojects) ;
3938
4039 for project in & mut projects {
4140 if project. description . len ( ) > MAX_DESCRIPTION_SIZE {
@@ -66,8 +65,10 @@ fn run() -> Result<(), failure::Error> {
6665 }
6766 }
6867
68+ let mut context = Context :: new ( ) ;
69+ context. insert ( "projects" , & projects) ;
6970 let index = tera
70- . render ( "index.html" , & hashmap ! { "projects" => projects } )
71+ . render ( "index.html" , & context )
7172 . map_err ( SyncFailure :: new) ?;
7273
7374 fs:: remove_dir_all ( "public" ) . ok ( ) ;
0 commit comments