mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 13:58:43 +00:00
parent
16a39e1183
commit
248fe64537
4 changed files with 43 additions and 52 deletions
|
@ -7,7 +7,7 @@
|
|||
}
|
||||
|
||||
html {
|
||||
background-color:#EFEFEF;
|
||||
background-color: #FFF;
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,14 @@ h2 {
|
|||
margin-right: 0;
|
||||
}
|
||||
|
||||
#feed-tabs {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.active {
|
||||
background-color: #FF1654;
|
||||
}
|
||||
|
||||
.user-pic {
|
||||
width: 2rem;
|
||||
height: auto;
|
||||
|
|
|
@ -49,54 +49,16 @@
|
|||
</div>
|
||||
|
||||
<div id="feed">
|
||||
<div id="feed-tabs">
|
||||
{% for tab in feed_tabs %}
|
||||
<div class="{% if tab == active_tab %}active{% endif %}">
|
||||
<a href="/{{ tab }}">{{ tab }}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% for activity in activities %}
|
||||
<div class="update">
|
||||
<h2>
|
||||
{% include 'snippets/avatar.html' with user=activity.user %}
|
||||
{% include 'snippets/username.html' with user=activity.user %}
|
||||
{% if activity.status_type == 'Review' %}
|
||||
{# display a review #}
|
||||
reviewed {{ activity.book.data.title }}
|
||||
</h2>
|
||||
<div class="book-preview review">
|
||||
{% include 'snippets/book.html' with book=activity.book size=large %}
|
||||
|
||||
<h3>{{ activity.name }}</h3>
|
||||
<p>{{ activity.rating | stars }}</p>
|
||||
<p>{{ activity.content | safe }}</p>
|
||||
</div>
|
||||
<div class="interaction">
|
||||
{% if activity.favorites.all %}
|
||||
<span>
|
||||
{{ activity.favorites.count }} like(s)
|
||||
</span>
|
||||
{% endif %}
|
||||
<form name="favorite" action="/favorite/{{ activity.id }}" method="post">
|
||||
{% csrf_token %}
|
||||
<button>⭐️ Like</button>
|
||||
</form>
|
||||
<form name="comment" action="/comment" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="review" value="{{ activity.id }}"></input>
|
||||
{{ comment_form.content }}
|
||||
<button type="submit">Comment</button>
|
||||
</form>
|
||||
</div>
|
||||
{% elif activity.status_type == 'Note' %}
|
||||
posted</h2>
|
||||
{{ activity.content | safe }}
|
||||
{% for book in activity.mention_books.all %}
|
||||
<div class="book-preview review">
|
||||
{% include 'snippets/book.html' with book=book size=large description=True %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{# generic handling for a misc activity, which perhaps should not be displayed at all #}
|
||||
did {{ activity.activity_type }}
|
||||
</h2>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include 'snippets/status.html' with activity=activity %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -38,7 +38,8 @@ urlpatterns = [
|
|||
# TODO: re_path(r'^.well-known/host-meta/?$', incoming.host_meta),
|
||||
|
||||
# ui views
|
||||
path(r'', views.home),
|
||||
path('', views.home),
|
||||
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
|
||||
re_path(r'^register/?$', views.register),
|
||||
re_path(r'^login/?$', views.user_login),
|
||||
re_path(r'^logout/?$', views.user_logout),
|
||||
|
|
|
@ -13,6 +13,12 @@ from fedireads.settings import DOMAIN
|
|||
|
||||
@login_required
|
||||
def home(request):
|
||||
''' this is the same as the feed on the home tab '''
|
||||
return home_tab(request, 'home')
|
||||
|
||||
|
||||
@login_required
|
||||
def home_tab(request, tab):
|
||||
''' user's homepage with activity feed '''
|
||||
# user's shelves for display
|
||||
reading = models.Shelf.objects.get(
|
||||
|
@ -37,11 +43,23 @@ def home(request):
|
|||
Q(followers=request.user) | Q(id=request.user.id)
|
||||
)
|
||||
|
||||
activities = models.Status.objects.filter(
|
||||
Q(user__in=following, privacy='public') | Q(mention_users=request.user)
|
||||
).select_subclasses().order_by(
|
||||
activities = models.Status.objects.select_subclasses().order_by(
|
||||
'-created_date'
|
||||
)[:10]
|
||||
)
|
||||
|
||||
if tab == 'home':
|
||||
# people you follow and direct mentions
|
||||
activities = activities.filter(
|
||||
Q(user__in=following, privacy='public') | Q(mention_users=request.user)
|
||||
)
|
||||
elif tab == 'local':
|
||||
# everyone on this instance
|
||||
activities = activities.filter(user__local=True, privacy='public')
|
||||
else:
|
||||
# all activities from everyone you federate with
|
||||
activities = activities.filter(privacy='public')
|
||||
|
||||
activities = activities[:10]
|
||||
|
||||
comment_form = forms.CommentForm()
|
||||
data = {
|
||||
|
@ -51,6 +69,8 @@ def home(request):
|
|||
'recent_books': recent_books,
|
||||
'user_books': user_books,
|
||||
'activities': activities,
|
||||
'feed_tabs': ['home', 'local', 'federated'],
|
||||
'active_tab': tab,
|
||||
'comment_form': comment_form,
|
||||
}
|
||||
return TemplateResponse(request, 'feed.html', data)
|
||||
|
|
Loading…
Reference in a new issue