From 0872033b216d12026b503630280a861e035040e8 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 25 Sep 2019 21:25:26 +0100 Subject: [PATCH] Update supported ingredient name and separator characters This is a part of work towards fixing #4 and #3 - this will allow more characters, but doesn't address validation failures. --- lang/en/recipe.lang | 1 + modules/ORB.pm | 4 ++-- templates/default/edit/content.tem | 4 ++-- templates/default/edit/ingredient.tem | 2 +- templates/default/edit/separator.tem | 2 +- templates/default/js/new.js | 8 +++++++- templates/default/new/content.tem | 4 ++-- templates/default/new/ingredient.tem | 2 +- templates/default/new/separator.tem | 2 +- 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lang/en/recipe.lang b/lang/en/recipe.lang index a22026d..d3b476f 100644 --- a/lang/en/recipe.lang +++ b/lang/en/recipe.lang @@ -52,6 +52,7 @@ RECIPE_ING_ING_PH = Ingredient RECIPE_ING_NOTE_PH = Notes RECIPE_ING_SEP_PH = Separator text RECIPE_ING_DELETE = Delete +RECIPE_ING_FORMAT = Ingredient names and separators may only contain alphanumrics, -, _, comma, period, colon, semi-colon, parenthesis, ampersand, octothorpe, * and backslash RECIPE_METHOD = Method RECIPE_NOTES = Notes diff --git a/modules/ORB.pm b/modules/ORB.pm index 2fd3fdc..1227932 100755 --- a/modules/ORB.pm +++ b/modules/ORB.pm @@ -77,8 +77,8 @@ sub new { "recipename" => '^[-\w,. ]+$', "tags" => '^[-\w ]+$', "quantity" => '^[\d\w./]+$', - "sepname" => '^[-\w,. ]{1,255}$', - "ingredient" => '^[-\w,. ]{1,255}$', + "sepname" => '^[-\w,.:()&;#*\ ]{1,255}$', + "ingredient" => '^[-\w,.:()&;#*\ ]{1,255}$', "notes" => '^[-()\w,."!\'\\/£$%;:@#?><* ]{1,255}$', }; diff --git a/templates/default/edit/content.tem b/templates/default/edit/content.tem index 5dc7b36..7238b94 100644 --- a/templates/default/edit/content.tem +++ b/templates/default/edit/content.tem @@ -126,7 +126,7 @@
- +
@@ -139,7 +139,7 @@
  • - +
    diff --git a/templates/default/edit/ingredient.tem b/templates/default/edit/ingredient.tem index ad3f5e4..c7db371 100644 --- a/templates/default/edit/ingredient.tem +++ b/templates/default/edit/ingredient.tem @@ -14,7 +14,7 @@
    - +
    diff --git a/templates/default/edit/separator.tem b/templates/default/edit/separator.tem index bbd2fcf..438ea97 100644 --- a/templates/default/edit/separator.tem +++ b/templates/default/edit/separator.tem @@ -1,7 +1,7 @@
  • - +
    diff --git a/templates/default/js/new.js b/templates/default/js/new.js index 3319b83..43e004f 100644 --- a/templates/default/js/new.js +++ b/templates/default/js/new.js @@ -42,6 +42,10 @@ function add_ingredient(count) function build_ingdata() { + if(!document.forms['recipeform'].reportValidity()) { + return false; + } + var values = new Array(); // Go through all the children of the ingredient list @@ -72,6 +76,8 @@ function build_ingdata() }); $('#ingdata').val(JSON.stringify({ "ingredients": values })); + + return true; } @@ -140,5 +146,5 @@ $(function() { }); // Build the ingredient list before submitting - $('#recipeform').on('submit', function() { build_ingdata(); return true }); + $('#recipeform').on('submit', function() { return build_ingdata(); }); }); diff --git a/templates/default/new/content.tem b/templates/default/new/content.tem index e8350be..309be39 100644 --- a/templates/default/new/content.tem +++ b/templates/default/new/content.tem @@ -126,7 +126,7 @@
    - +
    @@ -139,7 +139,7 @@
  • - +
    diff --git a/templates/default/new/ingredient.tem b/templates/default/new/ingredient.tem index ad3f5e4..c7db371 100644 --- a/templates/default/new/ingredient.tem +++ b/templates/default/new/ingredient.tem @@ -14,7 +14,7 @@
    - +
    diff --git a/templates/default/new/separator.tem b/templates/default/new/separator.tem index bbd2fcf..438ea97 100644 --- a/templates/default/new/separator.tem +++ b/templates/default/new/separator.tem @@ -1,7 +1,7 @@
  • - +