From 3e3de7ea597a6ee4d804b08beca567162d4065d9 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sat, 12 Oct 2024 00:04:40 +0200 Subject: [PATCH 1/5] pyproject.toml: add dependency required with newer lxml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7cedace..e6bf155 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = "Smart recipe static site generator" authors = [{ name = "Emi Vasilek", email = "emi.vasilek@gmail.com" }] keywords = ["recipes", "recipe", "static site generator"] requires-python = ">= 3.8" -dependencies = ["jsonschema", "jinja2", "PyYAML", "mistune", "lxml"] +dependencies = ["jsonschema", "jinja2", "PyYAML", "mistune", "lxml", "lxml_html_clean"] classifiers = [ "Development Status :: 3 - Alpha", "Programming Language :: Python", From cc9206306ab3c771a0fdc2bd6dc876d050e4abe1 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sat, 12 Oct 2024 00:05:45 +0200 Subject: [PATCH 2/5] parsing: also accept short ingredients without amounts for example 'oil' will now be allowed, previously it would have to be `1 spoon oil` when sometimes people don't know the amount --- comfyrecipes/parsing.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/comfyrecipes/parsing.py b/comfyrecipes/parsing.py index 6778e05..fd61440 100644 --- a/comfyrecipes/parsing.py +++ b/comfyrecipes/parsing.py @@ -197,23 +197,24 @@ class IngredientInstance(Element): def from_dict(cls, ctx: Context, dct: str | Dict[str, Any]) -> Self: if isinstance(dct, str): string = dct.strip() - p = re.compile(r"^(?:([0-9\.]+) ([a-zA-Z]+) )?([\w ]+)(?: \((.*)\))?$") + p = re.compile(r"^(?:([0-9\.]+) ([a-zA-Z]+) )+([\w ]+)(?: \((.*)\))?$") match = p.match(string) - if match is None: - raise RuntimeError( - "ingredient {string} regex not matched, it should be in the format [amount(num) unit(string, one word)] name(string, any number of words) [(note(string))]" - ) - amount = float(match.group(1)) - unitstr = match.group(2) + + amount = float(1) unit = ctx.default_unit - if unit is not None: - unitx = ctx.units.get(unitstr) - if unitx is None: - ctx.issues.error(issues.ISSUE_UNKNOWN_UNIT, "unknown unit {unitstr}") - else: - unit = unitx - name = match.group(3) - note = match.group(4) + name = string + note = None + if match is not None: + amount = float(match.group(1)) + unitstr = match.group(2) + if unit is not None: + unitx = ctx.units.get(unitstr) + if unitx is None: + ctx.issues.error(issues.ISSUE_UNKNOWN_UNIT, f"unknown unit {unitstr}") + else: + unit = unitx + name = match.group(3) + note = match.group(4) if note is None: note = "" return cls( From 8a9ae16ad344876e17926b654b9db0f8b390fdfb Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sat, 12 Oct 2024 00:12:20 +0200 Subject: [PATCH 3/5] .woodpecker: add --- .woodpecker/containers.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .woodpecker/containers.yaml diff --git a/.woodpecker/containers.yaml b/.woodpecker/containers.yaml new file mode 100644 index 0000000..3a83407 --- /dev/null +++ b/.woodpecker/containers.yaml @@ -0,0 +1,15 @@ +when: + - event: push + branch: main + +steps: + - name: publish + image: woodpeckerci/plugin-docker-buildx + settings: + platforms: linux/amd64,linux/arm64/v8 + repo: git.comfy.city/emi/comfy-recipes + registry: git.comfy.city + tags: latest + username: ${CI_REPO_OWNER} + password: + from_secret: registry_token From ae3ee28ab441b88a00addddb4b6fd9dfe8ff11fd Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sat, 12 Oct 2024 00:20:05 +0200 Subject: [PATCH 4/5] README.md: update --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3e886c8..15c3e4b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,13 @@ Comfy Recipes is a simple application that renders your recipes into HTML. Documentation is available at -## Building the python package +## Running +```sh +docker run -v ./recipes:/recipes git.comfy.city/Emi/comfy-recipes:latest build /recipes +``` + +## Building +### Building the python package Make sure you have hatchling and build modules installed. ```sh python3 -m build @@ -15,17 +21,17 @@ The package can now be installed with pip install dist/comfy-recipes-*-py3-none-any.whl ``` -## Building the docker container +### Building the docker container ```sh docker buildx build -t git.comfy.city/Emi/comfy-recipes:local . ``` The container can now be ran ```sh -docker run --rm git.comfy.city/Emi/comfy-recipes:local +docker run -v ./recipes:/recipes git.comfy.city/Emi/comfy-recipes:local build /recipes ``` -## Building the documentation +### Building the documentation ```sh cd docs mdbook build From b05610cae327b0b8220846e98876a7d973a5f676 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sat, 12 Oct 2024 00:20:25 +0200 Subject: [PATCH 5/5] Dockerfile: fix entrypoint --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c9bddac..e2b34a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ FROM python:3.13-alpine COPY --from=build /build/dist/ /mnt RUN pip install /mnt/comfy_recipes-*-py3-none-any.whl && \ rm -r /mnt -ENTRYPOINT ["/usr/bin/recipes-cli"] +ENTRYPOINT ["/usr/local/bin/recipes-cli"]