@@ -7,6 +7,25 @@ use iron::response::Response;
77use  handlebars_iron:: Template ; 
88
99
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+ 
1029pub  struct  Page < T :  ToJson >  { 
1130    title :  Option < String > , 
1231    content :  T , 
@@ -89,6 +108,11 @@ impl<T: ToJson> ToJson for Page<T> {
89108            tree. insert ( "title" . to_owned ( ) ,  title. to_json ( ) ) ; 
90109        } 
91110
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+ 
92116        tree. insert ( "content" . to_owned ( ) ,  self . content . to_json ( ) ) ; 
93117        tree. insert ( "cratesfyi_version" . to_owned ( ) ,  :: BUILD_VERSION . to_json ( ) ) ; 
94118        tree. insert ( "cratesfyi_version_safe" . to_owned ( ) , 
0 commit comments