From afb76c04f997eb79d6c4fdf627126f0e2801dc3a Mon Sep 17 00:00:00 2001 From: fuxiaohei Date: Mon, 30 Oct 2023 21:00:20 +0800 Subject: [PATCH] center: add more hbs templates --- binary/center/src/pages/mod.rs | 23 ++++--- binary/center/src/server.rs | 14 ++-- binary/center/templates/css/input.css | 17 ++++- binary/center/templates/partials/footer.hbs | 4 ++ binary/center/templates/partials/meta.hbs | 6 +- binary/center/templates/project-single.hbs | 64 +++++++++++++++++++ .../templates/{dashboard.hbs => projects.hbs} | 24 ++++--- binary/center/templates/signin.hbs | 57 +++++++++++++++++ 8 files changed, 180 insertions(+), 29 deletions(-) create mode 100644 binary/center/templates/partials/footer.hbs create mode 100644 binary/center/templates/project-single.hbs rename binary/center/templates/{dashboard.hbs => projects.hbs} (78%) create mode 100644 binary/center/templates/signin.hbs diff --git a/binary/center/src/pages/mod.rs b/binary/center/src/pages/mod.rs index ecc65e75..2fda3e38 100644 --- a/binary/center/src/pages/mod.rs +++ b/binary/center/src/pages/mod.rs @@ -1,11 +1,7 @@ use anyhow::Result; use axum::extract::Path; use axum::response::{IntoResponse, Response}; -use axum::{ - body::Body, - routing::{any, get}, - Router, -}; +use axum::{body::Body, routing::get, Router}; use axum_template::engine::Engine; use axum_template::RenderHtml; use handlebars::Handlebars; @@ -19,7 +15,9 @@ type AppEngine = Engine>; pub fn router() -> Router { let hbs = init_templates().unwrap(); Router::new() - .route("/dashboard", any(render_dashboard)) + .route("/projects", get(render_projects)) + .route("/projects/:name", get(render_project_single)) + .route("/sign-in", get(render_signin)) .route("/static/*path", get(render_static)) .with_state(Engine::from(hbs)) } @@ -42,8 +40,17 @@ async fn render_static(Path(path): Path) -> Response { .unwrap() } -async fn render_dashboard(engine: AppEngine) -> impl IntoResponse { - RenderHtml("dashboard.hbs", engine, &()) +async fn render_projects(engine: AppEngine) -> impl IntoResponse { + RenderHtml("projects.hbs", engine, &()) +} + +async fn render_project_single(engine: AppEngine, Path(param): Path) -> impl IntoResponse { + debug!("param: {}", param); + RenderHtml("project-single.hbs", engine, &()) +} + +async fn render_signin(engine: AppEngine) -> impl IntoResponse { + RenderHtml("signin.hbs", engine, &()) } fn init_templates() -> Result> { diff --git a/binary/center/src/server.rs b/binary/center/src/server.rs index a818408d..4ac7ca6f 100644 --- a/binary/center/src/server.rs +++ b/binary/center/src/server.rs @@ -2,12 +2,8 @@ use crate::apiv2; use crate::pages; use anyhow::Result; use axum::extract::DefaultBodyLimit; -use axum::{ - body::Body, - http::{Request, Response}, - routing::any, - Router, -}; +use axum::response::{IntoResponse, Redirect}; +use axum::{body::Body, http::Request, routing::any, Router}; use std::net::SocketAddr; use std::process::exit; use tokio::signal; @@ -35,10 +31,8 @@ pub async fn start(addr: SocketAddr) -> Result<()> { } /// default_handler is the default handler for all requests. -async fn default_handler(_req: Request) -> Response { - let mut builder = Response::builder().status(200); - builder = builder.header("x-land-version", land_core::version::get()); - builder.body(Body::from("Hello, Runtime.land!")).unwrap() +async fn default_handler(_req: Request) -> impl IntoResponse { + Redirect::to("/projects").into_response() } async fn shutdown_signal() { diff --git a/binary/center/templates/css/input.css b/binary/center/templates/css/input.css index b9444007..096f924a 100644 --- a/binary/center/templates/css/input.css +++ b/binary/center/templates/css/input.css @@ -41,13 +41,13 @@ @apply block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white; } #main { - @apply max-w-4xl mx-auto my-6; + @apply max-w-4xl mx-auto my-6 min-h-[70%]; } #project-top h1 { @apply text-3xl font-semibold; } #project-top .count { - @apply text-gray-500 leading-8; + @apply text-gray-400 block py-2; } #project-searchbar { @apply flex justify-between items-center my-4; @@ -93,3 +93,16 @@ .project-card .action-button { @apply px-3 py-2 rounded-lg text-white bg-emerald-600 hover:bg-emerald-700 duration-200; } + +#footer { + @apply border-t p-6 text-center text-gray-300 mt-6; +} + +#sign-in-btn-container { + @apply text-center; + padding-top: 8rem; +} + +#sign-in-button { + @apply text-xl px-4 py-2 bg-primary rounded-lg text-white hover:bg-white hover:border hover:border-primary hover:text-primary; +} diff --git a/binary/center/templates/partials/footer.hbs b/binary/center/templates/partials/footer.hbs new file mode 100644 index 00000000..ac06fd2d --- /dev/null +++ b/binary/center/templates/partials/footer.hbs @@ -0,0 +1,4 @@ +
+ @2023 Runtime.land | v0.1.4 | 2023-10-30 02:39 UTC +
+ \ No newline at end of file diff --git a/binary/center/templates/partials/meta.hbs b/binary/center/templates/partials/meta.hbs index 50b5e330..dfff763c 100644 --- a/binary/center/templates/partials/meta.hbs +++ b/binary/center/templates/partials/meta.hbs @@ -3,4 +3,8 @@ -Runtime.land \ No newline at end of file +Runtime.land + \ No newline at end of file diff --git a/binary/center/templates/project-single.hbs b/binary/center/templates/project-single.hbs new file mode 100644 index 00000000..8f53da5f --- /dev/null +++ b/binary/center/templates/project-single.hbs @@ -0,0 +1,64 @@ + + + + + {{> partials/meta.hbs}} + + + + {{> partials/navbar.hbs}} +
+
+

spryest-pyknoses-242

+ PENDING PRODUCTION DEPLOYMENT +
+
+ +
+
+
+
+
+
spryest-pyknoses-242
+ + +
+
+ Running +
+
+
+
+
spryest-pyknoses-242
+ +
+
+ Running +
+
+
+
+
+ {{> partials/footer.hbs}} + + + \ No newline at end of file diff --git a/binary/center/templates/dashboard.hbs b/binary/center/templates/projects.hbs similarity index 78% rename from binary/center/templates/dashboard.hbs rename to binary/center/templates/projects.hbs index 36409b4c..859e51c6 100644 --- a/binary/center/templates/dashboard.hbs +++ b/binary/center/templates/projects.hbs @@ -32,7 +32,7 @@
-
+
spryest-pyknoses-242
+
+
+
+
spryest-pyknoses-242
+ +
+
-
w-1/2
-
-
-
w-1/2
-
w-1/2
- + {{> partials/footer.hbs}} \ No newline at end of file diff --git a/binary/center/templates/signin.hbs b/binary/center/templates/signin.hbs new file mode 100644 index 00000000..caf0451b --- /dev/null +++ b/binary/center/templates/signin.hbs @@ -0,0 +1,57 @@ + + + + + {{> partials/meta.hbs}} + + + +
+
+
+ +
+
+ + + + + \ No newline at end of file