mirror of
https://github.com/nullishamy/ferri.git
synced 2025-06-28 00:54:17 +00:00
feat: scaffold web elements
This commit is contained in:
parent
77fba1a082
commit
4167a2f8bb
6 changed files with 103 additions and 2 deletions
|
@ -18,4 +18,5 @@ tracing = { workspace = true }
|
|||
tracing-subscriber = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
askama = "0.14.0"
|
||||
|
|
20
ferri-server/src/endpoints/admin/mod.rs
Normal file
20
ferri-server/src/endpoints/admin/mod.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use rocket::{get, post, response::content::RawHtml};
|
||||
use askama::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate {
|
||||
val: String
|
||||
}
|
||||
|
||||
#[post("/clicked")]
|
||||
pub async fn button_clicked() -> RawHtml<String> {
|
||||
let tmpl = IndexTemplate { val: "clicked".to_string() };
|
||||
RawHtml(tmpl.render().unwrap())
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn index() -> RawHtml<String> {
|
||||
let tmpl = IndexTemplate { val: "test".to_string() };
|
||||
RawHtml(tmpl.render().unwrap())
|
||||
}
|
|
@ -4,6 +4,8 @@ pub mod oauth;
|
|||
pub mod user;
|
||||
|
||||
pub mod api;
|
||||
pub mod admin;
|
||||
|
||||
pub mod custom;
|
||||
pub mod inbox;
|
||||
pub mod well_known;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use endpoints::{
|
||||
api::{self, timeline},
|
||||
custom, inbox, oauth, user, well_known,
|
||||
admin, custom, inbox, oauth, user, well_known,
|
||||
};
|
||||
|
||||
use tracing_subscriber::fmt;
|
||||
|
@ -122,6 +122,13 @@ pub fn launch(cfg: Config) -> Rocket<Build> {
|
|||
.attach(Db::init())
|
||||
.attach(cors::CORS)
|
||||
.mount("/assets", rocket::fs::FileServer::from("./assets"))
|
||||
.mount(
|
||||
"/admin",
|
||||
routes![
|
||||
admin::index,
|
||||
admin::button_clicked
|
||||
]
|
||||
)
|
||||
.mount(
|
||||
"/",
|
||||
routes![
|
||||
|
|
19
ferri-server/templates/index.html
Normal file
19
ferri-server/templates/index.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="https://ferri.amy.mov/admin/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Ferri Test</title>
|
||||
|
||||
<link rel="stylesheet" href="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/dbc8023a08964f513c20796e170cb91ce891df3f/packages/tailwindcss/preflight.css">
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||
</head>
|
||||
<body>
|
||||
<button hx-post="clicked" hx-swap="outerHTML">
|
||||
Click Me {{ val }}
|
||||
</button>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue