chore: implement initial simple website
This commit is contained in:
32
src/base.rs
Normal file
32
src/base.rs
Normal file
@ -0,0 +1,32 @@
|
||||
use maud::{html, Markup, DOCTYPE};
|
||||
|
||||
pub fn header() -> Markup {
|
||||
html! {
|
||||
(DOCTYPE)
|
||||
head {
|
||||
meta charset="utf-8";
|
||||
title class="title" { "Clego" }
|
||||
script src="/public/htmx.min.js" {};
|
||||
link rel="stylesheet" href="/public/styles/main.css";
|
||||
link rel="icon" href="/public/favicon.ico";
|
||||
}
|
||||
section class="hero is-primary is-small"{
|
||||
div class="hero-head" {
|
||||
nav class="navbar" role="navigation" aria-label="main navigation" {
|
||||
div class="container" {
|
||||
div class="navbar-brand" {
|
||||
img src="/public/images/logo.svg" alt="logo";
|
||||
h1 class="title" { "Clego" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error_tmpl() -> Markup {
|
||||
html! {
|
||||
h1 { "Something went terribly wrong :(" }
|
||||
}
|
||||
}
|
42
src/main.rs
42
src/main.rs
@ -1,3 +1,41 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use axum::{routing::get, Router};
|
||||
use maud::{html, Markup};
|
||||
use tower_http::services::ServeDir;
|
||||
use tracing::info;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
mod base;
|
||||
// mod tasks;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "clego_app=debug".into()),
|
||||
)
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
info!("initializing router...");
|
||||
|
||||
let router = Router::new()
|
||||
.route("/", get(hello))
|
||||
.nest_service("/public", ServeDir::new("public"));
|
||||
let port = 3000_u16;
|
||||
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
info!("router initialized, now listening on port {}", port);
|
||||
axum::serve(listener, router).await.unwrap();
|
||||
}
|
||||
|
||||
async fn hello() -> Markup {
|
||||
html! {
|
||||
(base::header())
|
||||
main class="content" {
|
||||
h1 { "Howdy!" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
src/tasks/mod.rs
Normal file
2
src/tasks/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod tasks;
|
||||
pub mod tasks_controller;
|
61
src/tasks/tasks.rs
Normal file
61
src/tasks/tasks.rs
Normal file
@ -0,0 +1,61 @@
|
||||
#[derive(Clone)]
|
||||
pub struct Task {
|
||||
pub id: i32,
|
||||
pub label: TaskLabel,
|
||||
pub title: String,
|
||||
pub status: TaskStatus,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
enum TaskLabel {
|
||||
Bug,
|
||||
Feature,
|
||||
Documentation,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
enum TaskStatus {
|
||||
Backlog {},
|
||||
}
|
||||
|
||||
impl TaskStatus {
|
||||
fn new(status: &str) -> Option<Self> {
|
||||
match status {
|
||||
"pending" => Some(TaskStatus::Backlog {
|
||||
icon: "🕒",
|
||||
title: "Backlog",
|
||||
}),
|
||||
"in_progress" => Some(TaskStatus::InProgress {
|
||||
icon: "⚙️",
|
||||
title: "In Progress",
|
||||
}),
|
||||
"completed" => Some(TaskStatus::Completed {
|
||||
icon: "✔️",
|
||||
title: "Completed",
|
||||
}),
|
||||
"failed" => Some(TaskStatus::Failed {
|
||||
icon: "❌",
|
||||
title: "Failed",
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn icon(&self) -> &'static str {
|
||||
match self {
|
||||
TaskStatus::Pending { icon, .. } => icon,
|
||||
TaskStatus::InProgress { icon, .. } => icon,
|
||||
TaskStatus::Completed { icon, .. } => icon,
|
||||
TaskStatus::Failed { icon, .. } => icon,
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self) -> &'static str {
|
||||
match self {
|
||||
TaskStatus::Pending { title, .. } => title,
|
||||
TaskStatus::InProgress { title, .. } => title,
|
||||
TaskStatus::Completed { title, .. } => title,
|
||||
TaskStatus::Failed { title, .. } => title,
|
||||
}
|
||||
}
|
||||
}
|
0
src/tasks/tasks_controler.rs
Normal file
0
src/tasks/tasks_controler.rs
Normal file
Reference in New Issue
Block a user