Make static file links typesafe
This commit is contained in:
parent
e64ea7ac12
commit
1ead78d44f
4 changed files with 53 additions and 9 deletions
|
|
@ -2,7 +2,10 @@ use std::fmt;
|
|||
|
||||
use crate::config::Config;
|
||||
|
||||
use super::paths::{PathIndex, PathQueue};
|
||||
use super::{
|
||||
paths::{PathIndex, PathQueue},
|
||||
r#static::{BASE_CSS, LOGO_SVG},
|
||||
};
|
||||
|
||||
pub enum Tab {
|
||||
None,
|
||||
|
|
@ -29,8 +32,8 @@ impl Base {
|
|||
Tab::Queue => "queue",
|
||||
};
|
||||
Self {
|
||||
link_logo_svg: Self::link_from_base(&config.web_base, "/logo.svg"), // TODO Static link
|
||||
link_base_css: Self::link_from_base(&config.web_base, "/base.css"), // TODO Static link
|
||||
link_logo_svg: Self::link_from_base(&config.web_base, LOGO_SVG),
|
||||
link_base_css: Self::link_from_base(&config.web_base, BASE_CSS),
|
||||
link_index: Self::link_from_base(&config.web_base, PathIndex {}),
|
||||
link_queue: Self::link_from_base(&config.web_base, PathQueue {}),
|
||||
web_base: config.web_base.clone(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use super::{
|
|||
base::{Base, Link, Tab},
|
||||
link::{LinkCommit, LinkRunShort, LinkWorker},
|
||||
paths::{PathQueue, PathQueueInner},
|
||||
r#static::QUEUE_JS,
|
||||
};
|
||||
|
||||
enum Status {
|
||||
|
|
@ -180,7 +181,7 @@ pub async fn get_queue(
|
|||
let workers = get_workers(&db, &sorted_workers, &base).await?;
|
||||
let tasks = get_queue_data(&db, &sorted_workers, &base).await?;
|
||||
Ok(QueueTemplate {
|
||||
link_queue_js: base.link("/queue.js"), // TODO Static link
|
||||
link_queue_js: base.link(QUEUE_JS),
|
||||
base,
|
||||
inner: QueueInnerTemplate { workers, tasks },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -32,3 +32,6 @@ pub async fn static_handler(uri: Uri) -> impl IntoResponse {
|
|||
let path = uri.path().trim_start_matches('/').to_string();
|
||||
StaticFile(path)
|
||||
}
|
||||
|
||||
// Constants for each static file, generated by the build script.
|
||||
include!(concat!(env!("OUT_DIR"), "/static.rs"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue