diff --git a/app/templates/base.html b/app/templates/base.html index 1e3db0e0..cb1cf8d0 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -197,6 +197,7 @@
  • {{ _('Edit profile & settings') }}
  • {{ _('Chats') }}
  • {{ _('Bookmarks') }}
  • +
  • {{ _('Read Posts') }}
  • diff --git a/app/templates/user/read_posts.html b/app/templates/user/read_posts.html new file mode 100644 index 00000000..8427646d --- /dev/null +++ b/app/templates/user/read_posts.html @@ -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 %} +
    +
    + +

    {{ _('Read Posts') }}

    +
    + {% for post in posts.items -%} + {% include 'post/_post_teaser.html' %} + {% endfor -%} +
    + + +
    +
    +{% endblock %} diff --git a/app/user/forms.py b/app/user/forms.py index 92bf12d3..dc702ad2 100644 --- a/app/user/forms.py +++ b/app/user/forms.py @@ -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')), diff --git a/app/user/routes.py b/app/user/routes.py index 2e3f23e0..5aee3efe 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -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)