Add typed commit links
This commit is contained in:
parent
0253d2d90b
commit
c3c597897c
10 changed files with 82 additions and 69 deletions
36
src/server/web/link.rs
Normal file
36
src/server/web/link.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use askama::Template;
|
||||
|
||||
use crate::server::util;
|
||||
|
||||
use super::Base;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(
|
||||
ext = "html",
|
||||
source = "
|
||||
{% import \"util.html\" as util %}
|
||||
|
||||
<a href=\"{{ root }}commit/{{ hash }}\"
|
||||
class=\"{% call util::commit_class(reachable) %}\"
|
||||
title=\"{% call util::commit_title(reachable) %}\">
|
||||
{{ short }}
|
||||
</a>
|
||||
"
|
||||
)]
|
||||
pub struct CommitLink {
|
||||
root: String,
|
||||
hash: String,
|
||||
short: String,
|
||||
reachable: i64,
|
||||
}
|
||||
|
||||
impl CommitLink {
|
||||
pub fn new(base: &Base, hash: String, message: &str, reachable: i64) -> Self {
|
||||
Self {
|
||||
root: base.root.clone(),
|
||||
short: util::format_commit_short(&hash, message),
|
||||
hash,
|
||||
reachable,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue