Adds status page

Works on #18
This commit is contained in:
Mouse Reeve 2020-03-07 15:28:11 -08:00
parent f4008eb8c8
commit f714b961f2
7 changed files with 49 additions and 23 deletions

View file

@ -38,7 +38,7 @@
{% include 'snippets/tabs.html' with tabs=feed_tabs active_tab=active_tab %} {% include 'snippets/tabs.html' with tabs=feed_tabs active_tab=active_tab %}
{% for activity in activities %} {% for activity in activities %}
{% include 'snippets/status.html' with activity=activity %} {% include 'snippets/activity.html' with activity=activity %}
{% endfor %} {% endfor %}
</div> </div>

View file

@ -1,7 +1,7 @@
{% load fr_display %} {% load fr_display %}
<div class="update"> <div class="update">
{% if activity.status_type == 'Review' %} {% if activity.status_type == 'Review' %}
{% include 'snippets/status_banner.html' with content="reviewed <i>"|add:activity.book.title|add:"</i>" %} {% include 'snippets/activity_banner.html' with content="reviewed <i>"|add:activity.book.title|add:"</i>" %}
<div class="book-preview review"> <div class="book-preview review">
{% include 'snippets/book.html' with book=activity.book size=large %} {% include 'snippets/book.html' with book=activity.book size=large %}
@ -11,7 +11,7 @@
</div> </div>
{% include 'snippets/interaction.html' with activity=activity %} {% include 'snippets/interaction.html' with activity=activity %}
{% elif activity.status_type == 'Note' %} {% elif activity.status_type == 'Note' %}
{% include 'snippets/status_banner.html' %} {% include 'snippets/activity_banner.html' %}
<span>{{ activity.content | safe }}</span> <span>{{ activity.content | safe }}</span>
{% for book in activity.mention_books.all %} {% for book in activity.mention_books.all %}
<div class="book-preview review"> <div class="book-preview review">

View file

@ -1,8 +0,0 @@
{% load fr_display %}
<div class="review">
<h4>{{ review.name }}
<small>{{ review.rating | stars }} stars, by {% include 'snippets/username.html' with user=review.user %}</small>
</h4>
<blockquote>{{ review.content }}</blockquote>
</div>

View file

@ -1,10 +0,0 @@
{% load humanize %}
<h2>
{% include 'snippets/avatar.html' with user=activity.user %}
{% include 'snippets/username.html' with user=activity.user %}
{{ content | safe }}
<span class="time-ago">
{{ activity.published_date | naturaltime }}
</span>
</h2>

View file

@ -0,0 +1,17 @@
{% extends 'layout.html' %}
{% block content %}
<div id="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 %}
</div>
{% endblock %}

View file

@ -17,12 +17,13 @@ urlpatterns = [
# federation endpoints # federation endpoints
re_path(r'^inbox/?$', incoming.shared_inbox), 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/inbox/?$' % local_user_path, incoming.inbox),
re_path(r'%s/outbox/?$' % local_user_path, outgoing.outbox), 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/followers/?$' % local_user_path, incoming.get_followers),
re_path(r'%s/following/?$' % local_user_path, incoming.get_following), 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), re_path(r'%s/replies/?$' % status_path, incoming.get_replies),
# .well-known endpoints # .well-known endpoints
@ -42,6 +43,7 @@ urlpatterns = [
re_path(r'%s/?$' % user_path, views.user_page), re_path(r'%s/?$' % user_path, views.user_page),
re_path(r'%s/edit/?$' % user_path, views.edit_profile_page), re_path(r'%s/edit/?$' % user_path, views.edit_profile_page),
re_path(r'^user/edit/?$', 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<book_identifier>\w+)/?$', views.book_page), re_path(r'^book/(?P<book_identifier>\w+)/?$', views.book_page),
re_path(r'^book/(?P<book_identifier>\w+)/(?P<tab>friends|local|federated)?$', views.book_page), re_path(r'^book/(?P<book_identifier>\w+)/(?P<tab>friends|local|federated)?$', views.book_page),
re_path(r'^author/(?P<author_identifier>\w+)/?$', views.author_page), re_path(r'^author/(?P<author_identifier>\w+)/?$', views.author_page),

View file

@ -150,6 +150,7 @@ def notifications_page(request):
return TemplateResponse(request, 'notifications.html', data) return TemplateResponse(request, 'notifications.html', data)
@login_required
def user_page(request, username): def user_page(request, username):
''' profile page for a user ''' ''' profile page for a user '''
content = request.headers.get('Accept') content = request.headers.get('Accept')
@ -178,6 +179,30 @@ def user_page(request, username):
return TemplateResponse(request, 'user.html', data) 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 @login_required
def edit_profile_page(request, username): def edit_profile_page(request, username):
''' profile page for a user ''' ''' profile page for a user '''