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"
|
name = "hagrid"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Kai Michaelis <kai@sequoia-pgp.org>"]
|
authors = ["Kai Michaelis <kai@sequoia-pgp.org>"]
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = "0"
|
rocket = "0"
|
||||||
|
@ -34,3 +35,6 @@ features = ["file-transport", "sendmail-transport"]
|
||||||
version = "0"
|
version = "0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["handlebars_templates"]
|
features = ["handlebars_templates"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
vergen = "3"
|
||||||
|
|
|
@ -36,17 +36,23 @@ mod templates {
|
||||||
pub verified: bool,
|
pub verified: bool,
|
||||||
pub userid: String,
|
pub userid: String,
|
||||||
pub fpr: String,
|
pub fpr: String,
|
||||||
|
pub commit: String,
|
||||||
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct Delete {
|
pub struct Delete {
|
||||||
pub token: String,
|
pub token: String,
|
||||||
pub fpr: String,
|
pub fpr: String,
|
||||||
|
pub commit: String,
|
||||||
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct Confirm {
|
pub struct Confirm {
|
||||||
pub deleted: bool,
|
pub deleted: bool,
|
||||||
|
pub commit: String,
|
||||||
|
pub version: String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +223,8 @@ fn verify(
|
||||||
verified: true,
|
verified: true,
|
||||||
userid: userid.to_string(),
|
userid: userid.to_string(),
|
||||||
fpr: fpr.to_string(),
|
fpr: fpr.to_string(),
|
||||||
|
version: env!("VERGEN_SEMVER").to_string(),
|
||||||
|
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Template::render("verify", context))
|
Ok(Template::render("verify", context))
|
||||||
|
@ -226,6 +234,8 @@ fn verify(
|
||||||
verified: false,
|
verified: false,
|
||||||
userid: "".into(),
|
userid: "".into(),
|
||||||
fpr: "".into(),
|
fpr: "".into(),
|
||||||
|
version: env!("VERGEN_SEMVER").to_string(),
|
||||||
|
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Template::render("verify", context))
|
Ok(Template::render("verify", context))
|
||||||
|
@ -255,6 +265,8 @@ fn delete(
|
||||||
let context = templates::Delete {
|
let context = templates::Delete {
|
||||||
fpr: fpr.to_string(),
|
fpr: fpr.to_string(),
|
||||||
token: token.clone(),
|
token: token.clone(),
|
||||||
|
version: env!("VERGEN_SEMVER").to_string(),
|
||||||
|
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
for uid in uids {
|
for uid in uids {
|
||||||
|
@ -278,12 +290,20 @@ fn confirm(
|
||||||
) -> result::Result<Template, Custom<String>> {
|
) -> result::Result<Template, Custom<String>> {
|
||||||
match db.confirm_deletion(&token) {
|
match db.confirm_deletion(&token) {
|
||||||
Ok(true) => {
|
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(Template::render("confirm", context))
|
||||||
}
|
}
|
||||||
Ok(false) | Err(_) => {
|
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))
|
Ok(Template::render("confirm", context))
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ mod template {
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct Verify {
|
pub struct Verify {
|
||||||
pub tokens: Vec<Token>,
|
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))
|
Ok(Template::render("upload", context))
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,5 +53,10 @@
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center py-3">
|
||||||
|
Hagrid v{{ version }} build from {{ commit }}
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue