diff --git a/blog_test/.gitignore b/blog_test/.gitignore new file mode 100644 index 0000000..80aab8e --- /dev/null +++ b/blog_test/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target +.DS_Store + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/blog_test/Cargo.toml b/blog_test/Cargo.toml new file mode 100644 index 0000000..da9542b --- /dev/null +++ b/blog_test/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "blog_test" +version = "0.1.0" +authors = ["Myrddin Dundragon "] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +axum = { version = "0.7.0", optional = true } +axum-server = { version = "0.7.1", optional = true } +dioxus = { version = "*", features = ["router", "fullstack"] } +dioxus-cli-config = { version = "*", optional = true } +bard = { version = "*", path="../bard", optional = true } +tokio = { version = "1.0", optional = true } + +[features] +default = ["web"] +web = ["dioxus/web", "bard"] +server = ["dioxus/server", "axum", "axum-server", "tokio/rt-multi-thread", "tokio/macros", "dioxus-cli-config", "bard/server"] + +[profile.wasm-dev] +inherits = "dev" +opt-level = 1 + +[profile.server-dev] +inherits = "dev" + +[profile.android-dev] +inherits = "dev" diff --git a/blog_test/Dioxus.toml b/blog_test/Dioxus.toml new file mode 100644 index 0000000..0d5db48 --- /dev/null +++ b/blog_test/Dioxus.toml @@ -0,0 +1,21 @@ +[application] + +[web.app] + +# HTML title tag content +title = "blog_test" + +# include `assets` in web platform +[web.resource] + +# Additional CSS style files +style = [] + +# Additional JavaScript files +script = [] + +[web.resource.dev] + +# Javascript code file +# serve: [dev-server] only +script = [] diff --git a/blog_test/README.md b/blog_test/README.md new file mode 100644 index 0000000..2685c0a --- /dev/null +++ b/blog_test/README.md @@ -0,0 +1,25 @@ +# Development + +Your new bare-bones project includes minimal organization with a single `main.rs` file and a few assets. + +``` +project/ +├─ assets/ # Any assets that are used by the app should be placed here +├─ src/ +│ ├─ main.rs # main.rs is the entry point to your application and currently contains all components for the app +├─ Cargo.toml # The Cargo.toml file defines the dependencies and feature flags for your project +``` + +### Serving Your App + +Run the following command in the root of your project to start developing with the default platform: + +```bash +dx serve --platform web +``` + +To run for a different platform, use the `--platform platform` flag. E.g. +```bash +dx serve --platform desktop +``` + diff --git a/blog_test/assets/favicon.ico b/blog_test/assets/favicon.ico new file mode 100644 index 0000000..eed0c09 Binary files /dev/null and b/blog_test/assets/favicon.ico differ diff --git a/blog_test/assets/header.svg b/blog_test/assets/header.svg new file mode 100644 index 0000000..59c96f2 --- /dev/null +++ b/blog_test/assets/header.svg @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/blog_test/assets/main.css b/blog_test/assets/main.css new file mode 100644 index 0000000..4314613 --- /dev/null +++ b/blog_test/assets/main.css @@ -0,0 +1,107 @@ +/* App-wide styling */ +body { + background-color: #0f1116; + color: #ffffff; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + margin: 20px; +} + +#hero { + margin: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +#links { + width: 400px; + text-align: left; + font-size: x-large; + color: white; + display: flex; + flex-direction: column; +} + +#links a { + color: white; + text-decoration: none; + margin-top: 20px; + margin: 10px 0px; + border: white 1px solid; + border-radius: 5px; + padding: 10px; +} + +#links a:hover { + background-color: #1f1f1f; + cursor: pointer; +} + +#header { + max-width: 1200px; +} + +/* Navbar */ +#navbar { + display: flex; + flex-direction: row; + } + +#navbar a { + color: #ffffff; + margin-right: 20px; + text-decoration: none; + transition: color 0.2s ease; +} + +#navbar a:hover { + cursor: pointer; + color: #91a4d2; +} + +/* Blog page */ +#blog { + margin-top: 50px; + } + +#blog a { + color: #ffffff; + margin-top: 50px; +} + +/* Echo */ +#echo { + width: 360px; + margin-left: auto; + margin-right: auto; + margin-top: 50px; + background-color: #1e222d; + padding: 20px; + border-radius: 10px; +} + +#echo>h4 { + margin: 0px 0px 15px 0px; +} + + +#echo>input { + border: none; + border-bottom: 1px white solid; + background-color: transparent; + color: #ffffff; + transition: border-bottom-color 0.2s ease; + outline: none; + display: block; + padding: 0px 0px 5px 0px; + width: 100%; +} + +#echo>input:focus { + border-bottom-color: #6d85c6; +} + +#echo>p { + margin: 20px 0px 0px auto; +} \ No newline at end of file diff --git a/blog_test/clippy.toml b/blog_test/clippy.toml new file mode 100644 index 0000000..40456af --- /dev/null +++ b/blog_test/clippy.toml @@ -0,0 +1,8 @@ +await-holding-invalid-types = [ + "generational_box::GenerationalRef", + { path = "generational_box::GenerationalRef", reason = "Reads should not be held over an await point. This will cause any writes to fail while the await is pending since the read borrow is still active." }, + "generational_box::GenerationalRefMut", + { path = "generational_box::GenerationalRefMut", reason = "Write should not be held over an await point. This will cause any reads or writes to fail while the await is pending since the write borrow is still active." }, + "dioxus_signals::Write", + { path = "dioxus_signals::Write", reason = "Write should not be held over an await point. This will cause any reads or writes to fail while the await is pending since the write borrow is still active." }, +] diff --git a/blog_test/src/main.rs b/blog_test/src/main.rs new file mode 100644 index 0000000..02b0fff --- /dev/null +++ b/blog_test/src/main.rs @@ -0,0 +1,116 @@ +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"); + + + +fn main() +{ + #[cfg(feature = "server")] + { + tokio::runtime::Runtime::new() + .unwrap() + .block_on(async move { bard::init_database("/home/myrddin/cybermages/website/tavern.db").await }); + } + + #[cfg(feature = "web")] + dioxus::launch(App); +} + +#[component] +fn App() -> Element +{ + rsx! + { + document::Link { rel: "icon", href: FAVICON } + Router:: {} + } +} + +/// Home page +#[component] +fn Home() -> Element +{ + rsx! + { + h1 { "Blog Test" } + } +} + +/// This is the content for the About page. +#[component] +pub fn PageNotFound(route: Vec) -> Element +{ + 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:?}" } + } +} + +/// Shared navbar component. +#[component] +fn Navbar() -> Element +{ + rsx! { + div { + id: "navbar", + Link { + to: Page::Home {}, + "Home" + } + Link { + to: Page::Bard{ child: bard::Page::Blog { tag: String::from("all") }}, + "Blog" + } + //a { href: "/blog/all", "Blog" } + } + + Outlet:: {} + } +} + + + + +#[derive(Debug, Clone, Routable, PartialEq)] +#[rustfmt::skip] +pub enum Page +{ + #[layout(Navbar)] + #[route("/")] + Home {}, + +// #[nest("/blog")] + #[child("/blog")] + Bard + { + child: bard::Page + }, +// #[end_nest] + + #[route("/:..route")] + PageNotFound { route: Vec } +}