{# Food pages: the core header (βŒ‚ πŸ“… … Β·Β·Β· β€Ή title β€Ί Β·Β·Β· βš™), Health's tab row when it lives there, and the left column both pages share β€” the energy ring + nutrient bars of the day shown, the add / describe buttons, the Day | History switch. #} {% from "_header.html" import nav_btns, settings_btn, title_block, subline, section_tabs %} {% macro head(title, sub, current=True, center_href="/food", prev_href=None, next_href=None, can_next=True) %}
{{ nav_btns() }} {{ title_block(title, center_href, current, prev_href, next_href, can_next=can_next, prev_title="Day before", next_title="Day after", link_title="Today") }} {{ settings_btn("food") }}
{{ subline(sub) }} {% if plugin_host("food") %}{{ section_tabs(plugin_host("food"), "/food") }}{% endif %}{# inside Health: its tab row #} {% endmacro %} {% macro n(x, unit="") %}{% if x is none %}β€”{% else %}{{ "{:,.0f}".format(x).replace(",", " ") }}{% if unit %} {{ unit }}{% endif %}{% endif %}{% endmacro %} {% macro g(x) %}{% if x is none %}β€”{% elif x < 10 %}{{ "%.1f" | format(x) | replace(".0", "") }}{% else %}{{ x | round | int }}{% endif %}{% endmacro %} {# protein / carbs / fat as coloured dots (the ring's colours), the names on hover (letters were tried: dots read better) #} {% macro mac(p, c, f) %}{% for k, x in [("protein", p), ("carbs", c), ("fat", f)] %}{{ g(x) }}{% if x is not none %} g{% endif %}{% endfor %}{% endmacro %} {% macro day_label(d, today) %}{% if d == today %}Today{% elif (today - d).days == 1 %}Yesterday{% elif (d - today).days == 1 %}Tomorrow{% else %}{{ d.strftime("%a") }} {{ d.day }} {{ d.strftime("%b") }}{% endif %}{% endmacro %} {# the energy ring (views.ring) β€” r: the ring, size: its CSS width #} {% macro plan_tip(p) %}{% if p.set %}Your own target (Settings β–Έ Food){% if p.calc %}; calculated: {{ n(p.calc) }} kcal{% endif %}.{% elif p.calc and not p.rate %}Your usual day, to keep your weight: {{ n(p.calc) }} kcal.{% elif p.calc %}Your usual day {{ n(p.maintenance) }} kcal {{ "+" if p.rate < 0 else "βˆ’" }} {{ n(p.deficit | abs) }} for {{ "%g" | format(p.rate | abs) }} % a week{% if p.capped %} (limited){% endif %} = {{ n(p.calc) }} kcal.{% else %}Default target β€” Health's profile and a weight give a calculated one.{% endif %}{% endmacro %} {% macro ring(r, p=None) %}
{{ n(r.kcal) }}of {{ n(r.target) }} kcal {% if r.left >= 0 %}{{ n(r.left) }} left{% else %}{{ n(-r.left) }} over{% endif %}
{% endmacro %} {# nutrient bars (views.bars): the three macros big, the rest small #} {% macro bars(bs) %}
{% for b in bs[:3] %}
{{ b.label }}{{ g(b.v) }} / {{ b.target }} g
{% endfor %}
{% for b in bs[3:] %} {% if b.kind == "info" %}
{{ b.label }}
{{ g(b.v) }} {{ b.unit }}
{% else %}
{{ b.label }}
{{ g(b.v) }} / {{ "β‰₯ " if b.kind == "min" else "≀ " if b.kind == "max" }}{{ n(b.target) }} {{ b.unit }}
{% endif %}
{% endfor %}
{% endmacro %} {# the day's activity from Health (views.day: activity, balance) β€” under the macros #} {% macro activity(v) %}{% set a, e = v.activity, v.activity.energy %}
Activity{{ " so far" if v.day == v.today }}Health β€Ί
{% if a.steps %}{{ n(a.steps) }} steps{% endif %} {% for w in a.workouts %}{{ w.name }} Β· {{ w.minutes }} min{% if w.kcal %} Β· {{ n(w.kcal) }} kcal{% endif %}{% endfor %} {% if not a.workouts %}no workout{% endif %}
{% if e %}
Burned β‰ˆ {{ n(e.total) }} kcal {% if v.balance is not none %}eaten βˆ’ burned {{ "+" if v.balance > 0 }}{{ n(v.balance) }}{% endif %}
{% endif %}
{% endmacro %} {# v = views.day(…) for the day shown (History: today) #} {% macro side(v) %}

{{ day_label(v.day, v.today) }}

{{ ring(v.ring, v.plan) }} {{ bars(v.bars) }} {% if v.activity %}{{ activity(v) }}{% endif %}
{% if model_off %}{# the model switched off (Settings β–Έ Food): just the form #}
{% else %}
{% if parser %} {% else %}Needs a language model β€” set its address in Settings β–Έ Food. Until then, add foods with the form.{% endif %}
{% endif %}
{% endmacro %} {% macro assets() %} {% endmacro %} {# the dialogs (no browser dialogs): one entry; the describe box's list to confirm #} {% macro dialogs(day) %} {# the inline editor (food.js InlineEditor): dropped into a meal card by its +, or into a logged food's line when clicked. data-mode: search (just the box) Β· food (a picked food: its numbers as text, amount + unit) Β· edit (Edit item: its values per 100 g + portions editable) Β· new (a food typed in) Β· totals (an entry without a food: its numbers). "More": day, meal, note. #} {% endmacro %}