diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-20 15:08:47 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-20 15:08:47 +0200 |
commit | e60087e68546a8a9b483e09a78f4389fcc9ebc4e (patch) | |
tree | acd780e7255d7de48a5519bc815c0e90f08d98b3 /src | |
parent | Draft for a public user profile page. (diff) | |
download | newspipe-e60087e68546a8a9b483e09a78f4389fcc9ebc4e.tar.gz newspipe-e60087e68546a8a9b483e09a78f4389fcc9ebc4e.tar.bz2 newspipe-e60087e68546a8a9b483e09a78f4389fcc9ebc4e.zip |
Few improvemnts for the tag cloud of the user's profile pages.
Diffstat (limited to 'src')
-rwxr-xr-x | src/web/lib/misc_utils.py | 4 | ||||
-rw-r--r-- | src/web/templates/feed_list.html | 52 | ||||
-rw-r--r-- | src/web/templates/feed_list_simple.html | 22 | ||||
-rw-r--r-- | src/web/templates/profile_public.html | 4 | ||||
-rw-r--r-- | src/web/views/user.py | 10 |
5 files changed, 56 insertions, 36 deletions
diff --git a/src/web/lib/misc_utils.py b/src/web/lib/misc_utils.py index 07cb6ed5..ea0b18ce 100755 --- a/src/web/lib/misc_utils.py +++ b/src/web/lib/misc_utils.py @@ -272,8 +272,8 @@ def tag_cloud(tags): Generates a tags cloud. """ tags.sort(key=operator.itemgetter(0)) - return '\n'.join([('<font size=%d><a href="/search?query=%s" title="Count: %s">%s</a></font>' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, format(count, ',d'), word)) \ + return '\n'.join([('<font size=%d>%s</font>' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word)) \ for (word, count) in tags]) if __name__ == "__main__": diff --git a/src/web/templates/feed_list.html b/src/web/templates/feed_list.html index 04543e4c..f8e3551e 100644 --- a/src/web/templates/feed_list.html +++ b/src/web/templates/feed_list.html @@ -4,45 +4,37 @@ <thead> <tr> <th>#</th> - {% if current_user.is_authenticated and current_user.id == user.id %} - <th>{{ _('Status') }}</th> - {% endif %} + <th>{{ _('Status') }}</th> <th>{{ _('Title') }}</th> <th>{{ _('Site') }}</th> - {% if current_user.is_authenticated and current_user.id == user.id %} - <th>{{ _('Articles') }}</th> - <th>{{ _('Actions') }}</th> - {% endif %} + <th>{{ _('Articles') }}</th> + <th>{{ _('Actions') }}</th> </tr> </thead> <tbody> {% for feed in feeds %} - <tr {% if not feed.enabled and current_user.is_authenticated %}class="warning"{% endif %}> + <tr {% if not feed.enabled %}class="warning"{% endif %}> <td>{{ loop.index }}</td> - {% if current_user.is_authenticated and current_user.id == user.id %} - <td> - {% if feed.enabled %} - <i class="glyphicon glyphicon-eye-open" title="{{ _('Feed enabled') }}"></i> - {% else %} - <i class="glyphicon glyphicon-eye-close" title="{{ _('Feed disabled') }}"></i> - {% endif %} - {% if feed.error_count >= conf.DEFAULT_MAX_ERROR %} - <i class="glyphicon glyphicon-exclamation-sign" title="{{ _('Feed encountered too much errors.') }}"></i> - {% endif %} - </td> - {% endif %} + <td> + {% if feed.enabled %} + <i class="glyphicon glyphicon-eye-open" title="{{ _('Feed enabled') }}"></i> + {% else %} + <i class="glyphicon glyphicon-eye-close" title="{{ _('Feed disabled') }}"></i> + {% endif %} + {% if feed.error_count >= conf.DEFAULT_MAX_ERROR %} + <i class="glyphicon glyphicon-exclamation-sign" title="{{ _('Feed encountered too much errors.') }}"></i> + {% endif %} + </td> <td>{% if feed.icon_url %}<img src="{{ url_for('icon.icon', url=feed.icon_url) }}" width="16px" /> {% endif %}{{ feed.title }}</td> <td><a href="{{ feed.site_link }}">{{ feed.site_link }}</a></td> - {% if current_user.is_authenticated and current_user.id == user.id %} - <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td> - <td> - <a href="{{ url_for("feed.feed", feed_id=feed.id) }}"><i class="glyphicon glyphicon-info-sign" title="{{ _('Information') }}"></i></a> - <a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a> - <a href="{{ url_for("feed.duplicates", feed_id=feed.id) }}"><i class="glyphicon glyphicon-book" title="{{ _('Duplicate articles') }}"></i></a> - <a href="{{ url_for("feed.delete", feed_id=feed.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a> - </td> - {% endif %} - </tr> + <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td> + <td> + <a href="{{ url_for("feed.feed", feed_id=feed.id) }}"><i class="glyphicon glyphicon-info-sign" title="{{ _('Information') }}"></i></a> + <a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a> + <a href="{{ url_for("feed.duplicates", feed_id=feed.id) }}"><i class="glyphicon glyphicon-book" title="{{ _('Duplicate articles') }}"></i></a> + <a href="{{ url_for("feed.delete", feed_id=feed.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a> + </td> + </tr> {% endfor %} </tbody> </table> diff --git a/src/web/templates/feed_list_simple.html b/src/web/templates/feed_list_simple.html new file mode 100644 index 00000000..976c3631 --- /dev/null +++ b/src/web/templates/feed_list_simple.html @@ -0,0 +1,22 @@ +{% if feeds.count() != 0 %} +<div class="table-responsive"> + <table 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 %}{{ feed.title }}</td> + <td><a href="{{ feed.site_link }}">{{ feed.site_link }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> +</div> +{% endif %} diff --git a/src/web/templates/profile_public.html b/src/web/templates/profile_public.html index 04beee8e..0b12b8df 100644 --- a/src/web/templates/profile_public.html +++ b/src/web/templates/profile_public.html @@ -9,8 +9,10 @@ </div> </div> + <div>{{ tag_cloud|safe }}</div> + <h2>Feeds</h2> - {% include "feed_list.html" %} + {% include "feed_list_simple.html" %} </div><!-- /.container --> {% endblock %} diff --git a/src/web/views/user.py b/src/web/views/user.py index bd12010c..01e26325 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -27,12 +27,16 @@ def profile_public(nickname=None): user = user_contr.get(nickname=nickname) if not user.is_public_profile: return redirect(url_for('home')) - art_contr = ArticleController(user.id) + + word_size = 6 + articles = ArticleController(user.id).read().all() + 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=user.feeds, - unread_article_count=art_contr.count_by_category(readed=False), - article_count=art_contr.count_by_category()) + tag_cloud=tag_cloud) @user_bp.route('/management', methods=['GET', 'POST']) @login_required |