diff --git a/fedireads/templates/feed.html b/fedireads/templates/feed.html index a0d952af..9fbb066b 100644 --- a/fedireads/templates/feed.html +++ b/fedireads/templates/feed.html @@ -38,7 +38,7 @@ {% include 'snippets/tabs.html' with tabs=feed_tabs active_tab=active_tab %} {% for activity in activities %} - {% include 'snippets/status.html' with activity=activity %} + {% include 'snippets/activity.html' with activity=activity %} {% endfor %} diff --git a/fedireads/templates/snippets/status.html b/fedireads/templates/snippets/activity.html similarity index 85% rename from fedireads/templates/snippets/status.html rename to fedireads/templates/snippets/activity.html index fa58fee4..405bcd0e 100644 --- a/fedireads/templates/snippets/status.html +++ b/fedireads/templates/snippets/activity.html @@ -1,7 +1,7 @@ {% load fr_display %}
{% if activity.status_type == 'Review' %} - {% include 'snippets/status_banner.html' with content="reviewed "|add:activity.book.title|add:"" %} + {% include 'snippets/activity_banner.html' with content="reviewed "|add:activity.book.title|add:"" %}
{% include 'snippets/book.html' with book=activity.book size=large %} @@ -11,7 +11,7 @@
{% include 'snippets/interaction.html' with activity=activity %} {% elif activity.status_type == 'Note' %} - {% include 'snippets/status_banner.html' %} + {% include 'snippets/activity_banner.html' %} {{ activity.content | safe }} {% for book in activity.mention_books.all %}
diff --git a/fedireads/templates/snippets/review.html b/fedireads/templates/snippets/review.html deleted file mode 100644 index 76c2f4a4..00000000 --- a/fedireads/templates/snippets/review.html +++ /dev/null @@ -1,8 +0,0 @@ -{% load fr_display %} -
-

{{ review.name }} - {{ review.rating | stars }} stars, by {% include 'snippets/username.html' with user=review.user %} -

-
{{ review.content }}
-
- diff --git a/fedireads/templates/snippets/status_banner.html b/fedireads/templates/snippets/status_banner.html deleted file mode 100644 index 1b99ed1f..00000000 --- a/fedireads/templates/snippets/status_banner.html +++ /dev/null @@ -1,10 +0,0 @@ -{% load humanize %} -

- {% include 'snippets/avatar.html' with user=activity.user %} - {% include 'snippets/username.html' with user=activity.user %} - {{ content | safe }} - - {{ activity.published_date | naturaltime }} - -

- diff --git a/fedireads/templates/status.html b/fedireads/templates/status.html new file mode 100644 index 00000000..d3811cf9 --- /dev/null +++ b/fedireads/templates/status.html @@ -0,0 +1,17 @@ +{% extends 'layout.html' %} +{% 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/urls.py b/fedireads/urls.py index 0de29308..4e1c5fee 100644 --- a/fedireads/urls.py +++ b/fedireads/urls.py @@ -17,12 +17,13 @@ urlpatterns = [ # federation endpoints re_path(r'^inbox/?$', incoming.shared_inbox), - re_path(r'%s.json/?$' % local_user_path, incoming.get_actor), + re_path(r'%s.json$' % local_user_path, incoming.get_actor), re_path(r'%s/inbox/?$' % local_user_path, incoming.inbox), re_path(r'%s/outbox/?$' % local_user_path, outgoing.outbox), re_path(r'%s/followers/?$' % local_user_path, incoming.get_followers), re_path(r'%s/following/?$' % local_user_path, incoming.get_following), - re_path(r'%s(/activity/?)?$' % status_path, incoming.get_status), + re_path(r'%s.json$' % status_path, incoming.get_status), + re_path(r'%s/activity/?$' % status_path, incoming.get_status), re_path(r'%s/replies/?$' % status_path, incoming.get_replies), # .well-known endpoints @@ -42,6 +43,7 @@ urlpatterns = [ re_path(r'%s/?$' % user_path, views.user_page), re_path(r'%s/edit/?$' % user_path, views.edit_profile_page), re_path(r'^user/edit/?$', views.edit_profile_page), + re_path(r'%s/?$' % status_path, views.status_page), re_path(r'^book/(?P\w+)/?$', views.book_page), re_path(r'^book/(?P\w+)/(?Pfriends|local|federated)?$', views.book_page), re_path(r'^author/(?P\w+)/?$', views.author_page), diff --git a/fedireads/views.py b/fedireads/views.py index 2ad6ff7f..8899f9a5 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -150,6 +150,7 @@ def notifications_page(request): return TemplateResponse(request, 'notifications.html', data) +@login_required def user_page(request, username): ''' profile page for a user ''' content = request.headers.get('Accept') @@ -178,6 +179,30 @@ def user_page(request, username): return TemplateResponse(request, 'user.html', data) +@login_required +def status_page(request, username, status_id): + ''' display a particular status (and replies, etc) ''' + content = request.headers.get('Accept') + if 'json' in content: + # we have a json request + return incoming.get_status(request, username, status_id) + try: + user = models.User.objects.get(localname=username) + status = models.Status.objects.select_subclasses().get(id=status_id) + except ValueError: + return HttpResponseNotFound() + + 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) + + @login_required def edit_profile_page(request, username): ''' profile page for a user '''