diff --git a/.gitignore b/.gitignore index f7732da6f..aa8f8f55f 100644 --- a/.gitignore +++ b/.gitignore @@ -153,3 +153,55 @@ ENV/ node_modules/ mealie/data/debug/last_recipe.json *.sqlite +app_data/backups/.gitkeep +app_data/backups/dev_sample_data_2021-Jan-12.zip +app_data/debug/.gitkeep +app_data/debug/last_recipe.json +app_data/img/.gitkeep +app_data/img/banana-bread.jpg +app_data/img/bon-appetit-s-perfect-pizza.jpg +app_data/img/braised-beans-and-sardines-with-fennel.jpg +app_data/img/broccoli-beer-cheese-soup.jpg +app_data/img/buttery-kimchi-chicken.jpg +app_data/img/cauliflower-cacciatore.jpg +app_data/img/chicken-salad-with-citrus-and-chile-oil.jpg +app_data/img/coffee-hazelnut-biscotti.jpg +app_data/img/corn-and-crab-beignets-with-yaji-aioli.jpg +app_data/img/crispy-carrots.jpg +app_data/img/crispy-rice-with-ginger-citrus-celery-salad.jpg +app_data/img/crockpot-buffalo-chicken.jpg +app_data/img/detroit-style-pepperoni-pizza.jpg +app_data/img/downtown-marinade.jpg +app_data/img/falafel-hummus-plate.jpg +app_data/img/five-spice-popcorn-chicken.jpg +app_data/img/ginger-citrus-cookies.jpg +app_data/img/green-chile-stew.jpg +app_data/img/green-seasoning-baked-cod.jpg +app_data/img/green-spaghetti.jpg +app_data/img/grilled-mushrooms-and-root-vegetables.jpg +app_data/img/how-to-make-instant-pot-kerala-vegetable-stew.jpg +app_data/img/huevos-rancheros-con-rajas-y-champinones.jpg +app_data/img/instant-pot-chicken-and-potatoes.jpg +app_data/img/jalapeno-cornbread.jpg +app_data/img/macadamia-and-brown-butter-blondies.jpg +app_data/img/marinated-tofu-with-brussels-sprouts-and-farro.jpg +app_data/img/marranitos-enfiestados.jpg +app_data/img/mississippi-pot-roast.jpg +app_data/img/mushroom-risotto.jpg +app_data/img/new-york-strip.jpg +app_data/img/nilla-wafer-french-toast.jpg +app_data/img/one-minute-muffin.jpg +app_data/img/one-pot-chicken-and-rice.jpg +app_data/img/pace-pork.jpg +app_data/img/pasta-with-mushrooms-and-cashew-cream.jpg +app_data/img/pizzettes.jpg +app_data/img/pork-steaks.jpg +app_data/img/roasted-brussels-sprouts.jpg +app_data/img/roasted-okra.jpg +app_data/img/salt-vinegar-potatoes.jpg +app_data/img/shrimp-and-cabbage-curry.jpg +app_data/img/smashed-carrots.jpg +app_data/img/tamarind-chicken-thighs-with-collard-greens-salad.jpg +app_data/img/tequila-beer-and-citrus-cocktail.jpg +app_data/migration/.gitkeep +app_data/templates/recipes.md diff --git a/Dockerfile.dev b/Dockerfile.dev index 5bc4891a3..ea8f2fb5f 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -8,7 +8,6 @@ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get- ln -s /opt/poetry/bin/poetry && \ poetry config virtualenvs.create false -RUN mkdir /app/ COPY ./pyproject.toml ./app/poetry.lock* /app/ WORKDIR /app @@ -17,7 +16,6 @@ RUN poetry install --no-root COPY ./mealie /app - ENTRYPOINT [ "python" ] CMD [ "app.py" ] \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index e92b6c9b2..c8fb6a749 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -29,6 +29,7 @@ services: db_type: sqlite TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly. volumes: + - ./app_data:/app_data - ./mealie:/app mealie-docs: @@ -38,3 +39,4 @@ services: - 9923:8000 volumes: - ./docs:/docs + diff --git a/docs/docs/roadmap.md b/docs/docs/roadmap.md index c436a6a97..1094ceb13 100644 --- a/docs/docs/roadmap.md +++ b/docs/docs/roadmap.md @@ -45,8 +45,7 @@ Feature placement is not set in stone. This is much more of a guideline than any - [ ] Setup SQL Migrations ## Breaking Changes -- Internal port 9000 changed to port 80 for better Traefik support - MongoDB support dropped ## Code Chores -- [ ] Remove MongoDB Interface Code +- [x] Remove MongoDB Interface Code - [ ] Dockerfile Trim diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json deleted file mode 100644 index b0b5a72c6..000000000 --- a/frontend/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cSpell.enableFiletypes": [ - "!javascript" - ] -} \ No newline at end of file diff --git a/mealie/app_config.py b/mealie/app_config.py index eff89f5de..bfdb8e1f7 100644 --- a/mealie/app_config.py +++ b/mealie/app_config.py @@ -17,7 +17,7 @@ dotenv.load_dotenv(ENV) # Helpful Globals BASE_DIR = CWD -DATA_DIR = CWD.joinpath("data") +DATA_DIR = CWD.parent.joinpath("app_data") WEB_PATH = CWD.joinpath("dist") IMG_DIR = DATA_DIR.joinpath("img") BACKUP_DIR = DATA_DIR.joinpath("backups") diff --git a/mealie/data/backups/.gitkeep b/mealie/data/backups/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/mealie/data/backups/dev_sample_data_2021-Jan-12.zip b/mealie/data/backups/dev_sample_data_2021-Jan-12.zip deleted file mode 100644 index ee5da95cc..000000000 Binary files a/mealie/data/backups/dev_sample_data_2021-Jan-12.zip and /dev/null differ diff --git a/mealie/data/debug/.gitkeep b/mealie/data/debug/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/mealie/data/debug/last_recipe.json b/mealie/data/debug/last_recipe.json deleted file mode 100644 index e26cfbf66..000000000 --- a/mealie/data/debug/last_recipe.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "@context": "http://schema.org", - "@type": "Recipe", - "articleBody": "\u201cMy great-grandmothers were Indigenous and mostly nomadic, which means lots of fungi foraging,\u201d says Maricela Vega, the chef at Atlanta restaurant 8ARM and founder of Chicomec\u00f3atl, an organization centering the foodways of Indigenous Mexican diaspora. \u201cWhen I serve lion\u2019s mane mushrooms to vegans they sometimes mistake them for chicken, but they\u2019re more affordable, better for the planet, and help strengthen your immune system! They grow wild during Georgia winters, but at-home cultivation kits are easy for those without forest access. I use pumpkin hot sauce, oil, and fresh herbs as a marinade, then bust out a baby grill or cast-iron skillet to get them nice and crispy.\u201d This is a multistep recipe but perfect for long winter days when you want to flood the house with toasty, irresistible aromas. When you chop the mixed herbs, save the stems and throw them into the blanching water for the vegetables to add flavor.", - "alternativeHeadline": "This dish is perfect for long winter days when you want to flood the house with toasty, irresistible aromas.", - "dateModified": "2021-01-11 18:32:43.962000", - "datePublished": "2021-01-12 04:00:00", - "keywords": [ - "recipes", - "healthyish", - "vegan", - "herb", - "apple cider vinegar", - "kosher salt", - "carrot", - "potato", - "radicchio", - "mushroom", - "oyster mushrooms", - "oil", - "black pepper", - "lemon", - "web" - ], - "thumbnailUrl": "https://assets.bonappetit.com/photos/5ffc74b39cbb0a3c54d7400f/1:1/w_1199,h_1199,c_limit/HLY-Maricela-Vega-Grilled%20Mushrooms%20and%20Root%20Vegetables.jpg", - "publisher": { - "@context": "https://schema.org", - "@type": "Organization", - "name": "Bon App\u00e9tit", - "logo": { - "@type": "ImageObject", - "url": "https://www.bonappetit.com/verso/static/bon-appetit/assets/logo-seo.328de564b950e3d5d1fbe3e42f065290ca1d3844.png", - "width": "479px", - "height": "100px" - }, - "url": "https://www.bonappetit.com" - }, - "isPartOf": { - "@type": [ - "CreativeWork", - "Product" - ], - "name": "Bon App\u00e9tit" - }, - "isAccessibleForFree": true, - "author": [ - { - "@type": "Person", - "name": "Maricela Vega", - "sameAs": "https://bon-appetit.com/contributor/maricela-vega/" - } - ], - "description": "This dish is perfect for long winter days when you want to flood the house with toasty, irresistible aromas.", - "image": "grilled-mushrooms-and-root-vegetables.jpg", - "headline": "Grilled Mushrooms and Root Vegetables", - "name": "Grilled Mushrooms and Root Vegetables", - "recipeIngredient": [ - "1 cup Sesame Cr\u00e8me", - "2 Tbsp. Allium Confit", - "2 Tbsp. finely chopped mixed tender herbs (parsley, oregano, and/or mint), stems reservedfor blanching vegetables", - "2 Tbsp. apple cider vinegar", - "Kosher salt, freshly ground pepper", - "1 cup finely chopped mixed herbs (parsley, oregano, and/or mint), stems reserved for blanching vegetables", - "Kosher salt", - "4 medium carrots (about 1 lb.), preferably rainbow, scrubbed, halved lengthwise, cut crosswise into thirds", - "4 lb. baby potatoes, halved", - "1 head of radicchio, coarsely chopped, divided", - "1 lb. lion\u2019s mane, king trumpet, or oyster mushrooms, cut into 2\" pieces", - "\u00bd cup Pumpkin Hot Sauce", - "\u00bd cup grapeseed or vegetable oil", - "Freshly ground black pepper", - "1 cup Spiced Pecans", - "1 lemon, halved" - ], - "recipeInstructions": [ - { - "text": "Pur\u00e9e Sesame Cr\u00e8me, Allium Confit, chopped herbs, and vinegar in a blender on high speed, adding ice water by the tablespoonful as needed to achieve a pourable consistency, until smooth and creamy. Season sauce with salt and pepper." - }, - { - "text": "Fill a large pot three quarters full with water, add reserved herb stems, and season heavily with salt. Bring water to a boil, then add carrots and cook until just tender, about 3 minutes. Using a slotted spoon, immediately transfer carrots to a large bowl of ice water and let cool." - }, - { - "text": "Place potatoes in same pot and return to a boil. Cook until tender (flesh should be easy to pierce with a fork), about 10 minutes. Using slotted spoon, transfer potatoes to bowl of ice water and let cool. Drain carrots and potatoes; place in a clean large bowl and add half of the radicchio. Place mushrooms in a medium bowl." - }, - { - "text": "Whisk Pumpkin Hot Sauce, oil, and chopped herbs in another medium bowl. Pour half of mixture over carrots and potatoes and the other half over mushrooms; toss each to coat. Season with salt and pepper." - }, - { - "text": "Prepare a grill for medium-high heat. (Alternatively, heat a large cast-iron skillet over medium-high.) Grill mushrooms, turning occasionally, until deep golden brown and crisp around the edges (or cook in batches, stirring often, if using a skillet), 12\u201314 minutes. Transfer mushrooms to a large shallow serving bowl." - }, - { - "text": "Grill carrots, potatoes, and radicchio, turning occasionally, until deep golden brown all over (or cook in batches, tossing often, if using a skillet), about 4 minutes. Transfer vegetables to bowl with mushrooms and toss to combine." - }, - { - "text": "To serve, drizzle generously with sesame sauce; top with Spiced Pecans and remaining radicchio. Squeeze juice from each lemon half over." - } - ], - "recipeYield": "4 Servings", - "url": "https://www.bonappetit.com/recipe/grilled-mushrooms-and-root-vegetables", - "slug": "grilled-mushrooms-and-root-vegetables", - "orgURL": "https://www.bonappetit.com/recipe/grilled-mushrooms-and-root-vegetables", - "categories": [], - "tags": [], - "dateAdded": null, - "notes": [], - "extras": [] -} \ No newline at end of file diff --git a/mealie/data/img/.gitkeep b/mealie/data/img/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/mealie/data/migration/.gitkeep b/mealie/data/migration/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/mealie/data/templates/recipes.md b/mealie/data/templates/recipes.md deleted file mode 100644 index 4f05230f0..000000000 --- a/mealie/data/templates/recipes.md +++ /dev/null @@ -1,26 +0,0 @@ - - -![Recipe Image](../images/{{ recipe.image }}) - -# {{ recipe.name }} -{{ recipe.description }} - -## Ingredients -{% for ingredient in recipe.recipeIngredient %} -- [ ] {{ ingredient }} -{% endfor %} - -## Instructions -{% for step in recipe.recipeInstructions %} -- [ ] {{ step.text }} -{% endfor %} - -{% for note in recipe.notes %} -**{{ note.title }}:** {{ note.text }} -{% endfor %} - ---- - -Tags: {{ recipe.tags }} -Categories: {{ recipe.categories }} -Original URL: {{ recipe.orgURL }} \ No newline at end of file diff --git a/mealie/db/database.py b/mealie/db/database.py index 72e02911b..c44bf5d3c 100644 --- a/mealie/db/database.py +++ b/mealie/db/database.py @@ -1,7 +1,62 @@ -from db.db_mealplan import _Meals -from db.db_recipes import _Recipes -from db.db_settings import _Settings -from db.db_themes import _Themes +from db.db_base import BaseDocument +from db.sql.db_session import create_session +from db.sql.meal_models import MealPlanModel +from db.sql.recipe_models import RecipeModel +from db.sql.settings_models import SiteSettingsModel +from db.sql.theme_models import SiteThemeModel + +""" +# TODO + - [ ] Abstract Classes to use save_new, and update from base models + - [ ] Create Category and Tags Table with Many to Many relationship +""" +class _Recipes(BaseDocument): + def __init__(self) -> None: + self.primary_key = "slug" + self.sql_model = RecipeModel + self.create_session = create_session + + def update_image(self, slug: str, extension: str) -> None: + pass + + +class _Meals(BaseDocument): + def __init__(self) -> None: + self.primary_key = "uid" + self.sql_model = MealPlanModel + self.create_session = create_session + + +class _Settings(BaseDocument): + def __init__(self) -> None: + self.primary_key = "name" + self.sql_model = SiteSettingsModel + self.create_session = create_session + + def save_new(self, main: dict, webhooks: dict) -> str: + session = create_session() + new_settings = self.sql_model(main.get("name"), webhooks) + + session.add(new_settings) + session.commit() + + return new_settings.dict() + + +class _Themes(BaseDocument): + def __init__(self) -> None: + self.primary_key = "name" + self.sql_model = SiteThemeModel + self.create_session = create_session + + def update(self, data: dict) -> dict: + session, theme_model = self._query_one( + match_value=data["name"], match_key="name" + ) + + theme_model.update(**data) + session.commit() + session.close() class Database: diff --git a/mealie/db/db_base.py b/mealie/db/db_base.py index 0037cc548..730c262aa 100644 --- a/mealie/db/db_base.py +++ b/mealie/db/db_base.py @@ -81,6 +81,8 @@ class BaseDocument: return_data = new_document.dict() session.commit() + + session.close() return return_data def update(self, match_value, new_data) -> dict: diff --git a/mealie/db/db_mealplan.py b/mealie/db/db_mealplan.py deleted file mode 100644 index 8c7cdb803..000000000 --- a/mealie/db/db_mealplan.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import List - -from app_config import USE_SQL - -from db.db_base import BaseDocument -from db.db_setup import USE_SQL -from db.sql.db_session import create_session -from db.sql.meal_models import MealPlanModel - - -class _Meals(BaseDocument): - def __init__(self) -> None: - self.primary_key = "uid" - self.sql_model = MealPlanModel - self.create_session = create_session diff --git a/mealie/db/db_recipes.py b/mealie/db/db_recipes.py deleted file mode 100644 index bf1f40fe8..000000000 --- a/mealie/db/db_recipes.py +++ /dev/null @@ -1,23 +0,0 @@ -from app_config import USE_SQL - -from db.db_base import BaseDocument -from db.sql.db_session import create_session -from db.sql.recipe_models import RecipeModel - - -class _Recipes(BaseDocument): - def __init__(self) -> None: - self.primary_key = "slug" - self.sql_model = RecipeModel - self.create_session = create_session - - def save_new_sql(self, recipe_data: dict): - session = self.create_session() - new_recipe = self.sql_model(**recipe_data) - session.add(new_recipe) - session.commit() - - return recipe_data - - def update_image(self, slug: str, extension: str) -> None: - pass diff --git a/mealie/db/db_settings.py b/mealie/db/db_settings.py deleted file mode 100644 index 5e767337f..000000000 --- a/mealie/db/db_settings.py +++ /dev/null @@ -1,22 +0,0 @@ -from app_config import USE_SQL - -from db.db_base import BaseDocument -from db.db_setup import USE_SQL -from db.sql.db_session import create_session -from db.sql.settings_models import SiteSettingsModel - - -class _Settings(BaseDocument): - def __init__(self) -> None: - self.primary_key = "name" - self.sql_model = SiteSettingsModel - self.create_session = create_session - - def save_new(self, main: dict, webhooks: dict) -> str: - session = create_session() - new_settings = self.sql_model(main.get("name"), webhooks) - - session.add(new_settings) - session.commit() - - return new_settings.dict() diff --git a/mealie/db/db_themes.py b/mealie/db/db_themes.py deleted file mode 100644 index 3a901fb10..000000000 --- a/mealie/db/db_themes.py +++ /dev/null @@ -1,34 +0,0 @@ -from app_config import USE_SQL - -from db.db_base import BaseDocument -from db.db_setup import USE_SQL -from db.sql.db_session import create_session -from db.sql.theme_models import SiteThemeModel - - -class _Themes(BaseDocument): - def __init__(self) -> None: - self.primary_key = "name" - self.sql_model = SiteThemeModel - self.create_session = create_session - - def save_new(self, theme_data: dict) -> None: - session = self.create_session() - new_theme = self.sql_model(**theme_data) - - session.add(new_theme) - session.commit() - - return_data = new_theme.dict() - - session.close() - return return_data - - def update(self, data: dict) -> dict: - session, theme_model = self._query_one( - match_value=data["name"], match_key="name" - ) - - theme_model.update(**data) - session.commit() - session.close() diff --git a/mealie/services/image_services.py b/mealie/services/image_services.py index 8b2432972..4200a186a 100644 --- a/mealie/services/image_services.py +++ b/mealie/services/image_services.py @@ -2,9 +2,7 @@ import shutil from pathlib import Path import requests - -CWD = Path(__file__).parent -IMG_DIR = CWD.parent.joinpath("data", "img") +from app_config import IMG_DIR def read_image(recipe_slug: str) -> Path: diff --git a/mealie/utils/api_docs.py b/mealie/utils/api_docs.py index 823afee0a..2d75bfa0e 100644 --- a/mealie/utils/api_docs.py +++ b/mealie/utils/api_docs.py @@ -1,6 +1,6 @@ import json -from app_config import BASE_DIR +from app_config import BASE_DIR, DATA_DIR """Script to export the ReDoc documentation page into a standalone HTML file.""" @@ -33,7 +33,7 @@ HTML_TEMPLATE = """ def generate_api_docs(app): - out_dir = BASE_DIR.joinpath(".temp") + out_dir = DATA_DIR.joinpath(".temp") out_dir.mkdir(parents=True, exist_ok=True) out_path = out_dir.joinpath("index.html") with open(out_path, "w") as fd: diff --git a/mealie/utils/logger.py b/mealie/utils/logger.py index f0780e1a3..e72531a26 100644 --- a/mealie/utils/logger.py +++ b/mealie/utils/logger.py @@ -1,9 +1,11 @@ import logging from pathlib import Path +from app_config import DATA_DIR + LOGGER_LEVEL = "INFO" CWD = Path(__file__).parent -LOGGER_FILE = CWD.parent.joinpath("data", "mealie.log") +LOGGER_FILE = DATA_DIR.joinpath("mealie.log") logging.basicConfig(