Add support for basic threading.

It works the same as the Mastodon web UI for now - active toot is highlighted,
ancestors displayed in order above, descendants in order below. I hope to
add actual full threading one day.
This commit is contained in:
Jason McBrayer 2018-04-26 18:49:43 -04:00
parent af30107368
commit 2e7fc810ac
6 changed files with 51 additions and 1 deletions

View File

@ -8,3 +8,7 @@ img.fav-avatar {
display: inline;
}
.box.active_context {
background-color: #FFF8DC;
}

View File

@ -192,3 +192,6 @@ img {
height: 64px;
}
.box.active_context {
background-color: #DDD;
}

View File

@ -0,0 +1,34 @@
{% extends "base.html" %}
{% load humanize %}
{% block title %}
Brutaldon - thread
{% endblock %}
{% comment %}
mastodon.status_context(<numerical id>)
# Returns the following dictionary:
{
'ancestors': # A list of toot dicts
'descendants': # A list of toot dicts
}
{% endcomment %}
{% block content %}
<h1 class="title">Thread</h1>
{% for ancestor in context.ancestors %}
<div class="box">
{% include "main/toot_partial.html" with toot=ancestor %}
</div>
{% endfor %}
<div class="box active_context">
{% include "main/toot_partial.html" with toot=toot %}
</div>
{% for descendant in context.descendants %}
<div class="box">
{% include "main/toot_partial.html" with toot=descendant %}
</div>
{% endfor %}
{% endblock %}

View File

@ -81,7 +81,7 @@
<span class="level-item">
{{ toot.visibility }}
</span>
<a class="level-item" >
<a class="level-item" href="{% url "thread" toot.id %}">
thread
</a>
</div>

View File

@ -27,5 +27,6 @@ urlpatterns = [
path('local', views.local, name='local'),
path('fed', views.fed, name='fed'),
path('settings', views.settings, name='settings'),
path('thread/<int:id>', views.thread, name='thread'),
path('', views.home),
]

View File

@ -120,6 +120,14 @@ def note(request):
{'notes': notes,'timeline': 'Notifications',
'fullbrutalism': fullbrutalism_p(request)})
def thread(request, id):
mastodon = get_mastodon(request)
context = mastodon.status_context(id)
toot = mastodon.status(id)
return render(request, 'main/thread.html',
{'context': context, 'toot': toot,
'fullbrutalism': fullbrutalism_p(request)})
def settings(request):
if request.method == 'POST':