mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
adding user read-posts page
This commit is contained in:
parent
c6fb8fc554
commit
48bae31d6c
4 changed files with 78 additions and 1 deletions
|
@ -197,6 +197,7 @@
|
|||
<li><a class="dropdown-item{% if active_child == 'edit_profile' %} active{% endif %}" href="/user/settings">{{ _('Edit profile & settings') }}</a></li>
|
||||
<li><a class="dropdown-item{% if active_child == 'chats' %} active{% endif %}" href="/chat">{{ _('Chats') }}</a></li>
|
||||
<li><a class="dropdown-item{% if active_child == 'bookmarks' %} active{% endif %}" href="/bookmarks">{{ _('Bookmarks') }}</a></li>
|
||||
<li><a class="dropdown-item{% if active_child == 'read_posts' %} active{% endif %}" href="/read-posts">{{ _('Read Posts') }}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item"><a class="nav-link" href="/donate">{{ _('Donate') }}</a></li>
|
||||
|
|
39
app/templates/user/read_posts.html
Normal file
39
app/templates/user/read_posts.html
Normal file
|
@ -0,0 +1,39 @@
|
|||
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
|
||||
{% extends 'themes/' + theme() + '/base.html' %}
|
||||
{% else %}
|
||||
{% extends "base.html" %}
|
||||
{% endif %}
|
||||
{% set active_child = 'read_posts' %}
|
||||
|
||||
{% block app_content %}
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-8 position-relative main_pane">
|
||||
<nav class="mb-2" aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li>
|
||||
<li class="breadcrumb-item"><a href="/u/{{ user.link() }}">{{ user.display_name() }}</a></li>
|
||||
<li class="breadcrumb-item active">{{ _('Read Posts') }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<h1>{{ _('Read Posts') }}</h1>
|
||||
<div class="post_list">
|
||||
{% for post in posts.items -%}
|
||||
{% include 'post/_post_teaser.html' %}
|
||||
{% endfor -%}
|
||||
</div>
|
||||
|
||||
<nav aria-label="Pagination" class="mt-4" role="navigation">
|
||||
{% if prev_url %}
|
||||
<a href="{{ prev_url }}" class="btn btn-primary" rel="nofollow">
|
||||
<span aria-hidden="true">←</span> {{ _('Previous page') }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if next_url %}
|
||||
<a href="{{ next_url }}" class="btn btn-primary" rel="nofollow">
|
||||
{{ _('Next page') }} <span aria-hidden="true">→</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -43,7 +43,7 @@ class SettingsForm(FlaskForm):
|
|||
markdown_editor = BooleanField(_l('Use markdown editor GUI when writing'))
|
||||
searchable = BooleanField(_l('Show profile in user list'))
|
||||
indexable = BooleanField(_l('My posts appear in search results'))
|
||||
hide_read_posts = BooleanField(_l('Do not display posts with which I have already interacted (opened/upvote/downvote)'))
|
||||
hide_read_posts = BooleanField(_l('Do not display posts with which I have already interacted (opened/upvoted/downvoted)'))
|
||||
manually_approves_followers = BooleanField(_l('Manually approve followers'))
|
||||
vote_privately = BooleanField(_l('Vote privately'))
|
||||
sorts = [('hot', _l('Hot')),
|
||||
|
|
|
@ -1172,3 +1172,40 @@ def fediverse_redirect(actor):
|
|||
send_to = request.cookies.get('remote_instance_url')
|
||||
form.instance_url.data = send_to
|
||||
return render_template('user/fediverse_redirect.html', form=form, user=user, send_to=send_to, current_app=current_app)
|
||||
|
||||
@bp.route('/read-posts')
|
||||
@login_required
|
||||
def user_read_posts():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1'
|
||||
|
||||
posts = Post.query.filter(Post.deleted == False)
|
||||
|
||||
if current_user.ignore_bots == 1:
|
||||
posts = posts.filter(Post.from_bot == False)
|
||||
if current_user.hide_nsfl == 1:
|
||||
posts = posts.filter(Post.nsfl == False)
|
||||
if current_user.hide_nsfw == 1:
|
||||
posts = posts.filter(Post.nsfw == False)
|
||||
|
||||
# get the list of post.ids that the
|
||||
# current_user has already read/voted on
|
||||
cu_rp = current_user.read_post.all()
|
||||
cu_rp_ids = []
|
||||
for p in cu_rp:
|
||||
cu_rp_ids.append(p.id)
|
||||
|
||||
# filter for just those post.ids
|
||||
posts = posts.filter(Post.id.in_(cu_rp_ids))
|
||||
|
||||
posts = posts.paginate(page=page, per_page=100 if current_user.is_authenticated and not low_bandwidth else 50,
|
||||
error_out=False)
|
||||
next_url = url_for('user.user_read_posts', page=posts.next_num) if posts.has_next else None
|
||||
prev_url = url_for('user.user_read_posts', page=posts.prev_num) if posts.has_prev and page != 1 else None
|
||||
|
||||
return render_template('user/read_posts.html', title=_('Read Posts'), posts=posts, show_post_community=True,
|
||||
low_bandwidth=low_bandwidth, user=current_user,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
menu_topics=menu_topics(), site=g.site,
|
||||
next_url=next_url, prev_url=prev_url)
|
||||
|
|
Loading…
Reference in a new issue