Doing some overall warning cleanup.

This commit is contained in:
2025-09-28 20:25:19 -04:00
parent 468b9449b2
commit cba2e95290
15 changed files with 134 additions and 66 deletions

6
Cargo.lock generated
View File

@ -224,7 +224,7 @@ dependencies = [
[[package]] [[package]]
name = "bard" name = "bard"
version = "0.3.2" version = "0.3.4"
dependencies = [ dependencies = [
"dioxus", "dioxus",
"tavern", "tavern",
@ -263,7 +263,7 @@ dependencies = [
[[package]] [[package]]
name = "blog_test" name = "blog_test"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"axum", "axum",
"axum-server", "axum-server",
@ -1941,7 +1941,7 @@ checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86"
[[package]] [[package]]
name = "loreweaver" name = "loreweaver"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"clap", "clap",
"tavern", "tavern",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bard" name = "bard"
version = "0.3.3" version = "0.3.4"
edition = "2024" edition = "2024"
description = "Dioxus components that will display a Tavern blogging system Blog." description = "Dioxus components that will display a Tavern blogging system Blog."
repository = "/CyberMages/tavern" repository = "/CyberMages/tavern"

View File

@ -92,8 +92,6 @@
.blog_post_tale .blog_post_tale
{ {
all: initial;
pre pre
{ {
padding-left: 20px; padding-left: 20px;
@ -144,6 +142,9 @@
flex-direction: column; flex-direction: column;
margin-top: 70px; margin-top: 70px;
margin-right: 70px; margin-right: 70px;
position:sticky;
top: 150px;
height: 50vh;
fieldset fieldset
{ {

View File

@ -1,30 +1,15 @@
use std::borrow::Borrow;
use std::collections::HashSet; use std::collections::HashSet;
use std::hash::Hash;
use dioxus::prelude::*; use dioxus::prelude::*;
use tavern::{Adventurer, Legend, Lore, Tale};
use crate::togglable::Togglable; use crate::togglable::Togglable;
use crate::page::Page; use crate::page::Page;
use crate::server::*; use crate::server::*;
use crate::settings::{BardSettings};
use super::tags::*; use super::tags::*;
#[component]
pub fn BlogAuthor() -> Element
{
rsx!
{
section
{
class: "blog_author_style",
}
}
}
#[component] #[component]
pub fn BlogItem(title: String, slug: String, author: String, summary: String, pub fn BlogItem(title: String, slug: String, author: String, summary: String,
tags: Vec<String>) tags: Vec<String>)
@ -68,6 +53,9 @@ pub fn BlogItem(title: String, slug: String, author: String, summary: String,
#[component] #[component]
pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element
{ {
// Retrieve the provided settings from context.
let settings = use_context::<BardSettings>();
let list = use_server_future(move || let list = use_server_future(move ||
{ {
let t = tags(); let t = tags();
@ -82,7 +70,23 @@ pub fn BlogList(tags: Signal<HashSet<String>>, children: Element) -> Element
{ {
class: "blog_list", 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() if let Some(Ok(lores)) = &*list.read()
{ {
@ -98,10 +102,9 @@ pub fn BlogList(tags: Signal<HashSet<String>>, 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 { "Please choose a category to see related blog posts." }
p { "{e}" }
} }
else else
{ {

View File

@ -1,12 +1,6 @@
use std::borrow::Borrow;
use std::collections::HashSet;
use std::hash::Hash;
use dioxus::prelude::*; 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 crate::server::*;
use super::tags::*; use super::tags::*;

View File

@ -3,7 +3,6 @@ use std::collections::HashSet;
use dioxus::prelude::*; use dioxus::prelude::*;
use crate::components::{BlogList, TagSelector}; use crate::components::{BlogList, TagSelector};
use crate::page::Page;
@ -11,7 +10,7 @@ use crate::page::Page;
#[component] #[component]
pub fn Blog(tag: ReadOnlySignal<String>) -> Element pub fn Blog(tag: ReadOnlySignal<String>) -> Element
{ {
let mut categories: Signal<HashSet<String>> = let categories: Signal<HashSet<String>> =
use_signal(|| HashSet::new()); use_signal(|| HashSet::new());
rsx! rsx!

View File

@ -1,7 +1,6 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use crate::components::{BlogPost, TagNav}; use crate::components::{BlogPost, TagNav};
use crate::page::Page;
@ -10,7 +9,7 @@ use crate::page::Page;
pub fn Post(slug: ReadOnlySignal<String>) -> Element pub fn Post(slug: ReadOnlySignal<String>) -> Element
{ {
// Create a copy of the current slug to detect changes. // Create a copy of the current slug to detect changes.
let mut url_slug = use_signal(|| slug()); let url_slug = use_signal(|| slug());
rsx! rsx!
{ {

View File

@ -1,8 +1,5 @@
use std::collections::HashSet;
use dioxus::prelude::*; use dioxus::prelude::*;
use crate::page::Page;
use crate::pages::Blog; use crate::pages::Blog;

View File

@ -15,9 +15,14 @@ pub enum StylesheetBehavior
} }
#[derive(Copy, Clone, Default)] #[derive(Clone, Default)]
pub struct BardSettings 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<String>,
/// A user defined stylesheet and how the library should include it. /// A user defined stylesheet and how the library should include it.
pub stylesheet: StylesheetBehavior pub stylesheet: StylesheetBehavior
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "blog_test" name = "blog_test"
version = "0.3.0" version = "0.3.1"
authors = ["Myrddin Dundragon <myrddin@cybermages.tech>"] authors = ["Myrddin Dundragon <myrddin@cybermages.tech>"]
edition = "2021" edition = "2021"

45
blog_test/assets/blog.css Normal file
View File

@ -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);
}

32
blog_test/blog.css Normal file
View File

@ -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);
}

View File

@ -1,27 +1,11 @@
use std::net::SocketAddr;
use dioxus::prelude::*; 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::*; use bard::*;
const FAVICON: Asset = asset!("/assets/favicon.ico"); const FAVICON: Asset = asset!("/assets/favicon.ico");
const BLOG: Asset = asset!("/assets/blog.css");
@ -29,7 +13,7 @@ fn main()
{ {
#[cfg(feature = "server")] #[cfg(feature = "server")]
{ {
tokio::runtime::Runtime::new() let _ = tokio::runtime::Runtime::new()
.unwrap() .unwrap()
.block_on(async move { bard::init_database("/home/myrddin/cybermages/website/tavern.db").await }); .block_on(async move { bard::init_database("/home/myrddin/cybermages/website/tavern.db").await });
} }
@ -41,6 +25,13 @@ fn main()
#[component] #[component]
fn App() -> Element fn App() -> Element
{ {
let custom_settings = BardSettings
{
blog_name: Some(String::from("Blog Test")),
stylesheet: StylesheetBehavior::Extend(BLOG),
};
provide_context(custom_settings);
rsx! rsx!
{ {
document::Link { rel: "icon", href: FAVICON } document::Link { rel: "icon", href: FAVICON }
@ -52,8 +43,7 @@ fn App() -> Element
#[component] #[component]
fn Home() -> Element fn Home() -> Element
{ {
rsx! rsx! {
{
h1 { "Blog Test" } h1 { "Blog Test" }
} }
} }
@ -62,8 +52,7 @@ fn Home() -> Element
#[component] #[component]
pub fn PageNotFound(route: Vec<String>) -> Element pub fn PageNotFound(route: Vec<String>) -> Element
{ {
rsx! rsx! {
{
h1 { "Page not found" } h1 { "Page not found" }
p { "We are terribly sorry, but the page you requested doesn't exist." } p { "We are terribly sorry, but the page you requested doesn't exist." }
pre { color: "red", "log:\nattemped to navigate to: {route:?}" } pre { color: "red", "log:\nattemped to navigate to: {route:?}" }
@ -94,7 +83,6 @@ fn Navbar() -> Element
#[derive(Debug, Clone, Routable, PartialEq)] #[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip] #[rustfmt::skip]
pub enum Page pub enum Page

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loreweaver" name = "loreweaver"
version = "0.3.0" version = "0.3.1"
edition = "2024" edition = "2024"
description = "Converts a blog repository into an SQLite database using the Tavern blog system." description = "Converts a blog repository into an SQLite database using the Tavern blog system."
repository = "/CyberMages/tavern" repository = "/CyberMages/tavern"

View File

@ -3,12 +3,15 @@
/// The environment variable defined by Cargo for the name. /// The environment variable defined by Cargo for the name.
#[allow(dead_code)]
const NAME: Option<&str> = option_env!("CARGO_PKG_NAME"); const NAME: Option<&str> = option_env!("CARGO_PKG_NAME");
/// The environment variable defined by Cargo for the version. /// The environment variable defined by Cargo for the version.
#[allow(dead_code)]
const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
/// The string to display if a value is not defined during compile time. /// The string to display if a value is not defined during compile time.
#[allow(dead_code)]
const NOT_DEFINED: &'static str = "UNDEFINED"; 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. /// 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. /// If a value is not found, then it will return the not defined value.
#[allow(dead_code)]
pub fn get_name() -> &'static str pub fn get_name() -> &'static str
{ {
NAME.unwrap_or(NOT_DEFINED) 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. /// 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. /// If a value is not found, then it will return the not defined value.
#[allow(dead_code)]
pub fn get_version() -> &'static str pub fn get_version() -> &'static str
{ {
VERSION.unwrap_or(NOT_DEFINED) VERSION.unwrap_or(NOT_DEFINED)