diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2018-10-27 00:34:08 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2018-10-27 00:34:08 +0200 |
commit | 488327324ab2f65fa8e0bc49a1d13efb505bba21 (patch) | |
tree | a56fbd64da4607ef4f94e354ea7605fdc6e0de2e /src | |
parent | Merge branch 'master' of github.com:newspipe/newspipe (diff) | |
download | newspipe-488327324ab2f65fa8e0bc49a1d13efb505bba21.tar.gz newspipe-488327324ab2f65fa8e0bc49a1d13efb505bba21.tar.bz2 newspipe-488327324ab2f65fa8e0bc49a1d13efb505bba21.zip |
Filter feeds per category on the user profile page.
Diffstat (limited to 'src')
-rw-r--r-- | src/web/templates/feed_list_per_categories.html | 54 | ||||
-rw-r--r-- | src/web/templates/profile_public.html | 2 | ||||
-rw-r--r-- | src/web/views/user.py | 6 |
3 files changed, 60 insertions, 2 deletions
diff --git a/src/web/templates/feed_list_per_categories.html b/src/web/templates/feed_list_per_categories.html new file mode 100644 index 00000000..4b0e517e --- /dev/null +++ b/src/web/templates/feed_list_per_categories.html @@ -0,0 +1,54 @@ +<div class="row"> + <div class="col-md-6"> + <form class="form-inline"> + <div class="form-group"> + <label>Filter per category</label> + <select class="form-control" id="category-select" name="category_id"> + <option value="0">All</option> + {% for category in user.categories %} + <option value="{{category.id}}" {% if category.id==selected_category_id %}selected{% endif %}>{{ category.name }}</option> + {% endfor %} + </select> + <button type="submit" class="btn btn-primary mb-2">OK</button> + </div> + </form> + </div> +</div> + +<br /> + +{% if feeds | length != 0 %} +<div class="table-responsive"> + <table id="table-feeds" class="table table-striped"> + <thead> + <tr> + <th>#</th> + <th>{{ _('Title') }}</th> + <th>{{ _('Site') }}</th> + </tr> + </thead> + <tbody> + {% for feed in feeds %} + <tr> + <td>{{ loop.index }}</td> + <td>{% if feed.icon_url %}<img src="{{ url_for('icon.icon', url=feed.icon_url) }}" width="16px" /> {% endif %} <a href="{{ url_for('feed.feed_pub', feed_id=feed.id) }}">{{ feed.title }}</a></td> + <td><a href="{{ feed.site_link }}">{{ feed.site_link }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> +</div> +<script> +$(document).ready(function() { + $('#table-feeds').DataTable( { + responsive: true, + columnDefs: [ + { + bSortable: false, + targets: [0] + } + ] + }); +}); +</script> +{% endif %} diff --git a/src/web/templates/profile_public.html b/src/web/templates/profile_public.html index 9198acea..e30ae300 100644 --- a/src/web/templates/profile_public.html +++ b/src/web/templates/profile_public.html @@ -38,7 +38,7 @@ <h2>{{ _('Feeds') }}</h2> <div class="row"> <div class="col-md-12"> - {% include "feed_list_simple.html" %} + {% include "feed_list_per_categories.html" %} </div> </div> </div><!-- /.container --> diff --git a/src/web/views/user.py b/src/web/views/user.py index 1460c708..c9c23ca7 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -25,6 +25,7 @@ def profile_public(nickname=None): """ Display the public profile of the user. """ + category_id = int(request.args.get('category_id', 0)) user_contr = UserController() user = user_contr.get(nickname=nickname) if not user.is_public_profile: @@ -34,6 +35,8 @@ def profile_public(nickname=None): filters = {} filters['private'] = False + if category_id: + filters['category_id'] = category_id feeds = FeedController(user.id).read(**filters).all() """word_size = 6 @@ -43,7 +46,8 @@ def profile_public(nickname=None): top_words = misc_utils.top_words(articles, n=50, size=int(word_size)) tag_cloud = misc_utils.tag_cloud(top_words)""" - return render_template('profile_public.html', user=user, feeds=feeds) + return render_template('profile_public.html', user=user, feeds=feeds, + selected_category_id=category_id) @user_bp.route('/management', methods=['GET', 'POST']) |