From cba2e9529000f91c16d16af2c13be6fbf0d59f01 Mon Sep 17 00:00:00 2001 From: Myrddin Dundragon Date: Sun, 28 Sep 2025 20:25:19 -0400 Subject: [PATCH] Doing some overall warning cleanup. --- Cargo.lock | 6 ++--- bard/Cargo.toml | 2 +- bard/assets/css/blog.css | 5 +++-- bard/src/components/list.rs | 43 ++++++++++++++++++----------------- bard/src/components/post.rs | 8 +------ bard/src/pages/blog.rs | 3 +-- bard/src/pages/post.rs | 3 +-- bard/src/pages/root.rs | 3 --- bard/src/settings.rs | 7 +++++- blog_test/Cargo.toml | 2 +- blog_test/assets/blog.css | 45 +++++++++++++++++++++++++++++++++++++ blog_test/blog.css | 32 ++++++++++++++++++++++++++ blog_test/src/main.rs | 34 +++++++++------------------- loreweaver/Cargo.toml | 2 +- loreweaver/src/info.rs | 5 +++++ 15 files changed, 134 insertions(+), 66 deletions(-) create mode 100644 blog_test/assets/blog.css create mode 100644 blog_test/blog.css diff --git a/Cargo.lock b/Cargo.lock index f315d5c..cffda6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "bard" -version = "0.3.2" +version = "0.3.4" dependencies = [ "dioxus", "tavern", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "blog_test" -version = "0.3.0" +version = "0.3.1" dependencies = [ "axum", "axum-server", @@ -1941,7 +1941,7 @@ checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86" [[package]] name = "loreweaver" -version = "0.3.0" +version = "0.3.1" dependencies = [ "clap", "tavern", diff --git a/bard/Cargo.toml b/bard/Cargo.toml index 8e9291f..8ae700b 100644 --- a/bard/Cargo.toml +++ b/bard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bard" -version = "0.3.3" +version = "0.3.4" edition = "2024" description = "Dioxus components that will display a Tavern blogging system Blog." repository = "/CyberMages/tavern" diff --git a/bard/assets/css/blog.css b/bard/assets/css/blog.css index 77fc082..e6a10a7 100644 --- a/bard/assets/css/blog.css +++ b/bard/assets/css/blog.css @@ -92,8 +92,6 @@ .blog_post_tale { - all: initial; - pre { padding-left: 20px; @@ -144,6 +142,9 @@ flex-direction: column; margin-top: 70px; margin-right: 70px; + position:sticky; + top: 150px; + height: 50vh; fieldset { diff --git a/bard/src/components/list.rs b/bard/src/components/list.rs index 8ffa868..eb8a976 100644 --- a/bard/src/components/list.rs +++ b/bard/src/components/list.rs @@ -1,30 +1,15 @@ -use std::borrow::Borrow; use std::collections::HashSet; -use std::hash::Hash; use dioxus::prelude::*; -use tavern::{Adventurer, Legend, Lore, Tale}; use crate::togglable::Togglable; use crate::page::Page; use crate::server::*; +use crate::settings::{BardSettings}; use super::tags::*; -#[component] -pub fn BlogAuthor() -> Element -{ - rsx! - { - section - { - class: "blog_author_style", - } - } -} - - #[component] pub fn BlogItem(title: String, slug: String, author: String, summary: String, tags: Vec) @@ -68,6 +53,9 @@ pub fn BlogItem(title: String, slug: String, author: String, summary: String, #[component] pub fn BlogList(tags: Signal>, children: Element) -> Element { + // Retrieve the provided settings from context. + let settings = use_context::(); + let list = use_server_future(move || { let t = tags(); @@ -82,7 +70,23 @@ pub fn BlogList(tags: Signal>, children: Element) -> Element { class: "blog_list", - h1 { class: "blog_title", "Runes & Ramblings" } + match settings.blog_name + { + Some(title) => + { + rsx! + { + h1 { class: "blog_title", "{title}" } + } + } + None => + { + rsx! + { + h1 { class: "blog_title visually_hidden", "Blog" } + } + } + } if let Some(Ok(lores)) = &*list.read() { @@ -98,10 +102,9 @@ pub fn BlogList(tags: Signal>, children: Element) -> Element } } } - else if let Some(Err(e)) = &*list.read() + else if let Some(Err(_e)) = &*list.read() { - p { "Unable to show post header." } - p { "{e}" } + p { "Please choose a category to see related blog posts." } } else { diff --git a/bard/src/components/post.rs b/bard/src/components/post.rs index b2461e0..8986a60 100644 --- a/bard/src/components/post.rs +++ b/bard/src/components/post.rs @@ -1,12 +1,6 @@ -use std::borrow::Borrow; -use std::collections::HashSet; -use std::hash::Hash; - use dioxus::prelude::*; -use tavern::{Adventurer, Legend, Lore, Tale}; +use tavern::{Adventurer, Tale}; -use crate::togglable::Togglable; -use crate::page::Page; use crate::server::*; use super::tags::*; diff --git a/bard/src/pages/blog.rs b/bard/src/pages/blog.rs index 30f25a0..eef718a 100644 --- a/bard/src/pages/blog.rs +++ b/bard/src/pages/blog.rs @@ -3,7 +3,6 @@ use std::collections::HashSet; use dioxus::prelude::*; use crate::components::{BlogList, TagSelector}; -use crate::page::Page; @@ -11,7 +10,7 @@ use crate::page::Page; #[component] pub fn Blog(tag: ReadOnlySignal) -> Element { - let mut categories: Signal> = + let categories: Signal> = use_signal(|| HashSet::new()); rsx! diff --git a/bard/src/pages/post.rs b/bard/src/pages/post.rs index b3b09e6..7c9339c 100644 --- a/bard/src/pages/post.rs +++ b/bard/src/pages/post.rs @@ -1,7 +1,6 @@ use dioxus::prelude::*; use crate::components::{BlogPost, TagNav}; -use crate::page::Page; @@ -10,7 +9,7 @@ use crate::page::Page; pub fn Post(slug: ReadOnlySignal) -> Element { // Create a copy of the current slug to detect changes. - let mut url_slug = use_signal(|| slug()); + let url_slug = use_signal(|| slug()); rsx! { diff --git a/bard/src/pages/root.rs b/bard/src/pages/root.rs index 3820678..f49b108 100644 --- a/bard/src/pages/root.rs +++ b/bard/src/pages/root.rs @@ -1,8 +1,5 @@ -use std::collections::HashSet; - use dioxus::prelude::*; -use crate::page::Page; use crate::pages::Blog; diff --git a/bard/src/settings.rs b/bard/src/settings.rs index 074836b..ea64a52 100644 --- a/bard/src/settings.rs +++ b/bard/src/settings.rs @@ -15,9 +15,14 @@ pub enum StylesheetBehavior } -#[derive(Copy, Clone, Default)] +#[derive(Clone, Default)] pub struct BardSettings { + /// The name to use for the blog. + /// If None, then the name will be Blog, but made invisible so that + /// it is still available for screen readers. + pub blog_name: Option, + /// A user defined stylesheet and how the library should include it. pub stylesheet: StylesheetBehavior } diff --git a/blog_test/Cargo.toml b/blog_test/Cargo.toml index e8c55c7..73769f3 100644 --- a/blog_test/Cargo.toml +++ b/blog_test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blog_test" -version = "0.3.0" +version = "0.3.1" authors = ["Myrddin Dundragon "] edition = "2021" diff --git a/blog_test/assets/blog.css b/blog_test/assets/blog.css new file mode 100644 index 0000000..db05c9f --- /dev/null +++ b/blog_test/assets/blog.css @@ -0,0 +1,45 @@ +:root +{ + --text-color: #000000; + --bg-color: #FFFFFF; + + --primary-color: #ffffff; + --secondary-color: #000000; + --accent-color: #7dfdfe; /* Tron grid or try 00a8ff 00eaff 26b4ca 59b4c7 5584AC*/ + --mobile-color: #363636; + + --desktop-size: 1230px; +} + +.toggle_button { + display: inline-block; + margin-top: 5px; + margin-right: 5px; + padding: 0px 6px; + border: 2px solid var(--text-color); + border-radius: 5px; + color: var(--text-color); + cursor: pointer; + user-select: none; + transition: 0.1s ease-in; +} + +.toggle_button:hover { + color: var(--accent-color); + border-color: var(--accent-color); + transform: translateY(-2px); +} + +.toggle_button input[type="checkbox"] { + position: absolute; + opacity: 0; + width: 0; + height: 0; + pointer-events: none; +} + +/* Checked state using :has() — modern browsers only */ +.toggle_button:has(input:checked) { + color: var(--accent-color); + border-color: var(--accent-color); +} diff --git a/blog_test/blog.css b/blog_test/blog.css new file mode 100644 index 0000000..e486153 --- /dev/null +++ b/blog_test/blog.css @@ -0,0 +1,32 @@ +.toggle_button { + display: inline-block; + margin-top: 5px; + margin-right: 5px; + padding: 0px 6px; + border: 2px solid var(--text-color); + border-radius: 5px; + color: var(--text-color); + cursor: pointer; + user-select: none; + transition: 0.1s ease-in; +} + +.toggle_button:hover { + color: var(--accent-color); + border-color: var(--accent-color); + transform: translateY(-2px); +} + +.toggle_button input[type="checkbox"] { + position: absolute; + opacity: 0; + width: 0; + height: 0; + pointer-events: none; +} + +/* Checked state using :has() — modern browsers only */ +.toggle_button:has(input:checked) { + color: var(--accent-color); + border-color: var(--accent-color); +} diff --git a/blog_test/src/main.rs b/blog_test/src/main.rs index a7a7e16..35727ec 100644 --- a/blog_test/src/main.rs +++ b/blog_test/src/main.rs @@ -1,27 +1,11 @@ -use std::net::SocketAddr; - use dioxus::prelude::*; -#[cfg(feature = "server")] -use axum::Router; -#[cfg(feature = "server")] -use axum::ServiceExt; -#[cfg(feature = "server")] -use axum::extract::{Extension, Host}; -#[cfg(feature = "server")] -use axum::http::uri::{Parts, Uri}; -#[cfg(feature = "server")] -use axum::http::StatusCode; -#[cfg(feature = "server")] -use axum::response::{IntoResponse, Redirect}; -#[cfg(feature = "server")] -use axum::routing::get; - use bard::*; const FAVICON: Asset = asset!("/assets/favicon.ico"); +const BLOG: Asset = asset!("/assets/blog.css"); @@ -29,7 +13,7 @@ fn main() { #[cfg(feature = "server")] { - tokio::runtime::Runtime::new() + let _ = tokio::runtime::Runtime::new() .unwrap() .block_on(async move { bard::init_database("/home/myrddin/cybermages/website/tavern.db").await }); } @@ -41,6 +25,13 @@ fn main() #[component] fn App() -> Element { + let custom_settings = BardSettings + { + blog_name: Some(String::from("Blog Test")), + stylesheet: StylesheetBehavior::Extend(BLOG), + }; + provide_context(custom_settings); + rsx! { document::Link { rel: "icon", href: FAVICON } @@ -52,8 +43,7 @@ fn App() -> Element #[component] fn Home() -> Element { - rsx! - { + rsx! { h1 { "Blog Test" } } } @@ -62,8 +52,7 @@ fn Home() -> Element #[component] pub fn PageNotFound(route: Vec) -> Element { - rsx! - { + rsx! { h1 { "Page not found" } p { "We are terribly sorry, but the page you requested doesn't exist." } pre { color: "red", "log:\nattemped to navigate to: {route:?}" } @@ -94,7 +83,6 @@ fn Navbar() -> Element - #[derive(Debug, Clone, Routable, PartialEq)] #[rustfmt::skip] pub enum Page diff --git a/loreweaver/Cargo.toml b/loreweaver/Cargo.toml index 0054b70..77c297f 100644 --- a/loreweaver/Cargo.toml +++ b/loreweaver/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "loreweaver" -version = "0.3.0" +version = "0.3.1" edition = "2024" description = "Converts a blog repository into an SQLite database using the Tavern blog system." repository = "/CyberMages/tavern" diff --git a/loreweaver/src/info.rs b/loreweaver/src/info.rs index 8b4ec0d..d81cbfd 100644 --- a/loreweaver/src/info.rs +++ b/loreweaver/src/info.rs @@ -3,12 +3,15 @@ /// The environment variable defined by Cargo for the name. +#[allow(dead_code)] const NAME: Option<&str> = option_env!("CARGO_PKG_NAME"); /// The environment variable defined by Cargo for the version. +#[allow(dead_code)] const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); /// The string to display if a value is not defined during compile time. +#[allow(dead_code)] const NOT_DEFINED: &'static str = "UNDEFINED"; @@ -17,6 +20,7 @@ const NOT_DEFINED: &'static str = "UNDEFINED"; /// set at compile time and comes from the Cargo.toml file. /// /// If a value is not found, then it will return the not defined value. +#[allow(dead_code)] pub fn get_name() -> &'static str { NAME.unwrap_or(NOT_DEFINED) @@ -27,6 +31,7 @@ pub fn get_name() -> &'static str /// This is set at compile time and comes from the Cargo.toml file. /// /// If a value is not found, then it will return the not defined value. +#[allow(dead_code)] pub fn get_version() -> &'static str { VERSION.unwrap_or(NOT_DEFINED)