Initial commit with webpage

This commit is contained in:
bkelldog committed 2026-11-06 11:42:34 -05:00
commit 26875de1dd
55 files changed
+5726

No files matched your search

+122
View File
@@ -0,0 +1,122 @@
{# Reusable pieces. Import with: {% import "macros.html" as ui %} #}
{% macro alerts(items) %}
{% for a in items %}
<div class="alert alert-{{ a.level }}" role="{{ 'alert' if a.level == 'serious' else 'status' }}">
<span class="alert-icon" aria-hidden="true">{{ {'info': 'i', 'warning': '!', 'serious': '!!'}[a.level] }}</span>
<span><strong class="alert-label">{{ {'info': 'Note', 'warning': 'Heads up', 'serious': 'Important'}[a.level] }}:</strong>
{{ a.text }}{% if a.href %} <a href="{{ a.href }}">{{ a.link_text or 'Details' }}</a>{% endif %}</span>
</div>
{% endfor %}
{% endmacro %}
{% macro event_row(ev, f, now, show_day=false) %}
<li class="ev{% if ev.is_open %} is-open{% endif %}">
<time datetime="{{ ev.started_at.isoformat() }}">{% if show_day %}<span class="muted">{{ f.day(ev.started_at) }}</span> {% endif %}{{ f.time(ev.started_at) }}</time>
<span class="dot cat-{{ ev.kind.category }}" aria-hidden="true"></span>
<span class="ev-main">
<span class="ev-title"><span class="emoji" aria-hidden="true">{{ ev.kind.emoji }}</span> {{ ev.kind.label }}</span>
{% if ev.kind.is_duration %}
{% if ev.ended_at %}<span class="muted">until {{ f.time(ev.ended_at) }} · {{ f.duration(ev.duration.total_seconds()) }}</span>
{% else %}<span class="badge badge-live">in progress · <span data-since="{{ f.unix(ev.started_at) }}">{{ f.duration((now - ev.started_at).total_seconds()) }}</span></span>{% endif %}
{% endif %}
{% if ev.note %}<span class="note">{{ ev.note }}</span>{% endif %}
</span>
<span class="ev-src muted" title="{{ 'From the Mamadachi, button ' ~ ev.button if ev.source == 'device' else 'Added on the website' }}">
{%- if ev.source == 'device' %}B{{ ev.button }}{% else %}web{% endif -%}
{%- if ev.clock_corrected %} ⏱{% endif -%}
</span>
<a class="ev-edit" href="/events/{{ ev.id }}" aria-label="Edit {{ ev.kind.label }} at {{ f.time(ev.started_at) }}">Edit</a>
</li>
{% endmacro %}
{% macro rhythm_legend() %}
<ul class="legend" aria-label="Legend">
<li><span class="lg lg-bar cat-sleep"></span>Sleep</li>
<li><span class="lg lg-dot cat-feeding"></span>Feed</li>
<li><span class="lg lg-ring cat-diaper"></span>Wet diaper</li>
<li><span class="lg lg-diamond cat-diaper"></span>Dirty diaper</li>
<li><span class="lg lg-tick cat-other"></span>Other</li>
</ul>
{% endmacro %}
{% macro rhythm_chart(rows, f, compact=false) %}
<div class="rhythm{% if compact %} compact{% endif %}">
<div class="rh-row rh-axis" aria-hidden="true">
<span class="rh-label"></span>
<div class="rh-ticks">
{% for h in [0, 6, 12, 18] %}<span style="left: {{ h / 24 * 100 }}%">{{ f.hour_label(h) }}</span>{% endfor %}
</div>
</div>
{% for row in rows %}
<div class="rh-row">
<span class="rh-label">{% if not compact %}{{ f.day_short(row.day) }}{% endif %}</span>
<div class="rh-track">
{% for m in row.marks %}
{% if m.shape == 'bar' %}
<span class="m m-bar cat-{{ m.cat }}{% if m.open %} m-open{% endif %}" style="left: {{ '%.2f' % m.left }}%; width: {{ '%.2f' % m.width }}%" data-tip="{{ m.tip }}"></span>
{% else %}
<span class="m m-{{ m.shape }} cat-{{ m.cat }}" style="left: {{ '%.2f' % m.left }}%" data-tip="{{ m.tip }}"></span>
{% endif %}
{% endfor %}
{% if row.now_pct is not none %}<span class="m-now" style="left: {{ '%.2f' % row.now_pct }}%" data-tip="Now"></span>{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endmacro %}
{% macro column_chart(c) %}
<figure class="card chart">
<figcaption>
<h3><span class="key cat-{{ c.cat }}" aria-hidden="true"></span>{{ c.title }}</h3>
<p class="muted">{{ c.summary }}</p>
</figcaption>
<div class="cols" role="img" aria-label="{{ c.title }}: {% for col in c.columns %}{{ col.tip }}{% if not loop.last %}; {% endif %}{% endfor %}">
<div class="cols-plot">
{% for t in c.ticks %}<span class="gridline" style="bottom: {{ t.pct }}%"><em>{{ t.label }}</em></span>{% endfor %}
<div class="cols-bars">
{% for col in c.columns %}
<div class="col" data-tip="{{ col.tip }}">
<div class="col-bar cat-{{ c.cat }}{% if col.value == 0 %} is-zero{% endif %}{% if col.partial %} is-partial{% endif %}" style="height: {{ '%.2f' % col.height }}%">
{% if col.show_value %}<b>{{ col.display }}</b>{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
{% set n = c.columns | length %}
{% set step = 1 if n <= 7 else (2 if n <= 14 else 5) %}
<div class="cols-x">
{% for col in c.columns %}<span>{% if (n - 1 - loop.index0) % step == 0 %}{{ col.label }}{% endif %}</span>{% endfor %}
</div>
</div>
</figure>
{% endmacro %}
{% macro battery_chart(c) %}
{% if c.empty %}
<p class="muted empty">No battery readings in this period yet.</p>
{% else %}
<div class="line" data-line>
<div class="line-plot">
{% for t in c.yticks %}<span class="gridline" style="bottom: {{ '%.2f' % t.pct }}%"><em>{{ t.label }}</em></span>{% endfor %}
<svg viewBox="0 0 1000 300" preserveAspectRatio="none" aria-hidden="true">
<path class="line-area" d="{{ c.area }}"></path>
<path class="line-path" d="{{ c.path }}"></path>
</svg>
<span class="line-cross" hidden></span>
<span class="line-dot" hidden></span>
<script type="application/json">[{% for p in c.points %}[{{ p.x / 10 }}, {{ 100 - p.y / 3 }}, {{ p.tip | tojson }}]{% if not loop.last %},{% endif %}{% endfor %}]</script>
</div>
<div class="line-x" aria-hidden="true">
{% for t in c.xticks %}<span style="left: {{ '%.2f' % t.pct }}%">{{ t.label }}</span>{% endfor %}
</div>
</div>
{% endif %}
{% endmacro %}