Add queue tab

This commit is contained in:
Joscha 2023-08-06 19:23:20 +02:00
parent 06e2f25107
commit 1eeee43f2c
4 changed files with 33 additions and 0 deletions

View file

@ -1,6 +1,7 @@
mod commit;
mod commit_hash;
mod index;
mod queue;
mod r#static;
use axum::{routing::get, Router, Server};
@ -10,6 +11,7 @@ use crate::{config::Config, somehow, state::AppState};
pub enum Tab {
Index,
Commit,
Queue,
}
pub struct Base {
@ -23,6 +25,7 @@ impl Base {
let current = match tab {
Tab::Index => "index",
Tab::Commit => "commit",
Tab::Queue => "queue",
};
Self {
root: config.web.base(),
@ -39,6 +42,7 @@ pub async fn run(state: AppState) -> somehow::Result<()> {
.route("/", get(index::get))
.route("/commit/", get(commit::get))
.route("/commit/:hash", get(commit_hash::get))
.route("/queue/", get(queue::get))
.fallback(get(r#static::static_handler))
.with_state(state.clone());

18
src/web/queue.rs Normal file
View file

@ -0,0 +1,18 @@
use askama::Template;
use axum::{extract::State, response::IntoResponse};
use crate::{config::Config, somehow};
use super::{Base, Tab};
#[derive(Template)]
#[template(path = "queue.html")]
struct CommitTemplate {
base: Base,
}
pub async fn get(State(config): State<&'static Config>) -> somehow::Result<impl IntoResponse> {
Ok(CommitTemplate {
base: Base::new(config, Tab::Queue),
})
}