This commit is contained in:
WanderingPenwing 2024-09-02 01:42:53 +02:00
parent 0d2d2fe504
commit d5326389d5
3 changed files with 54 additions and 6 deletions

46
Cargo.lock generated
View file

@ -19,6 +19,29 @@ dependencies = [
"tracing",
]
[[package]]
name = "actix-files"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0773d59061dedb49a8aed04c67291b9d8cf2fe0b60130a381aab53c6dd86e9be"
dependencies = [
"actix-http",
"actix-service",
"actix-utils",
"actix-web",
"bitflags",
"bytes",
"derive_more",
"futures-core",
"http-range",
"log",
"mime",
"mime_guess",
"percent-encoding",
"pin-project-lite",
"v_htmlescape",
]
[[package]]
name = "actix-http"
version = "3.9.0"
@ -569,6 +592,12 @@ dependencies = [
"itoa",
]
[[package]]
name = "http-range"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
[[package]]
name = "httparse"
version = "1.9.4"
@ -679,6 +708,16 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "miniz_oxide"
version = "0.7.4"
@ -1191,6 +1230,12 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "v_htmlescape"
version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"
[[package]]
name = "version_check"
version = "0.9.5"
@ -1280,6 +1325,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
name = "yuya"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"pulldown-cmark",
]

View file

@ -7,4 +7,5 @@ edition = "2021"
[dependencies]
actix-web = "4"
actix-files = "0.6"
pulldown-cmark = "0.9" # Markdown parser

View file

@ -28,8 +28,8 @@ async fn serve_markdown(file_path: &str) -> impl Responder {
</head>
<body>
<div class="sidenav">
<h3><a href="https://www.penwing.org">Summary</a></h3>
<h3><a href="https://www.penwing.org/tools.html">Tools</a></h3>
<h3><a href="/">Summary</a></h3>
<h3><a href="/tools">Tools</a></h3>
<a class="description" href="https://www.penwing.org/tools.html#nginx">proxy</a>
<a class="description" href="https://www.penwing.org/tools.html#cloudflare">domain</a>
<a class="description" href="https://www.penwing.org/tools.html#portainer">dashboard</a>
@ -44,10 +44,10 @@ async fn serve_markdown(file_path: &str) -> impl Responder {
<h3><a href="https://www.penwing.org/games.html">my Games</a></h3>
</div>
<p class="topbar">
<a href="https://www.penwing.org">Home</a> -
<a href="https://www.penwing.org/tools.html">Tools</a> -
<a href="https://www.penwing.org/art.html">Art</a> -
<a href="https://www.penwing.org/games.html">Games</a>
<a href="/">Home</a> -
<a href="/tools">Tools</a> -
<a href="/art">Art</a> -
<a href="/games">Games</a>
</p>
<div class="main">
#CONTENT#
@ -85,6 +85,7 @@ async fn main() -> std::io::Result<()> {
App::new()
.route("/", web::get().to(summary)) // Route for root
.route("/tools", web::get().to(tools)) // Route for tools
.service(actix_files::Files::new("/assets", "./assets").show_files_listing())
})
.bind("127.0.0.1:8080")?
.run()