diff --git a/inquisitor/app.py b/inquisitor/app.py index 28f11e3..f78136c 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -1,4 +1,5 @@ # Standard library imports +from datetime import datetime, timedelta import os import traceback @@ -99,6 +100,22 @@ def deactivate(): params = request.get_json() if 'source' not in params and 'itemid' not in params: logger.error("Bad request params: {}".format(params)) - item = loader.WritethroughDict(os.path.join(DUNGEON_PATH, params['source'], params['itemid'] + '.item')) + item = loader.WritethroughDict(os.path.join( + DUNGEON_PATH, params['source'], params['itemid'] + '.item')) + if item['active']: + logger.debug(f"Deactivating {params['source']}/{params['itemid']}") item['active'] = False return jsonify({'active': item['active']}) + +@app.route("/punt/", methods=['POST']) +def punt(): + params = request.get_json() + if 'source' not in params and 'itemid' not in params: + logger.error("Bad request params: {}".format(params)) + item = loader.WritethroughDict(os.path.join( + DUNGEON_PATH, params['source'], params['itemid'] + '.item')) + tomorrow = datetime.now() + timedelta(days=1) + morning = datetime(tomorrow.year, tomorrow.month, tomorrow.day, 6, 0, 0) + til_then = morning.timestamp() - item['created'] + item['tts'] = til_then + return jsonify(item.item) diff --git a/inquisitor/templates/feed.html b/inquisitor/templates/feed.html index 6572325..8b020c9 100644 --- a/inquisitor/templates/feed.html +++ b/inquisitor/templates/feed.html @@ -10,11 +10,14 @@ word-break: break-word; } .item-title { font-size: 1.4em; } - .readable-item button { font-size: 1em; float:right; } + .readable-item button { + font-size: 1em; + float:right; + margin-left: 2px; + } .item-link { text-decoration: none; float:right; - margin: 0px 2px; font-size: 1em; padding: 2px 7px; border: 1px solid; @@ -24,10 +27,8 @@ .readable-item img { max-width: 100%; } button, summary { cursor: pointer; } summary:focus { outline: 1px dotted gray; } - .strikethru span, .strikethru p { - text-decoration: line-through; - color: rgba(0, 0, 0, 0.2); - } + .strikethru span, .strikethru p { text-decoration: line-through; } + .fade span, .fade p { color: rgba(0, 0, 0, 0.2); } pre { white-space: pre-wrap; } table.feed-control td { font-family: monospace; padding: 5px 10px; } @@ -44,10 +45,26 @@ .then(function (data) { if (!data.active) { document.getElementById(source + "-" + itemid) - .classList.add("strikethru") + .classList.add("strikethru", "fade"); } }); - } + }; + var punt = function (source, itemid) { + fetch('punt/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: JSON.stringify({source: source, itemid: itemid}), + }) + .then(response => response.json()) + .then(function (data) { + if (data.tts) { + document.getElementById(source + "-" + itemid) + .classList.add("fade"); + } + }); + };
@@ -55,7 +72,8 @@ {% if items %} {% for item in items %}