second pass cleanup

This commit is contained in:
Hayden 2021-01-17 12:43:01 -09:00
commit e33f240f2d
22 changed files with 123 additions and 247 deletions

52
.gitignore vendored
View file

@ -153,3 +153,55 @@ ENV/
node_modules/ node_modules/
mealie/data/debug/last_recipe.json mealie/data/debug/last_recipe.json
*.sqlite *.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

View file

@ -8,7 +8,6 @@ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-
ln -s /opt/poetry/bin/poetry && \ ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false poetry config virtualenvs.create false
RUN mkdir /app/
COPY ./pyproject.toml ./app/poetry.lock* /app/ COPY ./pyproject.toml ./app/poetry.lock* /app/
WORKDIR /app WORKDIR /app
@ -17,7 +16,6 @@ RUN poetry install --no-root
COPY ./mealie /app COPY ./mealie /app
ENTRYPOINT [ "python" ] ENTRYPOINT [ "python" ]
CMD [ "app.py" ] CMD [ "app.py" ]

View file

@ -29,6 +29,7 @@ services:
db_type: sqlite db_type: sqlite
TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly. TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly.
volumes: volumes:
- ./app_data:/app_data
- ./mealie:/app - ./mealie:/app
mealie-docs: mealie-docs:
@ -38,3 +39,4 @@ services:
- 9923:8000 - 9923:8000
volumes: volumes:
- ./docs:/docs - ./docs:/docs

View file

@ -45,8 +45,7 @@ Feature placement is not set in stone. This is much more of a guideline than any
- [ ] Setup SQL Migrations - [ ] Setup SQL Migrations
## Breaking Changes ## Breaking Changes
- Internal port 9000 changed to port 80 for better Traefik support
- MongoDB support dropped - MongoDB support dropped
## Code Chores ## Code Chores
- [ ] Remove MongoDB Interface Code - [x] Remove MongoDB Interface Code
- [ ] Dockerfile Trim - [ ] Dockerfile Trim

View file

@ -1,5 +0,0 @@
{
"cSpell.enableFiletypes": [
"!javascript"
]
}

View file

@ -17,7 +17,7 @@ dotenv.load_dotenv(ENV)
# Helpful Globals # Helpful Globals
BASE_DIR = CWD BASE_DIR = CWD
DATA_DIR = CWD.joinpath("data") DATA_DIR = CWD.parent.joinpath("app_data")
WEB_PATH = CWD.joinpath("dist") WEB_PATH = CWD.joinpath("dist")
IMG_DIR = DATA_DIR.joinpath("img") IMG_DIR = DATA_DIR.joinpath("img")
BACKUP_DIR = DATA_DIR.joinpath("backups") BACKUP_DIR = DATA_DIR.joinpath("backups")

View file

@ -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": []
}

View file

@ -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 }}

View file

@ -1,7 +1,62 @@
from db.db_mealplan import _Meals from db.db_base import BaseDocument
from db.db_recipes import _Recipes from db.sql.db_session import create_session
from db.db_settings import _Settings from db.sql.meal_models import MealPlanModel
from db.db_themes import _Themes 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: class Database:

View file

@ -81,6 +81,8 @@ class BaseDocument:
return_data = new_document.dict() return_data = new_document.dict()
session.commit() session.commit()
session.close()
return return_data return return_data
def update(self, match_value, new_data) -> dict: def update(self, match_value, new_data) -> dict:

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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()

View file

@ -2,9 +2,7 @@ import shutil
from pathlib import Path from pathlib import Path
import requests import requests
from app_config import IMG_DIR
CWD = Path(__file__).parent
IMG_DIR = CWD.parent.joinpath("data", "img")
def read_image(recipe_slug: str) -> Path: def read_image(recipe_slug: str) -> Path:

View file

@ -1,6 +1,6 @@
import json 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.""" """Script to export the ReDoc documentation page into a standalone HTML file."""
@ -33,7 +33,7 @@ HTML_TEMPLATE = """<!DOCTYPE html>
def generate_api_docs(app): 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_dir.mkdir(parents=True, exist_ok=True)
out_path = out_dir.joinpath("index.html") out_path = out_dir.joinpath("index.html")
with open(out_path, "w") as fd: with open(out_path, "w") as fd:

View file

@ -1,9 +1,11 @@
import logging import logging
from pathlib import Path from pathlib import Path
from app_config import DATA_DIR
LOGGER_LEVEL = "INFO" LOGGER_LEVEL = "INFO"
CWD = Path(__file__).parent CWD = Path(__file__).parent
LOGGER_FILE = CWD.parent.joinpath("data", "mealie.log") LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
logging.basicConfig( logging.basicConfig(