Always display nav bar
This commit is contained in:
parent
f532c55772
commit
8fe3fcad72
4 changed files with 15 additions and 20 deletions
|
|
@ -11,7 +11,6 @@ use crate::{
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
pub enum Tab {
|
pub enum Tab {
|
||||||
None,
|
|
||||||
Index,
|
Index,
|
||||||
Graph,
|
Graph,
|
||||||
Queue,
|
Queue,
|
||||||
|
|
@ -20,7 +19,7 @@ pub enum Tab {
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
config: &'static ServerConfig,
|
config: &'static ServerConfig,
|
||||||
title: String,
|
title: String,
|
||||||
nav: Option<Markup>,
|
tab: Option<Tab>,
|
||||||
heads: Vec<Markup>,
|
heads: Vec<Markup>,
|
||||||
bodies: Vec<Markup>,
|
bodies: Vec<Markup>,
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +29,7 @@ impl Page {
|
||||||
Self {
|
Self {
|
||||||
config,
|
config,
|
||||||
title: "???".to_string(),
|
title: "???".to_string(),
|
||||||
nav: None,
|
tab: None,
|
||||||
heads: vec![],
|
heads: vec![],
|
||||||
bodies: vec![],
|
bodies: vec![],
|
||||||
}
|
}
|
||||||
|
|
@ -41,18 +40,8 @@ impl Page {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nav(mut self, tab: Tab) -> Self {
|
pub fn tab(mut self, tab: Tab) -> Self {
|
||||||
self.nav = Some(html! {
|
self.tab = Some(tab);
|
||||||
nav {
|
|
||||||
a .current[tab == Tab::Index] href=(self.config.path(PathIndex {})) {
|
|
||||||
img src=(self.config.path(LOGO_SVG)) alt="";
|
|
||||||
(self.config.repo_name)
|
|
||||||
}
|
|
||||||
a .current[tab == Tab::Graph] href=(self.config.path(PathGraph {})) { "graph" }
|
|
||||||
a .current[tab == Tab::Queue] href=(self.config.path(PathQueue {})) { "queue" }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,10 +65,17 @@ impl Page {
|
||||||
title { (self.title) " - " (self.config.repo_name) }
|
title { (self.title) " - " (self.config.repo_name) }
|
||||||
link rel="icon" href=(self.config.path(LOGO_SVG));
|
link rel="icon" href=(self.config.path(LOGO_SVG));
|
||||||
link rel="stylesheet" href=(self.config.path(BASE_CSS));
|
link rel="stylesheet" href=(self.config.path(BASE_CSS));
|
||||||
@if let Some(nav) = self.nav { (nav) }
|
|
||||||
@for head in self.heads { (head) }
|
@for head in self.heads { (head) }
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
|
nav {
|
||||||
|
a .current[self.tab == Some(Tab::Index)] href=(self.config.path(PathIndex {})) {
|
||||||
|
img src=(self.config.path(LOGO_SVG)) alt="";
|
||||||
|
(self.config.repo_name)
|
||||||
|
}
|
||||||
|
a .current[self.tab == Some(Tab::Graph)] href=(self.config.path(PathGraph {})) { "graph" }
|
||||||
|
a .current[self.tab == Some(Tab::Queue)] href=(self.config.path(PathQueue {})) { "queue" }
|
||||||
|
}
|
||||||
@for body in self.bodies { (body) }
|
@for body in self.bodies { (body) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use crate::{
|
||||||
util,
|
util,
|
||||||
web::{
|
web::{
|
||||||
components,
|
components,
|
||||||
page::{Page, Tab},
|
page::Page,
|
||||||
paths::{PathAdminQueueAdd, PathCommitByHash},
|
paths::{PathAdminQueueAdd, PathCommitByHash},
|
||||||
server_config_ext::ServerConfigExt,
|
server_config_ext::ServerConfigExt,
|
||||||
},
|
},
|
||||||
|
|
@ -93,7 +93,6 @@ pub async fn get_commit_by_hash(
|
||||||
|
|
||||||
let html = Page::new(config)
|
let html = Page::new(config)
|
||||||
.title(util::format_commit_summary(&commit.message))
|
.title(util::format_commit_summary(&commit.message))
|
||||||
.nav(Tab::None)
|
|
||||||
.body(html! {
|
.body(html! {
|
||||||
h2 { "Commit" }
|
h2 { "Commit" }
|
||||||
div .commit-like .commit {
|
div .commit-like .commit {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ pub async fn get_graph(
|
||||||
) -> somehow::Result<impl IntoResponse> {
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
let html = Page::new(config)
|
let html = Page::new(config)
|
||||||
.title("graph")
|
.title("graph")
|
||||||
.nav(Tab::Graph)
|
.tab(Tab::Graph)
|
||||||
.head(html! {
|
.head(html! {
|
||||||
link rel="stylesheet" href=(config.path(UPLOT_CSS));
|
link rel="stylesheet" href=(config.path(UPLOT_CSS));
|
||||||
script type="module" src=(config.path(GRAPH_JS)) {}
|
script type="module" src=(config.path(GRAPH_JS)) {}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ pub async fn get_index(
|
||||||
|
|
||||||
let html = Page::new(config)
|
let html = Page::new(config)
|
||||||
.title("overview")
|
.title("overview")
|
||||||
.nav(Tab::Index)
|
.tab(Tab::Index)
|
||||||
.body(html! {
|
.body(html! {
|
||||||
h2 { "Refs" }
|
h2 { "Refs" }
|
||||||
details .refs-list open {
|
details .refs-list open {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue