From 08fce0ae1602e2b4d44f22210b123921ba458a97 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Tue, 12 Dec 2023 02:32:04 +0000 Subject: [PATCH 1/3] update package name in dockerfile --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7243e52..a4621d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,9 @@ RUN apk add --no-cache python3 py3-build py3-hatchling && \ python3 -m build . FROM alpine:3.18 -COPY --from=build /build/dist/comfy-recipes-*-py3-none-any.whl / +COPY --from=build /build/dist/ /mnt RUN apk add --no-cache python3 py3-pip && \ - pip install /comfy-recipes-*-py3-none-any.whl && \ - apk del py3-pip + pip install /mnt/comfy_recipes-*-py3-none-any.whl && \ + apk del py3-pip && \ + rm -r /mnt ENTRYPOINT ["/usr/bin/recipes-cli"] From 8046f0d237c3cae18cb5be64ecd8b8b85c6f3cc3 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Tue, 12 Dec 2023 02:33:12 +0000 Subject: [PATCH 2/3] responsive website --- comfyrecipes/templates/base.html | 1 + 1 file changed, 1 insertion(+) diff --git a/comfyrecipes/templates/base.html b/comfyrecipes/templates/base.html index cf3a0b6..720c2a8 100644 --- a/comfyrecipes/templates/base.html +++ b/comfyrecipes/templates/base.html @@ -7,6 +7,7 @@ {% block title %}{% endblock %} + {% block body %}{% endblock %} From 88f801cadbe176ef06fb790757612b39dd3d5e54 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sun, 12 May 2024 22:18:45 +0000 Subject: [PATCH 3/3] show full recipe price every time with a clarification if necessary --- comfyrecipes/parsing.py | 27 +++++++++++++++++++++++---- comfyrecipes/templates/base.html | 11 +++++++++++ comfyrecipes/templates/index.html | 2 +- comfyrecipes/templates/recipe.html | 7 +++++-- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/comfyrecipes/parsing.py b/comfyrecipes/parsing.py index 7f73140..6778e05 100644 --- a/comfyrecipes/parsing.py +++ b/comfyrecipes/parsing.py @@ -289,7 +289,7 @@ class Recipe(Element): source: Optional[SafeHTML], ingredients: List[IngredientInstance], subrecipes: List["Recipe"], - price: Optional["PriceDB"], + price: Optional["MultiPriceDB"], stepsections: List[StepSection], ) -> None: super().__init__(ctx) @@ -317,7 +317,7 @@ class Recipe(Element): rp = Recipe.from_dict(ctx, partdct) subrecipes.append(rp) - price: Optional[PriceDB] = None + price: Optional[MultiPriceDB] = None pricex: float = 0 ingswithprice = 0 ingswithoutprice = 0 @@ -335,16 +335,22 @@ class Recipe(Element): # we don't know how to convert currencies yet currency = None break - if currency is None or ingswithoutprice != 0 or len(ingredients) == 0: + if currency is None or len(ingredients) == 0: price = None else: - price = PriceDB( + pricedb = PriceDB( ctx=ctx, price=pricex, amount=1, unit=ctx.default_unit, currency=currency, ) + price = MultiPriceDB( + ctx=ctx, + pricedb=pricedb, + item_count=len(ingredients), + item_prices_missing=ingswithoutprice, + ) stepsections: List[StepSection] = [] if "steps" in dct: @@ -594,3 +600,16 @@ class PriceDB(Element): if currency is None: raise RuntimeError("currency not specified and default_currency is also not set") return cls(ctx=ctx, price=price, amount=amount, unit=unit, currency=currency) + +class MultiPriceDB(Element): + def __init__( + self, + ctx: Context, + pricedb: PriceDB, + item_count: int, + item_prices_missing: int, + ) -> None: + super().__init__(ctx) + self.pricedb = pricedb + self.item_count = item_count + self.item_prices_missing = item_prices_missing diff --git a/comfyrecipes/templates/base.html b/comfyrecipes/templates/base.html index 720c2a8..b85b929 100644 --- a/comfyrecipes/templates/base.html +++ b/comfyrecipes/templates/base.html @@ -1,6 +1,17 @@ {% macro price(price) -%} {% if price != None and price is defined and price.price is defined %}{{price.price|round(1)|numprint}}{%else%}?{% endif %} {{price.currency}} {%- endmacro %} +{% macro multiprice(multiprice, shortform) -%} +{% if multiprice != None and multiprice.pricedb != None and multiprice.pricedb is defined and multiprice.pricedb.price is defined -%} +{{multiprice.pricedb.price|round(1)|numprint}} +{%else%} +? +{%- endif %} + {{multiprice.pricedb.currency}} +{%if multiprice.item_prices_missing != 0 and not shortform%} +({{multiprice.item_prices_missing}}/{{multiprice.item_count}} prices missing) +{%endif%} +{%- endmacro %} diff --git a/comfyrecipes/templates/index.html b/comfyrecipes/templates/index.html index 9a38e25..eaccdb5 100644 --- a/comfyrecipes/templates/index.html +++ b/comfyrecipes/templates/index.html @@ -3,6 +3,6 @@ {%block body %}

Recipes

{% for recipe in recipes %} -
  • {% if recipe.price != None %}{{price(recipe.price)}} {%endif%}{{ recipe.title }}
  • +
  • {% if recipe.price != None %}{{multiprice(recipe.price, true)}} {%endif%}{{ recipe.title }}
  • {% endfor %} {%endblock%} diff --git a/comfyrecipes/templates/recipe.html b/comfyrecipes/templates/recipe.html index 2ffc5b1..81e7591 100644 --- a/comfyrecipes/templates/recipe.html +++ b/comfyrecipes/templates/recipe.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% macro ingredientpart(ing) -%} -{% if recipe.price != None %}{{price(ing.price)}} {%endif%} +{% if ing.price != None %}{{price(ing.price)}} {%endif%} {% if ing.amount != None %} {{ing.amount|amountprint}} {% if ing.unit != None %} {{ing.unit.name}}{% endif %} {%endif%} @@ -29,7 +29,10 @@ {% for ing in rec.ingredients %}
  • {{ingredient(ing)}}
  • {% endfor %} -{% if rec.price != None %}price: {{price(rec.price)}}{%endif%} +{% if rec.price != None %} +
    +price: {{multiprice(rec.price)}} +{%endif%} {% endif %} {% if rec.stepsections|length != 0 %}

    Steps