summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/app.py5
-rw-r--r--app/templates/index.html24
2 files changed, 25 insertions, 4 deletions
diff --git a/app/app.py b/app/app.py
index e3e45d9..da5dc8d 100644
--- a/app/app.py
+++ b/app/app.py
@@ -325,7 +325,7 @@ def logout():
@app.route('/')
def index():
- ws = week_start_from_str(None)
+ ws = week_start_from_str(request.args.get('week'))
dates = week_dates(ws)
uid = current_user.id if current_user.is_authenticated else 1
db = database.get_db()
@@ -345,6 +345,9 @@ def index():
stat_map=stat_map, meal_types=MEAL_TYPES,
cuisine_emoji=CUISINE_EMOJI_MAP,
today_str=date.today().isoformat(),
+ prev_week=(ws - timedelta(weeks=1)).isoformat(),
+ next_week=(ws + timedelta(weeks=1)).isoformat(),
+ is_current_week=(ws == week_start_from_str(None)),
)
diff --git a/app/templates/index.html b/app/templates/index.html
index 55b5ef0..c690525 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -7,9 +7,16 @@
<h1 class="h3 mb-0 fw-bold">This Week's Plan</h1>
<p class="text-muted mb-0">{{ week_start.strftime('%B %d') }} – {{ (dates[-1]).strftime('%B %d, %Y') }}</p>
</div>
- <div class="d-flex gap-2">
- <a href="/meal-plan" class="btn btn-primary"><i class="bi bi-pencil-square me-1"></i>Edit Plan</a>
- <a href="/shopping-list" class="btn btn-outline-secondary"><i class="bi bi-cart me-1"></i>Shopping List</a>
+ <div class="d-flex gap-2 align-items-center">
+ <a href="/?week={{ prev_week }}" class="btn btn-outline-secondary btn-sm"><i class="bi bi-chevron-left"></i></a>
+ <input type="week" id="weekPicker" class="form-control form-control-sm" style="width:160px"
+ value="{{ week_start.strftime('%G-W%V') }}">
+ {% if not is_current_week %}
+ <a href="/" class="btn btn-outline-secondary btn-sm">Today</a>
+ {% endif %}
+ <a href="/?week={{ next_week }}" class="btn btn-outline-secondary btn-sm"><i class="bi bi-chevron-right"></i></a>
+ <a href="/meal-plan?week={{ week_start.isoformat() }}" class="btn btn-primary btn-sm"><i class="bi bi-pencil-square me-1"></i>Edit Plan</a>
+ <a href="/shopping-list?week={{ week_start.isoformat() }}" class="btn btn-outline-secondary btn-sm"><i class="bi bi-cart me-1"></i>Shopping List</a>
</div>
</div>
@@ -114,5 +121,16 @@
{% block scripts %}
<script>
const todayStr = '{{ today_str }}';
+ document.getElementById('weekPicker').addEventListener('change', function() {
+ if (!this.value) return;
+ // value is "YYYY-Www" — convert to Mon of that ISO week
+ const [year, week] = this.value.split('-W').map(Number);
+ const jan4 = new Date(year, 0, 4); // Jan 4 is always in week 1
+ const dayOfWeek = jan4.getDay() || 7; // Mon=1..Sun=7
+ const mon = new Date(jan4);
+ mon.setDate(jan4.getDate() - (dayOfWeek - 1) + (week - 1) * 7);
+ const iso = mon.toISOString().split('T')[0];
+ window.location.href = '/?week=' + iso;
+ });
</script>
{% endblock %}