Added highlighting for navbar

Added a top button at the bottom of each page
This commit is contained in:
Awstin 2024-03-24 15:12:36 -04:00
parent 74a4e07bb0
commit e90cda7359
7 changed files with 133 additions and 27 deletions

6
assets/javascript/main.js Executable file
View file

@ -0,0 +1,6 @@
function setActive(i) {
if (i != "") {
var temp = document.getElementById(i);
temp.className = "active";
}
}

View file

@ -101,6 +101,10 @@ img {
height: auto;
}
.active {
font-weight: bold;
}
@media (max-width: 1024px) {
html {
line-height: 1.75rem;

View file

@ -34,6 +34,7 @@ pub fn get_router() -> Router {
async fn fsdi() -> impl IntoResponse {
let template = FirstStepsToDigitalIndependenceTemplate {
active_navbar: html::NavBar::BLOG,
previous: "independence",
};
html::HtmlTemplate(template)
@ -42,11 +43,13 @@ async fn fsdi() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/FirstStepsToDigitalIndependence.html")]
struct FirstStepsToDigitalIndependenceTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
}
async fn independence() -> impl IntoResponse {
let template = IndependenceTemplate {
active_navbar: html::NavBar::BLOG,
previous: "pwi",
next: "fsdi",
};
@ -56,12 +59,14 @@ async fn independence() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/Independence.html")]
struct IndependenceTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn pwi() -> impl IntoResponse {
let template = PetsWorryAndInformationTemplate {
active_navbar: html::NavBar::BLOG,
previous: "gs",
next: "independence",
};
@ -71,12 +76,14 @@ async fn pwi() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/PetsWorryAndInformation.html")]
struct PetsWorryAndInformationTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn gs() -> impl IntoResponse {
let template = GraduateSchoolTemplate {
active_navbar: html::NavBar::BLOG,
previous: "srw",
next: "pwi",
};
@ -86,12 +93,14 @@ async fn gs() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/GraduateSchool.html")]
struct GraduateSchoolTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn srw() -> impl IntoResponse {
let template = SpeedReadingWorkbookTemplate {
active_navbar: html::NavBar::BLOG,
previous: "tw",
next: "gs",
};
@ -101,12 +110,14 @@ async fn srw() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/SpeedReadingWorkbook.html")]
struct SpeedReadingWorkbookTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn tw() -> impl IntoResponse {
let template = ThisWebsiteTemplate {
active_navbar: html::NavBar::BLOG,
previous: "lt",
next: "srw",
};
@ -116,12 +127,14 @@ async fn tw() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/ThisWebsite.html")]
struct ThisWebsiteTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn lt() -> impl IntoResponse {
let template = LevelingToolTemplate {
active_navbar: html::NavBar::BLOG,
previous: "writing",
next: "tw",
};
@ -131,12 +144,14 @@ async fn lt() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/LevelingTool.html")]
struct LevelingToolTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn writing() -> impl IntoResponse {
let template = WritingTemplate {
active_navbar: html::NavBar::BLOG,
previous: "lim",
next: "lt",
};
@ -146,12 +161,14 @@ async fn writing() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/Writing.html")]
struct WritingTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn lim() -> impl IntoResponse {
let template = LessIsMoreTemplate {
active_navbar: html::NavBar::BLOG,
previous: "ile",
next: "writing",
};
@ -161,12 +178,14 @@ async fn lim() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/LessIsMore.html")]
struct LessIsMoreTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn ile() -> impl IntoResponse {
let template = ImmersiveLearningAndExperimentationTemplate {
active_navbar: html::NavBar::BLOG,
previous: "dmwi",
next: "lim",
};
@ -176,12 +195,14 @@ async fn ile() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/ImmersiveLearningAndExperimentation.html")]
struct ImmersiveLearningAndExperimentationTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn dmwi() -> impl IntoResponse {
let template = DoingMoreWithMyIdeasTemplate {
active_navbar: html::NavBar::BLOG,
previous: "wgl",
next: "ile",
};
@ -191,12 +212,14 @@ async fn dmwi() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/DoingMoreWithMyIdeas.html")]
struct DoingMoreWithMyIdeasTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn wgl() -> impl IntoResponse {
let template = WhyAndGettingLostTemplate {
active_navbar: html::NavBar::BLOG,
previous: "dm",
next: "dmwi",
};
@ -206,12 +229,14 @@ async fn wgl() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/WhyAndGettingLost.html")]
struct WhyAndGettingLostTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn dm() -> impl IntoResponse {
let template = DisciplineAndMotivationTemplate {
active_navbar: html::NavBar::BLOG,
previous: "llf",
next: "wgl",
};
@ -221,12 +246,14 @@ async fn dm() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/DisciplineAndMotivation.html")]
struct DisciplineAndMotivationTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn llf() -> impl IntoResponse {
let template = LookingLikeAFoolTemplate {
active_navbar: html::NavBar::BLOG,
previous: "habits",
next: "dm",
};
@ -236,12 +263,14 @@ async fn llf() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/LookingLikeAFool.html")]
struct LookingLikeAFoolTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn habits() -> impl IntoResponse {
let template = HabitsTemplate {
active_navbar: html::NavBar::BLOG,
previous: "deepwork",
next: "llf",
};
@ -251,12 +280,14 @@ async fn habits() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/Habits.html")]
struct HabitsTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn deepwork() -> impl IntoResponse {
let template = DeepWorkTemplate {
active_navbar: html::NavBar::BLOG,
previous: "ewt",
next: "habits",
};
@ -266,12 +297,14 @@ async fn deepwork() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/DeepWork.html")]
struct DeepWorkTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn ewt() -> impl IntoResponse {
let template = ExercisingWithoutTimeTemplate {
active_navbar: html::NavBar::BLOG,
previous: "afh",
next: "deepwork",
};
@ -281,12 +314,14 @@ async fn ewt() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/ExercisingWithoutTime.html")]
struct ExercisingWithoutTimeTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn afh() -> impl IntoResponse {
let template = AskingForHelpTemplate {
active_navbar: html::NavBar::BLOG,
previous: "mfn",
next: "ewt",
};
@ -296,12 +331,14 @@ async fn afh() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/AskingForHelp.html")]
struct AskingForHelpTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn mfn() -> impl IntoResponse {
let template = AMindForNumbersTemplate {
active_navbar: html::NavBar::BLOG,
previous: "sdl",
next: "afh",
};
@ -311,12 +348,14 @@ async fn mfn() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/AMindForNumbers.html")]
struct AMindForNumbersTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn sdl() -> impl IntoResponse {
let template = SelfDirectedLearningTemplate {
active_navbar: html::NavBar::BLOG,
previous: "foundation",
next: "mfn",
};
@ -326,12 +365,14 @@ async fn sdl() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/SelfDirectedLearning.html")]
struct SelfDirectedLearningTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn foundation() -> impl IntoResponse {
let template = TheFoundationTemplate {
active_navbar: html::NavBar::BLOG,
previous: "mop",
next: "sdl",
};
@ -341,12 +382,14 @@ async fn foundation() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/TheFoundation.html")]
struct TheFoundationTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn mop() -> impl IntoResponse {
let template = TheMythOfPerfectionTemplate {
active_navbar: html::NavBar::BLOG,
previous: "onreading",
next: "foundation",
};
@ -356,12 +399,14 @@ async fn mop() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/TheMythOfPerfection.html")]
struct TheMythOfPerfectionTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn onreading() -> impl IntoResponse {
let template = OnReadingTemplate {
active_navbar: html::NavBar::BLOG,
previous: "thestart",
next: "mop",
};
@ -371,12 +416,14 @@ async fn onreading() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/OnReading.html")]
struct OnReadingTemplate<'a> {
active_navbar: &'static str,
previous: &'a str,
next: &'a str,
}
async fn thestart() -> impl IntoResponse {
let template = TheStartTemplate {
active_navbar: html::NavBar::BLOG,
next: "onreading"
};
html::HtmlTemplate(template)
@ -385,5 +432,6 @@ async fn thestart() -> impl IntoResponse {
#[derive(Template)]
#[template(path = "blog/TheStart.html")]
struct TheStartTemplate<'a> {
active_navbar: &'static str,
next: &'a str,
}

View file

@ -29,3 +29,16 @@ 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";
}

View file

@ -12,28 +12,40 @@ pub fn get_router() -> Router {
}
async fn archserver() -> impl IntoResponse {
let template = ArchServerTemplate {};
let template = ArchServerTemplate {
active_navbar: html::NavBar::PROJECTS
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "projects/ArchServer.html")]
struct ArchServerTemplate;
struct ArchServerTemplate {
active_navbar: &'static str,
}
async fn tak() -> impl IntoResponse {
let template = TakTemplate {};
let template = TakTemplate {
active_navbar: html::NavBar::PROJECTS
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "projects/Tak.html")]
struct TakTemplate;
struct TakTemplate {
active_navbar: &'static str,
}
async fn ed() -> impl IntoResponse {
let template = EdgeDetectionTemplate {};
let template = EdgeDetectionTemplate {
active_navbar: html::NavBar::PROJECTS
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "projects/EdgeDetection.html")]
struct EdgeDetectionTemplate;
struct EdgeDetectionTemplate {
active_navbar: &'static str,
}

View file

@ -21,55 +21,79 @@ pub fn get_router() -> Router {
}
async fn home() -> impl IntoResponse {
let template = HomeTemplate {};
let template = HomeTemplate {
active_navbar: html::NavBar::HOME,
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "home.html")]
struct HomeTemplate;
struct HomeTemplate {
active_navbar: &'static str,
}
pub async fn blog() -> impl IntoResponse {
let template = BlogTemplate {};
let template = BlogTemplate {
active_navbar: html::NavBar::BLOG
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "blog.html")]
struct BlogTemplate;
struct BlogTemplate {
active_navbar: &'static str,
}
pub async fn projects() -> impl IntoResponse {
let template = ProjectsTemplate {};
let template = ProjectsTemplate {
active_navbar: html::NavBar::PROJECTS,
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "projects.html")]
struct ProjectsTemplate;
struct ProjectsTemplate {
active_navbar: &'static str,
}
async fn now() -> impl IntoResponse {
let template = NowTemplate {};
let template = NowTemplate {
active_navbar: html::NavBar::NOW,
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "now.html")]
struct NowTemplate;
struct NowTemplate {
active_navbar: &'static str,
}
async fn about() -> impl IntoResponse {
let template = AboutTemplate {};
let template = AboutTemplate {
active_navbar: html::NavBar::ABOUT,
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "about.html")]
struct AboutTemplate;
struct AboutTemplate {
active_navbar: &'static str,
}
async fn contact() -> impl IntoResponse {
let template = ContactTemplate {};
let template = ContactTemplate {
active_navbar: html::NavBar::CONTACT
};
html::HtmlTemplate(template)
}
#[derive(Template)]
#[template(path = "contact.html")]
struct ContactTemplate;
struct ContactTemplate {
active_navbar: &'static str,
}

View file

@ -4,25 +4,24 @@
<head>
<link href="/assets/main.css" rel="stylesheet" />
<script src="/assets/htmx.min.js"></script>
<!-- Allow any inheriting page to set it's own title -->
<script src="/assets/javascript/main.js"></script>
<title>Awstin</title>
<!-- Allow any inheriting page to extend head with additional assets -->
{% block head %}{% endblock %}
</head>
<body>
<!-- Inheriting pages will have their content rendered here, similar to app root in React, Angular, etc. -->
<body onload="setActive('{{active_navbar}}');">
<h1><a href="/">Awstin Chubb</a></h1>
<div class="navbar">
<ul class="navbar-list">
<li><a href="/blog">Blog</a></li>
<li><a href="/projects">Projects</a></li>
<li><a href="/now">Now</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
<li><a id="blog" href="/blog">Blog</a></li>
<li><a id="projects" href="/projects">Projects</a></li>
<li><a id="now" href="/now">Now</a></li>
<li><a id="about" href="/about">About</a></li>
<li><a id="contact" href="/contact">Contact</a></li>
</ul>
</div>
{% block content %}{% endblock %}
<a href="#">Top</a>
</body>
</html>