From 2e7fc810acea14e7177a4679d8fb33125f5162d9 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Thu, 26 Apr 2018 18:49:43 -0400 Subject: [PATCH] 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. --- brutaldon/static/css/brutaldon.css | 4 +++ brutaldon/static/css/fullbrutalism.css | 3 ++ brutaldon/templates/main/thread.html | 34 ++++++++++++++++++++++ brutaldon/templates/main/toot_partial.html | 2 +- brutaldon/urls.py | 1 + brutaldon/views.py | 8 +++++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 brutaldon/templates/main/thread.html diff --git a/brutaldon/static/css/brutaldon.css b/brutaldon/static/css/brutaldon.css index d4cc357..bde3445 100644 --- a/brutaldon/static/css/brutaldon.css +++ b/brutaldon/static/css/brutaldon.css @@ -8,3 +8,7 @@ img.fav-avatar { display: inline; } + +.box.active_context { + background-color: #FFF8DC; +} diff --git a/brutaldon/static/css/fullbrutalism.css b/brutaldon/static/css/fullbrutalism.css index 3550c30..4d2b5e0 100644 --- a/brutaldon/static/css/fullbrutalism.css +++ b/brutaldon/static/css/fullbrutalism.css @@ -192,3 +192,6 @@ img { height: 64px; } +.box.active_context { + background-color: #DDD; +} diff --git a/brutaldon/templates/main/thread.html b/brutaldon/templates/main/thread.html new file mode 100644 index 0000000..ce43c43 --- /dev/null +++ b/brutaldon/templates/main/thread.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} +{% load humanize %} + +{% block title %} +Brutaldon - thread +{% endblock %} + +{% comment %} +mastodon.status_context() + # Returns the following dictionary: + { + 'ancestors': # A list of toot dicts + 'descendants': # A list of toot dicts + } +{% endcomment %} + +{% block content %} +

Thread

+ {% for ancestor in context.ancestors %} +
+ {% include "main/toot_partial.html" with toot=ancestor %} +
+ {% endfor %} +
+ {% include "main/toot_partial.html" with toot=toot %} +
+ {% for descendant in context.descendants %} +
+ {% include "main/toot_partial.html" with toot=descendant %} +
+ {% endfor %} + + +{% endblock %} diff --git a/brutaldon/templates/main/toot_partial.html b/brutaldon/templates/main/toot_partial.html index a5230c4..1ff7151 100644 --- a/brutaldon/templates/main/toot_partial.html +++ b/brutaldon/templates/main/toot_partial.html @@ -81,7 +81,7 @@ {{ toot.visibility }} - + thread diff --git a/brutaldon/urls.py b/brutaldon/urls.py index f2e1fe5..0903285 100644 --- a/brutaldon/urls.py +++ b/brutaldon/urls.py @@ -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/', views.thread, name='thread'), path('', views.home), ] diff --git a/brutaldon/views.py b/brutaldon/views.py index db4534c..4e73316 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -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':