File tree 4 files changed +20
-6
lines changed
4 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,27 @@ use sha2::{Digest, Sha256};
2
2
use walkdir:: WalkDir ;
3
3
4
4
fn main ( ) -> anyhow:: Result < ( ) > {
5
- let mut hasher = Sha256 :: new ( ) ;
5
+ let mut css_hasher = Sha256 :: new ( ) ;
6
6
for entry in WalkDir :: new ( "static/css" ) {
7
7
let entry = entry. unwrap ( ) ;
8
8
if entry. file_type ( ) . is_file ( ) {
9
- hasher . update ( std:: fs:: read_to_string ( entry. path ( ) ) ?) ;
9
+ css_hasher . update ( std:: fs:: read_to_string ( entry. path ( ) ) ?) ;
10
10
}
11
11
}
12
12
13
- let hash = hasher. finalize ( ) ;
14
- println ! ( "cargo:rustc-env=CSS_VERSION={:x}" , hash) ;
13
+ let css_hash = css_hasher. finalize ( ) ;
14
+ println ! ( "cargo:rustc-env=CSS_VERSION={:x}" , css_hash) ;
15
+
16
+ let mut js_hasher = Sha256 :: new ( ) ;
17
+ for entry in WalkDir :: new ( "static/js" ) {
18
+ let entry = entry. unwrap ( ) ;
19
+ if entry. file_type ( ) . is_file ( ) {
20
+ js_hasher. update ( std:: fs:: read_to_string ( entry. path ( ) ) ?) ;
21
+ }
22
+ }
23
+
24
+ let js_hash = js_hasher. finalize ( ) ;
25
+ println ! ( "cargo:rustc-env=JS_VERSION={:x}" , js_hash) ;
15
26
16
27
Ok ( ( ) )
17
28
}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ pub struct Context {
33
33
}
34
34
35
35
const CSS_VERSION : & str = std:: env!( "CSS_VERSION" ) ;
36
+ const JS_VERSION : & str = std:: env!( "JS_VERSION" ) ;
36
37
37
38
struct TplContext < ' a > {
38
39
is_admin : bool ,
@@ -42,6 +43,7 @@ struct TplContext<'a> {
42
43
err_msg : Vec < String > ,
43
44
warning_msg : Vec < String > ,
44
45
css_version : & ' a str ,
46
+ js_version : & ' a str ,
45
47
}
46
48
47
49
impl < ' a > TplContext < ' a > {
@@ -54,6 +56,7 @@ impl<'a> TplContext<'a> {
54
56
err_msg : session. err_msg . drain ( ..) . collect ( ) ,
55
57
warning_msg : session. warning_msg . drain ( ..) . collect ( ) ,
56
58
css_version : CSS_VERSION ,
59
+ js_version : JS_VERSION ,
57
60
} ;
58
61
59
62
session
Original file line number Diff line number Diff line change 57
57
{% block main %}{% endblock main %}
58
58
</ main >
59
59
</ div >
60
- < script src ="/static/js/time.js " defer > </ script >
60
+ < script src ="/static/js/time.js?{{ base.js_version}} " defer > </ script >
61
61
{% block scripts %}
62
62
{% endblock scripts %}
63
63
</ body >
Original file line number Diff line number Diff line change 131
131
</ script >
132
132
< script src ="/static/contrib/highlight.js/highlight.min.js " defer > </ script >
133
133
< script src ="/static/contrib/highlight.js/yaml.min.js " defer > </ script >
134
- < script src ="/static/js/viewer.js " defer > </ script >
134
+ < script src ="/static/js/viewer.js?{{ base.js_version }} " defer > </ script >
135
135
{% endblock %}
136
136
137
137
{% block styles %}
You can’t perform that action at this time.
0 commit comments