From 747db9602d5d37334709319f2edbcfac9820b1d2 Mon Sep 17 00:00:00 2001 From: eraden Date: Fri, 22 Nov 2024 21:42:41 +0100 Subject: [PATCH] Add tmpl.js --- cooked/src/routes.rs | 8 ++ cooked/templates/base.jinja | 1 + cooked/templates/recipies/create_form.jinja | 7 ++ .../templates/recipies/ingredients-list.jinja | 35 +++++++++ cooked/templates/tmpl.js | 75 +++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 cooked/templates/recipies/ingredients-list.jinja create mode 100644 cooked/templates/tmpl.js diff --git a/cooked/src/routes.rs b/cooked/src/routes.rs index fcd76e7..6032704 100644 --- a/cooked/src/routes.rs +++ b/cooked/src/routes.rs @@ -1349,6 +1349,13 @@ pub async fn health() -> HttpResponse { HttpResponse::Ok().finish() } +#[get("/tmpl.js")] +async fn tmpl() -> HttpResponse { + HttpResponse::Ok() + .append_header(("Content-Type", "application/javascript")) + .body(include_str!("../templates/tmpl.js").to_string()) +} + pub fn configure(config: &mut actix_web::web::ServiceConfig) { tmp_cleanup(); @@ -1374,5 +1381,6 @@ pub fn configure(config: &mut actix_web::web::ServiceConfig) { .service(no_ads) .service(no_sellers) .service(health) + .service(tmpl) .service(Files::new("/assets", "./assets")); } diff --git a/cooked/templates/base.jinja b/cooked/templates/base.jinja index 683a6cb..ff727f1 100644 --- a/cooked/templates/base.jinja +++ b/cooked/templates/base.jinja @@ -6,6 +6,7 @@ + Cooked {% block head %}{% endblock %} diff --git a/cooked/templates/recipies/create_form.jinja b/cooked/templates/recipies/create_form.jinja index de58ed2..a52694c 100644 --- a/cooked/templates/recipies/create_form.jinja +++ b/cooked/templates/recipies/create_form.jinja @@ -42,6 +42,10 @@ + + {% include "recipies/ingredients-list.jinja" %} + +
{% for ingredient in known_ingredients %} {% endfor %}
+
+ {% include "recipies/ingredients-list.jinja" %} +
Ingeredients should be listed as list of AMOUNT UNIT INGEREDIENT. Example: diff --git a/cooked/templates/recipies/ingredients-list.jinja b/cooked/templates/recipies/ingredients-list.jinja new file mode 100644 index 0000000..ea07f66 --- /dev/null +++ b/cooked/templates/recipies/ingredients-list.jinja @@ -0,0 +1,35 @@ +
+ + + + + +
diff --git a/cooked/templates/tmpl.js b/cooked/templates/tmpl.js new file mode 100644 index 0000000..384010a --- /dev/null +++ b/cooked/templates/tmpl.js @@ -0,0 +1,75 @@ +/** + *