diff --git a/fedireads/static/format.css b/fedireads/static/format.css
index 94e01dbd..6cd3ba08 100644
--- a/fedireads/static/format.css
+++ b/fedireads/static/format.css
@@ -197,3 +197,27 @@ th, td {
font-size: 0.8em;
color: #FF1654;
}
+
+.comment-thread .reply h2 {
+ background: none;
+}
+.post.main {
+ background-color: #F3FFBD;
+}
+.post {
+ margin-left: 4em;
+ border-left: 2px solid #247BA0;
+}
+.post.depth-1 {
+ margin-left: 0;
+ border: none;
+}
+.post.depth-2 {
+ margin-left: 1em;
+}
+.post.depth-3 {
+ margin-left: 2em;
+}
+.post.depth-4 {
+ margin-left: 3em;
+}
diff --git a/fedireads/templates/book.html b/fedireads/templates/book.html
index 73e3c12d..f5f55f53 100644
--- a/fedireads/templates/book.html
+++ b/fedireads/templates/book.html
@@ -20,7 +20,7 @@
{% for review in user_reviews %}
- {% include 'snippets/review.html' with review=review %}
+ {% include 'snippets/status.html' with status=review hide_book=True main=True depth=1 %}
{% endfor %}
@@ -62,7 +62,7 @@
- {% if activity.status_type == 'Review' %}
- {% include 'snippets/activity_banner.html' with content="reviewed
"|add:activity.book.title|add:"" %}
-
- {% include 'snippets/book.html' with book=activity.book size=large %}
-
-
{{ activity.name }}
-
{{ activity.rating | stars }}
-
{{ activity.content | safe }}
-
- {% include 'snippets/interaction.html' with activity=activity %}
- {% elif activity.status_type == 'Note' %}
- {% include 'snippets/activity_banner.html' %}
-
{{ activity.content | safe }}
- {% for book in activity.mention_books.all %}
-
- {% include 'snippets/book.html' with book=book size=large description=True %}
-
- {% endfor %}
- {% include 'snippets/interaction.html' with activity=activity %}
- {% else %}
- {# generic handling for a misc activity, which perhaps should not be displayed at all #}
- did {{ activity.activity_type }}
-
- {% endif %}
-
-
diff --git a/fedireads/templates/snippets/activity_banner.html b/fedireads/templates/snippets/activity_banner.html
new file mode 100644
index 00000000..f0e99720
--- /dev/null
+++ b/fedireads/templates/snippets/activity_banner.html
@@ -0,0 +1,10 @@
+{% load humanize %}
+
+ {% include 'snippets/activity_banner.html' with activity=status %}
+ {% if not hide_book and status.mention_books.count %}
+
+ {% include 'snippets/book.html' with book=status.mention_books.first %}
+
+ {% endif %}
+ {% if not hide_book and status.book%}
+
+ {% include 'snippets/book.html' with book=status.book %}
+
+ {% endif %}
+ {% if status.status_type == 'Review' %}
{{ status.name }}
+ {{ status.rating | stars }} stars, by {% include 'snippets/username.html' with user=status.user %}
+
{% endif %}
+
{{ status.content }}
+ {% include 'snippets/interaction.html' with activity=status %}
+
+
diff --git a/fedireads/templates/snippets/thread.html b/fedireads/templates/snippets/thread.html
new file mode 100644
index 00000000..34da43df
--- /dev/null
+++ b/fedireads/templates/snippets/thread.html
@@ -0,0 +1,18 @@
+{% load fr_display %}
+{% with depth=depth|add:1 %}
+ {% if depth <= max_depth and status.reply_parent and direction <= 0 %}
+ {% with direction=-1 %}
+ {% include 'snippets/thread.html' with status=status|parent is_root=False %}
+ {% endwith %}
+ {% endif %}
+
+{% include 'snippets/status.html' with status=status main=is_root %}
+
+{% if depth <= max_depth and direction >= 0 %}
+ {% for reply in status|replies %}
+ {% with direction=1 %}
+ {% include 'snippets/thread.html' with status=reply is_root=False %}
+ {% endwith %}
+ {% endfor %}
+{% endif %}
+{% endwith %}
diff --git a/fedireads/templates/status.html b/fedireads/templates/status.html
index d3811cf9..3221b5cd 100644
--- a/fedireads/templates/status.html
+++ b/fedireads/templates/status.html
@@ -2,15 +2,9 @@
{% block content %}
- {% if status.reply_parent %}
- {% include 'snippets/status.html' with status=status.reply_parent %}
- {% endif %}
-
- {% include 'snippets/status.html' with status=status main=True %}
-
- {% for reply in replies %}
- {% include 'snippets/status.html' with status=reply %}
- {% endfor %}
+
{% endblock %}
diff --git a/fedireads/templatetags/fr_display.py b/fedireads/templatetags/fr_display.py
index 62d86175..ac249c9c 100644
--- a/fedireads/templatetags/fr_display.py
+++ b/fedireads/templatetags/fr_display.py
@@ -55,6 +55,16 @@ def get_notification_count(user):
return user.notification_set.filter(read=False).count()
+@register.filter(name='replies')
+def get_replies(status):
+ return models.Status.objects.filter(reply_parent=status).select_subclasses().all()[:10]
+
+
+@register.filter(name='parent')
+def get_parent(status):
+ return models.Status.objects.filter(id=status.reply_parent_id).select_subclasses().get()
+
+
@register.simple_tag(takes_context=True)
def shelve_button_identifier(context, book):
''' check what shelf a user has a book on, if any '''
diff --git a/fedireads/views.py b/fedireads/views.py
index 17f183fa..e1d23f2e 100644
--- a/fedireads/views.py
+++ b/fedireads/views.py
@@ -56,9 +56,9 @@ def home_tab(request, tab):
Q(followers=request.user) | Q(id=request.user.id)
)
- activities = models.Status.objects.select_subclasses().order_by(
+ activities = models.Status.objects.order_by(
'-created_date'
- )
+ ).select_subclasses()
if tab == 'home':
# people you follow and direct mentions
@@ -75,7 +75,6 @@ def home_tab(request, tab):
activities = activities[:10]
- comment_form = forms.CommentForm()
data = {
'user': request.user,
'shelves': shelves,
@@ -84,7 +83,6 @@ def home_tab(request, tab):
'activities': activities,
'feed_tabs': ['home', 'local', 'federated'],
'active_tab': tab,
- 'comment_form': comment_form,
}
return TemplateResponse(request, 'feed.html', data)
@@ -195,10 +193,8 @@ def status_page(request, username, status_id):
if user != status.user:
return HttpResponseNotFound()
- replies = models.Status.objects.filter(reply_parent=status).select_subclasses().all()
data = {
'status': status,
- 'replies': replies,
}
return TemplateResponse(request, 'status.html', data)