Commit

Author:

Hash:

Timestamp:

+56 -1 +/-5 browse

Kevin Schoon [me@kevinschoon.com]

f499260cc6e4dc9792dad9b27658ef40ecfdae51

Wed, 06 Aug 2025 09:19:48 +0000 (3 months ago)

add build info for each page render
1diff --git a/Cargo.lock b/Cargo.lock
2index b13dd7b..d08c202 100644
3--- a/Cargo.lock
4+++ b/Cargo.lock
5 @@ -331,6 +331,7 @@ dependencies = [
6 "comrak",
7 "file-mode",
8 "futures",
9+ "git2",
10 "globwalk",
11 "headers",
12 "httparse",
13 @@ -344,6 +345,7 @@ dependencies = [
14 "quick-xml 0.38.0",
15 "rand 0.9.2",
16 "rss",
17+ "rustc_version",
18 "serde",
19 "serde_json",
20 "tabwriter",
21 diff --git a/ayllu/Cargo.toml b/ayllu/Cargo.toml
22index 20032bf..68087e2 100644
23--- a/ayllu/Cargo.toml
24+++ b/ayllu/Cargo.toml
25 @@ -62,3 +62,5 @@ nix = { version = "0.30.1", default-features = false, features = ["user"] }
26
27 [build-dependencies]
28 cc="*"
29+ rustc_version = "0.4.1"
30+ git2 = { workspace = true }
31 diff --git a/ayllu/build.rs b/ayllu/build.rs
32new file mode 100644
33index 0000000..8935694
34--- /dev/null
35+++ b/ayllu/build.rs
36 @@ -0,0 +1,19 @@
37+ use git2::Repository;
38+ use rustc_version::version;
39+
40+ fn main() {
41+ if let Ok(lorry_repo) = Repository::open("..") {
42+ let commit_sha = lorry_repo
43+ .head()
44+ .expect("Could not get HEAD ref")
45+ .resolve()
46+ .expect("Could not resolve the HEAD ref")
47+ .target()
48+ .expect("Could not get OID of the HEAD ref");
49+ println!("cargo::rustc-env=AYLLU_COMMIT={commit_sha}");
50+ }
51+ let toolchain_version = version()
52+ .expect("Could not get the toolchain version")
53+ .to_string();
54+ println!("cargo::rustc-env=AYLLU_TOOLCHAIN_VERSION={toolchain_version}");
55+ }
56 diff --git a/ayllu/src/web2/template.rs b/ayllu/src/web2/template.rs
57index 0406a5c..d54d0fc 100644
58--- a/ayllu/src/web2/template.rs
59+++ b/ayllu/src/web2/template.rs
60 @@ -36,7 +36,7 @@ macro_rules! with_preamble {
61 }
62
63 /// top-level theme options available in all pages
64- #[derive(Clone, Serialize, Deserialize, Debug, Default)]
65+ #[derive(Clone, Serialize, Deserialize, Debug)]
66 pub struct Base {
67 pub title: String,
68 pub origin: String,
69 @@ -54,6 +54,8 @@ pub struct Base {
70 pub nav_elements: Items,
71 pub logo: String,
72 pub feed_icon: String,
73+ pub version_info: &'static str,
74+ pub rust_version: &'static str,
75 }
76
77 impl Base {
78 @@ -66,6 +68,31 @@ impl Base {
79 }
80 }
81
82+ impl Default for Base {
83+ fn default() -> Self {
84+ Self {
85+ title: Default::default(),
86+ origin: Default::default(),
87+ site_name: Default::default(),
88+ collection: Default::default(),
89+ name: Default::default(),
90+ url: Default::default(),
91+ path: Default::default(),
92+ fluid: Default::default(),
93+ keywords: Default::default(),
94+ description: Default::default(),
95+ subpath_mode: Default::default(),
96+ render_time: Default::default(),
97+ current_time: Default::default(),
98+ nav_elements: Default::default(),
99+ logo: Default::default(),
100+ feed_icon: Default::default(),
101+ version_info: env!("AYLLU_COMMIT"),
102+ rust_version: env!("AYLLU_TOOLCHAIN_VERSION"),
103+ }
104+ }
105+ }
106+
107 pub mod filters {
108
109 use file_mode::Mode;
110 diff --git a/ayllu/templates/base.html b/ayllu/templates/base.html
111index 47e73da..2257fb0 100644
112--- a/ayllu/templates/base.html
113+++ b/ayllu/templates/base.html
114 @@ -24,7 +24,12 @@
115 </div>
116 </main>
117 <footer>
118+ <section id="render-info">
119 Rendered {%- if let Some(render_time) = base.render_time %}in {{ render_time }} (ms){%- endif %} @ {{ base.current_time }}
120+ </section>
121+ <section id="build-info">
122+ <pre>Commit = {{ base.version_info }}, Rust = {{ base.rust_version }}</pre>
123+ </section>
124 </footer>
125 </body>
126 </html>