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