diff --git a/src/reader/_app/v2/__init__.py b/src/reader/_app/v2/__init__.py index 36a578c4..4d43f331 100644 --- a/src/reader/_app/v2/__init__.py +++ b/src/reader/_app/v2/__init__.py @@ -1,6 +1,8 @@ from functools import partial +from flask import abort from flask import Blueprint +from flask import redirect from flask import request from .. import get_reader @@ -22,9 +24,9 @@ def entries(): # TODO: if search/tags is active, search/tags box should not be hidden # TODO: highlight active filter preset + uncollapse more # TODO: feed filter - # TODO: pagination + # TODO: paqgination # TODO: read time - # TODO: mark as ... + # TODO: htmx mark as ... form = EntryFilter(request.args) kwargs = dict(form.data) @@ -40,3 +42,33 @@ def entries(): return stream_template( 'v2/entries.html', presets=ENTRY_FILTER_PRESETS, form=form, entries=entries ) + + +@blueprint.route('/mark-as', methods=['POST']) +def mark_as(): + reader = get_reader() + + entry = request.form['feed-url'], request.form['entry-id'] + + if 'read' in request.form: + match request.form['read']: + case 'true': + reader.set_entry_read(entry, True) + case 'false': + reader.set_entry_read(entry, False) + case _: + abort(422) + + if 'important' in request.form: + match request.form['important']: + case 'true': + reader.set_entry_important(entry, True) + case 'false': + reader.set_entry_important(entry, False) + case 'none': + reader.set_entry_important(entry, None) + case _: + abort(422) + + print(request.form['next']) + return redirect(request.form['next'], code=303) diff --git a/src/reader/_app/v2/templates/v2/entries.html b/src/reader/_app/v2/templates/v2/entries.html index 0096c3e9..213a5e52 100644 --- a/src/reader/_app/v2/templates/v2/entries.html +++ b/src/reader/_app/v2/templates/v2/entries.html @@ -46,7 +46,7 @@ {% for entry in entries %} -