From fa8af5596f585619b2ffa6bb1d0c463c85a48848 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 27 May 2025 16:53:10 +0200 Subject: [PATCH] various fixes and improvements --- Dockerfile | 4 +- cookbook/helper/recipe_url_import.py | 6 +- docs/system/configuration.md | 6 + recipes/settings.py | 2 +- vue3/src/apps/tandoor/Tandoor.vue | 7 +- vue3/src/apps/tandoor/main.ts | 4 +- .../components/dialogs/MessageListDialog.vue | 2 +- .../dialogs/StepIngredientSorterDialog.vue | 3 +- .../components/display/VSnackbarQueued.vue | 2 +- vue3/src/components/inputs/StepEditor.vue | 19 +- .../components/model_editors/RecipeEditor.vue | 5 +- .../composables/useModelEditorFunctions.ts | 1 - vue3/src/locales/ar.json | 6 + vue3/src/locales/bg.json | 6 + vue3/src/locales/ca.json | 6 + vue3/src/locales/cs.json | 6 + vue3/src/locales/da.json | 6 + vue3/src/locales/de.json | 6 + vue3/src/locales/el.json | 6 + vue3/src/locales/en.json | 6 + vue3/src/locales/es.json | 6 + vue3/src/locales/fi.json | 6 + vue3/src/locales/fr.json | 6 + vue3/src/locales/he.json | 6 + vue3/src/locales/hu.json | 6 + vue3/src/locales/hy.json | 6 + vue3/src/locales/id.json | 6 + vue3/src/locales/is.json | 6 + vue3/src/locales/it.json | 6 + vue3/src/locales/lt.json | 6 + vue3/src/locales/nb_NO.json | 6 + vue3/src/locales/nl.json | 6 + vue3/src/locales/pl.json | 6 + vue3/src/locales/pt.json | 6 + vue3/src/locales/pt_BR.json | 6 + vue3/src/locales/ro.json | 6 + vue3/src/locales/ru.json | 6 + vue3/src/locales/sl.json | 6 + vue3/src/locales/sv.json | 6 + vue3/src/locales/tr.json | 6 + vue3/src/locales/uk.json | 6 + vue3/src/locales/zh_Hans.json | 6 + vue3/src/locales/zh_Hant.json | 6 + vue3/src/pages/ModelEditPage.vue | 13 +- vue3/src/pages/PropertyEditorPage.vue | 10 +- vue3/src/pages/RecipeImportPage.vue | 169 ++++++++++++++++-- vue3/src/stores/MessageStore.ts | 9 + 47 files changed, 410 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index c58cf28ea..15e8ca852 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.13-alpine3.21 #Install all dependencies. -RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap git +RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap git libgcc libstdc++ #Print all logs without buffering it. ENV PYTHONUNBUFFERED 1 @@ -24,7 +24,7 @@ RUN \ # remove Development dependencies from requirements.txt RUN sed -i '/# Development/,$d' requirements.txt -RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev libgcc libstdc++ cargo openldap-dev python3-dev xmlsec-dev xmlsec build-base g++ curl && \ +RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev cargo openldap-dev python3-dev xmlsec-dev xmlsec build-base g++ curl && \ echo -n "INPUT ( libldap.so )" > /usr/lib/libldap_r.so && \ python -m venv venv && \ /opt/recipes/venv/bin/python -m pip install --upgrade pip && \ diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 32560fafc..4b543e359 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -491,7 +491,11 @@ def get_images_from_soup(soup, url): u = u.split('?')[0] filename = re.search(r'/([\w_-]+[.](jpg|jpeg|gif|png))$', u) if filename: - if (('http' not in u) and (url)): + if u.startswith('//'): + # urls from e.g. ottolenghi.co.uk start with // + u = 'https:' + u + if ('http' not in u) and url: + print(f'rewriting URL {u}') # sometimes an image source can be relative # if it is provide the base url u = '{}://{}{}'.format(prot, site, u) diff --git a/docs/system/configuration.md b/docs/system/configuration.md index 5ac6afd9e..2dacc1049 100644 --- a/docs/system/configuration.md +++ b/docs/system/configuration.md @@ -300,6 +300,12 @@ PRIVACY_URL= IMPRINT_URL= ``` +#### Rate Limits + +There are some rate limits that can be configured. + +- RATELIMIT_URL_IMPORT_REQUESTS: limit the number of external URL import requests. Useful to prevent your server from being abused for malicious requests. + ### Authentication All configurable variables regarding authentication. diff --git a/recipes/settings.py b/recipes/settings.py index 1540abfda..b33747ffc 100644 --- a/recipes/settings.py +++ b/recipes/settings.py @@ -141,7 +141,7 @@ AI_RATELIMIT = os.getenv('AI_RATELIMIT', '60/hour') SHARING_ABUSE = extract_bool('SHARING_ABUSE', False) SHARING_LIMIT = int(os.getenv('SHARING_LIMIT', 0)) -DRF_THROTTLE_RECIPE_URL_IMPORT = os.getenv('DRF_THROTTLE_RECIPE_URL_IMPORT', '60/hour') +DRF_THROTTLE_RECIPE_URL_IMPORT = os.getenv('DRF_THROTTLE_RECIPE_URL_IMPORT', os.getenv('RATELIMIT_URL_IMPORT_REQUESTS', '60/hour')) TERMS_URL = os.getenv('TERMS_URL', '') PRIVACY_URL = os.getenv('PRIVACY_URL', '') diff --git a/vue3/src/apps/tandoor/Tandoor.vue b/vue3/src/apps/tandoor/Tandoor.vue index ea163dadb..87952890a 100644 --- a/vue3/src/apps/tandoor/Tandoor.vue +++ b/vue3/src/apps/tandoor/Tandoor.vue @@ -4,7 +4,7 @@ - + @@ -120,7 +120,7 @@ {{ useUserPreferenceStore().activeSpace.name }} - + @@ -144,7 +144,7 @@ - + @@ -163,6 +163,7 @@ + diff --git a/vue3/src/apps/tandoor/main.ts b/vue3/src/apps/tandoor/main.ts index e68c7b506..7d315a4b9 100644 --- a/vue3/src/apps/tandoor/main.ts +++ b/vue3/src/apps/tandoor/main.ts @@ -14,8 +14,8 @@ import {setupI18n} from "@/i18n"; import MealPlanPage from "@/pages/MealPlanPage.vue"; const routes = [ - {path: '/', component: () => import("@/pages/StartPage.vue"), name: 'view_home'}, - {path: '/search', redirect: {name: 'view_home'}}, + {path: '/', component: () => import("@/pages/StartPage.vue"), name: 'StartPage'}, + {path: '/search', redirect: {name: 'StartPage'}}, {path: '/test', component: () => import("@/pages/TestPage.vue"), name: 'view_test'}, {path: '/help', component: () => import("@/pages/HelpPage.vue"), name: 'HelpPage'}, { diff --git a/vue3/src/components/dialogs/MessageListDialog.vue b/vue3/src/components/dialogs/MessageListDialog.vue index 201b1816c..9a408e840 100644 --- a/vue3/src/components/dialogs/MessageListDialog.vue +++ b/vue3/src/components/dialogs/MessageListDialog.vue @@ -165,7 +165,7 @@ const showDetailDialog = ref(false) */ function addTestMessage() { let types = [MessageType.SUCCESS, MessageType.ERROR, MessageType.INFO, MessageType.WARNING] - useMessageStore().addMessage(types[Math.floor(Math.random() * types.length)], {title: 'Test', text: `Lorem Ipsum ${Math.random() * 1000}`}, 5000, {json: "data", 'msg': 'whatever', data: 1}) + useMessageStore().addMessage(types[Math.floor(Math.random() * types.length)], {title: 'Test', text: `Lorem Ipsum Lorem Ipsum Lorem Ipsum LINEBREAK \n Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum ${Math.random() * 1000}`}, 5000, {json: "data", 'msg': 'whatever', data: 1}) } diff --git a/vue3/src/components/dialogs/StepIngredientSorterDialog.vue b/vue3/src/components/dialogs/StepIngredientSorterDialog.vue index 5d9ee212a..eba616a58 100644 --- a/vue3/src/components/dialogs/StepIngredientSorterDialog.vue +++ b/vue3/src/components/dialogs/StepIngredientSorterDialog.vue @@ -8,6 +8,7 @@ :sub-title="ingredientToString(step.ingredients[editingIngredientIndex])"> - {{ $t('Step') }} + {{ $t('MoveToStep') }} {{ i + 1 }} {{ s.name }} diff --git a/vue3/src/components/display/VSnackbarQueued.vue b/vue3/src/components/display/VSnackbarQueued.vue index 819ee140c..b8f62ac5f 100644 --- a/vue3/src/components/display/VSnackbarQueued.vue +++ b/vue3/src/components/display/VSnackbarQueued.vue @@ -12,7 +12,7 @@ >

{{ visibleMessage.msg.title }}

- {{ visibleMessage.msg.text }} + {{ visibleMessage.msg.text }}