]>
Commit | Line | Data |
---|---|---|
29982470 RBR |
1 | mod static_files; |
2 | mod html; | |
3 | mod rss; | |
4 | mod txt; | |
5 | ||
6 | use std::io::Result; | |
7 | use std::path::PathBuf; | |
8 | use crate::post::Post; | |
f6a545b0 | 9 | use crate::template::TemplateContext; |
29982470 RBR |
10 | |
11 | pub fn generate(static_directory: &PathBuf, template_directory: &PathBuf, output_directory: &PathBuf, posts: &Vec<Post>) -> Result<()> { | |
12 | let generators = available_generators(); | |
f6a545b0 | 13 | let context = Post::to_template_context(&posts); |
29982470 | 14 | for generator in generators { |
f6a545b0 | 15 | generator(static_directory, template_directory, output_directory, &context)?; |
29982470 RBR |
16 | } |
17 | Ok(()) | |
18 | } | |
19 | ||
20 | ||
f6a545b0 | 21 | fn available_generators() -> Vec<fn(&PathBuf, &PathBuf, &PathBuf, &TemplateContext) -> Result<()>> { |
29982470 RBR |
22 | vec![ |
23 | static_files::generate, | |
60307a9a | 24 | // These three are actually the same. Can generalize, don't know how in rust yet. |
29982470 RBR |
25 | html::generate, |
26 | rss::generate, | |
27 | txt::generate | |
28 | ] | |
29 | } |