2 // AGPL-3.0 License (see LICENSE)
4 use sailfish::Template;
6 use crate::site::helper::Helper;
9 #[template(path = "screenshot.stpl")]
10 #[derive(Clone, Debug)]
11 pub struct Screenshot {
12 pub screenshots_title: String,
13 pub screenshots_url: String,
15 pub image_min: String,
16 pub image_big: String,
18 pub screenshots: Vec<Screenshot>,
22 pub fn new() -> Self {
24 screenshots_title: String::new(),
25 screenshots_url: String::new(),
27 image_min: String::new(),
28 image_big: String::new(),
30 screenshots: Vec::new(),
34 pub fn generate(&self) {
35 // create output dir needed:
36 self.create_output_dir();
38 // write page to disk:
39 Helper::write_file_sync(
40 &Helper::get_output_dir().join(&self.url).join("index.html"),
41 &self.render().unwrap().as_bytes(),
46 fn create_output_dir(&self) {
47 Helper::create_dir_all(&Helper::get_output_dir().join(&self.url));