227 lines
9.7 KiB
HTML
227 lines
9.7 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Public Profile{% endblock %}
|
|
|
|
{% block content %}
|
|
<section class="rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
|
|
<h1 class="text-3xl font-bold tracking-tight">@{{ page.username }}</h1>
|
|
<p class="mt-2 text-sm text-slate-600">Public profile</p>
|
|
</section>
|
|
|
|
{% if page.show_entries || page.show_weights %}
|
|
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-xl font-bold tracking-tight">{{ page.month_label }}</h2>
|
|
<p class="text-xs text-slate-500">Calendar view</p>
|
|
</div>
|
|
<div class="mt-4 overflow-x-auto">
|
|
<div class="min-w-[720px]">
|
|
<div class="mb-4 grid grid-cols-7 gap-2">
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Sun</div>
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Mon</div>
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Tue</div>
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Wed</div>
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Thu</div>
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Fri</div>
|
|
<div class="text-center text-xs font-semibold uppercase tracking-wide text-slate-500">Sat</div>
|
|
</div>
|
|
<div class="grid grid-cols-7 gap-2">
|
|
{% for cell in page.calendar_cells %}
|
|
{% if cell.is_padding %}
|
|
<div class="h-32 rounded-2xl border border-dashed border-slate-300/80 bg-white/40" aria-hidden="true"></div>
|
|
{% else %}
|
|
{% if cell.is_future %}
|
|
<div class="h-32 rounded-2xl border border-slate-200 bg-slate-100/80 p-3 opacity-65">
|
|
<div class="flex items-start justify-between">
|
|
<span class="text-sm font-semibold text-slate-500">{{ cell.date_text }}</span>
|
|
<span class="rounded-full bg-slate-400 px-2 py-0.5 text-xs font-semibold text-white">{{ cell.day_num }}</span>
|
|
</div>
|
|
<div class="mt-6">
|
|
<p class="text-xl font-bold text-slate-500">{% if page.show_entries %}{{ cell.total }} cal{% else %}Hidden{% endif %}</p>
|
|
<p class="text-xs text-slate-500">{% if page.show_entries %}{{ cell.entry_label }}{% else %}Entries hidden{% endif %}</p>
|
|
<p class="text-xs text-slate-500">{% if page.show_weights %}{{ cell.weight_label }}{% else %}Weight hidden{% endif %}</p>
|
|
<p class="mt-1 text-[11px] uppercase tracking-wide text-slate-400">Future</p>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
{% if cell.href != "#" %}
|
|
<a class="{{ cell.card_class }}" href="{{ cell.href }}">
|
|
<div class="flex items-start justify-between">
|
|
<span class="text-sm font-semibold text-slate-500">{{ cell.date_text }}</span>
|
|
<span class="{{ cell.badge_class }}">{{ cell.day_num }}</span>
|
|
</div>
|
|
<div class="mt-6">
|
|
<p class="{{ cell.total_class }}">{% if page.show_entries %}{{ cell.total }} cal{% else %}Hidden{% endif %}</p>
|
|
<p class="{{ cell.entry_class }}">{% if page.show_entries %}{{ cell.entry_label }}{% else %}Entries hidden{% endif %}</p>
|
|
<p class="{{ cell.entry_class }}">{% if page.show_weights %}{{ cell.weight_label }}{% else %}Weight hidden{% endif %}</p>
|
|
</div>
|
|
</a>
|
|
{% else %}
|
|
<div class="h-32 rounded-2xl border border-slate-200 bg-white p-3">
|
|
<div class="flex items-start justify-between">
|
|
<span class="text-sm font-semibold text-slate-500">{{ cell.date_text }}</span>
|
|
<span class="rounded-full bg-slate-900 px-2 py-0.5 text-xs font-semibold text-white">{{ cell.day_num }}</span>
|
|
</div>
|
|
<div class="mt-6">
|
|
<p class="text-xl font-bold text-slate-900">{% if page.show_entries %}{{ cell.total }} cal{% else %}Hidden{% endif %}</p>
|
|
<p class="text-xs text-slate-600">{% if page.show_entries %}{{ cell.entry_label }}{% else %}Entries hidden{% endif %}</p>
|
|
<p class="text-xs text-slate-600">{% if page.show_weights %}{{ cell.weight_label }}{% else %}Weight hidden{% endif %}</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
|
|
<h2 class="text-xl font-bold tracking-tight">Recent Days</h2>
|
|
<div class="mt-3 overflow-x-auto">
|
|
<table class="w-full border-collapse">
|
|
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500">
|
|
<tr><th class="px-3 py-2">Date</th><th class="px-3 py-2">Calories</th><th class="px-3 py-2">Weight</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for row in page.recent_days %}
|
|
<tr class="border-t border-slate-200">
|
|
<td class="px-3 py-2 text-sm">
|
|
{% if page.show_entries %}
|
|
<a href="{{ row.day_href }}" class="font-semibold text-teal-700 hover:text-teal-900 hover:underline">{{ row.date_text }}</a>
|
|
{% else %}
|
|
{{ row.date_text }}
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-3 py-2 text-sm">{% if page.show_entries %}{{ row.calories }}{% else %}Hidden{% endif %}</td>
|
|
<td class="px-3 py-2 text-sm">{% if page.show_weights %}{{ row.weight_label }}{% else %}Hidden{% endif %}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if page.show_entries || page.show_weights %}
|
|
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
|
|
<h2 class="text-xl font-bold tracking-tight text-slate-900">Recent Trends</h2>
|
|
<p class="mt-1 text-sm text-slate-600">Past 14 days</p>
|
|
<div class="mt-4 grid gap-4 lg:grid-cols-2">
|
|
{% if page.show_entries %}
|
|
<article class="rounded-2xl border border-slate-200 bg-white p-4">
|
|
<h3 class="text-sm font-semibold uppercase tracking-wide text-slate-600">Daily Calories</h3>
|
|
<div class="mt-3 h-72">
|
|
<canvas id="public-calorie-chart"></canvas>
|
|
</div>
|
|
</article>
|
|
{% endif %}
|
|
{% if page.show_weights %}
|
|
<article class="rounded-2xl border border-slate-200 bg-white p-4">
|
|
<h3 class="text-sm font-semibold uppercase tracking-wide text-slate-600">Daily Weight (lbs)</h3>
|
|
<div class="mt-3 h-72">
|
|
<canvas id="public-weight-chart"></canvas>
|
|
</div>
|
|
</article>
|
|
{% endif %}
|
|
</div>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if page.show_reports %}
|
|
<section class="mt-4 grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
|
|
{% for card in page.report_cards %}
|
|
<article class="rounded-2xl border border-slate-200/90 bg-white p-4 shadow-sm">
|
|
<h2 class="text-base font-bold text-slate-900">{{ card.title }}</h2>
|
|
<p class="mt-1 text-xs text-slate-500">{{ card.range_label }}</p>
|
|
<p class="mt-4 text-3xl font-bold tracking-tight text-slate-900">{{ card.average_calories_per_day }}</p>
|
|
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">avg cal/day</p>
|
|
</article>
|
|
{% endfor %}
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if page.show_planning %}
|
|
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
|
|
<h2 class="text-xl font-bold tracking-tight">Planning</h2>
|
|
<dl class="mt-3 space-y-2 text-sm text-slate-700">
|
|
<div class="flex justify-between"><dt>Target weight (lbs)</dt><dd class="font-semibold">{{ page.target_weight_label }}</dd></div>
|
|
<div class="flex justify-between"><dt>Target calories</dt><dd class="font-semibold">{{ page.target_calories_label }}</dd></div>
|
|
<div class="flex justify-between"><dt>BMR</dt><dd class="font-semibold">{{ page.bmr_label }}</dd></div>
|
|
</dl>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if !page.show_entries && !page.show_weights && !page.show_reports && !page.show_planning %}
|
|
<section class="mt-4 rounded-3xl border border-slate-200/80 bg-white/90 p-6 shadow-sm">
|
|
<p class="text-sm text-slate-600">This user has not shared any data publicly.</p>
|
|
</section>
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
{% if page.show_entries || page.show_weights %}
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script>
|
|
const labels = {{ page.chart_labels_js|safe }};
|
|
|
|
{% if page.show_entries %}
|
|
const calories = {{ page.calories_js|safe }};
|
|
new Chart(
|
|
document.getElementById("public-calorie-chart"),
|
|
{
|
|
type: "line",
|
|
data: {
|
|
labels,
|
|
datasets: [
|
|
{
|
|
label: "Daily calories",
|
|
data: calories,
|
|
borderColor: "#0f766e",
|
|
backgroundColor: "rgba(15, 118, 110, 0.15)",
|
|
fill: true,
|
|
tension: 0.25,
|
|
pointRadius: 1.5
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
maintainAspectRatio: false,
|
|
scales: { y: { beginAtZero: true } }
|
|
}
|
|
}
|
|
);
|
|
{% endif %}
|
|
|
|
{% if page.show_weights %}
|
|
const weights = {{ page.weights_js|safe }};
|
|
new Chart(
|
|
document.getElementById("public-weight-chart"),
|
|
{
|
|
type: "line",
|
|
data: {
|
|
labels,
|
|
datasets: [
|
|
{
|
|
label: "Daily weight (lbs)",
|
|
data: weights,
|
|
borderColor: "#2563eb",
|
|
backgroundColor: "rgba(37, 99, 235, 0.15)",
|
|
fill: true,
|
|
tension: 0.25,
|
|
pointRadius: 1.5,
|
|
spanGaps: true
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
maintainAspectRatio: false
|
|
}
|
|
}
|
|
);
|
|
{% endif %}
|
|
</script>
|
|
{% endif %}
|
|
{% endblock %}
|