Removed unneeded js delivery for site, removed active_navbar from backend
This commit is contained in:
parent
e761790f8e
commit
10a4c30bf5
5 changed files with 18 additions and 56 deletions
|
|
@ -9,7 +9,7 @@ use core::panic;
|
|||
use sqlx::PgPool;
|
||||
use std::{collections::HashMap, error::Error};
|
||||
|
||||
use super::{root::AppState, ArticleTemplate, HtmlTemplate, NavBar};
|
||||
use super::{root::AppState, ArticleTemplate, HtmlTemplate};
|
||||
|
||||
pub fn get_router() -> Router {
|
||||
Router::new()
|
||||
|
|
@ -23,7 +23,6 @@ async fn blog(state: Extension<AppState>) -> impl IntoResponse {
|
|||
.await
|
||||
.expect("couldn't get articles");
|
||||
let template = BlogTemplate {
|
||||
active_navbar: NavBar::BLOG,
|
||||
article_list: list.join("\n"),
|
||||
};
|
||||
HtmlTemplate(template)
|
||||
|
|
@ -32,7 +31,6 @@ async fn blog(state: Extension<AppState>) -> impl IntoResponse {
|
|||
#[derive(Template)]
|
||||
#[template(path = "blog.html")]
|
||||
struct BlogTemplate {
|
||||
active_navbar: &'static str,
|
||||
article_list: String,
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +62,6 @@ async fn article(
|
|||
},
|
||||
};
|
||||
let template = ArticleTemplate {
|
||||
active_navbar: NavBar::BLOG,
|
||||
content: article.content,
|
||||
footer: footer.to_string(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,23 +31,9 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
pub struct NavBar {
|
||||
}
|
||||
|
||||
impl NavBar {
|
||||
pub const HOME: &'static str = "";
|
||||
pub const BLOG: &'static str = "blog";
|
||||
pub const PROJECTS: &'static str = "projects";
|
||||
pub const NOW: &'static str = "now";
|
||||
pub const ABOUT: &'static str = "about";
|
||||
pub const CONTACT: &'static str = "contact";
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "article.html")]
|
||||
pub struct ArticleTemplate {
|
||||
active_navbar: &'static str,
|
||||
footer: String,
|
||||
content: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use achubb_database::data::{PsqlData, project::Project};
|
||||
use axum::extract::{Extension, Path};
|
||||
use achubb_database::data::{project::Project, PsqlData};
|
||||
use askama::Template;
|
||||
use axum::extract::{Extension, Path};
|
||||
use axum::response::IntoResponse;
|
||||
use axum::{routing::get, Router};
|
||||
use std::{ error::Error, collections::HashMap};
|
||||
use sqlx::PgPool;
|
||||
use std::{collections::HashMap, error::Error};
|
||||
|
||||
use super::{root::AppState, ArticleTemplate, HtmlTemplate, NavBar};
|
||||
use super::{root::AppState, ArticleTemplate, HtmlTemplate};
|
||||
|
||||
pub fn get_router() -> Router {
|
||||
Router::new()
|
||||
|
|
@ -20,7 +20,6 @@ pub async fn projects(state: Extension<AppState>) -> impl IntoResponse {
|
|||
.await
|
||||
.expect("couldn't get projects");
|
||||
let template = ProjectsTemplate {
|
||||
active_navbar: NavBar::PROJECTS,
|
||||
project_list: list.join("\n"),
|
||||
};
|
||||
HtmlTemplate(template)
|
||||
|
|
@ -29,7 +28,6 @@ pub async fn projects(state: Extension<AppState>) -> impl IntoResponse {
|
|||
#[derive(Template)]
|
||||
#[template(path = "projects.html")]
|
||||
struct ProjectsTemplate {
|
||||
active_navbar: &'static str,
|
||||
project_list: String,
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +43,9 @@ async fn project(
|
|||
};
|
||||
let footer: &str = "<a href=\"/projects\">Back to Projects</a>";
|
||||
let template = ArticleTemplate {
|
||||
active_navbar: NavBar::PROJECTS,
|
||||
content: project.content.expect("Should have had content if it got this far"),
|
||||
content: project
|
||||
.content
|
||||
.expect("Should have had content if it got this far"),
|
||||
footer: footer.to_string(),
|
||||
};
|
||||
HtmlTemplate(template)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::html::{api, blog, projects, HtmlTemplate, NavBar};
|
||||
use crate::html::{api, blog, projects, HtmlTemplate};
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
response::{IntoResponse, Redirect},
|
||||
|
|
@ -53,7 +53,6 @@ async fn home(state: Extension<AppState>) -> impl IntoResponse {
|
|||
let (project_head, _) = project_list.split_at(5);
|
||||
|
||||
let template = HomeTemplate {
|
||||
active_navbar: NavBar::HOME,
|
||||
recent_blogs: article_head.join("\n"),
|
||||
recent_projects: project_head.join("\n"),
|
||||
};
|
||||
|
|
@ -63,59 +62,42 @@ async fn home(state: Extension<AppState>) -> impl IntoResponse {
|
|||
#[derive(Template)]
|
||||
#[template(path = "home.html")]
|
||||
struct HomeTemplate {
|
||||
active_navbar: &'static str,
|
||||
recent_blogs: String,
|
||||
recent_projects: String,
|
||||
}
|
||||
|
||||
async fn now() -> impl IntoResponse {
|
||||
let template = NowTemplate {
|
||||
active_navbar: NavBar::NOW,
|
||||
};
|
||||
let template = NowTemplate {};
|
||||
HtmlTemplate(template)
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "now.html")]
|
||||
struct NowTemplate {
|
||||
active_navbar: &'static str,
|
||||
}
|
||||
struct NowTemplate {}
|
||||
|
||||
async fn about() -> impl IntoResponse {
|
||||
let template = AboutTemplate {
|
||||
active_navbar: NavBar::ABOUT,
|
||||
};
|
||||
let template = AboutTemplate {};
|
||||
HtmlTemplate(template)
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "about.html")]
|
||||
struct AboutTemplate {
|
||||
active_navbar: &'static str,
|
||||
}
|
||||
struct AboutTemplate {}
|
||||
|
||||
async fn contact() -> impl IntoResponse {
|
||||
let template = ContactTemplate {
|
||||
active_navbar: NavBar::CONTACT,
|
||||
};
|
||||
let template = ContactTemplate {};
|
||||
HtmlTemplate(template)
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "contact.html")]
|
||||
struct ContactTemplate {
|
||||
active_navbar: &'static str,
|
||||
}
|
||||
struct ContactTemplate {}
|
||||
|
||||
async fn uses() -> impl IntoResponse {
|
||||
let template = UsesTemplate{
|
||||
active_navbar: NavBar::ABOUT,
|
||||
};
|
||||
let template = UsesTemplate {};
|
||||
HtmlTemplate(template)
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "uses.html")]
|
||||
struct UsesTemplate {
|
||||
active_navbar: &'static str,
|
||||
}
|
||||
struct UsesTemplate {}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@
|
|||
|
||||
<head>
|
||||
<link href="/assets/main.css" rel="stylesheet" />
|
||||
<script src="/assets/htmx.min.js"></script>
|
||||
<script src="/assets/javascript/main.js"></script>
|
||||
<link rel="shortcut icon" href="/assets/favicon.ico">
|
||||
<title>Awstin</title>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body onload="setActive('{{active_navbar}}');">
|
||||
<body>
|
||||
<div class="container">
|
||||
<nav class="sidebar">
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Reference in a new issue