diff --git a/mealie/app.py b/mealie/app.py index 3b3b6e7a7..5f829d4dc 100644 --- a/mealie/app.py +++ b/mealie/app.py @@ -10,6 +10,7 @@ from routes import ( migration_routes, setting_routes, static_routes, + theme_routes, user_routes, ) from routes.recipe import ( @@ -30,10 +31,11 @@ TODO: - [x] Category Endpoints - [ ] Endpoint Tests - [ ] Finish Frontend Category Management - - [ ] Delete Category / Tags + - [x] Delete Category - [ ] Sort Sidebar A-Z -- [ ] Ingredient Drag-Drop / Reorder -- [ ] Refactor Endpoints +- [x] Ingredient Drag-Drop / Reorder +- [x] Refactor Endpoints +- [ ] Refactor Test Endpoints - Abstract to fixture? """ @@ -57,13 +59,14 @@ def start_scheduler(): def api_routers(): # Recipes app.include_router(all_recipe_routes.router) - app.include_router(recipe_crud_routes.router) app.include_router(category_routes.router) app.include_router(tag_routes.router) + app.include_router(recipe_crud_routes.router) # Meal Routes app.include_router(meal_routes.router) # Settings Routes app.include_router(setting_routes.router) + app.include_router(theme_routes.router) # Backups/Imports Routes app.include_router(backup_routes.router) # User Routes diff --git a/mealie/db/database.py b/mealie/db/database.py index 9a3d06f79..93b26f10f 100644 --- a/mealie/db/database.py +++ b/mealie/db/database.py @@ -1,4 +1,3 @@ -from sqlalchemy.orm import load_only from sqlalchemy.orm.session import Session from db.db_base import BaseDocument diff --git a/mealie/services/category_services.py b/mealie/services/category_services.py deleted file mode 100644 index 5223a2fa4..000000000 --- a/mealie/services/category_services.py +++ /dev/null @@ -1,13 +0,0 @@ -from typing import List - -from db.database import db - - -def get_all_categories(session) -> List[str]: - categories = db.categories.get_all_primary_keys(session) - - return categories - - -def get_recipes_by_category(session): - pass diff --git a/mealie/services/scrape_services.py b/mealie/services/scrape_services.py index d2cfbbd66..fc9ae6d95 100644 --- a/mealie/services/scrape_services.py +++ b/mealie/services/scrape_services.py @@ -1,6 +1,6 @@ import html import json -from pathlib import Path +import re from typing import List, Tuple import extruct @@ -14,10 +14,15 @@ from w3lib.html import get_base_url from services.image_services import scrape_image from services.recipe_services import Recipe -CWD = Path(__file__).parent TEMP_FILE = DEBUG_DIR.joinpath("last_recipe.json") +def cleanhtml(raw_html): + cleanr = re.compile("<.*?>") + cleantext = re.sub(cleanr, "", raw_html) + return cleantext + + def normalize_image_url(image) -> str: if type(image) == list: return image[0] @@ -55,7 +60,7 @@ def normalize_instructions(instructions) -> List[dict]: def normalize_instruction(line) -> str: - l = line.strip() + l = cleanhtml(line.strip()) # Some sites erroneously escape their strings on multiple levels while not l == (l := html.unescape(l)): pass @@ -63,7 +68,8 @@ def normalize_instruction(line) -> str: def normalize_ingredient(ingredients: list) -> str: - return [html.unescape(ing) for ing in ingredients] + + return [cleanhtml(html.unescape(ing)) for ing in ingredients] def normalize_yield(yld) -> str: @@ -82,6 +88,7 @@ def normalize_time(time_entry) -> str: def normalize_data(recipe_data: dict) -> dict: recipe_data["totalTime"] = normalize_time(recipe_data.get("totalTime")) + recipe_data["description"] = cleanhtml(recipe_data.get("description")) recipe_data["prepTime"] = normalize_time(recipe_data.get("prepTime")) recipe_data["performTime"] = normalize_time(recipe_data.get("performTime")) recipe_data["recipeYield"] = normalize_yield(recipe_data.get("recipeYield"))