From e11577f7867a5f232d09ac1444315b24e17ec95a Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 9 Apr 2021 08:59:24 -0800 Subject: [PATCH] Fix Docker Init Scripts (#277) * fix links * actually fix #238 * Feature/mkdocs version bump (#240) * fix links (#239) Co-authored-by: hay-kot * fix #238 * bump mkdocs version * light/dark toggle * light/dark mode css * API_DOCS defaults to True * disable build on push for master Co-authored-by: hay-kot * Feature/recipe viewer (#244) * fix dialog placement * markdown support in ingredients * fix line render issue * fix tag rendering bug * change ingredients to text area * no slug error * add tag pages * remove console.logs Co-authored-by: hay-kot * changelog v0.4.1 * bug/backup-download (#245) * fix blocked download * + download blocked Co-authored-by: hay-kot * Feature/meal planner (#246) * fixes duplicate recipes in meal-plan #221 * add quick week option * scope css * add mealplanner info Co-authored-by: hay-kot * Nextcloud Import Bugs - #248 (#250) * parses datetime properly + clean category - #248 * add default credentials to docs Co-authored-by: hay-kot * Add bulk import examples to docs. (#252) * Add bulk import examples to docs. * Update api-usage.md * Add Python example for bulk import. * Change IP address in API example. * Refactor/app settings (#251) * fix env setup bugs * remove unused import * fix layout issues * changelog Co-authored-by: hay-kot * env setup fixes * Feature/about api (#253) * fix settings * app info cleanup Co-authored-by: hay-kot * Feature/image minify (#256) * fix settings * app info cleanup * bottom-bar experiment * remove dup key * type hints * add dependency * updated image with query parameters * read image options * add image minification * add image minification step * alt image routes * add image minification * set mobile bar to top Co-authored-by: hay-kot * Feature/additional endpoints (#257) * new recipe summary route * add categories to cards * add pillow * show tags instead of categories * additional debug info * add todays meal image url * about page * fix reactive tag * changelog + docs * bump version Co-authored-by: hay-kot * add pillow dependencies (#258) Co-authored-by: hay-kot * Feature/search page (#259) * add pillow dependencies * advanced search page * advanced search apge * remove extra dependencies * add pre-run script Co-authored-by: hay-kot * no image assignment * advanced search * fix docker dev build * Do not force theme settings on login form (#260) * Fix docker dev db persistence (#264) * Fix docker dev db persistence * Make run.sh the only startup script for prod + dev Credits to @hay-kot for run.sh script logic * Restore dev backend initialization in non-docker setup * Make run.sh POSIX-friendly * Allow dev backend to auto-reload in Docker * Frontend Refactor + Bug Fixes * merge category and tag selector * unifiy category selector * add hint * spacing * fix nextcloud migration * simplify email validator #261 * formatting * cleanup * auto-gen * format * update run script * unified category/tag selector * rename component * Add advanced search link * remove old code * convert keywords to tags * add proper behavior on rename * proper image name association on rename * fix test cleanup * changelog * set docker comppand * minify on migration Co-authored-by: hay-kot * bug-fixes/category-tag-creator (#266) * fix category labels * set loader for migration * v0.4.1 Co-authored-by: hay-kot * Hot Fix (#269) * fix category labels * set loader for migration * v0.4.1 * reorganize API docs Co-authored-by: hay-kot * Fix some pytests (#265) * Fix encoding issue in cleaner unit test * Add VS Code task to run pytests * Fix FileExistsError when running Windows * Add Portuguese Translation (#232) * Add Portuguese Translation * add portuguese translation option * formatting * add missing } * specify absolute path Co-authored-by: hay-kot Co-authored-by: Nat Co-authored-by: sephrat <34862846+sephrat@users.noreply.github.com> Co-authored-by: Pedro Mata Rodrigues --- .vscode/tasks.json | 9 ++ Dockerfile | 2 +- frontend/src/locales/pt-PT.json | 160 +++++++++++++++++++++++++ frontend/src/store/modules/language.js | 10 +- mealie/run.sh | 6 +- mealie/services/image/minify.py | 5 +- tests/unit_tests/test_cleaner.py | 2 +- 7 files changed, 185 insertions(+), 9 deletions(-) create mode 100644 frontend/src/locales/pt-PT.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9b7582bd1..24b1da2e0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -52,6 +52,15 @@ "group": "groupA" }, "problemMatcher": [] + }, + { + "label": "Run python tests", + "command": "make test", + "type": "shell", + "presentation": { + "reveal": "always" + }, + "problemMatcher": [] } ] } diff --git a/Dockerfile b/Dockerfile index 2528d200b..53025eccd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,9 +40,9 @@ RUN apk add --update --no-cache --virtual .build-deps \ cd /app/ && poetry install --no-root --no-dev && \ apk --purge del .build-deps - COPY ./mealie /app/mealie RUN poetry install --no-dev + COPY ./Caddyfile /app COPY ./dev/data/templates /app/data/templates COPY --from=build-stage /app/dist /app/dist diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.json new file mode 100644 index 000000000..d10b43433 --- /dev/null +++ b/frontend/src/locales/pt-PT.json @@ -0,0 +1,160 @@ +{ + "404": { + "page-not-found": "404 Página não encontrada", + "take-me-home": "Voltar ao início" + }, + "new-recipe": { + "from-url": "Do URL", + "recipe-url": "URL da Receita", + "error-message": "Ocorreu um erro ao ler o URL. Verifica os registos e o debug/last_recipe.json para perceber o que correu mal." , + "bulk-add": "Adicionar Vários", + "paste-in-your-recipe-data-each-line-will-be-treated-as-an-item-in-a-list": "Insira os dados da sua receita. Cada linha será tratada como um item numa lista." + }, + "general": { + "upload": "Enviar", + "submit": "Submeter", + "name": "Nome", + "settings": "Definições", + "close": "Fechar", + "save": "Guardar", + "image-file": "Ficheiro de Imagem", + "update": "Atualizar", + "edit": "Editar", + "delete": "Eliminar", + "select": "Seleccionar", + "random": "Aleatório", + "new": "Novo", + "create": "Criar", + "cancel": "Cancelar", + "ok": "OK", + "enabled": "Ativado", + "download": "Transferir", + "import": "Importar", + "options": "Opções", + "templates": "Templates", + "recipes": "Receitas", + "themes": "Temas", + "confirm": "Confirmar" + }, + "login": { + "stay-logged-in": "Manter a sessão iniciada?", + "email": "Email", + "password": "Password", + "sign-in": "Iniciar Sessão", + "sign-up": "Criar Conta" + }, + "meal-plan": { + "shopping-list": "Lista de Compras", + "dinner-this-week": "Jantar esta semana", + "meal-planner": "Planeador de Refeições", + "dinner-today": "Jantar Hoje", + "planner": "Planeador", + "edit-meal-plan": "Editar Plano de Refeições", + "meal-plans": "Planos de Refeições", + "create-a-new-meal-plan": "Criar novo Plano de Refeições", + "start-date": "Data de Inicio", + "end-date": "Data de Fim" + }, + "recipe": { + "description": "Descrição", + "ingredients": "Ingredientes", + "categories": "Categorias", + "tags": "Etiquetas", + "instructions": "Instruções", + "step-index": "Passo: {step}", + "recipe-name": "Nome da Receita", + "servings": "Porções", + "ingredient": "Ingrediente", + "notes": "Notas", + "note": "Nota", + "original-url": "URL Original", + "view-recipe": "Ver Receita", + "title": "Título", + "total-time": "Tempo Total", + "prep-time": "Tempo de Preparação", + "perform-time": "Tempo de Cozedura", + "api-extras": "Extras API", + "object-key": "Chave do Objeto", + "object-value": "Valor do Objeto", + "new-key-name": "Novo nome da Chave", + "add-key": "Adicionar Chave", + "key-name-required": "Nome da Chave é Obrigatório", + "no-white-space-allowed": "Espaço em Branco não Permitido", + "delete-recipe": "Eliminar Receita", + "delete-confirmation": "Tem a certeza que deseja eliminar esta receita?" + }, + "search": { + "search-mealie": "Pesquisar Mealie" + }, + "settings": { + "general-settings": "Definições Gerais", + "local-api": "API Local", + "language": "Língua", + "add-a-new-theme": "Adicionar novo tema", + "set-new-time": "Definir hora", + "current": "Versão:", + "latest": "Mais Recente", + "explore-the-docs": "Explorar Documentação", + "contribute": "Contribuir", + "backup-and-exports": "Backups", + "backup-info": "Backups are exported in standard JSON format along with all the images stored on the file system. In your backup folder you'll find a .zip file that contains all of the recipe JSON and images from the database. Additionally, if you selected a markdown file, those will also be stored in the .zip file. To import a backup, it must be located in your backups folder. Automated backups are done each day at 3:00 AM.", + "available-backups": "Backups Disponíveis", + "theme": { + "theme-name": "Nome do Tema", + "theme-settings": "Definições do Tema", + "select-a-theme-from-the-dropdown-or-create-a-new-theme-note-that-the-default-theme-will-be-served-to-all-users-who-have-not-set-a-theme-preference": "Selecione um tema da lista ou crie um novo tema. Note que o tema por defeito será utilizado por todos os utilizadores que não selecionaram um tema preferido.", + "dark-mode": "Modo Escuro", + "theme-is-required": "Tema é Obrigatório", + "primary": "Primário", + "secondary": "Secondário", + "accent": "Accent", + "success": "Successo", + "info": "Info", + "warning": "Aviso", + "error": "Erro", + "default-to-system": "Mesmo do Sistema", + "light": "Claro", + "dark": "Escuro", + "theme": "Tema", + "saved-color-theme": "Cor de Tema Guardado", + "delete-theme": "Eliminar Tema", + "are-you-sure-you-want-to-delete-this-theme": "Tem a certeza que deseja eliminar este tema?", + "choose-how-mealie-looks-to-you-set-your-theme-preference-to-follow-your-system-settings-or-choose-to-use-the-light-or-dark-theme": "Escolha como o Mealie estará visivel. Escolha o Mesmo do sistema para seguir o tema do seu dispositivo, ou selecione claro ou escuro.", + "theme-name-is-required": "Nome do Tema é Obrigatório." + }, + "webhooks": { + "meal-planner-webhooks": "Webhooks do Organizador de Refeições", + "the-urls-listed-below-will-recieve-webhooks-containing-the-recipe-data-for-the-meal-plan-on-its-scheduled-day-currently-webhooks-will-execute-at": "Os URLs apresentados abaixo receberão webhooks que contêm os dados da receita para o plano de refeições no dia marcado. Atualmente, os webhooks serão executados a ", + "test-webhooks": "Webhooks de Teste", + "webhook-url": "Webhook URL" + }, + "new-version-available": "Uma nova versão do Mealie está disponível, Visite o Repo ", + "backup": { + "import-recipes": "Importar Receitas", + "import-themes": "Importar Temas", + "import-settings": "Importa Definições", + "create-heading": "Criar um Backup", + "backup-tag": "Etiqueta do Backup", + "full-backup": "Backup Completo", + "partial-backup": "Backup Parcial", + "backup-restore-report": "Análise do Resultado do Backup", + "successfully-imported": "Importado com Sucesso", + "failed-imports": "Importações falhadas" + } + }, + "migration": { + "recipe-migration": "Migração da Receita", + "failed-imports": "Importações Falhadas", + "migration-report": "Análise das Migrações", + "successful-imports": "Importações Bem sucedidas", + "no-migration-data-available": "Não há dados de migração disponíveis", + "nextcloud": { + "title": "Nextcloud Cookbook", + "description": "Migraar dados de uma instância do Nextcloud CookBook" + }, + "chowdown": { + "title": "Chowdown", + "description": "Migrar dados do Chowdown" + } + } +} diff --git a/frontend/src/store/modules/language.js b/frontend/src/store/modules/language.js index 8fad87b07..7eed2de85 100644 --- a/frontend/src/store/modules/language.js +++ b/frontend/src/store/modules/language.js @@ -35,6 +35,10 @@ const state = { name: "German", value: "de", }, + { + name: "Português", + value: "pt-PT", + }, ], }; @@ -48,13 +52,13 @@ const mutations = { const actions = { initLang({ getters }, { currentVueComponent }) { VueI18n.locale = getters.getActiveLang; - currentVueComponent.$vuetify.lang.current = getters.getActiveLang; + currentVueComponent.$vuetify.lang.current = getters.getActiveLang; }, }; const getters = { - getActiveLang: (state) => state.lang, - getAllLangs: (state) => state.allLangs, + getActiveLang: state => state.lang, + getAllLangs: state => state.allLangs, }; export default { diff --git a/mealie/run.sh b/mealie/run.sh index 12a5d142d..56ce31532 100755 --- a/mealie/run.sh +++ b/mealie/run.sh @@ -4,11 +4,11 @@ ARG1=${1:-production} # Set Script Directory - Used for running the script from a different directory. -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # # Initialize Database Prerun -poetry run python $DIR/db/init_db.py -poetry run python $DIR/services/image/minify.py +poetry run python /app/mealie/db/init_db.py +poetry run python /app/mealie/services/image/minify.py # Migrations # TODO diff --git a/mealie/services/image/minify.py b/mealie/services/image/minify.py index 024656a50..c6f781e3a 100644 --- a/mealie/services/image/minify.py +++ b/mealie/services/image/minify.py @@ -60,7 +60,10 @@ def move_all_images(): continue new_folder = app_dirs.IMG_DIR.joinpath(image_file.stem) new_folder.mkdir(parents=True, exist_ok=True) - image_file.rename(new_folder.joinpath(f"original{image_file.suffix}")) + new_file = new_folder.joinpath(f"original{image_file.suffix}") + if new_file.is_file(): + new_file.unlink() + image_file.rename(new_file) def validate_slugs_in_database(session: Session = None): diff --git a/tests/unit_tests/test_cleaner.py b/tests/unit_tests/test_cleaner.py index b1630a132..dbe597281 100644 --- a/tests/unit_tests/test_cleaner.py +++ b/tests/unit_tests/test_cleaner.py @@ -80,7 +80,7 @@ def test_cleaner_instructions(instructions): def test_html_with_recipe_data(): path = TEST_RAW_HTML.joinpath("healthy_pasta_bake_60759.html") url = "https://www.bbc.co.uk/food/recipes/healthy_pasta_bake_60759" - recipe_data = extract_recipe_from_html(open(path).read(), url) + recipe_data = extract_recipe_from_html(open(path,encoding="utf8").read(), url) assert len(recipe_data["name"]) > 10 assert len(recipe_data["slug"]) > 10