diff --git a/.dockerignore b/.dockerignore index cc5da2130..8d23634e1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,3 @@ */node_modules */dist -## \ No newline at end of file +*/data/db \ No newline at end of file diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 3a7a0116e..3712b2cff 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -2,7 +2,7 @@ name: Publish docs via GitHub Pages on: push: branches: - - main + - master jobs: build: @@ -17,4 +17,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CONFIG_FILE: docs/mkdocs.yml - EXTRA_PACKAGES: build-base \ No newline at end of file + EXTRA_PACKAGES: build-base diff --git a/.github/workflows/dockerbuild.dev.yml b/.github/workflows/dockerbuild.dev.yml new file mode 100644 index 000000000..85c9e4c30 --- /dev/null +++ b/.github/workflows/dockerbuild.dev.yml @@ -0,0 +1,49 @@ +name: Docker Build Dev + +on: + push: + branches: + - dev + +jobs: + build: + runs-on: ubuntu-latest + steps: + # + # Checkout + # + - name: checkout code + uses: actions/checkout@v2 + # + # Setup QEMU + # + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + # + # Setup Buildx + # + - name: install buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + # + # Login to Docker Hub + # + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # + # Build + # + - name: build the image + run: | + docker build --push \ + --tag hkotel/mealie:dev \ + --platform linux/amd64,linux/arm/v7,linux/arm64 . diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 000000000..3ba6b1d6c --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,55 @@ +name: Project Tests +on: + push: + branches: + - master + - dev + - cd/cd + pull_request: + branches: + - master + - dev + +jobs: + tests: + runs-on: ubuntu-latest + steps: + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v2 + - name: Set up python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + #---------------------------------------------- + # ----- install & configure poetry ----- + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1.1.1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + run: poetry install + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + #---------------------------------------------- + # run test suite + #---------------------------------------------- + - name: Run tests + run: | + source .venv/bin/activate + pytest mealie/tests/ diff --git a/.gitignore b/.gitignore index 4ec39805f..f7732da6f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ __pycache__/ docs/site/ mealie/temp/* mealie/temp/api.html +.temp/ mealie/data/backups/* @@ -150,3 +151,5 @@ ENV/ # Node Modules node_modules/ +mealie/data/debug/last_recipe.json +*.sqlite diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 000000000..c149059af --- /dev/null +++ b/.pylintrc @@ -0,0 +1,588 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-whitelist= + +# Specify a score threshold to be exceeded before program exits with error. +fail-under=10.0 + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating, + deprecated-operator-function, + deprecated-urllib-function, + xreadlines-attribute, + deprecated-sys-function, + exception-escape, + comprehension-escape + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'error', 'warning', 'refactor', and 'convention' +# which contain the number of messages in each category, as well as 'statement' +# which is the total number of statements analyzed. This score is used by the +# global evaluation report (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit + + +[STRING] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=no + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + +# Regular expression of note tags to take in consideration. +#notes-rgx= + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it work, +# install the python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. +#class-attribute-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. +#variable-rgx= + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members=pydantic.* + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes +w54 +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[DESIGN] + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules=optparse,tkinter.tix + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled). +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled). +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "BaseException, Exception". +overgeneral-exceptions=BaseException, + Exception diff --git a/.vscode/settings.json b/.vscode/settings.json index 0445b096a..24b79e7fc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "python.formatting.provider": "black", - "python.pythonPath": "venv/bin/python", + "python.pythonPath": ".venv/bin/python3.8", "python.linting.pylintEnabled": true, "python.linting.enabled": true, "python.autoComplete.extraPaths": ["mealie", "mealie/mealie"], @@ -8,13 +8,12 @@ "python.testing.unittestEnabled": false, "python.testing.nosetestsEnabled": false, - "python.discoverTest": true, "python.testing.pytestEnabled": true, - "cSpell.enableFiletypes": [ - "!javascript", - "!python" + "cSpell.enableFiletypes": ["!javascript", "!python"], + "python.testing.pytestArgs": ["mealie"], + "i18n-ally.localesPaths": "frontend/src/locales", + "i18n-ally.enabledFrameworks": [ + "vue" ], - "python.testing.pytestArgs": [ - "mealie" - ] + "i18n-ally.keystyle": "nested" } diff --git a/Dockerfile b/Dockerfile index 4a803d026..dd4b51eb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,25 +5,28 @@ RUN npm install COPY ./frontend/ . RUN npm run build -FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8 +# FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim +FROM mrnr91/uvicorn-gunicorn-fastapi:python3.8 -RUN apt-get update -y && \ - apt-get install -y python-pip python-dev - -# We copy just the requirements.txt first to leverage Docker cache -COPY ./requirements.txt /app/requirements.txt WORKDIR /app -RUN pip install -r requirements.txt +RUN apt-get update -y && \ + apt-get install -y python-pip python-dev git curl python3-dev libxml2-dev libxslt1-dev zlib1g-dev --no-install-recommends && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false + +COPY ./pyproject.toml /app/ COPY ./mealie /app -COPY ./mealie/data/templates/recipes.md /app/data/templates/recipes.md +RUN poetry install --no-root --no-dev COPY --from=build-stage /app/dist /app/dist -RUN rm -rf /app/test /app/temp +RUN rm -rf /app/test /app/.temp ENV ENV prod +ENV APP_MODULE "app:app" VOLUME [ "/app/data" ] - -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "9000"] \ No newline at end of file diff --git a/Dockerfile.arm b/Dockerfile.arm new file mode 100644 index 000000000..6f35a9284 --- /dev/null +++ b/Dockerfile.arm @@ -0,0 +1,33 @@ +FROM node:lts-alpine as build-stage +WORKDIR /app +COPY ./frontend/package*.json ./ +RUN npm install +COPY ./frontend/ . +RUN npm run build + +FROM mrnr91/uvicorn-gunicorn-fastapi:python3.8 + + +COPY ./requirements.txt /app/requirements.txt + +WORKDIR /app + +RUN apt-get update -y && \ + apt-get install -y python-pip python-dev git curl --no-install-recommends + +RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false + +COPY ./pyproject.toml ./app/poetry.lock* /app/ + +COPY ./mealie /app +RUN poetry install --no-root --no-dev +COPY --from=build-stage /app/dist /app/dist +RUN rm -rf /app/test /app/.temp + +ENV ENV prod +ENV APP_MODULE "app:app" + +VOLUME [ "/app/data" ] diff --git a/Dockerfile.dev b/Dockerfile.dev index de37b9cc1..5bc4891a3 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -3,13 +3,17 @@ FROM python:3 RUN apt-get update -y && \ apt-get install -y python-pip python-dev +RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ + cd /usr/local/bin && \ + ln -s /opt/poetry/bin/poetry && \ + poetry config virtualenvs.create false -COPY ./requirements.txt /app/requirements.txt +RUN mkdir /app/ +COPY ./pyproject.toml ./app/poetry.lock* /app/ WORKDIR /app -RUN pip install -r requirements.txt -RUN pip install pytest +RUN poetry install --no-root COPY ./mealie /app diff --git a/dev/dev-notes.md b/dev/dev-notes.md index a1b0d7108..7cb8c8258 100644 --- a/dev/dev-notes.md +++ b/dev/dev-notes.md @@ -16,46 +16,42 @@ Don't forget to [join the Discord](https://discord.gg/R6QDyJgbD2)! # Todo's +Documentation +- [ ] V0.1.0 Release Notes +- [ ] Nextcloud Migration How To +- [ ] New Docker Setup with Sqlite +- [ ] Update Env Variables +- [ ] New Roadmap / Milestones + Frontend -- [x] .Vue file reorganized into something that makes sense +- [x] Prep / Cook / Total Time Indicator + Editor +- [ ] No Meal Today Page instead of Null - [ ] Recipe Print Page -- [x] Catch 400 / bad response on create from URL - [ ] Recipe Editor Data Validation Client Side -- [x] Favicon -- [x] Rename Window -- [x] Add version indicator and notification for new version available -- [ ] Enhanced Search Functionality - [ ] Organize Home Page my Category, ideally user selectable. +- [ ] Advanced Search Page, draft started + - [ ] Filter by Category + - [ ] Filter by Tags +- [ ] Search Bar redesign + - [x] Initial + - [ ] Results redesign +- [ ] Replace Backups card with something like Home Assistant +- [x] Replace import card with something like Home Assistant + - [x] Select which imports to do Backend -- [x] Add Debug folder for writing the last pulled recipe data to. -- [x] Recipe Editor Data Validation Server Side -- [ ] Normalize Recipe data on scrape -- [ ] Support how to Sections and how to steps -- [ ] Export Markdown on Auto backups +- [ ] Database Import + - [x] Recipes + - [x] Images + - [ ] Meal Plans + - [x] Settings + - [x] Themes +- [x] Remove Print / Debug Code +- [ ] Support how to sections and how to steps - [ ] Recipe request by category/tags -- [ ] Add Additional Migrations, See mealie/services/migrations/chowdown.py for examples of how to do this. - - [ ] Open Eats [See Issue #4](https://github.com/hay-kot/mealie/issues/4) - - [ ] NextCloud [See Issue #14](https://github.com/hay-kot/mealie/issues/14) + + +SQL +- [ ] Setup Database Migrations # Draft Changelog -## v0.0.2 - -Bug Fixes -- Fixed opacity issues with marked steps - [mtoohey31](https://github.com/mtoohey31) -- Fixed hot-reloading development environment - [grssmnn](https://github.com/grssmnn) -- Fixed recipe not saving without image -- Fixed parsing error on image property null - -General Improvements -- Added Confirmation component to deleting recipes - [zackbcom](https://github.com/zackbcom) -- Updated Theme backend - [zackbcom](https://github.com/zackbcom) -- Added Persistent storage to vuex - [zackbcom](https://github.com/zackbcom) -- General Color/Theme Improvements - - More consistent UI - - More minimalist coloring -- Added API Key Extras to Recipe Data - - Users can now add custom json key/value pairs to all recipes via the editor for access in 3rd part applications. For example users can add a "message" field in the extras that can be accessed on API calls to play a message over google home. -- Improved image rendering (nearly x2 speed) -- Improved documentation + API Documentation -- Improved recipe parsing diff --git a/dev/scratch/write_settings.py b/dev/scratch/write_settings.py index 21b897dbc..a76bcd023 100644 --- a/dev/scratch/write_settings.py +++ b/dev/scratch/write_settings.py @@ -37,4 +37,3 @@ if __name__ == "__main__": data = json.dumps(theme) response = requests.post(POST_URL, data) response = requests.get(GET_URL) - print(response.text) diff --git a/dev/scripts/scrape_recipe.py b/dev/scripts/scrape_recipe.py index de18e64b2..ce5f119ef 100644 --- a/dev/scripts/scrape_recipe.py +++ b/dev/scripts/scrape_recipe.py @@ -3,8 +3,11 @@ Helper script to download raw recipe data from a URL and dump it to disk. The resulting files can be used as test input data. """ -import sys, json +import sys, json, pprint +import requests +import extruct from scrape_schema_recipe import scrape_url +from w3lib.html import get_base_url for url in sys.argv[1:]: try: @@ -16,3 +19,9 @@ for url in sys.argv[1:]: print(f"Saved {filename}") except Exception as e: print(f"Error for {url}: {e}") + print("Trying extruct instead") + pp = pprint.PrettyPrinter(indent=2) + r = requests.get(url) + base_url = get_base_url(r.text, r.url) + data = extruct.extract(r.text, base_url=base_url) + pp.pprint(data) diff --git a/docker-compose.arm.yml b/docker-compose.arm.yml new file mode 100644 index 000000000..5c7bc88de --- /dev/null +++ b/docker-compose.arm.yml @@ -0,0 +1,16 @@ +# Use root/example as user/password credentials +# Frontend/Backend Served via the same Uvicorn Server +version: "3.1" +services: + mealie: + build: + context: ./ + dockerfile: Dockerfile.arm + container_name: mealie + restart: always + ports: + - 9090:80 + environment: + db_type: sql + volumes: + - ./mealie/data/:/app/data diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 72b5f9a84..c7ea72e98 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -34,6 +34,14 @@ services: volumes: - ./mealie:/app + mealie-docs: + image: squidfunk/mkdocs-material + restart: always + ports: + - 9924:8000 + volumes: + - ./docs:/docs + # Database mongo: image: mongo diff --git a/docker-compose.yml b/docker-compose.yml index 1b044e1dc..181370e27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -# Use root/example as user/password credentials -# Frontend/Backend Served via the same Uvicorn Server version: "3.1" services: mealie: @@ -9,25 +7,26 @@ services: container_name: mealie restart: always ports: - - 9090:9000 + - 9090:80 environment: + db_type: sql db_username: root db_password: example db_host: mongo db_port: 27017 - volumes: - - ./mealie/data/:/app/data - mongo: - image: mongo - restart: always - environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: example - mongo-express: # Optional Mongo GUI - image: mongo-express - restart: always - ports: - - 9091:8081 - environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: root - ME_CONFIG_MONGODB_ADMINPASSWORD: example + # volumes: + # - ./mealie/data/:/app/data + # mongo: + # image: mongo + # restart: always + # environment: + # MONGO_INITDB_ROOT_USERNAME: root + # MONGO_INITDB_ROOT_PASSWORD: example + # mongo-express: # Optional Mongo GUI + # image: mongo-express + # restart: always + # ports: + # - 9091:8081 + # environment: + # ME_CONFIG_MONGODB_ADMINUSERNAME: root + # ME_CONFIG_MONGODB_ADMINPASSWORD: example diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md index 267eae44a..1ea3ab2b4 100644 --- a/docs/docs/changelog.md +++ b/docs/docs/changelog.md @@ -1,7 +1,39 @@ # Release Notes +## v0.1.0 - Initial Beta +### Bug Fixes + - Fixed Can't delete recipe after changing name - Closes Issue #67 + - Fixed No image when added by URL, and can;t add an image - Closes Issue #66 + - Fixed Images saved with no way to delete when add recipe via URL fails - Closes Issue #43 + +### Features + - Additional Language Support + - Improved deployment documentation + - Additional database! SQlite is now supported! - Closes #48 + - All site data is now backed up. + - Support for Prep Time, Total Time, and Cook Time field - Closes #63 + - New backup import process with support for themes and site settings + - **BETA** ARM support! - Closes #69 + +### Code / Developer Improvements + - Unified Database Access Layers + - Poetry / pyproject.toml support over requirements.txt + - Local development without database is now possible! + - Local mkdocs server added to docker-compose.dev.yml + - Major code refactoring to support new database layer + - Global variable refactor + +### Break Changes + +- Internal docker port is now 80 instead of 9000. You MUST remap the internal port to connect to the UI. + +!!! error "Breaking Changes" + As I've adopted the SQL database model I find that using 2 different types of databases will inevitably hinder development. As such after release v0.1.0 support for mongoDB will no longer be available. Prior to upgrading to v0.2.0 you will need to export your site and import after updating. This should be a painless process and require minimal intervention on the users part. Moving forward we will do our best to minimize changes that require user intervention like this and make updates a smooth process. + + ## v0.0.2 - Pre-release Second Patch A quality update with major props to [zackbcom](https://github.com/zackbcom) for working hard on making the theming just that much better! + ### Bug Fixes - Fixed empty backup failure without markdown template - Fixed opacity issues with marked steps - [mtoohey31](https://github.com/mtoohey31) diff --git a/docs/docs/contributors/non-coders.md b/docs/docs/contributors/non-coders.md index cb0480b28..686d0003d 100644 --- a/docs/docs/contributors/non-coders.md +++ b/docs/docs/contributors/non-coders.md @@ -7,6 +7,7 @@ We love your input! We want to make contributing to this project as easy and tra - Submitting a fix - Proposing new features - Becoming a maintainer +- [Help translate to a new language or improve current translations](../translating) [Remember to join the Discord and stay in touch with other developers working on the project](https://discord.gg/R6QDyJgbD2)! diff --git a/docs/docs/contributors/translating.md b/docs/docs/contributors/translating.md new file mode 100644 index 000000000..a53f0d2ad --- /dev/null +++ b/docs/docs/contributors/translating.md @@ -0,0 +1,15 @@ +# Contributing with translations + +Having Mealie in different language could help the adaption of Mealie. Translations can be a great way for non-coders to contribute to Mealie. + +## Is Mealie missing in your language? +If your language is missing, you can add it, by beginning to translate. We use a Vue-i18n in json files. Copy frontend/src/locales/en.json to get started. + +## Improving translations +If your language is missing the translation for some strings, you can help out by adding a translation for that string. If you find a string you think could be improved, please feel free to do so. + +## Tooling +Currently we use Vue-i18n for translations. Translations are stored in json format located in [frontend/src/locales](https://github.com/hay-kot/mealie/tree/master/frontend/src/locales). +If you have experience with a good Translation Management System, please feel free to chime in on the [Discord](https://discord.gg/R6QDyJgbD2), as such a system could be helpful as the projects grow. +Until then, [i18n Ally for VScode](https://marketplace.visualstudio.com/items?itemName=antfu.i18n-ally) is recommended to aid in translating. It also has a nice feature, which shows translations in-place when editing code. +i18n Ally will also show which languages is missing translations. \ No newline at end of file diff --git a/docs/docs/getting-started/backups-and-exports.md b/docs/docs/getting-started/backups-and-exports.md index f20e0c32d..668ddb3e8 100644 --- a/docs/docs/getting-started/backups-and-exports.md +++ b/docs/docs/getting-started/backups-and-exports.md @@ -3,7 +3,7 @@ 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 view the availible variables, open a recipe in the json editor. +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 available 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. diff --git a/docs/docs/getting-started/install.md b/docs/docs/getting-started/install.md index b5196d2b3..8663fcd16 100644 --- a/docs/docs/getting-started/install.md +++ b/docs/docs/getting-started/install.md @@ -1,26 +1,46 @@ # Installation -To deploy docker on your local network it is highly recommended to use docker to deploy the image straight from dockerhub. Using the docker-compose below you should be able to get a stack up and running easily by changing a few default values and deploying. Currently the only supported database is Mongo. Mealie is looking for contributors to support additional databases. +To deploy docker on your local network it is highly recommended to use docker to deploy the image straight from dockerhub. Using the docker-compose below you should be able to get a stack up and running easily by changing a few default values and deploying. Currently MongoDB and SQLite are supported. MongoDB support will be dropped in v0.2.0 so it is recommended to go with SQLite for new deployments. Postrgres support is planned for the next release, however for most loads you may find SQLite performant enough. [Get Docker](https://docs.docker.com/get-docker/) [Mealie Docker Image](https://hub.docker.com/r/hkotel/mealie) -## Env Variables -| Variables | default | description | -| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| mealie_db_name | mealie | The name of the database to be created in Mongodb | -| mealie_port | 9000 | The port exposed by mealie. **do not change this if you're running in docker** If you'd like to use another port, map 9000 to another port of the host. | -| db_username | root | The Mongodb username you specified in your mongo container | -| db_password | example | The Mongodb password you specified in your mongo container | -| db_host | mongo | The host address of MongoDB if you're in docker and using the same network you can use mongo as the host name | -| db_port | 27017 | the port to access MongoDB 27017 is the default for mongo | -| api_docs | True | Turns on/off access to the API documentation locally. | -| TZ | | You should set your time zone accordingly so the date/time features work correctly | +## Quick Start - Docker CLI +Deployment with the Docker CLI can be done with `docker run` and specify the database type, in this case `sqlite`, setting the exposed port `9000`, mounting the current directory, and pull the latest image. After the image is up an running you can navigate to http://your.ip.addres:9000 and you'll should see mealie up and running! + +```shell +docker run \ + -e db_type='sqlite' \ + -p 9000:80 \ + -v `pwd`:'/app/data/' \ + hkotel/mealie:latest + +``` + +## Docker Compose with SQLite +Deployment with docker-compose is the recommended method for deployment. The example below will create an instance of mealie available on port `9000` with the data volume mounted from the local directory. To use, create a docker-compose.yml file, paste the contents below and save. In the terminal run `docker-compose up -d` to start the container. + +```yaml +version: "3.1" +services: + mealie: + container_name: mealie + image: hkotel/mealie:latest + restart: always + ports: + - 9000:80 + environment: + db_type: sqlite + TZ: America/Anchorage + volumes: + - ./mealie/data/:/app/data + +``` -## Docker Compose +## Docker Compose with Mongo - DEPRECIATED ```yaml # docker-compose.yml @@ -31,7 +51,7 @@ services: image: hkotel/mealie:latest restart: always ports: - - 9000:9000 + - 9000:80 environment: db_username: root # Your Mongo DB Username - Please Change db_password: example # Your Mongo DB Password - Please Change @@ -61,55 +81,21 @@ services: ``` -## Ansible Tasks Template -```yaml -- name: ensures Mealie directory dir exists - file: - path: "{{ docker_dir }}/mealie/" - state: directory - owner: "{{ main_user}}" - group: "{{ main_group }}" +## Env Variables -- name: ensures Mealie directory dir exists - file: - path: "{{ docker_dir }}/mealie/" - state: directory - owner: "{{ main_user}}" - group: "{{ main_group }}" +| Variables | default | description | +| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| db_type | sqlite | The database type to be used. Current Options 'sqlite' and 'mongo' | +| mealie_db_name | mealie | The name of the database to be created in Mongodb | +| mealie_port | 9000 | The port exposed by mealie. **do not change this if you're running in docker** If you'd like to use another port, map 9000 to another port of the host. | +| db_username | root | The Mongodb username you specified in your mongo container | +| db_password | example | The Mongodb password you specified in your mongo container | +| db_host | mongo | The host address of MongoDB if you're in docker and using the same network you can use mongo as the host name | +| db_port | 27017 | the port to access MongoDB 27017 is the default for mongo | +| api_docs | True | Turns on/off access to the API documentation locally. | +| TZ | | You should set your time zone accordingly so the date/time features work correctly | -- name: Deploy Monogo Database - docker_container: - name: mealie-mongo - image: mongo - restart_policy: unless-stopped - networks: - - name: web - env: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: example - - -- name: deploy Mealie Docker Container - docker_container: - name: mealie - image: hkotel/mealie:latest - restart_policy: unless-stopped - ports: - - 9090:9000 - networks: - - name: web - mounts: - - type: bind - source: "{{ docker_dir }}/mealie" - target: /app/data - env: - db_username: root - db_password: example - db_host: mealie-mongo - db_port: "27017" - -``` ## Deployed as a Python Application Alternatively, this project is built on Python and Mongodb. If you are dead set on deploying on a linux machine you can run this in an python environment with a dedicated MongoDatabase. Provided that you know thats how you want to host the application, I'll assume you know how to do that. I may or may not get around to writing this guide. I'm open to pull requests if anyone has a good guide on it. \ No newline at end of file diff --git a/docs/docs/getting-started/migration-imports.md b/docs/docs/getting-started/migration-imports.md index 1326b5d00..7d417026b 100644 --- a/docs/docs/getting-started/migration-imports.md +++ b/docs/docs/getting-started/migration-imports.md @@ -6,7 +6,21 @@ In the Admin page on the in the Migration section you can provide a URL for a re We'd like to support additional migration paths. [See open issues.](https://github.com/hay-kot/mealie/issues) -**Currently Proposed Are:** +### Nextcloud Recipes +Nextcloud recipes can be imported from either a zip file the contains the data stored in Nextcloud. The zip file can be uploaded from the frontend or placed in the data/migrations/Nextcloud directory. See the example folder structure below to ensure your recipes are able to be imported. -- NextCloud Recipes +``` +nextcloud_recipes.zip + ├── recipe_1 + │ ├── recipe.json + │ ├── full.jpg + │ └── thumb.jpg + ├── recipe_2 + │ ├── recipe.json + │ └── full.jpg + └── recipe_3 + └── recipe.json +``` + +**Currently Proposed Are:** - Open Eats \ No newline at end of file diff --git a/docs/docs/html/api.html b/docs/docs/html/api.html index 7a1046cc7..36f3bba3d 100644 --- a/docs/docs/html/api.html +++ b/docs/docs/html/api.html @@ -18,7 +18,7 @@