microblog.pub/templates/stream.html
Thomas Sileo d70c73cad7 Improve notifications
- Keep track of unread count
 - "follow back" action
2019-07-29 19:36:22 +02:00

101 lines
4.1 KiB
HTML

{% extends "layout.html" %}
{% import 'utils.html' as utils %}
{% block title %}{% if request.path == url_for('admin_stream') %}Stream{% else %}Notifications{% endif %} - {{ config.NAME }}{% endblock %}
{% block content %}
<div class="h-feed" id="container">
{% include "header.html" %}
<div id="admin">
{% if request.path == url_for('admin_notifications') and unread_notifications_count %}
<div style="clear:both;padding-bottom:30px;">
<form action="/api/mark_notifications_as_read" method="POST">
<input type="hidden" name="redirect" value="{{ request.path }}"/>
<input type="hidden" name="nid" value="{{ nid }}"/>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="bar-item" style="text-transform:uppercase">Mark as read</button>
</form>
</div>
{% endif %}
<div id="notes" style="clear:both;">
{% for item in inbox_data %}
{% if 'actor' in item.meta %}
{% if item | has_type('Create') %}
{{ utils.display_note(item.activity.object, ui=True, meta=item.meta) }}
{% else %}
{% if item | has_type('Announce') %}
{% set boost_actor = item.meta.actor %}
{% if boost_actor %}
<p style="margin-left:70px;padding-bottom:5px;display:inline-block;"><span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url | get_url }}">{{ boost_actor.name or boost_actor.preferredUsername }}</a> boosted</span></p>
{% endif %}
{% if item.meta.object %}
{{ utils.display_note(item.meta.object, ui=True, meta=item.meta) }}
{% endif %}
{% endif %}
{% if item | has_type('Like') %}
{% set boost_actor = item.meta.actor %}
<p style="margin-left:70px;padding-bottom:5px;display:inline-block;"><span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url | get_url }}">{{ boost_actor.name or boost_actor.preferredUsername }}</a> liked</span></p>
{% if item.meta.object %}
{{ utils.display_note(item.meta.object, ui=False, meta=item.meta) }}
{% endif %}
{% endif %}
{% if item | has_type('Follow') %}
<div style="margin-left:70px;padding-bottom:5px;margin-bottom:15px;display:inline-block;">
{% if item.meta.notification_unread %}<span class="bar-item-no-bg"><span class="pcolor">new</span></span>{% endif %}
<span class="bar-item-no-bg">new follower</span>
{% if item.meta.notification_follows_back %}<span class="bar-item-no-hover">already following</span>
{% else %}
<form action="/api/follow" class="action-form" method="POST">
<input type="hidden" name="redirect" value="{{ request.path }}"/>
<input type="hidden" name="actor" value="{{ item.meta.actor_id }}"/>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit" class="bar-item">follow back</button>
</form>
{% endif %}
</div>
<div style="height: 100px;">
{{ utils.display_actor_inline(item.meta.actor, size=50) }}
</div>
{% elif item | has_type('Accept') %}
<div style="margin-left:70px;padding-bottom:5px;margin-bottom:15px;display:inline-block;">
{% if item.meta.notification_unread %}<span class="bar-item-no-bg"><span class="pcolor">new</span></span>{% endif %}
<span class="bar-item-no-bg">you started following</span>
{% if item.meta.notification_follows_back %}<span class="bar-item-no-hover">follows you back</span>{% endif %}
</div>
<div style="height: 100px;">
{{ utils.display_actor_inline(item.meta.actor, size=50) }}
</div>
{% elif item | has_type('Undo') %}
<p style="margin-left:70px;padding-bottom:5px;display:inline-block;"><span class="bar-item-no-hover">unfollowed you</span></p>
<div style="height: 100px;">
{{ utils.display_actor_inline(item.meta.actor, size=50) }}
</div>
{% else %}
{% endif %}
{% endif %}
{% else %}
{% if item | has_type('question_ended') %}
<p style="margin-left:70px;padding-bottom:5px;display:inline-block;"><span class="bar-item-no-hover">poll ended</span></p>
{{ utils.display_note(item.activity, meta={"object_visibility": "PUBLIC"}) }}
{% endif %}
{% endif %}
{% endfor %}
{{ utils.display_pagination(older_than, newer_than) }}
</div>
</div>
</div>
{% endblock %}