From fbfe8fc7ea6ba91661027ea51dec290823f9e0bb Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Wed, 10 Oct 2012 19:12:07 +0200 Subject: Improve styling in headers and thread view --- hyperkitty/static/css/style.css | 69 +++++++++++++++++---- hyperkitty/static/css/thread.css | 1 + hyperkitty/templates/base.html | 14 ++--- hyperkitty/templates/messages/message.html | 4 +- hyperkitty/templates/month_view.html | 62 +++++++++++-------- hyperkitty/templates/recent_activities.html | 19 ++---- hyperkitty/templates/search.html | 12 ++-- hyperkitty/templates/thread.html | 2 +- hyperkitty/templates/threads/month_list.html | 17 +++++ hyperkitty/templates/user_profile.html | 2 +- hyperkitty/templatetags/hk_generic.py | 92 ++++++++++++++++++++++++++++ hyperkitty/templatetags/poll_extras.py | 55 ----------------- hyperkitty/templatetags/storm.py | 34 ---------- hyperkitty/views/list.py | 13 +++- hyperkitty/views/message.py | 7 +++ hyperkitty/views/thread.py | 8 +++ 16 files changed, 252 insertions(+), 159 deletions(-) create mode 100644 hyperkitty/templates/threads/month_list.html create mode 100644 hyperkitty/templatetags/hk_generic.py delete mode 100644 hyperkitty/templatetags/poll_extras.py (limited to 'hyperkitty') diff --git a/hyperkitty/static/css/style.css b/hyperkitty/static/css/style.css index fe53a2f..a8c7a16 100644 --- a/hyperkitty/static/css/style.css +++ b/hyperkitty/static/css/style.css @@ -55,24 +55,27 @@ body { /* Add icons to some text */ -.participant { - background: url("../img/participant.png") no-repeat scroll left top; +.participant, .discussion, .saved, .notsaved { padding-left: 20px; + padding-right: 10px; + background: no-repeat scroll left center; +} + +.participant { + background-image: url("../img/participant.png"); + padding-left: 16px; } .discussion { - background: url("../img/discussion.png") no-repeat scroll left top; - padding-left: 20px; + background-image: url("../img/discussion.png"); } .saved { - background: url("../img/saved.png") no-repeat scroll left top; - padding-left: 20px; + background-image: url("../img/saved.png"); } .notsaved { - background: url("../img/notsaved.png") no-repeat scroll left top; - padding-left: 20px; + background-image: url("../img/notsaved.png"); } .gravatar { @@ -209,7 +212,7 @@ body { font-style: italic; } -#recent_activities{ +#recent_activities, #month-view { width: 88%; margin-top: 20px; margin-right: 10px; @@ -234,9 +237,43 @@ body { #archives li { list-style-type: none; } +#archives li.current { + font-weight: bold; +} + +/* Month view header */ + +#month-view header { + margin-bottom: 4em; +} + +#month-view header .list-name { + display: inline; + font-size: 190%; + font-weight: bold; + padding-right: 0.5em; +} + +#month-view header .month-name { + display: inline; + font-size: 190%; + padding-right: 1em; +} + +#month-view header .month-info { + display: inline; + list-style-type: none; +} +#month-view header .month-info li { + display: inline; +} /* Thread list */ +.thread { + margin-bottom: 3em; +} + .thread_title { font-weight: bold; font-size: 125%; @@ -249,12 +286,20 @@ body { } .thread_content { - margin-top:10px; + margin-top: 0.5em; } .thread_info { text-align:right; - padding-right: 50px; +} +.thread_info .btn { + padding-top: 2px; + padding-bottom: 2px; +} + +.thread_content .thread_email { + display: inline-block; + margin-bottom: 5px; } .tags { @@ -265,7 +310,7 @@ body { /* Part containing the body of the mail which can be shown/hidden */ .expander { - width: 665px; + width: 740px; background-image: linear-gradient(bottom, rgb(236,236,236) 11%, rgb(255,255,255) 100%); background-image: -o-linear-gradient(bottom, rgb(236,236,236) 11%, rgb(255,255,255) 100%); background-image: -moz-linear-gradient(bottom, rgb(236,236,236) 11%, rgb(255,255,255) 100%); diff --git a/hyperkitty/static/css/thread.css b/hyperkitty/static/css/thread.css index 43fca6b..cc3e8a4 100644 --- a/hyperkitty/static/css/thread.css +++ b/hyperkitty/static/css/thread.css @@ -153,6 +153,7 @@ header .thread-newer { vertical-align: middle; } + /* Main section with the whole thread */ /* First email of the thread. */ diff --git a/hyperkitty/templates/base.html b/hyperkitty/templates/base.html index 7a62c5f..c679687 100644 --- a/hyperkitty/templates/base.html +++ b/hyperkitty/templates/base.html @@ -18,22 +18,22 @@ -
- {% for key, value in archives_length|sort %} -

{{ key }}

-
- -
- {% endfor %} -
+{% include 'threads/month_list.html' %} {% endblock %} diff --git a/hyperkitty/templates/recent_activities.html b/hyperkitty/templates/recent_activities.html index 4bca218..f044dad 100644 --- a/hyperkitty/templates/recent_activities.html +++ b/hyperkitty/templates/recent_activities.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load poll_extras %} +{% load hk_generic %} {% load gravatar %} {% load storm %} @@ -202,20 +202,9 @@ {% endif %} -
- {% for key, value in archives_length|sort %} -

{{ key }}

-
- -
- {% endfor %} -
+ +{% include 'threads/month_list.html' %} + {% endblock %} {% block additionaljs %} diff --git a/hyperkitty/templates/search.html b/hyperkitty/templates/search.html index 0fd6e44..5763eeb 100644 --- a/hyperkitty/templates/search.html +++ b/hyperkitty/templates/search.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load poll_extras %} +{% load hk_generic %} {% load gravatar %} {% block content %} @@ -59,14 +59,14 @@ diff --git a/hyperkitty/templates/thread.html b/hyperkitty/templates/thread.html index b019d8a..3fe03f6 100644 --- a/hyperkitty/templates/thread.html +++ b/hyperkitty/templates/thread.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% load gravatar %} -{% load storm %} +{% load hk_generic %} {% block additional_stylesheets %} diff --git a/hyperkitty/templates/threads/month_list.html b/hyperkitty/templates/threads/month_list.html new file mode 100644 index 0000000..b3918f8 --- /dev/null +++ b/hyperkitty/templates/threads/month_list.html @@ -0,0 +1,17 @@ +{% load hk_generic %} + +
+ {% for year, months in archives_length|sort %} +

{{ year }}

+
+ +
+ {% endfor %} +
diff --git a/hyperkitty/templates/user_profile.html b/hyperkitty/templates/user_profile.html index 6e58549..f5bca76 100644 --- a/hyperkitty/templates/user_profile.html +++ b/hyperkitty/templates/user_profile.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% load i18n %} -{% load poll_extras %} +{% load hk_generic %} {% block content %}

User Profile - {{ user }}

diff --git a/hyperkitty/templatetags/hk_generic.py b/hyperkitty/templatetags/hk_generic.py new file mode 100644 index 0000000..5f30bc2 --- /dev/null +++ b/hyperkitty/templatetags/hk_generic.py @@ -0,0 +1,92 @@ +import datetime +import re + +from django import template +from django.utils.datastructures import SortedDict + +register = template.Library() + + +@register.filter +def trimString(str): + return re.sub('\s+', ' ', str) + + +@register.filter(name='sort') +def listsort(value): + if isinstance(value, dict): + new_dict = SortedDict() + key_list = value.keys() + key_list.sort() + key_list.reverse() + for key in key_list: + values = value[key] + values.sort() + values.reverse() + new_dict[key] = values + return new_dict.items() + elif isinstance(value, list): + new_list = list(value) + new_list.sort() + return new_list + else: + return value + listsort.is_safe = True + + +@register.filter(name="monthtodate") +def to_date(month, year): + return datetime.date(year, month, 1) + + +@register.filter +def strip_page(value): + print repr(value), repr(value)[-2] + if not value: + return value + if value.endswith('/') and value[-3] == '/': + end_with_number = False + try: + if int(value[-2]) in range(0,10): + end_with_number = True + if end_with_number: + output = value.rsplit('/', 2) + except ValueError: + output = value.rsplit('/', 1) + else: + output = value.rsplit('/', 1) + return output[0] + + +# From http://djangosnippets.org/snippets/1259/ +@register.filter +def truncatesmart(value, limit=80): + """ + Truncates a string after a given number of chars keeping whole words. + + Usage: + {{ string|truncatesmart }} + {{ string|truncatesmart:50 }} + """ + try: + limit = int(limit) + # invalid literal for int() + except ValueError: + # Fail silently. + return value + + # Make sure it's unicode + value = unicode(value) + + # Return the string itself if length is smaller or equal to the limit + if len(value) <= limit: + return value + + # Cut the string + value = value[:limit] + + # Break into words and remove the last + words = value.split(' ')[:-1] + + # Join the words and return + return ' '.join(words) + '...' diff --git a/hyperkitty/templatetags/poll_extras.py b/hyperkitty/templatetags/poll_extras.py deleted file mode 100644 index 0f243c6..0000000 --- a/hyperkitty/templatetags/poll_extras.py +++ /dev/null @@ -1,55 +0,0 @@ -from django import template -from django.http import HttpRequest -from django.utils.datastructures import SortedDict -import re - -register = template.Library() - -@register.filter(name="trimString") -def trimString(str): - return re.sub('\s+', ' ', str) - -@register.filter(name='sort') -def listsort(value): - if isinstance(value, dict): - new_dict = SortedDict() - key_list = value.keys() - key_list.sort() - key_list.reverse() - for key in key_list: - values = value[key] - values.sort() - values.reverse() - new_dict[key] = values - return new_dict.items() - elif isinstance(value, list): - new_list = list(value) - new_list.sort() - return new_list - else: - return value - listsort.is_safe = True - -@register.filter(name="tomonth") -def to_month(value): - months = ('January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December') - return months[value -1] - -@register.filter(name="strip_page") -def strip_page(value): - print repr(value), repr(value)[-2] - if not value: - return value - if value.endswith('/') and value[-3] == '/': - end_with_number = False - try: - if int(value[-2]) in range(0,10): - end_with_number = True - if end_with_number: - output = value.rsplit('/', 2) - except ValueError: - output = value.rsplit('/', 1) - else: - output = value.rsplit('/', 1) - return output[0] diff --git a/hyperkitty/templatetags/storm.py b/hyperkitty/templatetags/storm.py index e0443ad..a116430 100644 --- a/hyperkitty/templatetags/storm.py +++ b/hyperkitty/templatetags/storm.py @@ -11,37 +11,3 @@ def count(expr): @register.filter(name="strip_subject") def count(subject, mlist): return stripped_subject(mlist, subject) - - -# From http://djangosnippets.org/snippets/1259/ -@register.filter -def truncatesmart(value, limit=80): - """ - Truncates a string after a given number of chars keeping whole words. - - Usage: - {{ string|truncatesmart }} - {{ string|truncatesmart:50 }} - """ - try: - limit = int(limit) - # invalid literal for int() - except ValueError: - # Fail silently. - return value - - # Make sure it's unicode - value = unicode(value) - - # Return the string itself if length is smaller or equal to the limit - if len(value) <= limit: - return value - - # Cut the string - value = value[:limit] - - # Break into words and remove the last - words = value.split(' ')[:-1] - - # Join the words and return - return ' '.join(words) + '...' diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index d8ea29a..91caa99 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -140,6 +140,14 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): except: thread.avgdislike = 0 + thread.likestatus = "neutral" + if thread.avglike - thread.avgdislike >= 10: + thread.likestatus = "likealot" + elif thread.avglike - thread.avgdislike > 0: + thread.likestatus = "like" + #elif thread.avglike - thread.avgdislike < 0: + # thread.likestatus = "dislike" + threads[cnt] = thread cnt = cnt + 1 @@ -170,7 +178,8 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): 'is_last': pageNo == paginator.num_pages, 'list_address': mlist_fqdn, 'search_form': search_form, - 'month': month_string, + 'month': begin_date, + 'month_num': begin_date.month, 'month_participants': len(participants), 'month_discussions': len(threads), 'threads': threads, @@ -256,7 +265,7 @@ def list(request, mlist_fqdn=None): 'mlist' : mlist, 'list_address': mlist_fqdn, 'search_form': search_form, - 'month': 'Recent activity', + 'month': None, 'month_participants': len(participants), 'month_discussions': len(threads), 'top_threads': top_threads[:5], diff --git a/hyperkitty/views/message.py b/hyperkitty/views/message.py index 19242fd..a1ca917 100644 --- a/hyperkitty/views/message.py +++ b/hyperkitty/views/message.py @@ -70,6 +70,13 @@ def index(request, mlist_fqdn, hashid): message.votes = votes message.likes = likes message.dislikes = dislikes + message.likestatus = "neutral" + if message.likes - message.dislikes >= 10: + message.likestatus = "likealot" + elif thread.likes - message.dislikes > 0: + message.likestatus = "like" + #elif message.likes - message.dislikes < 0: + # message.likestatus = "dislike" c = RequestContext(request, { 'list_name' : list_name, diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 558e51d..577c8f4 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -72,6 +72,14 @@ def thread_index (request, mlist_fqdn, threadid): message.votes = votes message.likes = likes message.dislikes = dislikes + message.likestatus = "neutral" + if message.likes - message.dislikes >= 10: + message.likestatus = "likealot" + elif thread.likes - message.dislikes > 0: + message.likestatus = "like" + #elif message.likes - message.dislikes < 0: + # message.likestatus = "dislike" + # Statistics on how many participants and messages this month participants[message.sender_name] = {'email': message.sender_email} -- cgit