aboutsummaryrefslogtreecommitdiff
path: root/src/templ_data/mod.rs
blob: 7645e95ef82456aba7320530d1c0ad99eb6fc91e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 `<type>/base` extended by
//! `<type>/<page>`, 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,
        }
    }
}