From 39434803fc057cdda61eb177800d4f7d404e4c76 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 25 May 2023 18:35:08 +0200 Subject: [PATCH] implemented main --- src/main.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main.rs diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a14a440 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,37 @@ +pub mod distro; + +use tera::{Tera, Context}; +use distro::{DistroList, Distro}; + +fn main() { + let tera = match Tera::new("templates/**/*.html") { + Ok(t) => t, + Err(e) => { + println!("Parsing error: {}", e); + panic!("parsing error"); + } + }; + let distro = Distro { + name: "fedora".to_owned(), + summary: "AAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaa".to_string(), + icon_url: "assets/distro-icon-fedora.png".to_owned(), + wiki: "".to_owned(), download: "".to_owned(), website: "".to_owned(), + freedom_positives: vec!["a".to_string(), "b".to_string(), "c".to_string()], + freedom_negatives: vec!["a".to_string(), "b".to_string(), "c".to_string()], + freedom_stars: 2, + usability_positives: vec!["a".to_string(), "b".to_string(), "c".to_string()], + usability_negatives: vec!["a".to_string(), "b".to_string(), "c".to_string()], + usability_stars: 3, + privacy_positives: vec!["a".to_string(), "b".to_string(), "c".to_string()], + privacy_negatives: vec!["a".to_string(), "b".to_string(), "c".to_string()], + privacy_stars: 3, + }; + let distros: DistroList = DistroList { + distros: vec![distro.to_owned(), distro.to_owned()] + }; + + let context = Context::from_serialize(distros).unwrap(); + + let html = tera.render("index.html", &context).unwrap(); + println!("{}", html); +}