fix redirects; start draft of rating page
This commit is contained in:
parent
bacce1c55a
commit
9a347d429b
@ -11,6 +11,7 @@
|
||||
- [x] Route_station
|
||||
- [x] Team
|
||||
- [ ] Rating view
|
||||
- [ ] auth for stations -> cookie?
|
||||
- [ ] Highscore list
|
||||
|
||||
## Fancy features
|
||||
|
@ -17,7 +17,7 @@ async fn index(State(db): State<Arc<SqlitePool>>, session: Session) -> Markup {
|
||||
|
||||
let content = html! {
|
||||
h1 {
|
||||
a href="/admin/" { "↩️" }
|
||||
a href="/admin" { "↩️" }
|
||||
"Routen"
|
||||
}
|
||||
article {
|
||||
|
@ -415,7 +415,7 @@ async fn index(State(db): State<Arc<SqlitePool>>, session: Session) -> Markup {
|
||||
|
||||
let content = html! {
|
||||
h1 {
|
||||
a href="/admin/" { "↩️" }
|
||||
a href="/admin" { "↩️" }
|
||||
(t!("stations"))
|
||||
}
|
||||
article {
|
||||
|
@ -454,7 +454,7 @@ async fn index(State(db): State<Arc<SqlitePool>>, session: Session) -> Markup {
|
||||
|
||||
let content = html! {
|
||||
h1 {
|
||||
a href="/admin/" { "↩️" }
|
||||
a href="/admin" { "↩️" }
|
||||
"Teams"
|
||||
}
|
||||
article {
|
||||
|
@ -3,6 +3,7 @@ extern crate rust_i18n;
|
||||
|
||||
i18n!("locales", fallback = "de-AT");
|
||||
|
||||
use admin::station::Station;
|
||||
use axum::{body::Body, response::Response, routing::get, Router};
|
||||
use partials::page;
|
||||
use sqlx::SqlitePool;
|
||||
@ -12,6 +13,7 @@ use tower_sessions::{MemoryStore, SessionManagerLayer};
|
||||
|
||||
pub(crate) mod admin;
|
||||
mod partials;
|
||||
pub(crate) mod station;
|
||||
|
||||
pub(crate) fn pl(amount: usize, single: &str, append: &str) -> String {
|
||||
if amount == 1 {
|
||||
@ -106,6 +108,7 @@ pub async fn start(listener: TcpListener, db: SqlitePool) {
|
||||
let session_layer = SessionManagerLayer::new(session_store);
|
||||
|
||||
let app = Router::new()
|
||||
.nest("/s", station::routes()) // TODO: maybe switch to "/"
|
||||
.nest("/admin", admin::routes())
|
||||
.route("/pico.css", get(serve_pico_css))
|
||||
.route("/style.css", get(serve_my_css))
|
||||
|
39
src/station.rs
Normal file
39
src/station.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use crate::{partials, Station};
|
||||
use axum::{extract::State, response::IntoResponse, routing::get, Router};
|
||||
use maud::{html, Markup};
|
||||
use sqlx::SqlitePool;
|
||||
use std::sync::Arc;
|
||||
use tower_sessions::Session;
|
||||
|
||||
async fn station_picker(State(db): State<Arc<SqlitePool>>, session: Session) -> Markup {
|
||||
let stations = Station::all(&db).await;
|
||||
let content = html! {
|
||||
h1 { "Wähle deine Station" }
|
||||
select onchange="window.location.href='/s/' + this.value;" {
|
||||
option selected value="" {
|
||||
"Deine Station..."
|
||||
}
|
||||
@for station in stations {
|
||||
option value=(station.id) { (station.name) };
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
partials::page(content, session, false).await
|
||||
}
|
||||
|
||||
async fn view(
|
||||
State(db): State<Arc<SqlitePool>>,
|
||||
session: Session,
|
||||
axum::extract::Path(id): axum::extract::Path<i64>,
|
||||
) -> Markup {
|
||||
//let Some(route) = Route::find_by_id(&db, id).await else {
|
||||
//}
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(super) fn routes() -> Router<Arc<SqlitePool>> {
|
||||
Router::new()
|
||||
.route("/", get(station_picker))
|
||||
.route("/{id}", get(view))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user