71 lines
2.3 KiB
Rust
71 lines
2.3 KiB
Rust
// Copyright (C) 2024 Philipp Hofer
|
|
//
|
|
// Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
|
|
// the European Commission - subsequent versions of the EUPL (the "Licence").
|
|
// You may not use this work except in compliance with the Licence.
|
|
//
|
|
// You should have received a copy of the European Union Public License along
|
|
// with this program. If not, you may obtain a copy of the Licence at:
|
|
// <https://joinup.ec.europa.eu/software/page/eupl>
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the Licence is distributed on an "AS IS" basis,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the Licence for the specific language governing permissions and
|
|
// limitations under the Licence.
|
|
|
|
use std::{fs, path::Path};
|
|
|
|
use part::Parts;
|
|
|
|
mod law;
|
|
mod part;
|
|
|
|
fn main() {
|
|
fs::create_dir_all("./output").unwrap();
|
|
|
|
let overview = law::create_law_files();
|
|
create_static_files();
|
|
|
|
create_index(&overview);
|
|
create_impressum();
|
|
create_datenschutz();
|
|
}
|
|
|
|
/// Creates the `impressum.html` file.
|
|
fn create_impressum() {
|
|
let index = fs::read_to_string("templates/impressum.html").unwrap();
|
|
let index = Parts::new().perform(index);
|
|
fs::write("output/impressum.html", index).expect("Unable to write file");
|
|
}
|
|
|
|
/// Creates the `datenschutz.html` file.
|
|
fn create_datenschutz() {
|
|
let index = fs::read_to_string("templates/datenschutz.html").unwrap();
|
|
let index = Parts::new().perform(index);
|
|
fs::write("output/datenschutz.html", index).expect("Unable to write file");
|
|
}
|
|
|
|
/// Creates the `index.html` file.
|
|
fn create_index(content: &str) {
|
|
let mut index = fs::read_to_string("templates/index.html").unwrap();
|
|
index = index.replace("{{content}}", content);
|
|
let index = Parts::new().perform(index);
|
|
fs::write("output/index.html", index).expect("Unable to write file");
|
|
}
|
|
|
|
/// Copies all files from `templates/static` to `output`
|
|
fn create_static_files() {
|
|
let from = Path::new("templates/static");
|
|
let to = Path::new("output");
|
|
|
|
for entry in fs::read_dir(from).expect("No templates/static folder") {
|
|
let entry = entry.unwrap();
|
|
let path = entry.path();
|
|
if path.is_file() {
|
|
let to_path = to.join(entry.file_name());
|
|
fs::copy(&path, &to_path).unwrap();
|
|
}
|
|
}
|
|
}
|