aboutsummaryrefslogtreecommitdiff
path: root/src/templ_data
diff options
context:
space:
mode:
authorKaiden Fey <kookie@spacekookie.de>2020-10-25 05:36:08 +0100
committerKatharina Fey <kookie@spacekookie.de>2020-10-25 05:36:08 +0100
commit63cd5d0a8d3f77c0267f12a6aef52533cc2f7d09 (patch)
treed46fb6058a6ade2726154fff76d5bda1d6dfc7e0 /src/templ_data
parent392444d21101ce7b637f2e5a385490605f93ccf1 (diff)
Adding a whole lot of shit (octopus and supergit)
Diffstat (limited to 'src/templ_data')
-rw-r--r--src/templ_data/files.rs13
-rw-r--r--src/templ_data/mod.rs18
-rw-r--r--src/templ_data/overview.rs11
3 files changed, 37 insertions, 5 deletions
diff --git a/src/templ_data/files.rs b/src/templ_data/files.rs
new file mode 100644
index 0000000..27a5bde
--- /dev/null
+++ b/src/templ_data/files.rs
@@ -0,0 +1,13 @@
+//! File browser template data
+
+use super::BaseData;
+use askama::Template;
+
+// This struct needs escapng=none to render README files it encounters along the way
+#[derive(Template)]
+#[template(path = "files.html", escape = "none")]
+pub(crate) struct Files {
+ pub base: BaseData,
+ pub path: String,
+ pub readme: Option<String>,
+}
diff --git a/src/templ_data/mod.rs b/src/templ_data/mod.rs
index 6c93266..7645e95 100644
--- a/src/templ_data/mod.rs
+++ b/src/templ_data/mod.rs
@@ -10,21 +10,29 @@
//! `page` module, which then uses the appropriate template structures
//! defined here.
-pub(crate) mod repo;
+pub(crate) mod overview;
+pub(crate) mod files;
+
+use std::env;
/// A basic application wide template structure
pub(crate) struct BaseData {
pub version: String,
pub source: String,
- pub url: String,
+ pub siteurl: String,
+ pub sitename: String,
+ pub has_wiki: bool,
}
impl Default for BaseData {
fn default() -> Self {
Self {
- version: "0.2.0".into(),
- source: "".into(),
- url: "http://localhost:8080".into(),
+ version: env!("CARGO_PKG_VERSION").into(),
+ source: env::var("_OCTOPUS_SOURCE")
+ .unwrap_or("https://dev.spacekookie.de/web/octopus".to_string()),
+ siteurl: env::var("_OCTOPUS_SITE_URL").unwrap_or("localhost:8080".to_string()),
+ sitename: env::var("_OCTOPUS_SITE_NAME").unwrap_or("test-octopus".to_string()),
+ has_wiki: true,
}
}
}
diff --git a/src/templ_data/overview.rs b/src/templ_data/overview.rs
new file mode 100644
index 0000000..693db0a
--- /dev/null
+++ b/src/templ_data/overview.rs
@@ -0,0 +1,11 @@
+//! Template data for the main overview
+
+use super::BaseData;
+use askama::Template;
+
+#[derive(Template)]
+#[template(path = "index.html", escape = "none")]
+pub(crate) struct Index {
+ pub base: BaseData,
+ pub readme: String,
+}