Port commit page to maud
This commit is contained in:
parent
99576a9209
commit
67960e08fa
3 changed files with 111 additions and 95 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use askama::Template;
|
||||
use maud::{html, Markup};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::server::util;
|
||||
|
|
@ -34,6 +35,44 @@ impl LinkCommit {
|
|||
reachable,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn class_and_title(&self) -> (&'static str, &'static str) {
|
||||
if self.reachable == 0 {
|
||||
(
|
||||
"commit-orphaned",
|
||||
"This commit is orphaned. It can't be reached from any ref.",
|
||||
)
|
||||
} else if self.reachable == -1 {
|
||||
(
|
||||
"commit-reachable",
|
||||
"This commit can only be reached from untracked refs.",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
"commit-tracked",
|
||||
"This commit can be reached from a tracked ref.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn html(&self) -> Markup {
|
||||
let (class, title) = self.class_and_title();
|
||||
|
||||
let truncate = self.short.chars().take(81).count() > 80;
|
||||
let short = if truncate {
|
||||
self.short
|
||||
.chars()
|
||||
.take(80 - 3)
|
||||
.chain("...".chars())
|
||||
.collect::<String>()
|
||||
} else {
|
||||
self.short.to_string()
|
||||
};
|
||||
|
||||
html! {
|
||||
a href=(self.link) .(class) title=(title) { (short) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
|
|
@ -72,6 +111,12 @@ impl LinkRunDate {
|
|||
date: util::format_time(start),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn html(&self) -> Markup {
|
||||
html! {
|
||||
a href=(self.link) { "Run from " (self.date) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue