This commit is contained in:
@ -1,3 +1,2 @@
|
||||
pub mod blog_post_model;
|
||||
pub mod featured_blog_posts;
|
||||
pub mod tag_list;
|
||||
|
17
src/main.rs
17
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
|
||||
|
@ -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<ParseResult<BlogPostMetadata>>,
|
||||
pub header_props: HeaderProps,
|
||||
pub tags: Vec<String>,
|
||||
pub featured_projects: Vec<ParseResult<ProjectMetadata>>,
|
||||
pub current_url: String,
|
||||
}
|
||||
use super::post_list::PostListTemplate;
|
||||
|
||||
pub async fn render_blog_post_list(
|
||||
tag: Option<Path<String>>,
|
||||
|
@ -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<Path<String>>,
|
||||
|
@ -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},
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
25
src/pages/not_found.rs
Normal file
25
src/pages/not_found.rs
Normal file
@ -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(),
|
||||
},
|
||||
))
|
||||
}
|
19
src/pages/post_list.rs
Normal file
19
src/pages/post_list.rs
Normal file
@ -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<ParseResult<BlogPostMetadata>>,
|
||||
pub header_props: HeaderProps,
|
||||
pub tags: Vec<String>,
|
||||
pub featured_projects: Vec<ParseResult<ProjectMetadata>>,
|
||||
pub current_url: String,
|
||||
}
|
@ -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,
|
||||
|
@ -1,2 +1,3 @@
|
||||
pub mod post_listing;
|
||||
pub mod post_parser;
|
||||
pub mod tags;
|
||||
|
@ -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,
|
||||
|
@ -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<String>) -> Result<Vec<String>, StatusCode> {
|
||||
const TAGS_LENGTH: usize = 7;
|
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user