From 9dacf748651ea7139c0e9f3dee9ae66d949bf73f Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sat, 31 Oct 2020 18:57:39 +0100 Subject: Add 'apps/servers/octopus/' from commit '623954d19fdf0dca47db319e5c88ee561aa8d25c' git-subtree-dir: apps/servers/octopus git-subtree-mainline: 4e09fe2509904ee64d2470ca8d41006d51e4ffd6 git-subtree-split: 623954d19fdf0dca47db319e5c88ee561aa8d25c --- apps/servers/octopus/src/templ_data/mod.rs | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 apps/servers/octopus/src/templ_data/mod.rs (limited to 'apps/servers/octopus/src/templ_data/mod.rs') diff --git a/apps/servers/octopus/src/templ_data/mod.rs b/apps/servers/octopus/src/templ_data/mod.rs new file mode 100644 index 000000000000..7645e95ef824 --- /dev/null +++ b/apps/servers/octopus/src/templ_data/mod.rs @@ -0,0 +1,38 @@ +//! Octopus template data structures +//! +//! All pages are generated by the server via template files that have +//! data inputs. Because the templates follow a well-defined +//! structure (i.e. `core` extended by `/base` extended by +//! `/`, the structure of these template data structures +//! is the same. +//! +//! The actual page initialisation and rendering is nested in the +//! `page` module, which then uses the appropriate template structures +//! defined here. + +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 siteurl: String, + pub sitename: String, + pub has_wiki: bool, +} + +impl Default for BaseData { + fn default() -> Self { + Self { + 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, + } + } +} -- cgit v1.2.3