From eca4820fd21eddc43a7bfa803c28c3e58a91250c Mon Sep 17 00:00:00 2001 From: didier amyot Date: Sat, 11 Feb 2023 06:57:25 -0500 Subject: [PATCH] Migrated all resources into the resources' directory. --- README.md | 2 +- {migrations => resources/migrations}/avro/events.ts | 0 .../migrations}/sql/create_tables_001.sql | 0 {templates => resources/templates}/actions.html | 0 {templates => resources/templates}/base.html | 0 {templates => resources/templates}/components/navbar.html | 0 {templates => resources/templates}/index.html | 0 {templates => resources/templates}/overview.html | 0 .../templates}/partials/actions/create_security.html | 0 .../templates}/partials/actions/create_user.html | 0 .../templates}/partials/actions/submit_button.html | 0 .../templates}/partials/v1/event_processed.html | 0 .../templates}/static/embedded-json-enc.js | 0 src/migration.rs | 2 +- src/webui/mod.rs | 2 +- src/webui/views.rs | 4 ---- 16 files changed, 3 insertions(+), 7 deletions(-) rename {migrations => resources/migrations}/avro/events.ts (100%) rename {migrations => resources/migrations}/sql/create_tables_001.sql (100%) rename {templates => resources/templates}/actions.html (100%) rename {templates => resources/templates}/base.html (100%) rename {templates => resources/templates}/components/navbar.html (100%) rename {templates => resources/templates}/index.html (100%) rename {templates => resources/templates}/overview.html (100%) rename {templates => resources/templates}/partials/actions/create_security.html (100%) rename {templates => resources/templates}/partials/actions/create_user.html (100%) rename {templates => resources/templates}/partials/actions/submit_button.html (100%) rename {templates => resources/templates}/partials/v1/event_processed.html (100%) rename {templates => resources/templates}/static/embedded-json-enc.js (100%) diff --git a/README.md b/README.md index 5b3f38b..6c822bd 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ nix develop #### Architecture -* [ ] put all the ressources (migrations, templates and statics) into a ressources directory +* [x] put all the ressources (migrations, templates and statics) into a ressources directory #### Backend diff --git a/migrations/avro/events.ts b/resources/migrations/avro/events.ts similarity index 100% rename from migrations/avro/events.ts rename to resources/migrations/avro/events.ts diff --git a/migrations/sql/create_tables_001.sql b/resources/migrations/sql/create_tables_001.sql similarity index 100% rename from migrations/sql/create_tables_001.sql rename to resources/migrations/sql/create_tables_001.sql diff --git a/templates/actions.html b/resources/templates/actions.html similarity index 100% rename from templates/actions.html rename to resources/templates/actions.html diff --git a/templates/base.html b/resources/templates/base.html similarity index 100% rename from templates/base.html rename to resources/templates/base.html diff --git a/templates/components/navbar.html b/resources/templates/components/navbar.html similarity index 100% rename from templates/components/navbar.html rename to resources/templates/components/navbar.html diff --git a/templates/index.html b/resources/templates/index.html similarity index 100% rename from templates/index.html rename to resources/templates/index.html diff --git a/templates/overview.html b/resources/templates/overview.html similarity index 100% rename from templates/overview.html rename to resources/templates/overview.html diff --git a/templates/partials/actions/create_security.html b/resources/templates/partials/actions/create_security.html similarity index 100% rename from templates/partials/actions/create_security.html rename to resources/templates/partials/actions/create_security.html diff --git a/templates/partials/actions/create_user.html b/resources/templates/partials/actions/create_user.html similarity index 100% rename from templates/partials/actions/create_user.html rename to resources/templates/partials/actions/create_user.html diff --git a/templates/partials/actions/submit_button.html b/resources/templates/partials/actions/submit_button.html similarity index 100% rename from templates/partials/actions/submit_button.html rename to resources/templates/partials/actions/submit_button.html diff --git a/templates/partials/v1/event_processed.html b/resources/templates/partials/v1/event_processed.html similarity index 100% rename from templates/partials/v1/event_processed.html rename to resources/templates/partials/v1/event_processed.html diff --git a/templates/static/embedded-json-enc.js b/resources/templates/static/embedded-json-enc.js similarity index 100% rename from templates/static/embedded-json-enc.js rename to resources/templates/static/embedded-json-enc.js diff --git a/src/migration.rs b/src/migration.rs index 8979659..db84188 100644 --- a/src/migration.rs +++ b/src/migration.rs @@ -94,7 +94,7 @@ fn check_migration(tx: &Transaction, id: usize, migration: &String) -> Result<() fn get_migrations() -> Vec { let mut ret = Vec::new(); ret.push( - resource_str!("migrations/sql/create_tables_001.sql") + resource_str!("resources/migrations/sql/create_tables_001.sql") .as_ref() .to_string(), ); diff --git a/src/webui/mod.rs b/src/webui/mod.rs index 4cdb935..9bc2ba5 100644 --- a/src/webui/mod.rs +++ b/src/webui/mod.rs @@ -76,7 +76,7 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io let tmpl_reloader = AutoReloader::new(move |notifier| { let mut env: minijinja::Environment<'static> = minijinja::Environment::new(); - let tmpl_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("templates"); + let tmpl_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("resources/templates"); log::info!("Using template dir {:?}", tmpl_path); // if watch_path is never called, no fs watcher is created diff --git a/src/webui/views.rs b/src/webui/views.rs index e676af4..6538206 100644 --- a/src/webui/views.rs +++ b/src/webui/views.rs @@ -56,8 +56,6 @@ pub async fn actions_partials( tmpl_env.render(template_location.as_str(), ctx) } - - #[actix_web::get("/static/{file_name}")] pub async fn static_file( req: HttpRequest @@ -69,8 +67,6 @@ pub async fn static_file( } - - #[derive(Deserialize, Debug)] struct Event1{ name: String,