summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-02-12 21:24:04 +0100
committermetamuffin <metamuffin@disroot.org>2023-02-12 21:24:04 +0100
commitdd57e08795efe27b314bcaf1407faca3b205142a (patch)
tree9c0c76750f5e71111bfb314506e5004057ebd308
parent4423c2e86179168339d90adbda53d9777e953db5 (diff)
downloadmetamuffin-website-dd57e08795efe27b314bcaf1407faca3b205142a.tar
metamuffin-website-dd57e08795efe27b314bcaf1407faca3b205142a.tar.bz2
metamuffin-website-dd57e08795efe27b314bcaf1407faca3b205142a.tar.zst
copy some content from the old page
-rw-r--r--.gitignore3
-rw-r--r--src/layout.rs15
-rw-r--r--src/main.rs51
-rw-r--r--src/pages.rs104
-rw-r--r--src/wellknown.rs30
5 files changed, 167 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore
index c41cc9e..ae9c070 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-/target \ No newline at end of file
+/target
+/modules
diff --git a/src/layout.rs b/src/layout.rs
index f1d0564..3906b6f 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -3,6 +3,8 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
+use crate::pages::*;
+use crate::uri;
use markup::Render;
use rocket::{
http::ContentType,
@@ -19,15 +21,22 @@ markup::define! {
title { @title " - " "metamuffin's website" }
}
body {
+ img[src="https://s.metamuffin.org/avatar/default-512.webp", align="left", height=80, hspace=10];
h1 { "metamuffin's personal website" }
nav {
-
+ a[href=uri!(r_about())] { "About" } " "
+ a[href=uri!(r_projects())] { "Projects" } " "
+ a[href=uri!(r_contact())] { "Contact" } " "
+ a[href="https://codeberg.org/metamuffin"] { "Codeberg" } " "
}
hr;
- @main
+ section { @main }
hr;
footer {
- p { "metamuffin's website; " a[href="https://"] {} }
+ p {
+ "metamuffin's website; "
+ "sources available on " a[href="https://codeberg.org/metamuffin/website"] { "codeberg" }
+ }
}
}
}
diff --git a/src/main.rs b/src/main.rs
index 746dfa3..2cee694 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,17 +4,12 @@
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
pub mod layout;
+pub mod pages;
+pub mod wellknown;
-use rocket::{
- fairing::AdHoc,
- fs::FileServer,
- get,
- http::Header,
- response::{self, Responder},
- routes,
- serde::json::{json, Value},
- Request,
-};
+use pages::*;
+use rocket::{catchers, fairing::AdHoc, fs::FileServer, http::Header, routes};
+use wellknown::*;
#[tokio::main]
async fn main() {
@@ -30,33 +25,25 @@ async fn main() {
}))
.mount(
"/",
- routes![r_wellknown_matrix_server, r_wellknown_matrix_client,],
+ routes![
+ r_root,
+ r_about,
+ r_contact,
+ r_projects,
+ r_wellknown_matrix_server,
+ r_wellknown_matrix_client,
+ ],
)
.mount("/", FileServer::from("modules"))
+ .register("/", catchers![r_catch])
.launch()
.await
.unwrap();
}
-pub struct Cors<T>(pub T);
-
-#[rocket::async_trait]
-impl<'r, T: Responder<'r, 'static>> Responder<'r, 'static> for Cors<T> {
- fn respond_to(self, request: &'r Request<'_>) -> response::Result<'static> {
- let mut resp = self.0.respond_to(request);
- if let Ok(resp) = &mut resp {
- resp.set_header(Header::new("access-control-allow-origin", "*"));
- }
- resp
- }
-}
-
-#[get("/.well-known/matrix/client")]
-fn r_wellknown_matrix_client() -> Cors<Value> {
- Cors(json!({"m.homeserver": {"base_url": "https://matrix.metamuffin.org"}} ))
-}
-
-#[get("/.well-known/matrix/server")]
-fn r_wellknown_matrix_server() -> Cors<Value> {
- Cors(json!({"m.server": "matrix.metamuffin.org:443"} ))
+#[macro_export]
+macro_rules! uri {
+ ($kk:stmt) => {
+ &rocket::uri!($kk).to_string()
+ };
}
diff --git a/src/pages.rs b/src/pages.rs
new file mode 100644
index 0000000..82b56ca
--- /dev/null
+++ b/src/pages.rs
@@ -0,0 +1,104 @@
+use rocket::{catch, get, http::Status, response::Redirect, uri, Request};
+
+use crate::layout::{DynLayoutPage, LayoutPage};
+
+#[get("/")]
+pub fn r_root() -> Redirect {
+ Redirect::to(uri!(r_about()))
+}
+
+#[get("/about")]
+pub fn r_about() -> DynLayoutPage<'static> {
+ LayoutPage {
+ title: "about".to_string(),
+ content: markup::new! {
+ p {
+ "Hi. I am a normal person from planet earth. "
+ "I enjoy starting projects and never finishing them. "
+ "I am also supporting the free software movement by writing exclusively free software in my spare time. "
+ }
+ h2 { "current interests" }
+ ul {
+ li { "development of a general-purpose systems programming language" }
+ li { "replacing existing software with rust rewrites and rocket emotes" }
+ li { "stuff" }
+ }
+ h2 { "languages I know" }
+ ul {
+ li { "Rust" }
+ li { "English" }
+ li { "Haskell" }
+ li { "German" }
+ li { "Typescript" }
+ li { "C" }
+ li { "toki pona" }
+ li { "Python" }
+ li { "Nim, Zig and some others that i don't care about" }
+ }
+ },
+ }
+}
+
+#[get("/projects")]
+pub fn r_projects() -> DynLayoutPage<'static> {
+ LayoutPage {
+ title: "projects".to_string(),
+ content: markup::new! {
+ p { "I am starting a lot of projects - here are a few selected ones:" }
+ ul {
+ li {
+ b{"keks-meet:"} " a simple secure web conferencing application. "
+ "(" a[href="https://meet.metamuffin.org"]{"hosted"} "; " a[href="https://codeberg.org/metamuffin/keks-meet"]{"code"} ")"
+ }
+ li {
+ b{"gnix:"} " a stupid reverse proxy to replace nginx. serving the webpage you are viewing right now. "
+ "(" a[href="https://metamuffin.org"]{"hosted"} "; " a[href="https://codeberg.org/metamuffin/gnix"]{"code"} ")"
+ }
+ li {
+ b{"pfadfinder:"} " parallel anytime A* for openstreetmap with custom frontend and integration into the existing one. "
+ "(" a[href="https://codeberg.org/metamuffin/pfadfinder"]{"code"} ")"
+ }
+ li {
+ b{"video-codec-experiments:"} " a few attempts of creating my own video codecs, making use of motion compensation, dct, quantization and more. "
+ "(" a[href="https://codeberg.org/metamuffin/video-codec-experiments"]{"code"} ")"
+ }
+ li {
+ b{"pixelflut tools:"} " the programs i hacked together when playing pixelflut. includes GPU-acceleration for updating the canvas with minimal bandwidth usage. "
+ "(" a[href="https://codeberg.org/metamuffin/video-codec-experiments"]{"code"} ")"
+ }
+ li {
+ b{"karlender:"} " a personal calender suite consisting of a daemon, a graphical and a command-line user interface. "
+ "supports very flexible condition based recurring tasks and automatic scheduling so you dont need to decide. "
+ "(" a[href="https://codeberg.org/metamuffin/video-codec-experiments"]{"code"} ")"
+ }
+ }
+ },
+ }
+}
+
+#[get("/contact")]
+pub fn r_contact() -> DynLayoutPage<'static> {
+ LayoutPage {
+ title: "contact".to_string(),
+ content: markup::new! {
+ p { "You can reach out to me in a bunch of ways. I am also generally looking for nice software ideas to implement." }
+ ul {
+ li { "matrix: " a[href="https://matrix.to/#/@metamuffin:metamuffin.org"]{"@metamuffin:metamuffin.org"} }
+ li { "fedi: " a[href="https://social.metamuffin.org/@metamuffin"]{"@metamuffin@social.metamuffin.org"} }
+ li { "electronic mail: " a[href="mailto:metamuffin@disroot.org"]{"mailto:metamuffin@disroot.org"} }
+ li { "telepathy: come on, just try hard enough" }
+ }
+ },
+ }
+}
+
+#[catch(default)]
+pub fn r_catch<'a>(status: Status, _request: &Request) -> DynLayoutPage<'a> {
+ LayoutPage {
+ title: "Error".to_string(),
+ content: markup::new! {
+ h2 { "Error" }
+ p { @format!("{status}") }
+ },
+ }
+}
diff --git a/src/wellknown.rs b/src/wellknown.rs
new file mode 100644
index 0000000..2ec3255
--- /dev/null
+++ b/src/wellknown.rs
@@ -0,0 +1,30 @@
+use rocket::{
+ get,
+ http::Header,
+ response::{self, Responder},
+ serde::json::{json, Value},
+ Request,
+};
+
+pub struct Cors<T>(pub T);
+
+#[rocket::async_trait]
+impl<'r, T: Responder<'r, 'static>> Responder<'r, 'static> for Cors<T> {
+ fn respond_to(self, request: &'r Request<'_>) -> response::Result<'static> {
+ let mut resp = self.0.respond_to(request);
+ if let Ok(resp) = &mut resp {
+ resp.set_header(Header::new("access-control-allow-origin", "*"));
+ }
+ resp
+ }
+}
+
+#[get("/.well-known/matrix/client")]
+pub fn r_wellknown_matrix_client() -> Cors<Value> {
+ Cors(json!({"m.homeserver": {"base_url": "https://matrix.metamuffin.org"}} ))
+}
+
+#[get("/.well-known/matrix/server")]
+pub fn r_wellknown_matrix_server() -> Cors<Value> {
+ Cors(json!({"m.server": "matrix.metamuffin.org:443"} ))
+}