diff --git a/inquisitor/app.py b/inquisitor/app.py index f78136c..bdc778b 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -92,8 +92,14 @@ def root(): } active_items.insert(0, feed_control) - return render_template("feed.html", items=active_items[:100]) + selection = active_items[:100] + return render_template("feed.html", + items=selection, + mdeac=[ + {'source': item['source'], 'itemid': item['id']} + for item in selection + if 'id' in item]) @app.route("/deactivate/", methods=['POST']) def deactivate(): @@ -119,3 +125,18 @@ def punt(): til_then = morning.timestamp() - item['created'] item['tts'] = til_then return jsonify(item.item) + +@app.route("/mass-deactivate/", methods=['POST']) +def mass_deactivate(): + params = request.get_json() + if 'items' not in params: + logger.error("Bad request params: {}".format(params)) + for info in params.get('items', []): + source = info['source'] + itemid = info['itemid'] + item = loader.WritethroughDict(os.path.join( + DUNGEON_PATH, source, itemid + ".item")) + if item['active']: + logger.debug(f"Deactivating {info['source']}/{info['itemid']}") + item['active'] = False + return jsonify({}) diff --git a/inquisitor/templates/feed.html b/inquisitor/templates/feed.html index 8b020c9..9a845ed 100644 --- a/inquisitor/templates/feed.html +++ b/inquisitor/templates/feed.html @@ -10,7 +10,7 @@ word-break: break-word; } .item-title { font-size: 1.4em; } - .readable-item button { + .item-button { font-size: 1em; float:right; margin-left: 2px; @@ -65,6 +65,19 @@ } }); }; + var mdeactivate = function (items) { + fetch('mass-deactivate/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: JSON.stringify({items: items}), + }) + .then(response => response.json()) + .then(function () { + location.reload() + }); + }; @@ -72,8 +85,8 @@ {% if items %} {% for item in items %}
- {% if item.id %}{% endif %} - {% if item.id %}{% endif %} + {% if item.id %}{% endif %} + {% if item.id %}{% endif %} {% if item.link %}{% endif %} {% if item.body %}
{{item.title}} @@ -95,6 +108,14 @@ {% endif %}
{% endfor %} +
+
+ Feed Management +
+ +
+
+
{% else %}
Feed is empty