From 3217569df583829d776bcbaf77b80696d3527005 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 27 Nov 2022 12:37:52 -0700 Subject: Link to post pages and show replies there Fixes #60, #59 --- activities/views/posts.py | 21 +++++++++++++++++++++ static/css/style.css | 9 ++++++++- templates/activities/_post.html | 2 +- templates/activities/post.html | 3 +++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/activities/views/posts.py b/activities/views/posts.py index 083df30..8fbe361 100644 --- a/activities/views/posts.py +++ b/activities/views/posts.py @@ -1,5 +1,6 @@ from django import forms from django.core.exceptions import PermissionDenied +from django.db import models from django.http import JsonResponse from django.shortcuts import get_object_or_404, redirect, render from django.utils.decorators import method_decorator @@ -47,6 +48,26 @@ class Individual(TemplateView): [self.post_obj], self.request.identity, ), + "replies": Post.objects.filter( + models.Q( + visibility__in=[ + Post.Visibilities.public, + Post.Visibilities.local_only, + Post.Visibilities.unlisted, + ] + ) + | models.Q( + visibility=Post.Visibilities.followers, + author__inbound_follows__source=self.identity, + ) + | models.Q( + visibility=Post.Visibilities.mentioned, + mentions=self.identity, + ), + in_reply_to=self.post_obj.object_uri, + ) + .distinct() + .order_by("published", "created"), } def serve_object(self): diff --git a/static/css/style.css b/static/css/style.css index 93ad329..772d527 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -695,10 +695,16 @@ h1.identity small { .post { margin-bottom: 20px; overflow: hidden; + cursor: pointer; } .post.mini { font-size: 14px; + cursor: inherit; +} + +.post.reply { + margin-left: 32px; } .left-column .post { @@ -778,7 +784,8 @@ h1.identity small { margin-left: 64px; } -.post.mini .content, .post.mini .edited { +.post.mini .content, +.post.mini .edited { margin-left: 0px; } diff --git a/templates/activities/_post.html b/templates/activities/_post.html index e294698..7402765 100644 --- a/templates/activities/_post.html +++ b/templates/activities/_post.html @@ -1,6 +1,6 @@ {% load static %} {% load activity_tags %} -
+
diff --git a/templates/activities/post.html b/templates/activities/post.html index eee254f..d27790f 100644 --- a/templates/activities/post.html +++ b/templates/activities/post.html @@ -4,4 +4,7 @@ {% block content %} {% include "activities/_post.html" %} + {% for reply in replies %} + {% include "activities/_post.html" with post=reply reply=True %} + {% endfor %} {% endblock %} -- cgit v1.2.3