From ceb3f4b89ddc0b4739317024324c1d94a34aabaf Mon Sep 17 00:00:00 2001
From: Michal Vanko
Date: Thu, 3 Oct 2024 14:59:28 +0200
Subject: [PATCH] so many changes
---
src/blog_posts/mod.rs | 1 -
src/main.rs | 17 +-----------
src/pages/blog_post_list.rs | 27 +++++--------------
src/pages/broadcast_list.rs | 12 ++++-----
src/pages/index.rs | 7 ++---
src/pages/mod.rs | 2 ++
src/pages/not_found.rs | 25 +++++++++++++++++
src/pages/post_list.rs | 19 +++++++++++++
src/picture_generator/image_src_generator.rs | 1 -
src/post_utils/mod.rs | 1 +
src/post_utils/post_parser.rs | 2 +-
.../tag_list.rs => post_utils/tags.rs} | 7 +++--
src/router.rs | 5 ++--
styles/output.css | 23 ++++++++++++++++
templates/components/social_card.html | 2 +-
templates/components/talent_card.html | 2 +-
templates/not_found.html | 15 +++++++++++
.../{blog_post_list.html => post_list.html} | 10 +++----
templates/site_footer.html | 12 ++++++---
19 files changed, 124 insertions(+), 66 deletions(-)
create mode 100644 src/pages/not_found.rs
create mode 100644 src/pages/post_list.rs
rename src/{blog_posts/tag_list.rs => post_utils/tags.rs} (91%)
create mode 100644 templates/not_found.html
rename templates/{blog_post_list.html => post_list.html} (89%)
diff --git a/src/blog_posts/mod.rs b/src/blog_posts/mod.rs
index bcaca0f..2efd6bc 100644
--- a/src/blog_posts/mod.rs
+++ b/src/blog_posts/mod.rs
@@ -1,3 +1,2 @@
pub mod blog_post_model;
pub mod featured_blog_posts;
-pub mod tag_list;
diff --git a/src/main.rs b/src/main.rs
index f2d0f90..c79b559 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,8 +41,6 @@ async fn main() {
.nest_service("/config.yml", ServeDir::new("static/resources/config.yml")) // Decap CMS config
.nest_service("/robots.txt", ServeDir::new("robots.txt"));
- let app = app.fallback(handler_404);
-
#[cfg(debug_assertions)]
let app = app.layer(LiveReloadLayer::new());
@@ -54,21 +52,8 @@ async fn main() {
axum::serve(listener, app).await.unwrap();
}
-async fn handler_404(OriginalUri(original_uri): OriginalUri) -> impl IntoResponse {
- info!("{original_uri} not found");
- (StatusCode::NOT_FOUND, "nothing to see here")
-}
-
// TODO Socials
// - fotos
-// background gradient color
-// TODO Change DNS system
// THINK deploy to alula? rather then katelyn? can be change whenever
-// TODO after release
-// OG tags
-// - projects page
-// TODO broken links
-// showcase/eggfetcher
-// broadcasts/
-// manifest.json
//
+// TODO 404 page
diff --git a/src/pages/blog_post_list.rs b/src/pages/blog_post_list.rs
index 8a0763b..c86ed58 100644
--- a/src/pages/blog_post_list.rs
+++ b/src/pages/blog_post_list.rs
@@ -1,4 +1,3 @@
-use askama::Template;
use axum::{
extract::{OriginalUri, Path},
http::StatusCode,
@@ -7,28 +6,16 @@ use tokio::try_join;
use tracing::debug;
use crate::{
- blog_posts::{
- blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
- tag_list::{get_popular_tags, get_posts_by_tag},
- },
+ blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
components::site_header::{HeaderProps, Link},
- filters,
- post_utils::{post_listing::get_post_list, post_parser::ParseResult},
- projects::{featured_projects::get_featured_projects, project_model::ProjectMetadata},
+ post_utils::{
+ post_listing::get_post_list,
+ tags::{get_popular_tags, get_posts_by_tag},
+ },
+ projects::featured_projects::get_featured_projects,
};
-#[derive(Template)]
-#[template(path = "blog_post_list.html")]
-pub struct PostListTemplate {
- pub title: String,
- pub og_title: String,
- pub segment: String,
- pub posts: Vec>,
- pub header_props: HeaderProps,
- pub tags: Vec,
- pub featured_projects: Vec>,
- pub current_url: String,
-}
+use super::post_list::PostListTemplate;
pub async fn render_blog_post_list(
tag: Option>,
diff --git a/src/pages/broadcast_list.rs b/src/pages/broadcast_list.rs
index 6c6ff3b..8321e91 100644
--- a/src/pages/broadcast_list.rs
+++ b/src/pages/broadcast_list.rs
@@ -6,16 +6,16 @@ use tokio::try_join;
use tracing::debug;
use crate::{
- blog_posts::{
- blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
- tag_list::{get_popular_tags, get_posts_by_tag},
- },
+ blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
components::site_header::{HeaderProps, Link},
- post_utils::post_listing::get_post_list,
+ post_utils::{
+ post_listing::get_post_list,
+ tags::{get_popular_tags, get_posts_by_tag},
+ },
projects::featured_projects::get_featured_projects,
};
-use super::blog_post_list::PostListTemplate;
+use super::post_list::PostListTemplate;
pub async fn render_broadcast_post_list(
tag: Option>,
diff --git a/src/pages/index.rs b/src/pages/index.rs
index 6de96e0..77660d6 100644
--- a/src/pages/index.rs
+++ b/src/pages/index.rs
@@ -3,13 +3,10 @@ use axum::http::StatusCode;
use tokio::try_join;
use crate::{
- blog_posts::{
- blog_post_model::BlogPostMetadata, featured_blog_posts::get_featured_blog_posts,
- tag_list::get_popular_tags,
- },
+ blog_posts::{blog_post_model::BlogPostMetadata, featured_blog_posts::get_featured_blog_posts},
components::site_header::HeaderProps,
filters,
- post_utils::post_parser::ParseResult,
+ post_utils::{post_parser::ParseResult, tags::get_popular_tags},
projects::{featured_projects::get_featured_projects, project_model::ProjectMetadata},
};
diff --git a/src/pages/mod.rs b/src/pages/mod.rs
index 43f6d8e..2bab04b 100644
--- a/src/pages/mod.rs
+++ b/src/pages/mod.rs
@@ -4,5 +4,7 @@ pub mod blog_post_page;
pub mod broadcast_list;
pub mod contact;
pub mod index;
+pub mod not_found;
+pub mod post_list;
pub mod project_list;
pub mod showcase;
diff --git a/src/pages/not_found.rs b/src/pages/not_found.rs
new file mode 100644
index 0000000..17df806
--- /dev/null
+++ b/src/pages/not_found.rs
@@ -0,0 +1,25 @@
+use askama::Template;
+use axum::{extract::OriginalUri, http::StatusCode};
+use tracing::info;
+
+use crate::components::site_header::HeaderProps;
+
+#[derive(Template)]
+#[template(path = "not_found.html")]
+pub struct NotFoundPage {
+ title: String,
+ header_props: HeaderProps,
+}
+
+pub async fn render_not_found(
+ OriginalUri(original_uri): OriginalUri,
+) -> Result<(StatusCode, NotFoundPage), StatusCode> {
+ info!("{original_uri} not found");
+ Ok((
+ StatusCode::NOT_FOUND,
+ NotFoundPage {
+ title: "This page does not exists".to_owned(),
+ header_props: HeaderProps::default(),
+ },
+ ))
+}
diff --git a/src/pages/post_list.rs b/src/pages/post_list.rs
new file mode 100644
index 0000000..6ef81d1
--- /dev/null
+++ b/src/pages/post_list.rs
@@ -0,0 +1,19 @@
+use askama::Template;
+
+use crate::{
+ blog_posts::blog_post_model::BlogPostMetadata, components::site_header::HeaderProps, filters,
+ post_utils::post_parser::ParseResult, projects::project_model::ProjectMetadata,
+};
+
+#[derive(Template)]
+#[template(path = "post_list.html")]
+pub struct PostListTemplate {
+ pub title: String,
+ pub og_title: String,
+ pub segment: String,
+ pub posts: Vec>,
+ pub header_props: HeaderProps,
+ pub tags: Vec,
+ pub featured_projects: Vec>,
+ pub current_url: String,
+}
diff --git a/src/picture_generator/image_src_generator.rs b/src/picture_generator/image_src_generator.rs
index f289da7..dcc245b 100644
--- a/src/picture_generator/image_src_generator.rs
+++ b/src/picture_generator/image_src_generator.rs
@@ -2,7 +2,6 @@ use std::{path::Path, sync::Arc};
use anyhow::Context;
use image::ImageReader;
-use tracing::debug;
use super::{
image_generator::generate_images,
diff --git a/src/post_utils/mod.rs b/src/post_utils/mod.rs
index 8c2382e..0629f5a 100644
--- a/src/post_utils/mod.rs
+++ b/src/post_utils/mod.rs
@@ -1,2 +1,3 @@
pub mod post_listing;
pub mod post_parser;
+pub mod tags;
diff --git a/src/post_utils/post_parser.rs b/src/post_utils/post_parser.rs
index 167a9fe..bdc0c79 100644
--- a/src/post_utils/post_parser.rs
+++ b/src/post_utils/post_parser.rs
@@ -10,7 +10,7 @@ use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag, TagEnd};
use serde::{de::DeserializeOwned, Deserialize, Deserializer};
use syntect::{highlighting::ThemeSet, html::highlighted_html_for_string, parsing::SyntaxSet};
use tokio::fs;
-use tracing::{debug, error, info};
+use tracing::{debug, error};
use crate::picture_generator::{
picture_markup_generator::generate_picture_markup, resolutions::get_max_resolution,
diff --git a/src/blog_posts/tag_list.rs b/src/post_utils/tags.rs
similarity index 91%
rename from src/blog_posts/tag_list.rs
rename to src/post_utils/tags.rs
index ad49ebd..8a5b58d 100644
--- a/src/blog_posts/tag_list.rs
+++ b/src/post_utils/tags.rs
@@ -2,10 +2,9 @@ use axum::http::StatusCode;
use std::collections::HashMap;
use tracing::debug;
-use crate::{
- blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
- post_utils::{post_listing::get_post_list, post_parser::ParseResult},
-};
+use crate::blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH};
+
+use super::{post_listing::get_post_list, post_parser::ParseResult};
pub async fn get_popular_tags(segment: Option) -> Result, StatusCode> {
const TAGS_LENGTH: usize = 7;
diff --git a/src/router.rs b/src/router.rs
index c450c4c..9002518 100644
--- a/src/router.rs
+++ b/src/router.rs
@@ -3,8 +3,8 @@ use crate::{
pages::{
admin::render_admin, blog_post_list::render_blog_post_list,
blog_post_page::render_blog_post, broadcast_list::render_broadcast_post_list,
- contact::render_contact, index::render_index, project_list::render_projects_list,
- showcase::egg_fetcher::render_egg_fetcher,
+ contact::render_contact, index::render_index, not_found::render_not_found,
+ project_list::render_projects_list, showcase::egg_fetcher::render_egg_fetcher,
},
};
use axum::{extract::MatchedPath, http::Request, routing::get, Router};
@@ -42,4 +42,5 @@ pub fn get_router() -> Router {
)
}),
)
+ .fallback(render_not_found)
}
diff --git a/styles/output.css b/styles/output.css
index efd8f5e..e0c86ee 100644
--- a/styles/output.css
+++ b/styles/output.css
@@ -702,6 +702,11 @@ video {
margin-bottom: 1.25rem;
}
+.mx-3 {
+ margin-left: 0.75rem;
+ margin-right: 0.75rem;
+}
+
.mb-1 {
margin-bottom: 0.25rem;
}
@@ -818,6 +823,10 @@ video {
max-width: 64rem;
}
+.flex-1 {
+ flex: 1 1 0%;
+}
+
.flex-grow {
flex-grow: 1;
}
@@ -868,6 +877,10 @@ video {
justify-content: space-between;
}
+.justify-around {
+ justify-content: space-around;
+}
+
.gap-2 {
gap: 0.5rem;
}
@@ -1034,6 +1047,16 @@ video {
line-height: 1.75rem;
}
+.text-6xl {
+ font-size: 3.75rem;
+ line-height: 1;
+}
+
+.text-9xl {
+ font-size: 8rem;
+ line-height: 1;
+}
+
.font-bold {
font-weight: 700;
}
diff --git a/templates/components/social_card.html b/templates/components/social_card.html
index e7c961e..bbe5873 100644
--- a/templates/components/social_card.html
+++ b/templates/components/social_card.html
@@ -2,7 +2,7 @@
-
-
- RSS feed
+