-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
510 additions
and
18 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
dirs = ["files"] | ||
[general] | ||
dirs = ["files/templates"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
<article class="full"> | ||
<p>Some content</p> | ||
|
||
</article> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html data-theme="dark"> | ||
<link rel="stylesheet" href="_assets/pico.min.css"> | ||
<link rel="stylesheet" href="_assets/app.css"> | ||
<script src="/_assets/htmx.min.js"></script> | ||
|
||
<head> | ||
<title>{{ title }}</title> | ||
</head> | ||
<body id="full_body"> | ||
<div class="container"> | ||
<nav> | ||
<ul> | ||
<li><strong>{{ title }}</strong></li> | ||
</ul> | ||
<ul> | ||
<li><button class="primary">Files</button></li> | ||
<li><button class="secondary">Settings</button></li> | ||
</ul> | ||
</nav> | ||
</div> | ||
<div class="container" > | ||
<div class="flexcontainer"> | ||
<aside class="sidebar"> | ||
<nav> | ||
<ul> | ||
<li><a href="#">Folder1</a></li> | ||
<li><a href="#">Folder2</a></li> | ||
<li><a href="#">Folder3</a></li> | ||
</ul> | ||
</nav> | ||
</aside> | ||
|
||
<div id="content" | ||
class="border" | ||
hx-get="/content" | ||
hx-trigger="load" | ||
> | ||
|
||
|
||
</div> | ||
|
||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod commands; | ||
mod out; | ||
mod server; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use askama::Template; | ||
use axum::response::Html; | ||
|
||
#[derive(Debug, Template)] | ||
#[template(path = "page.html")] | ||
struct PageTemplate { | ||
title: String, | ||
} | ||
|
||
pub async fn render_page_html() -> Html<String> { | ||
let page = PageTemplate { | ||
title: "Fog Pit".to_string(), | ||
}; | ||
Html(page.render().unwrap()) | ||
} | ||
|
||
#[derive(Debug, Template)] | ||
#[template(path = "content.html")] | ||
struct ContentTemplate; | ||
|
||
pub async fn render_content_html() -> Html<String> { | ||
let content = ContentTemplate; | ||
Html(content.render().unwrap()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use axum::{http::StatusCode, response::IntoResponse, routing::get, Router}; | ||
|
||
use crate::out::green_fog; | ||
mod html; | ||
|
||
pub async fn start_server(port: impl Into<String>) -> crate::out::Foggy { | ||
tracing_subscriber::fmt::init(); | ||
|
||
let app = Router::new() | ||
.route("/healthz", get(health)) | ||
.route("/", get(html::render_page_html)) | ||
.route("/content", get(html::render_content_html)) | ||
.nest("/", assets()); | ||
|
||
let p = format!("0.0.0.0:{}", port.into()); | ||
let listener = tokio::net::TcpListener::bind(p.clone()).await.unwrap(); | ||
|
||
let path = format!("http://{}", p); | ||
if webbrowser::open(&path).is_ok() { | ||
axum::serve(listener, app).await.unwrap(); | ||
} | ||
green_fog("Normal server shutdown") | ||
} | ||
|
||
async fn health() -> impl IntoResponse { | ||
StatusCode::OK | ||
} | ||
|
||
use tower_http::services::ServeDir; | ||
|
||
fn assets() -> Router { | ||
Router::new().nest_service("/_assets", using_serve_dir()) | ||
} | ||
|
||
pub fn using_serve_dir() -> ServeDir { | ||
ServeDir::new("files/assets") | ||
} |