From 17e892a654ab4a5e4988ff2609c8880618125781 Mon Sep 17 00:00:00 2001 From: Adrian Hedqvist Date: Wed, 22 Mar 2023 23:52:57 +0100 Subject: [PATCH] stuff --- .vscode/launch.json | 45 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 9 +++++++ src/handlers/posts.rs | 1 + src/main.rs | 7 ++--- static/avatar.png | Bin 0 -> 2292 bytes templates/base.html | 1 + templates/partials/footer.html | 2 +- templates/partials/head.html | 1 + templates/partials/header.html | 2 +- 9 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 static/avatar.png diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5d7ad14 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'website'", + "cargo": { + "args": [ + "build", + "--bin=website", + "--package=website" + ], + "filter": { + "name": "website", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'website'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=website", + "--package=website" + ], + "filter": { + "name": "website", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..718e72c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "spellright.language": [ + "sv" + ], + "spellright.documentTypes": [ + "latex", + "plaintext" + ] +} \ No newline at end of file diff --git a/src/handlers/posts.rs b/src/handlers/posts.rs index fc3913e..5efc99d 100644 --- a/src/handlers/posts.rs +++ b/src/handlers/posts.rs @@ -17,6 +17,7 @@ pub async fn view(Path(path): Path, Extension(state): Extension Option { + info!("Rendering post..."); let post = state.posts.iter().find(|p| p.slug == path)?; let options = Options::all(); diff --git a/src/main.rs b/src/main.rs index 30d1d2d..df64ffd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,10 +69,11 @@ async fn main() -> Result<()> { let app = Router::new() .route("/", get(handlers::index)) - .route("/posts/", get(handlers::posts::index)) - .route("/posts/:path/", get(handlers::posts::view)) + .nest("/posts", Router::new() + .route("/", get(handlers::posts::index)) + .route("/:route/", get(handlers::posts::view)) + .fallback_service(tower_http::services::ServeDir::new("./posts"))) .nest_service("/static", tower_http::services::ServeDir::new("./static")) - .fallback_service(tower_http::services::ServeDir::new("./")) .layer(middleware); info!("Now listening at http://localhost:8180"); diff --git a/static/avatar.png b/static/avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..8e107a0ef3133ae53e85f9b06662363dc7173faa GIT binary patch literal 2292 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&di49pAxJ|V6^@iM2bcZX*I8KYn{1V&m26mB%R3(7SmL4LviM>b#x{?4un zjDOAokH}&M2EM}}%y>M1MG8<*vcxr_Bsf2ef;`iP(#fc z5e0c|))U9Q7(Z>q%UxS1`#?V#s6>0a?#Jndnht#hhnM#3^WmDH{H8{8vHoPHC#r9L zh|ROnWj*12+j#><;^uAx9o?;>Mctc zZa(_kzu6BcpnLDX#cPOwZp6zCA_~!a_Ofcr0`(@|yW4e@&y(?!L4MxRto9`gl^x%= zr5sJwbdY}9gkO`+`bC2}^ zHB7O-)guYCLIdOmpoxJXHw?T1M-FrU`1OnT8=GtI`6sUhKsA!5tDnm{r-UW|H*7Q8 literal 0 HcmV?d00001 diff --git a/templates/base.html b/templates/base.html index f7608dd..0c1c572 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,6 +9,7 @@
{% block main %}{% endblock main %}
+
{% include "partials/footer.html" %}
diff --git a/templates/partials/footer.html b/templates/partials/footer.html index 9c5cc0d..7a80ace 100644 --- a/templates/partials/footer.html +++ b/templates/partials/footer.html @@ -1 +1 @@ -

footer stuff goes here

\ No newline at end of file +

footer stuff goes here

\ No newline at end of file diff --git a/templates/partials/head.html b/templates/partials/head.html index 3e2c07e..80b7145 100644 --- a/templates/partials/head.html +++ b/templates/partials/head.html @@ -3,5 +3,6 @@ + Document \ No newline at end of file diff --git a/templates/partials/header.html b/templates/partials/header.html index 0062155..341c03d 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -1,3 +1,3 @@ \ No newline at end of file +