Port index page to maud
This commit is contained in:
parent
ae81831bdd
commit
b3f8c6390c
2 changed files with 42 additions and 66 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
use askama::Template;
|
|
||||||
use axum::{extract::State, response::IntoResponse};
|
use axum::{extract::State, response::IntoResponse};
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
|
use maud::html;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::ServerConfig,
|
config::ServerConfig,
|
||||||
server::web::{
|
server::web::{
|
||||||
base::{Base, Link, Tab},
|
base::{Base, Tab},
|
||||||
link::LinkCommit,
|
link::LinkCommit,
|
||||||
paths::{PathAdminRefsTrack, PathAdminRefsUntrack, PathAdminRefsUpdate, PathIndex},
|
paths::{PathAdminRefsTrack, PathAdminRefsUntrack, PathAdminRefsUpdate, PathIndex},
|
||||||
},
|
},
|
||||||
|
|
@ -19,18 +19,6 @@ struct Ref {
|
||||||
tracked: bool,
|
tracked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
|
||||||
#[template(path = "pages/index.html")]
|
|
||||||
struct IndexTemplate {
|
|
||||||
link_admin_refs_track: Link,
|
|
||||||
link_admin_refs_untrack: Link,
|
|
||||||
link_admin_refs_update: Link,
|
|
||||||
base: Base,
|
|
||||||
|
|
||||||
tracked_refs: Vec<Ref>,
|
|
||||||
untracked_refs: Vec<Ref>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_index(
|
pub async fn get_index(
|
||||||
_path: PathIndex,
|
_path: PathIndex,
|
||||||
State(config): State<&'static ServerConfig>,
|
State(config): State<&'static ServerConfig>,
|
||||||
|
|
@ -65,13 +53,44 @@ pub async fn get_index(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(IndexTemplate {
|
Ok(base.html(
|
||||||
link_admin_refs_track: base.link(PathAdminRefsTrack {}),
|
"overview",
|
||||||
link_admin_refs_untrack: base.link(PathAdminRefsUntrack {}),
|
html! {},
|
||||||
link_admin_refs_update: base.link(PathAdminRefsUpdate {}),
|
html! {
|
||||||
base: Base::new(config, Tab::Index),
|
h2 { "Refs" }
|
||||||
|
details .refs-list open {
|
||||||
tracked_refs,
|
summary { "Tracked (" (tracked_refs.len()) ")" }
|
||||||
untracked_refs,
|
form method="post" action=(base.link(PathAdminRefsUntrack {})) {
|
||||||
})
|
dl {
|
||||||
|
@for r#ref in tracked_refs {
|
||||||
|
dt {
|
||||||
|
(r#ref.name) " ["
|
||||||
|
button .linkish name="ref" value=(r#ref.name) { "untrack" }
|
||||||
|
"]"
|
||||||
|
}
|
||||||
|
dd { (r#ref.commit.html()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
details .refs-list {
|
||||||
|
summary { "Untracked (" (untracked_refs.len()) ")" }
|
||||||
|
form method="post" action=(base.link(PathAdminRefsTrack {})) {
|
||||||
|
dl {
|
||||||
|
@for r#ref in untracked_refs {
|
||||||
|
dt {
|
||||||
|
(r#ref.name) " ["
|
||||||
|
button .linkish name="ref" value=(r#ref.name) { "track" }
|
||||||
|
"]"
|
||||||
|
}
|
||||||
|
dd { (r#ref.commit.html()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
form method="post" action=(base.link(PathAdminRefsUpdate {})) {
|
||||||
|
button { "Update" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}overview{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
|
|
||||||
<h2>Refs</h2>
|
|
||||||
|
|
||||||
<details class="refs-list" open>
|
|
||||||
<summary>Tracked ({{ tracked_refs.len() }})</summary>
|
|
||||||
<form method="post" action="{{ link_admin_refs_untrack }}">
|
|
||||||
<dl>
|
|
||||||
{% for ref in tracked_refs %}
|
|
||||||
<dt>
|
|
||||||
{{ ref.name }}
|
|
||||||
[<button class="linkish" name="ref" value="{{ ref.name }}">untrack</button>]
|
|
||||||
</dt>
|
|
||||||
<dd>{{ ref.commit|safe }}</dd>
|
|
||||||
{% endfor %}
|
|
||||||
</dl>
|
|
||||||
</form>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details class="refs-list">
|
|
||||||
<summary>Untracked ({{ untracked_refs.len() }})</summary>
|
|
||||||
<form method="post" action="{{ link_admin_refs_track }}">
|
|
||||||
<dl>
|
|
||||||
{% for ref in untracked_refs %}
|
|
||||||
<dt>
|
|
||||||
{{ ref.name }}
|
|
||||||
[<button class="linkish" name="ref" value="{{ ref.name }}">track</button>]
|
|
||||||
</dt>
|
|
||||||
<dd>{{ ref.commit|safe }}</dd>
|
|
||||||
{% endfor %}
|
|
||||||
</dl>
|
|
||||||
</form>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<form method="post" action="{{ link_admin_refs_update }}">
|
|
||||||
<button>Update</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue