Skip to content

Commit

Permalink
Link to post pages and show replies there
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Nov 27, 2022
1 parent 03ba96f commit 3217569
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
21 changes: 21 additions & 0 deletions activities/views/posts.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -47,6 +48,26 @@ def get_context_data(self):
[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):
Expand Down
9 changes: 8 additions & 1 deletion static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/activities/_post.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load static %}
{% load activity_tags %}
<div class="post" data-takahe-id="{{ post.id }}">
<div class="post {% if reply %}reply{% endif %}" data-takahe-id="{{ post.id }}" _="on click go url {{ post.urls.view }}">

<a href="{{ post.author.urls.view }}">
<img src="{{ post.author.local_icon_url }}" class="icon">
Expand Down
3 changes: 3 additions & 0 deletions templates/activities/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

0 comments on commit 3217569

Please sign in to comment.