news-reader-php/templates/entry/_single.html.twig
Daniel Siepmann a4e4f5da0d
WIP|Allow to mark entries as read and unread
Add new read link to each entry. If entry was read the link will be
replaced with an unread link.
Clicking the link will mark the entry as read or unread.
Afterwards a redirect to referrer happens. If it is unkown, for whatever
reason, fallback to start.
Flash messages are added and rendered to let user know what happened.

Also respect already read entries when opening a feed.

WIP:

Still need to adjust entry listing for buckets.
Still need to add tests for new feature.

Still need to add new start page to show newest unread entries from all
buckets.
2020-08-14 13:03:08 +02:00

38 lines
1.7 KiB
Twig

<article>
<h1><a href="{{ path('entry', {slug: entry.slug}) }}">{{ entry.name }}</a></h1>
<time>{{ entry.published | format_datetime(dateFormat = 'medium', timeFormat = 'short') }}</time>
<main>
{% if short is defined and short %}
{{ entry.content | striptags() | u.truncate(1000, '…') }}
<p><a href="{{ path('entry', {slug: entry.slug}) }}">Read more …</a></p>
{% else %}
{# TODO: Use something like parsefunc from TYPO3 to output allowed and secured content #}
{# Also in entries.html.twig? But with different configuration #}
{# <main>{{ entry.content | striptags('<p>,<a>,<strong>,<i>,<h1>,<h2>,<h3>,<h4>,<ul>,<li>') | raw }}</main> #}
{{ entry.content | striptags('<p>,<a>,<strong>,<i>,<h1>,<h2>,<h3>,<h4>,<ul>,<li>') | raw }}
{% endif %}
</main>
<nav>
{% if entry.url %}
<a href="{{ entry.url }}" target="_blank"
rel="external nofollow noopener noreferrer"
referrerpolicy="no-referrer">Entry URL</a>
{% endif %}
<a href="{{ entry.feed.url }}" target="_blank"
rel="external nofollow noopener noreferrer"
referrerpolicy="no-referrer">Feed URL</a>
<a href="{{ path('bucket', {slug: entry.feed.bucket.slug}) }}">{{ entry.feed.bucket.name }} bucket</a>
<a href="{{ path('feed', {slug: entry.feed.slug}) }}">{{ entry.feed.name }} feed</a>
{% if entry.wasRead %}
<a href="{{ path('entry-mark-as-un-read', {slug: entry.slug}) }}">Mark as unread</a>
{% else %}
<a href="{{ path('entry-mark-as-read', {slug: entry.slug}) }}">Mark as read</a>
{% endif %}
</nav>
</article>