mirror of
https://gitlab.com/hagrid-keyserver/hagrid.git
synced 2023-02-13 20:55:02 -05:00
display hagrid version and commit in footer of all templates
This commit is contained in:
parent
e0a081470b
commit
2ddca1dd6d
4 changed files with 38 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
name = "hagrid"
|
||||
version = "0.1.0"
|
||||
authors = ["Kai Michaelis <kai@sequoia-pgp.org>"]
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
rocket = "0"
|
||||
|
@ -34,3 +35,6 @@ features = ["file-transport", "sendmail-transport"]
|
|||
version = "0"
|
||||
default-features = false
|
||||
features = ["handlebars_templates"]
|
||||
|
||||
[build-dependencies]
|
||||
vergen = "3"
|
||||
|
|
|
@ -36,17 +36,23 @@ mod templates {
|
|||
pub verified: bool,
|
||||
pub userid: String,
|
||||
pub fpr: String,
|
||||
pub commit: String,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Delete {
|
||||
pub token: String,
|
||||
pub fpr: String,
|
||||
pub commit: String,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Confirm {
|
||||
pub deleted: bool,
|
||||
pub commit: String,
|
||||
pub version: String,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,6 +223,8 @@ fn verify(
|
|||
verified: true,
|
||||
userid: userid.to_string(),
|
||||
fpr: fpr.to_string(),
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
Ok(Template::render("verify", context))
|
||||
|
@ -226,6 +234,8 @@ fn verify(
|
|||
verified: false,
|
||||
userid: "".into(),
|
||||
fpr: "".into(),
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
Ok(Template::render("verify", context))
|
||||
|
@ -255,6 +265,8 @@ fn delete(
|
|||
let context = templates::Delete {
|
||||
fpr: fpr.to_string(),
|
||||
token: token.clone(),
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
for uid in uids {
|
||||
|
@ -278,12 +290,20 @@ fn confirm(
|
|||
) -> result::Result<Template, Custom<String>> {
|
||||
match db.confirm_deletion(&token) {
|
||||
Ok(true) => {
|
||||
let context = templates::Confirm { deleted: true };
|
||||
let context = templates::Confirm {
|
||||
deleted: true,
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
Ok(Template::render("confirm", context))
|
||||
}
|
||||
Ok(false) | Err(_) => {
|
||||
let context = templates::Confirm { deleted: false };
|
||||
let context = templates::Confirm {
|
||||
deleted: false,
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
Ok(Template::render("confirm", context))
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ mod template {
|
|||
#[derive(Serialize)]
|
||||
pub struct Verify {
|
||||
pub tokens: Vec<Token>,
|
||||
pub commit: String,
|
||||
pub version: String,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +172,11 @@ where
|
|||
})?;
|
||||
}
|
||||
|
||||
let context = template::Verify { tokens: tokens };
|
||||
let context = template::Verify {
|
||||
tokens: tokens,
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
||||
Ok(Template::render("upload", context))
|
||||
}
|
||||
|
|
|
@ -53,5 +53,10 @@
|
|||
<div class="col"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-3">
|
||||
Hagrid v{{ version }} build from {{ commit }}
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue