@@ -7,6 +7,25 @@ use iron::response::Response;
7
7
use handlebars_iron:: Template ;
8
8
9
9
10
+ pub ( crate ) struct GlobalAlert {
11
+ pub ( crate ) url : & ' static str ,
12
+ pub ( crate ) text : & ' static str ,
13
+ pub ( crate ) css_class : & ' static str ,
14
+ pub ( crate ) fa_icon : & ' static str ,
15
+ }
16
+
17
+ impl ToJson for GlobalAlert {
18
+ fn to_json ( & self ) -> Json {
19
+ let mut map = BTreeMap :: new ( ) ;
20
+ map. insert ( "url" . to_string ( ) , self . url . to_json ( ) ) ;
21
+ map. insert ( "text" . to_string ( ) , self . text . to_json ( ) ) ;
22
+ map. insert ( "css_class" . to_string ( ) , self . css_class . to_json ( ) ) ;
23
+ map. insert ( "fa_icon" . to_string ( ) , self . fa_icon . to_json ( ) ) ;
24
+ Json :: Object ( map)
25
+ }
26
+ }
27
+
28
+
10
29
pub struct Page < T : ToJson > {
11
30
title : Option < String > ,
12
31
content : T ,
@@ -89,6 +108,11 @@ impl<T: ToJson> ToJson for Page<T> {
89
108
tree. insert ( "title" . to_owned ( ) , title. to_json ( ) ) ;
90
109
}
91
110
111
+ tree. insert ( "has_global_alert" . to_owned ( ) , :: GLOBAL_ALERT . is_some ( ) . to_json ( ) ) ;
112
+ if let Some ( ref global_alert) = :: GLOBAL_ALERT {
113
+ tree. insert ( "global_alert" . to_owned ( ) , global_alert. to_json ( ) ) ;
114
+ }
115
+
92
116
tree. insert ( "content" . to_owned ( ) , self . content . to_json ( ) ) ;
93
117
tree. insert ( "cratesfyi_version" . to_owned ( ) , :: BUILD_VERSION . to_json ( ) ) ;
94
118
tree. insert ( "cratesfyi_version_safe" . to_owned ( ) ,
0 commit comments