Remove now unnecessary Base
This commit is contained in:
parent
eb1e82dae6
commit
1bae83d116
4 changed files with 2 additions and 77 deletions
|
|
@ -1,6 +1,5 @@
|
|||
mod admin;
|
||||
mod api;
|
||||
mod base;
|
||||
mod components;
|
||||
mod page;
|
||||
mod pages;
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
use maud::{html, Markup, DOCTYPE};
|
||||
|
||||
use crate::config::ServerConfig;
|
||||
|
||||
use super::{
|
||||
paths::{PathGraph, PathIndex, PathQueue},
|
||||
r#static::{BASE_CSS, LOGO_SVG},
|
||||
server_config_ext::{AbsPath, ServerConfigExt},
|
||||
};
|
||||
|
||||
pub enum Tab {
|
||||
None,
|
||||
Index,
|
||||
Graph,
|
||||
Queue,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Base {
|
||||
pub link_logo_svg: AbsPath,
|
||||
pub link_base_css: AbsPath,
|
||||
pub link_index: AbsPath,
|
||||
pub link_graph: AbsPath,
|
||||
pub link_queue: AbsPath,
|
||||
pub config: &'static ServerConfig,
|
||||
pub tab: &'static str,
|
||||
}
|
||||
|
||||
impl Base {
|
||||
pub fn new(config: &'static ServerConfig, tab: Tab) -> Self {
|
||||
let tab = match tab {
|
||||
Tab::None => "",
|
||||
Tab::Index => "index",
|
||||
Tab::Graph => "graph",
|
||||
Tab::Queue => "queue",
|
||||
};
|
||||
Self {
|
||||
link_logo_svg: config.path(LOGO_SVG),
|
||||
link_base_css: config.path(BASE_CSS),
|
||||
link_index: config.path(PathIndex {}),
|
||||
link_graph: config.path(PathGraph {}),
|
||||
link_queue: config.path(PathQueue {}),
|
||||
config,
|
||||
tab,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn html(&self, title: &str, head: Markup, body: Markup) -> Markup {
|
||||
html!(
|
||||
(DOCTYPE)
|
||||
html lang="en" {
|
||||
head {
|
||||
meta charset="utf-8";
|
||||
meta name="viewport" content="width=device-width";
|
||||
title { (title) " - " (self.config.repo_name) }
|
||||
link rel="icon" href=(self.link_logo_svg);
|
||||
link rel="stylesheet" href=(self.link_base_css);
|
||||
(head)
|
||||
}
|
||||
body {
|
||||
nav {
|
||||
a .current[self.tab == "index"] href=(self.link_index) {
|
||||
img src=(self.link_logo_svg) alt="";
|
||||
(self.config.repo_name)
|
||||
}
|
||||
a .current[self.tab == "graph"] href=(self.link_graph) { "graph" }
|
||||
a .current[self.tab == "queue"] href=(self.link_queue) { "queue" }
|
||||
}
|
||||
(body)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
config::ServerConfig,
|
||||
server::web::{
|
||||
paths::{PathGraph, PathIndex, PathQueue},
|
||||
r#static::{BASE_CSS, LOGO_SVG},
|
||||
r#static::{LOGO_SVG, PAGE_CSS},
|
||||
server_config_ext::ServerConfigExt,
|
||||
},
|
||||
};
|
||||
|
|
@ -64,7 +64,7 @@ impl Page {
|
|||
meta name="viewport" content="width=device-width";
|
||||
title { (self.title) " - " (self.config.repo_name) }
|
||||
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(PAGE_CSS));
|
||||
@for head in self.heads { (head) }
|
||||
}
|
||||
body {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue