From e60087e68546a8a9b483e09a78f4389fcc9ebc4e Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Tue, 20 Sep 2016 15:08:47 +0200 Subject: Few improvemnts for the tag cloud of the user's profile pages. --- src/web/lib/misc_utils.py | 4 +-- src/web/templates/feed_list.html | 52 ++++++++++++++------------------- src/web/templates/feed_list_simple.html | 22 ++++++++++++++ src/web/templates/profile_public.html | 4 ++- src/web/views/user.py | 10 +++++-- 5 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 src/web/templates/feed_list_simple.html (limited to 'src') 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([('%s' % \ - (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, format(count, ',d'), word)) \ + return '\n'.join([('%s' % \ + (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 @@ # - {% if current_user.is_authenticated and current_user.id == user.id %} - {{ _('Status') }} - {% endif %} + {{ _('Status') }} {{ _('Title') }} {{ _('Site') }} - {% if current_user.is_authenticated and current_user.id == user.id %} - {{ _('Articles') }} - {{ _('Actions') }} - {% endif %} + {{ _('Articles') }} + {{ _('Actions') }} {% for feed in feeds %} - + {{ loop.index }} - {% if current_user.is_authenticated and current_user.id == user.id %} - - {% if feed.enabled %} - - {% else %} - - {% endif %} - {% if feed.error_count >= conf.DEFAULT_MAX_ERROR %} - - {% endif %} - - {% endif %} + + {% if feed.enabled %} + + {% else %} + + {% endif %} + {% if feed.error_count >= conf.DEFAULT_MAX_ERROR %} + + {% endif %} + {% if feed.icon_url %} {% endif %}{{ feed.title }} {{ feed.site_link }} - {% if current_user.is_authenticated and current_user.id == user.id %} - ( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }} - - - - - - - {% endif %} - + ( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }} + + + + + + + {% endfor %} 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 %} +
+ + + + + + + + + + {% for feed in feeds %} + + + + + + {% endfor %} + +
#{{ _('Title') }}{{ _('Site') }}
{{ loop.index }}{% if feed.icon_url %} {% endif %}{{ feed.title }}{{ feed.site_link }}
+
+{% 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 @@ +
{{ tag_cloud|safe }}
+

Feeds

- {% include "feed_list.html" %} + {% include "feed_list_simple.html" %} {% 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 -- cgit