diff --git a/.gitignore b/.gitignore index 807d687..3399b78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ # Devfiles .devfiles/bin/**/* -public/assets/** -public/.vite #### -- TEMPLATES BEGIN -- #### @@ -111,6 +109,7 @@ dist # vuepress v2.x temp and cache directory .temp +.cache # Docusaurus cache and generated files .docusaurus @@ -146,3 +145,4 @@ dist # Added by cargo /target +.env diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/QuickJinja_project.xml b/.idea/QuickJinja_project.xml deleted file mode 100644 index 76760d4..0000000 --- a/.idea/QuickJinja_project.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/biome.xml b/.idea/biome.xml deleted file mode 100644 index 8fa01ec..0000000 --- a/.idea/biome.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/bun.xml b/.idea/bun.xml deleted file mode 100644 index 56b40f0..0000000 --- a/.idea/bun.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/compendium.iml b/.idea/compendium.iml deleted file mode 100644 index cf84ae4..0000000 --- a/.idea/compendium.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index 9567d63..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - postgresql - true - org.postgresql.Driver - jdbc:postgresql://localhost/compendium - $ProjectFileDir$ - - - \ No newline at end of file diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml deleted file mode 100644 index 5f28118..0000000 --- a/.idea/dictionaries/project.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - endblock - htmx - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index fefa8f5..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 99958cd..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Dev.xml b/.idea/runConfigurations/Dev.xml deleted file mode 100644 index a76dce5..0000000 --- a/.idea/runConfigurations/Dev.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Run_with_vite.xml b/.idea/runConfigurations/Run_with_vite.xml deleted file mode 100644 index e695ac0..0000000 --- a/.idea/runConfigurations/Run_with_vite.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Vite_Dev_Server.xml b/.idea/runConfigurations/Vite_Dev_Server.xml deleted file mode 100644 index 63cf301..0000000 --- a/.idea/runConfigurations/Vite_Dev_Server.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - {% endif %} - - + + + + - {% block title %}Axum web service!{% endblock %} + {% block title %}Axum web service!{% endblock %} - + - -
- {% include "partials/header.html" ignore missing %} -
-
- {% block content %}{% endblock %} -
-
- {% include "partials/footer.html" ignore missing %} -
- + +
+ {% include "partials/header.html" ignore missing %} +
+
+ {% block content %}{% endblock %} +
+
+ {% include "partials/footer.html" ignore missing %} +
+ diff --git a/frontend/templates/partials/header.html b/frontend/templates/partials/header.html index e6060c8..e69de29 100644 --- a/frontend/templates/partials/header.html +++ b/frontend/templates/partials/header.html @@ -1,35 +0,0 @@ - diff --git a/package.json b/package.json index 0988d01..5fbe37b 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,18 @@ { - "name": "compendium", - "module": "index.ts", - "version": "0.1.1", - "scripts": { - "dev": "vite", - "build": "vite build" - }, - "devDependencies": { - "@alecodes/tmpl-build-and-load": "^0.1.3", - "@biomejs/biome": "1.9.4", - "@types/bun": "^1.2.10", - "sass-embedded": "^1.86.3", - "vite": "^6.3.1" - }, - "peerDependencies": { - "typescript": "^5.7.3" - }, - "type": "module", - "dependencies": { - "@mini-strap/core": "^0.1.2", - "@picocss/pico": "^2.1.1", - "feather-icons": "^4.29.2", - "htmx.org": "2.0.4" - } + "name": "compendium", + "module": "index.ts", + "version": "0.1.0", + "devDependencies": { + "@alecodes/tmpl-build-and-load": "^0.1.3", + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "type": "module", + "dependencies": { + "@mini-strap/core": "^0.1.2", + "@picocss/pico": "^2.1.1", + "htmx.org": "2.0.4" + } } diff --git a/public/.gitkeep b/public/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/assets/.gitkeep b/public/assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/config.rs b/src/config.rs index daff0d9..7fde8e0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -40,12 +40,12 @@ impl Default for DBConfig { } impl DBConfig { - pub fn generate_db_string(&self, obfuscate: bool) -> Result { + pub fn generate_db_string(&self, ofuscate: bool) -> Result { if let Some(value) = &self.string { return Ok(value.clone()); } - let db_password = if obfuscate { + let db_password = if ofuscate { let mut db_password = self .password .clone() @@ -84,7 +84,6 @@ impl DBConfig { pub struct Config { pub db: DBConfig, pub addr: SocketAddr, - pub public_dir: PathBuf, } impl Default for Config { @@ -92,7 +91,6 @@ impl Default for Config { Config { db: DBConfig::default(), addr: "0.0.0.0:3000".parse().unwrap(), - public_dir: PathBuf::from("public"), } } } diff --git a/src/error.rs b/src/error.rs index a1c55bf..5bef9fb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -22,9 +22,6 @@ pub enum Error { #[error(transparent)] Env(#[from] std::env::VarError), - #[error(transparent)] - JsonParse(#[from] serde_json::Error), - #[error(transparent)] Template(#[from] minijinja::Error), diff --git a/src/lib.rs b/src/lib.rs index 5ba886b..109a915 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,23 +1,34 @@ -pub mod static_assets; pub mod config; mod error; pub mod router; -use crate::static_assets::Assets; use axum::extract::FromRef; pub use error::{Error, Result, ResultTemplate}; +use minijinja::{Environment, Template}; +use serde::{Deserialize, Serialize}; pub type Tx = axum_sqlx_tx::Tx; pub type TxState = axum_sqlx_tx::State; +#[derive(Serialize, Deserialize, Debug)] +pub struct Link { + pub path: String, + pub text: String, + pub subpages: Vec, +} + #[derive(Clone, FromRef)] pub struct AppState { - pub assets: Assets, - pub tx: TxState, + tmpl_env: Environment<'static>, + tx: TxState, } impl AppState { - pub fn new(assets: Assets, tx: TxState) -> Self { - AppState { assets, tx } + pub fn new(tmpl_env: Environment<'static>, tx: TxState) -> Self { + AppState { tmpl_env, tx } + } + + pub fn get_template(&self, name: &str) -> Result