211 lines
5.7 KiB
Django/Jinja
211 lines
5.7 KiB
Django/Jinja
<html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Intake{% if items %} ({{ items|length }}){% endif %}</title>
|
|
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS41ZEdYUgAAAGFJREFUOE+lkFEKwDAIxXrzXXB3ckMm9EnAV/YRCxFCcUXEL3Jc77NDjpDA/VGL3RFWYEICfeGC8oQc9IPuCAnQDcoRVmBCAn3hgvKEHPSD7ggJ0A3KEVZgQgJ94YLSJ9YDUzNGDXGZ/JEAAAAASUVORK5CYII=">
|
|
<style>
|
|
main {
|
|
max-width: 700px;
|
|
margin: 0 auto;
|
|
}
|
|
article {
|
|
border: 1px solid black; border-radius: 6px;
|
|
padding: 5px;
|
|
margin-bottom: 20px;
|
|
word-break: break-word;
|
|
}
|
|
.item-title {
|
|
font-size: 1.4em;
|
|
}
|
|
.item-button {
|
|
font-size: 1em;
|
|
float:right;
|
|
margin-left: 2px;
|
|
}
|
|
.item-link {
|
|
text-decoration: none;
|
|
float:right;
|
|
font-size: 1em;
|
|
padding: 2px 7px;
|
|
border: 1px solid;
|
|
border-radius: 2px;
|
|
}
|
|
.item-info {
|
|
color: rgba(0, 0, 0, 0.7);
|
|
}
|
|
article img {
|
|
max-width: 100%;
|
|
}
|
|
button, summary {
|
|
cursor: pointer;
|
|
}
|
|
summary {
|
|
display: block;
|
|
}
|
|
summary:focus {
|
|
outline: 1px dotted gray;
|
|
}
|
|
.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;
|
|
}
|
|
article.center {
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
<script>
|
|
var deactivate = function (source, itemid) {
|
|
fetch(`/item/${source}/${itemid}`, {
|
|
method: 'DELETE',
|
|
})
|
|
.then(response => response.json())
|
|
.then(function (data) {
|
|
if (!data.active) {
|
|
document.getElementById(source + "-" + itemid)
|
|
.classList.add("strikethru", "fade");
|
|
}
|
|
});
|
|
};
|
|
var punt = function (source, itemid) {
|
|
fetch(`/item/${source}/${itemid}`, {
|
|
method: 'PATCH',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({tts: "+1"}),
|
|
})
|
|
.then(response => response.json())
|
|
.then(function (data) {
|
|
if (data.tts) {
|
|
document.getElementById(source + "-" + itemid)
|
|
.classList.add("fade");
|
|
}
|
|
});
|
|
};
|
|
var mdeactivate = function (items) {
|
|
console.log(items);
|
|
if (confirm(`Deactivate ${items.length} items?`)) {
|
|
fetch('/mass-deactivate/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({items: items}),
|
|
})
|
|
.then(function () {
|
|
location.reload();
|
|
});
|
|
}
|
|
};
|
|
var doAction = function (source, itemid, action) {
|
|
document.getElementById(`${source}-${itemid}-action-${action}`).disabled = true;
|
|
fetch(`/action/${source}/${itemid}/${action}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
})
|
|
.then(function (data) {
|
|
location.reload()
|
|
});
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<article class="center">
|
|
<span class="item-title">
|
|
<a href="{{url_for('root')}}">Home</a>
|
|
[<a href="{{ set_query(hidden='false', page=None, count=None) }}">Active</a> | <a href="{{ set_query(hidden='true', page=None, count=None) }}">All</a>]
|
|
{% if item_count > items|length -%}
|
|
[<a {% if page_num is greaterthan(0) -%} href="{{ set_query(page=page_num - 1) }}" {%- endif %}>Prev</a>
|
|
|
|
|
<a {% if ((page_num + 1) * page_count) is lessthan(item_count) -%} href="{{ set_query(page=page_num + 1) }}" {%- endif %}>Next</a>]
|
|
{%- endif %}
|
|
</span>
|
|
</article>
|
|
{% if items %}
|
|
{% for item in items %}
|
|
<article class="
|
|
{%- if not item.active %} strikethru{% endif %}
|
|
{%- if item.is_hidden %} fade{% endif -%}
|
|
" id="{{item.source}}-{{item.id}}">
|
|
{% if item.id %}
|
|
<button class="item-button" onclick="javascript:deactivate('{{item.source}}', '{{item.id}}')" title="Deactivate">✕</button>
|
|
{% endif %}
|
|
{% if item.id %}
|
|
<button class="item-button" onclick="javascript:punt('{{item.source}}', '{{item.id}}')" title="Punt to tomorrow">↷</button>
|
|
{% endif %}
|
|
{% if item.link %}
|
|
<a class="item-link" href="{{item.link}}" target="_blank">⇗</a>
|
|
{% endif %}
|
|
|
|
{# The item title is a clickable <summary> if there is body content #}
|
|
{% if item.body or item.action %}
|
|
<details>
|
|
<summary><span class="item-title">{{item.display_title}}</span></summary>
|
|
{% if item.body %}
|
|
<p>{{item.body|safe}}</p>
|
|
{% endif %}
|
|
{% for action in item.action %}
|
|
<p><button id="{{item.source}}-{{item.id}}-action-{{action}}" onclick="javascript:doAction('{{item.source}}', '{{item.id}}', '{{action}}')">{{action}}</button></p>
|
|
{% endfor %}
|
|
</details>
|
|
{% else %}
|
|
<span class="item-title">{{item.display_title}}</span><br>
|
|
{% endif %}
|
|
|
|
{# author/time footer line #}
|
|
{% if item.author or item.time %}
|
|
<span class="item-info">
|
|
{% if item.author %}{{item.author}}{% endif %}
|
|
{% if item.time %}{{item.time|datetimeformat}}{% endif %}
|
|
</span><br>
|
|
{% endif %}
|
|
|
|
{# source/id/created footer line #}
|
|
{% if item.source or item.id or item.created %}
|
|
<span class="item-info" title="{{ 'Tags: {}'.format(', '.join(item.tags)) }}">
|
|
{% if item.source %}{{item.source}}{% endif %}
|
|
{% if item.id %}{{item.id}}{% endif %}
|
|
{% if item.created %}{{item.created|datetimeformat}}{% endif %}
|
|
{% if item.ttl %}L{% endif %}{% if item.ttd %}D{% endif %}{% if item.tts %}S{% endif %}
|
|
</span>
|
|
{% endif %}
|
|
|
|
</article>
|
|
{% endfor %}
|
|
|
|
{% if item_count > items|length %}
|
|
<article class="center">
|
|
<span class="item-title">
|
|
<a {% if page_num is greaterthan(0) -%} href="{{ set_query(page=page_num - 1) }}" {%- endif %}>Prev</a>
|
|
|
|
|
<a {% if ((page_num + 1) * page_count) is lessthan(item_count) -%} href="{{ set_query(page=page_num + 1) }}" {%- endif %}>Next</a>
|
|
</span>
|
|
</article>
|
|
{% endif %}
|
|
|
|
<article class="center">
|
|
<button onclick="javascript:mdeactivate({{ mdeac|safe }})">Deactivate All</button>
|
|
</article>
|
|
|
|
{# if items #}
|
|
{% else %}
|
|
<article class="center">
|
|
<span class="item-title">Feed is empty</span>
|
|
</article>
|
|
{% endif %}
|
|
|
|
</main>
|
|
</body>
|
|
</html>
|