working html
This commit is contained in:
commit
0d2d2fe504
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
1334
Cargo.lock
generated
Normal file
1334
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "yuya"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4"
|
||||
pulldown-cmark = "0.9" # Markdown parser
|
BIN
assets/flake.png
Executable file
BIN
assets/flake.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
131
assets/style.css
Normal file
131
assets/style.css
Normal file
|
@ -0,0 +1,131 @@
|
|||
body {
|
||||
margin: 40px auto;
|
||||
padding: 0 60px;
|
||||
font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
color: #444;
|
||||
margin-left: 0px; /* Adjusted for sidebar */
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
line-height: 1.2;
|
||||
text-indent: 40px;
|
||||
}
|
||||
|
||||
/* The sidebar menu */
|
||||
.sidenav {
|
||||
height: 100%; /* Full-height */
|
||||
width: 200px; /* Set the width of the sidebar */
|
||||
position: fixed; /* Fixed Sidebar */
|
||||
z-index: 1; /* Stay on top */
|
||||
top: 0; /* Stay at the top */
|
||||
left: 0;
|
||||
background-color: #e8e8e8; /* Default color for sidebar */
|
||||
overflow-x: hidden; /* Disable horizontal scroll */
|
||||
padding-top: 40px;
|
||||
}
|
||||
|
||||
/* The navigation menu links */
|
||||
.sidenav a {
|
||||
padding: 0px 0px 0px 20px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* When you mouse over the navigation links, change their color */
|
||||
.sidenav a:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* Dark mode styles */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
color: #cccccc;
|
||||
background: #222222;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #58a6ff;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #8e96f0;
|
||||
}
|
||||
|
||||
.sidenav {
|
||||
background-color: #181818; /* Dark background color for sidebar */
|
||||
}
|
||||
|
||||
.sidenav a {
|
||||
color: #818181; /* Light text color for dark mode */
|
||||
}
|
||||
|
||||
.sidenav a:hover {
|
||||
color: #f1f1f1; /* Lighter text color on hover for dark mode */
|
||||
}
|
||||
}
|
||||
|
||||
/* Style page content */
|
||||
.main {
|
||||
margin-left: 200px; /* Same as the width of the sidebar */
|
||||
padding: 0px 10px;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
margin-left: 0px;
|
||||
padding: 0px 10px;
|
||||
display: none;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 200px; /* Adjust this value to the desired square size */
|
||||
height: 200px; /* Ensure the height matches the width to make it a square */
|
||||
object-fit: cover; /* Maintain aspect ratio and cover the square area */
|
||||
}
|
||||
|
||||
/* On smaller screens, hide the sidebar */
|
||||
@media screen and (max-width: 768px) {
|
||||
.sidenav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.main {
|
||||
margin-left: 0; /* Adjust main content margin when sidebar is hidden */
|
||||
padding: 0px 10px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* On smaller screens, where height is less than 450px, change the style of the sidebar (less padding and a smaller font size) */
|
||||
@media screen and (max-height: 450px) {
|
||||
.sidenav {
|
||||
padding-top: 15px;
|
||||
}
|
||||
.sidenav a {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Additional styles */
|
||||
.summary {
|
||||
border-spacing: 10px 20px;
|
||||
}
|
||||
|
||||
.description {
|
||||
text-indent: 20px;
|
||||
}
|
||||
|
||||
.game-list {
|
||||
border-spacing: 20px 30px;
|
||||
}
|
||||
|
||||
|
2
pages/summary.md
Normal file
2
pages/summary.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Summary
|
||||
test
|
2
pages/tools.md
Normal file
2
pages/tools.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Tools
|
||||
test 2
|
14
shell.nix
Normal file
14
shell.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ pkgs ? import <nixpkgs> { overlays = [ (import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz)) ]; },}:
|
||||
with pkgs;
|
||||
|
||||
mkShell {
|
||||
nativeBuildInputs = with xorg; [
|
||||
pkg-config
|
||||
] ++ [
|
||||
cargo
|
||||
rustc
|
||||
];
|
||||
buildInputs = [
|
||||
latest.rustChannels.stable.rust
|
||||
];
|
||||
}
|
94
src/main.rs
Normal file
94
src/main.rs
Normal file
|
@ -0,0 +1,94 @@
|
|||
use pulldown_cmark::{Parser, html};
|
||||
use actix_web::{web, App, HttpServer, HttpResponse, Responder};
|
||||
use std::fs;
|
||||
|
||||
fn markdown_to_html(markdown_content: &str) -> String {
|
||||
let mut html_output = String::new();
|
||||
let parser = Parser::new(markdown_content);
|
||||
html::push_html(&mut html_output, parser);
|
||||
html_output
|
||||
}
|
||||
|
||||
async fn serve_markdown(file_path: &str) -> impl Responder {
|
||||
// Read the Markdown file
|
||||
let markdown_content = fs::read_to_string(file_path).unwrap_or_else(|_| String::from("Error reading file"));
|
||||
|
||||
// Convert Markdown to HTML
|
||||
let html_content = markdown_to_html(&markdown_content);
|
||||
|
||||
// Create the common HTML wrapper
|
||||
let common_html = r#"
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>yuya</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="Penwing's Website">
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
<link rel="icon" href="/assets/flake.png" type="image/png">
|
||||
</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>
|
||||
<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>
|
||||
<a class="description" href="https://www.penwing.org/tools.html#pihole">adblocker</a>
|
||||
<a class="description" href="https://www.penwing.org/tools.html#searxng">search</a>
|
||||
<a class="description" href="https://www.penwing.org/tools.html#forgejo">git server</a>
|
||||
<a class="description" href="https://www.penwing.org/tools.html#jellyfin">streaming</a>
|
||||
<a class="description" href="https://www.penwing.org/tools.html#stirling">pdf edit</a>
|
||||
<a class="description" href="https://www.penwing.org/tools.html#seafile">storage</a>
|
||||
|
||||
<h3><a href="https://www.penwing.org/art.html">my Art</a></h3>
|
||||
<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>
|
||||
</p>
|
||||
<div class="main">
|
||||
#CONTENT#
|
||||
<hr>
|
||||
<p id="spacer"><br></p>
|
||||
|
||||
<h2 id="epilogue">Epilogue</h2>
|
||||
|
||||
<p>Inspired by the geniuses behind <a href="https://perfectmotherfuckingwebsite.com/">perfectwebsite.com</a>,
|
||||
because a webpage does not have to be heavier than <a href="https://github.com/chrislgarry/Apollo-11">the code that took us to the moon</a>.</p>
|
||||
|
||||
<p>This page is licensed under <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a></p>
|
||||
|
||||
</div>
|
||||
</body></html>
|
||||
"#;
|
||||
|
||||
// Replace #CONTENT# placeholder with the actual Markdown HTML content
|
||||
let page_html = common_html.replace("#CONTENT#", &html_content);
|
||||
|
||||
HttpResponse::Ok().content_type("text/html").body(page_html)
|
||||
}
|
||||
|
||||
async fn summary() -> impl Responder {
|
||||
serve_markdown("pages/summary.md").await
|
||||
}
|
||||
|
||||
async fn tools() -> impl Responder {
|
||||
serve_markdown("pages/tools.md").await
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.route("/", web::get().to(summary)) // Route for root
|
||||
.route("/tools", web::get().to(tools)) // Route for tools
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue