1+ //! Support for writing static files.
2+
13use log:: { debug, warn} ;
24
35use crate :: config:: HtmlConfig ;
@@ -18,7 +20,7 @@ use std::path::{Path, PathBuf};
1820/// It also writes files to their final destination, when `write_files` is called,
1921/// and interprets the `{{ resource }}` directives to allow assets to name each other.
2022///
21- /// [fingerprinting]: https://guides.rubyonrails.org/asset_pipeline.html#what-is- fingerprinting-and-why-should-i-care-questionmark
23+ /// [fingerprinting]: https://guides.rubyonrails.org/asset_pipeline.html#fingerprinting-versioning-with-digest-based-urls
2224pub struct StaticFiles {
2325 static_files : Vec < StaticFile > ,
2426 hash_map : HashMap < String , String > ,
@@ -154,12 +156,16 @@ impl StaticFiles {
154156
155157 Ok ( this)
156158 }
159+
157160 pub fn add_builtin ( & mut self , filename : & str , data : & [ u8 ] ) {
158161 self . static_files . push ( StaticFile :: Builtin {
159162 filename : filename. to_owned ( ) ,
160163 data : data. to_owned ( ) ,
161164 } ) ;
162165 }
166+
167+ /// Updates this [`StaticFiles`] to hash the contents for determining the
168+ /// filename for each resource.
163169 pub fn hash_files ( & mut self ) -> Result < ( ) > {
164170 use sha2:: { Digest , Sha256 } ;
165171 use std:: io:: Read ;
@@ -218,6 +224,7 @@ impl StaticFiles {
218224 }
219225 Ok ( ( ) )
220226 }
227+
221228 pub fn write_files ( self , destination : & Path ) -> Result < ResourceHelper > {
222229 use crate :: utils:: fs:: write_file;
223230 use regex:: bytes:: { Captures , Regex } ;
0 commit comments