2
2
3
3
use std:: { fs, path:: Path } ;
4
4
5
- use chrono:: { Date , NaiveDate , Utc } ;
5
+ use chrono:: { TimeZone , Utc } ;
6
6
use exitfailure:: ExitFailure ;
7
7
use failure:: { bail, SyncFailure } ;
8
8
use fs_extra:: dir:: { self , CopyOptions } ;
9
- use maplit:: hashmap;
10
9
use serde_derive:: { Deserialize , Serialize } ;
11
- use tera:: Tera ;
10
+ use tera:: { Context , Tera } ;
12
11
13
12
const MAX_DESCRIPTION_SIZE : usize = 280 ; // characters (assuming ASCII)
14
13
@@ -33,9 +32,9 @@ fn run() -> Result<(), failure::Error> {
33
32
34
33
// rotate the project list so that the first entry is not always shown at the top
35
34
// (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 ( ) ;
37
36
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) ;
39
38
40
39
for project in & mut projects {
41
40
if project. description . len ( ) > MAX_DESCRIPTION_SIZE {
@@ -66,8 +65,10 @@ fn run() -> Result<(), failure::Error> {
66
65
}
67
66
}
68
67
68
+ let mut context = Context :: new ( ) ;
69
+ context. insert ( "projects" , & projects) ;
69
70
let index = tera
70
- . render ( "index.html" , & hashmap ! { "projects" => projects } )
71
+ . render ( "index.html" , & context )
71
72
. map_err ( SyncFailure :: new) ?;
72
73
73
74
fs:: remove_dir_all ( "public" ) . ok ( ) ;
0 commit comments