From 7e5ba43ac0c490fcbb0420de756d40db7b350e19 Mon Sep 17 00:00:00 2001 From: mtoohey31 Date: Sun, 3 Jan 2021 15:04:01 -0500 Subject: [PATCH 1/4] Added note about where to find template variables. --- docs/docs/1.3 - admin-panel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/1.3 - admin-panel.md b/docs/docs/1.3 - admin-panel.md index 57084d5c..5eb731a4 100644 --- a/docs/docs/1.3 - admin-panel.md +++ b/docs/docs/1.3 - admin-panel.md @@ -15,7 +15,7 @@ Color themes can be created and set from the UI in the settings page. You can se ## Backup and Export All recipe data can be imported and exported as necessary from the UI. Under the admin page you'll find the section for using Backups and Exports. -To create an export simple add the tag and the markdown template and click Backup Recipes and your backup will be created on the server. The backup is a standard zipfile containing all the images, json files, and rendered markdown files for each recipe. Markdown files are rendered from jinja2 templates. Adding your own markdown file into the templates folder will automatically show up as an option to select when creating a backup. +To create an export simple add the tag and the markdown template and click Backup Recipes and your backup will be created on the server. The backup is a standard zipfile containing all the images, json files, and rendered markdown files for each recipe. Markdown files are rendered from jinja2 templates. Adding your own markdown file into the templates folder will automatically show up as an option to select when creating a backup. To view the availible variables, open a recipe in the json editor. To import a backup it must be in your backups folder. If it is in the backup folder it will automatically show up as an source to restore from. Selected the desired backup and import the backup file. From 5c59400a5d96ca5351f2dee19c885e9d9da7745e Mon Sep 17 00:00:00 2001 From: mtoohey31 Date: Sun, 3 Jan 2021 15:16:16 -0500 Subject: [PATCH 2/4] Fixed spelling of availible Sorry about all the small changes across lots of files, I think it would be best to fix this though to avoid potential future confusion. --- README.md | 2 +- frontend/src/api/backup.js | 4 ++-- frontend/src/components/Admin/Theme.vue | 10 +++++----- frontend/src/components/MealPlan/MealSelect.vue | 4 ++-- mealie/routes/backup_routes.py | 4 ++-- mealie/routes/meal_routes.py | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ae2cf9d4..7cadf8a0 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ **Mealie** is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relavent data or add a family recipe with the UI editor. -Mealie also provides a secure API for interactions from 3rd party applications. **Why does my recipe manager need an API?** An API allows integration into applications like [Home Assistant]() that can act as notification engines to provide custom notifications based of Meal Plan data to remind you to defrost the chicken, marinade the steak, or start the CrockPot. See the section on [Meal Plan hooks](#hooks) for more information. Additionally, you can access any avaiable API from the backend server. To explore the API spin up your server and navigate to http://yourserver.com/docs for interactive API documentation. +Mealie also provides a secure API for interactions from 3rd party applications. **Why does my recipe manager need an API?** An API allows integration into applications like [Home Assistant]() that can act as notification engines to provide custom notifications based of Meal Plan data to remind you to defrost the chicken, marinade the steak, or start the CrockPot. See the section on [Meal Plan hooks](#hooks) for more information. Additionally, you can access any available API from the backend server. To explore the API spin up your server and navigate to http://yourserver.com/docs for interactive API documentation. diff --git a/frontend/src/api/backup.js b/frontend/src/api/backup.js index 8d8f611d..e6971151 100644 --- a/frontend/src/api/backup.js +++ b/frontend/src/api/backup.js @@ -6,7 +6,7 @@ const backupBase = baseURL + "backups/"; const backupURLs = { // Backup - avaiable: `${backupBase}avaiable/`, + available: `${backupBase}available/`, createBackup: `${backupBase}export/database/`, importBackup: (fileName) => `${backupBase}${fileName}/import/`, deleteBackup: (fileName) => `${backupBase}${fileName}/delete/`, @@ -14,7 +14,7 @@ const backupURLs = { export default { async requestAvailable() { - let response = await apiReq.get(backupURLs.avaiable); + let response = await apiReq.get(backupURLs.available); return response.data; }, diff --git a/frontend/src/components/Admin/Theme.vue b/frontend/src/components/Admin/Theme.vue index 9dc68281..392f58a9 100644 --- a/frontend/src/components/Admin/Theme.vue +++ b/frontend/src/components/Admin/Theme.vue @@ -21,7 +21,7 @@ Choose a Recipe Date: Sun, 3 Jan 2021 15:52:38 -0500 Subject: [PATCH 3/4] Changed backup snackbar to display the absolute path of the backup file --- mealie/routes/backup_routes.py | 4 ++-- mealie/services/backup_services.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mealie/routes/backup_routes.py b/mealie/routes/backup_routes.py index 25111811..9d5c966f 100644 --- a/mealie/routes/backup_routes.py +++ b/mealie/routes/backup_routes.py @@ -26,14 +26,14 @@ async def export_database(data: BackupJob): """ Returns this weeks meal plan """ try: - export_db(data.tag, data.template) + export_path = export_db(data.tag, data.template) except: HTTPException( status_code=400, detail=SnackResponse.error("Error Creating Backup. See Log File"), ) - return SnackResponse.success("Backup Created in /data/backups") + return SnackResponse.success("Backup Created at " + export_path) @router.post( diff --git a/mealie/services/backup_services.py b/mealie/services/backup_services.py index 61e6faa9..39db0299 100644 --- a/mealie/services/backup_services.py +++ b/mealie/services/backup_services.py @@ -56,7 +56,7 @@ def import_from_archive(file_name: str) -> list: return successful_imports -def export_db(tag=None, template=None): +def export_db(tag=None, template=None) -> str: if tag: export_tag = tag + "_" + datetime.now().strftime("%Y-%b-%d") else: @@ -80,6 +80,8 @@ def export_db(tag=None, template=None): shutil.rmtree(backup_folder) shutil.rmtree(TEMP_DIR) + return str(zip_path.absolute()) + ".zip" + def export_images(dest_dir) -> Path: From 89674b2580fe2c327e491aa6b795861323f653f5 Mon Sep 17 00:00:00 2001 From: mtoohey31 Date: Sun, 3 Jan 2021 15:53:18 -0500 Subject: [PATCH 4/4] Incorrect docstrings in backup_routes --- mealie/routes/backup_routes.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mealie/routes/backup_routes.py b/mealie/routes/backup_routes.py index 9d5c966f..f2752684 100644 --- a/mealie/routes/backup_routes.py +++ b/mealie/routes/backup_routes.py @@ -9,7 +9,6 @@ router = APIRouter() @router.get("/api/backups/available/", tags=["Import / Export"]) async def available_imports(): - """ Returns this weeks meal plan """ imports = [] templates = [] for archive in BACKUP_DIR.glob("*.zip"): @@ -23,7 +22,6 @@ async def available_imports(): @router.post("/api/backups/export/database/", tags=["Import / Export"], status_code=201) async def export_database(data: BackupJob): - """ Returns this weeks meal plan """ try: export_path = export_db(data.tag, data.template) @@ -40,7 +38,6 @@ async def export_database(data: BackupJob): "/api/backups/{file_name}/import/", tags=["Import / Export"], status_code=200 ) async def import_database(file_name: str): - """ Returns this weeks meal plan """ imported = import_from_archive(file_name) return imported @@ -51,7 +48,6 @@ async def import_database(file_name: str): status_code=200, ) async def delete_backup(backup_name: str): - """ Returns this weeks meal plan """ try: BACKUP_DIR.joinpath(backup_name).unlink()