js bundle wip

This commit is contained in:
Robin Appelman 2023-04-09 17:03:46 +02:00
commit 305e8ec8ed
11 changed files with 3090 additions and 130 deletions

View file

@ -1,3 +1,4 @@
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use config::ConfigError;
@ -25,7 +26,9 @@ pub enum Error {
impl IntoResponse for Error {
fn into_response(self) -> Response {
dbg!(self);
todo!()
match self {
Error::NotFound => (StatusCode::NOT_FOUND, "not found").into_response(),
_ => todo!(),
}
}
}

View file

@ -73,6 +73,7 @@ async fn main() -> Result<()> {
let app = Router::new()
.route("/", get(index))
.route("/style.css", get(serve_compiled!("style.css")))
.route("/upload.js", get(serve_compiled!("upload.js")))
.route("/images/logo.png", get(serve_static!("../images/logo.png")))
.route("/images/logo.svg", get(serve_static!("../images/logo.svg")))
.route("/about", get(about))
@ -137,9 +138,10 @@ async fn about(State(_app): State<Arc<App>>, session: SessionData) -> Result<Mar
async fn demo(
State(app): State<Arc<App>>,
Path(id): Path<u32>,
Path(id): Path<String>,
session: SessionData,
) -> Result<Markup> {
let id = id.parse().map_err(|_| Error::NotFound)?;
let demo = Demo::by_id(&app.connection, id)
.await?
.ok_or(Error::NotFound)?;

View file

@ -1,3 +1,4 @@
use crate::asset::saved_asset_url;
use crate::pages::plugin_section::PluginSection;
use crate::pages::Page;
use maud::{html, Markup};
@ -21,6 +22,7 @@ impl Page for UploadPage {
}
fn render(&self) -> Markup {
let script = saved_asset_url!("upload.js");
html! {
.upload-page {
section.upload {
@ -50,6 +52,7 @@ impl Page for UploadPage {
}
(self.plugin_section())
}
script src = (script);
}
}
}