diff options
21 files changed, 225 insertions, 404 deletions
diff --git a/hyperkitty/static/css/hyperkitty.css b/hyperkitty/static/css/hyperkitty.css index b8f56b4..5381e86 100644 --- a/hyperkitty/static/css/hyperkitty.css +++ b/hyperkitty/static/css/hyperkitty.css @@ -373,29 +373,29 @@ form.likeform { } -/* Month view header */ +/* Threads view header */ -#month-view .month-header { +#thread-list .thread-list-header { margin-bottom: 4em; } -#month-view .month-header .month-info { +#thread-list .thread-list-header .thread-list-info { display: inline; list-style-type: none; margin: 0; padding: 0; } -#month-view .month-header .month-info li { +#thread-list .thread-list-header .thread-list-info li { display: inline; margin-right: 2em; } -#month-view .month-header .month-info li.list-address { +#thread-list .thread-list-header .thread-list-info li.list-address { font-size: 120%; margin-right: 4em; } -/* Thread list */ +/* Thread view */ .thread { margin: 2em 0 2em 0; diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js index 6fb7ef8..d5898dc 100644 --- a/hyperkitty/static/js/hyperkitty.js +++ b/hyperkitty/static/js/hyperkitty.js @@ -296,8 +296,28 @@ function setup_quotes() { function setup_months_list() { var current = $("#months-list li.current").parent().prev(); - if (!current.length) { current = 0; } // overview - $("#months-list").accordion({ active: current }); + if (!current.length) { + current = false; // overview or search + } else { + current = current.prevAll("h3").length; + } + $("#months-list").accordion({ collapsible: true, active: current }); +} + +function setup_expander() { + $('span.expander').expander({ + slicePoint: 500, + userCollapseText : '\n[-]', + expandText : '\n[+]', + beforeExpand: function() { + $(this).removeClass("collapsed"); + $(this).addClass("expanded"); + }, + onCollapse: function() { + $(this).removeClass("expanded"); + $(this).addClass("collapsed"); + } + }); } @@ -313,4 +333,5 @@ $(document).ready(function() { setup_months_list(); setup_favorites(); setup_replies(); + setup_expander(); }); diff --git a/hyperkitty/templates/base.html b/hyperkitty/templates/base.html index f8eb95e..d645dbe 100644 --- a/hyperkitty/templates/base.html +++ b/hyperkitty/templates/base.html @@ -36,13 +36,13 @@ <ul class="nav"> - <li {% if not list_address %} class="active"{% endif %}> + <li {% if not mlist %} class="active"{% endif %}> <a href="{% url root %}">All lists</a> </li> - {% if list_address %} + {% if mlist %} <li id="list_name" class="active"> - <a href="{% url list_overview mlist_fqdn=list_address %}">{{list_address}}</a> + <a href="{% url list_overview mlist_fqdn=mlist.name %}">{{mlist.name}}</a> </li> {% endif %} diff --git a/hyperkitty/templates/message.html b/hyperkitty/templates/message.html index 10e71ec..3a19268 100644 --- a/hyperkitty/templates/message.html +++ b/hyperkitty/templates/message.html @@ -18,7 +18,7 @@ <div class="message-header"> <a class="thread-back" - href="{% url thread threadid=message.thread_id, mlist_fqdn=list_address %}#{{message.message_id_hash}}"> + href="{% url thread threadid=message.thread_id, mlist_fqdn=mlist.name %}#{{message.message_id_hash}}"> </a> {# the background image will be a "back to thread" button #} <h1>{{ message.subject }}</h1> </div> diff --git a/hyperkitty/templates/messages/like_form.html b/hyperkitty/templates/messages/like_form.html index 39f5c6d..7896fed 100644 --- a/hyperkitty/templates/messages/like_form.html +++ b/hyperkitty/templates/messages/like_form.html @@ -1,5 +1,5 @@ <form method="post" class="likeform" - action="{% url message_vote mlist_fqdn=list_address, message_id_hash=message_id_hash %}"> + action="{% url message_vote mlist_fqdn=mlist.name, message_id_hash=message_id_hash %}"> {% csrf_token %} <span class="likestatus {{ object.likestatus }}"> +<span class="likecount">{{ object.likes }}</span>/-<span class="dislikecount">{{ object.dislikes }}</span> diff --git a/hyperkitty/templates/messages/message.html b/hyperkitty/templates/messages/message.html index 4e37290..f8417d7 100644 --- a/hyperkitty/templates/messages/message.html +++ b/hyperkitty/templates/messages/message.html @@ -21,7 +21,7 @@ {% gravatar email.sender_email 40 %} </div> <div class="email-author inline-block"> - <span class="name"><a href="{% url message_index mlist_fqdn=list_address, message_id_hash=email.message_id_hash %}">{{email.sender_name|escapeemail}}</a></span> + <span class="name"><a href="{% url message_index mlist_fqdn=mlist.name, message_id_hash=email.message_id_hash %}">{{email.sender_name|escapeemail}}</a></span> {% if use_mockups %} <br /> <span class="rank"> @@ -39,7 +39,7 @@ <p class="attachments">Attachments:</p> <ul class="attachments-list"> {% for attachment in email.attachments %} - <li><a href="{% url message_attachment mlist_fqdn=list_address, message_id_hash=email.message_id_hash, counter=attachment.counter, filename=attachment.name %}">{{attachment.name}}</a> + <li><a href="{% url message_attachment mlist_fqdn=mlist.name, message_id_hash=email.message_id_hash, counter=attachment.counter, filename=attachment.name %}">{{attachment.name}}</a> ({{attachment.content_type}} — {{attachment.size|filesizeformat}}) </li> {% endfor %} @@ -54,14 +54,14 @@ <a class="attachments" href="#attachments">{{ email.attachments|count }} attachment(s)</a> <ul class="attachments-list"> {% for attachment in email.attachments %} - <li><a href="{% url message_attachment mlist_fqdn=list_address, message_id_hash=email.message_id_hash, counter=attachment.counter, filename=attachment.name %}">{{attachment.name}}</a> + <li><a href="{% url message_attachment mlist_fqdn=mlist.name, message_id_hash=email.message_id_hash, counter=attachment.counter, filename=attachment.name %}">{{attachment.name}}</a> ({{attachment.content_type}} — {{attachment.size|filesizeformat}}) </li> {% endfor %} </ul> </div> {% endif %} - {% include "messages/reply_form.html" with mlist_fqdn=list_address message_id_hash=email.message_id_hash %} + {% include "messages/reply_form.html" with mlist_fqdn=mlist.name message_id_hash=email.message_id_hash %} </div> </div> diff --git a/hyperkitty/templates/month_view.html b/hyperkitty/templates/month_view.html deleted file mode 100644 index 595a71b..0000000 --- a/hyperkitty/templates/month_view.html +++ /dev/null @@ -1,135 +0,0 @@ -{% extends "base.html" %} -{% load gravatar %} -{% load hk_generic %} -{% load storm %} - - -{% block title %} -{{ month|date:"F Y"|capfirst }} - {{ mlist.display_name|default:mlist.name|escapeemail }} - {{ app_name|title }} -{% endblock %} - -{% block content %} - -<div class="row-fluid"> - -{% include 'threads/month_list.html' %} - - <div id="month-view" class="span8"> - - <div class="month-header page-header"> - <h1>{{ mlist.display_name|default:mlist.name|escapeemail }} - <small>{{ month|date:"F Y"|capfirst }}</small> - </h1> - <ul class="month-info"> - {% if mlist.display_name %} - <li class="list-address"> - {{ list_address|escapeemail }} - </li> - {% endif %} - <li class="participant"> - {{ month_participants }} participants - </li> - <li class="discussion"> - {{ month_discussions }} discussions - </li> - </ul> - </div> - - {% for thread in threads %} - <!-- New thread --> - <div class="thread"> - <div class="{% if thread.favorite %}saved{% else %}notsaved{% endif %}"> - <span class="thread_title"><a name="{{thread.thread_id}}" - href="{% url thread threadid=thread.thread_id, mlist_fqdn=list_address %}" - >{{ thread.starting_email.subject|strip_subject:mlist }}</a></span> - <span class="thread_date">{{thread.date_active|timesince }}</span> - </div> - <div class="thread_content"> - {% if thread.category_tag %} - <div class="inline-block type type_{{thread.category_tag}}"> - <a href="{% url search_tag mlist_fqdn=list_address, tag=thread.category_tag %}" - >{{thread.category}}</a> - </div> - {% endif %} - {% if thread.category %} - <div class="inline-block type type_{{thread.category|lower}}"> - <a href="{% url search_tag mlist_fqdn=list_address, tag=thread.category|lower %}" - >{{thread.category}}</a> - </div> - {% endif %} - <div class="gravatar"> - {% if thread.starting_email.sender_email %} - {% gravatar thread.starting_email.sender_email 40 %} - <br /> - {% endif %} - {{ thread.starting_email.sender_name|escapeemail }} - </div> - <div class="thread_email"> - <span class="expander collapsed"> - {{ thread.starting_email.content|urlizetrunc:76|escapeemail }} - </span> - </div> - </div> - <div class="thread_info"> - <ul class="tags inline"> - {% if thread.tags|length %} - <li> - Tags: - </li> - {% for tag in thread.tags %} - <li> - <a href="{% url search_tag mlist_fqdn=list_address, tag=tag %}">{{tag}}</a> - </li> - {% endfor %} - {% endif %} - </ul> - <ul class="inline-block"> - <li class="participant"> - {{ thread.participants|length }} participants - </li> - <li class="discussion"> - {{ thread|length }} comments - </li> - </ul> - <ul class="inline-block"> - {% include "messages/like_form.html" with message_id_hash=thread.starting_email.message_id_hash object=thread %} - </ul> - <a href="{% url thread threadid=thread.thread_id, mlist_fqdn=list_address %}" - class="btn">Show discussion</a> - </div> - </div> - <!-- End of thread --> - {% empty %} - Sorry no emails could be found for this month. - {% endfor %} - - {% include "paginator.html" %} - - </div> - -</div> - -{% endblock %} - -{% block additionaljs %} -<script src="{{ STATIC_URL }}libs/jquery.expander.js"></script> -<script> - $(document).ready(function() { - $('span.expander').expander({ - slicePoint: 500, - userCollapseText : '\nView Less', - expandText : '\nView More', - beforeExpand: function() { - $(this).removeClass("collapsed"); - $(this).addClass("expanded"); - }, - onCollapse: function() { - $(this).removeClass("expanded"); - $(this).addClass("collapsed"); - } - }); - }); -</script> -{% endblock %} - -{# vim: set noet: #} diff --git a/hyperkitty/templates/paginator.html b/hyperkitty/templates/paginator.html index 7978f06..1b3ad90 100644 --- a/hyperkitty/templates/paginator.html +++ b/hyperkitty/templates/paginator.html @@ -1,26 +1,12 @@ {% load i18n %} <ul class="pager"> - <li{% if not has_previous %} class="disabled"{% endif %}> - <a href="?page={{ previous }}">← Newer</a> + <li{% if not pager.has_previous %} class="disabled"{% endif %}> + <a href="?page={{ pager.previous_page_number }}">← Newer</a> </li> - {% if show_first %} - <li class="page"><a href="?page=1">1</a></li> - <li class="ellipsis">...</li> - {% endif %} - {% for linkpage in page_numbers %} - {% ifequal linkpage page %} - <li class="current">{{ page }}</li> - {% else %} - <li class="page"><a href="?page={{ linkpage }}">{{ linkpage }}</a></li> - {% endifequal %} - {% endfor %} - {% if show_last %} - <li class="ellipsis">...</li> - <li class="page"><a href="?page=last">{{ pages }}</a></li> - {% endif %} - - <li{% if not has_next %} class="disabled"{% endif %}><a href="?page={{ next }}">Older →</a></li> + <li{% if not pager.has_next %} class="disabled"{% endif %}> + <a href="?page={{ pager.next_page_number }}">Older →</a> + </li> </ul> {# vim: set noet: #} diff --git a/hyperkitty/templates/recent_activities.html b/hyperkitty/templates/recent_activities.html index 711e0c5..0daa6e3 100644 --- a/hyperkitty/templates/recent_activities.html +++ b/hyperkitty/templates/recent_activities.html @@ -24,7 +24,7 @@ activity_graph( ["{{days|join:'","'}}"], {{evolution}}, - "{% url archives_latest mlist_fqdn=list_address %}" + "{% url archives_latest mlist_fqdn=mlist.name %}" ); </script> </div> diff --git a/hyperkitty/templates/search.html b/hyperkitty/templates/search.html deleted file mode 100644 index facc733..0000000 --- a/hyperkitty/templates/search.html +++ /dev/null @@ -1,102 +0,0 @@ -{% extends "base.html" %} -{% load hk_generic %} -{% load gravatar %} - - -{% block title %} -{{ search_type }} - {{ app_name|title }} -{% endblock %} - -{% block content %} - -<div class="row-fluid"> - -{% if threads.object_list %} -<div class="pagination"> - <span class="step-links"> {% if threads.has_previous %} <a href="{{full_path|strip_page}}/{{ threads.previous_page_number }}">previous</a> {% endif %} <span class="current"> Page {{ threads.number }} of {{ threads.paginator.num_pages }}. </span> {% if threads.has_next %} <a href="{{full_path|strip_page}}/{{ threads.next_page_number }}">next</a> {% endif %} </span> -</div> -{% endif %} - -{% for email in threads.object_list %} -<!-- New thread --> -<div class="thread"> - <div class="notsaved"> - <a href="{% url thread threadid=email.thread_id, mlist_fqdn=list_address %}"> <span class="thread_title">{{email.subject}}</span> </a> - <span class="thread_date">{{email.date}}</span> - </div> - <div class="thread_content"> - {% if email.category_tag %} - <div class="inline-block type type_{{email.category_tag}}"> - <a href="{% url search_tag mlist_fqdn=list_address, tag=email.category_tag %}">{{email.category}}</a> - </div> - {% endif %} - {% if email.category %} - <div class="inline-block type type_{{email.category|lower}}"> - <a href="{% url search_tag mlist_fqdn=list_address, tag=email.category|lower %}">{{email.category}}</a> - </div> - {% endif %} - <div class="inline-block gravatar"> - {% if email.sender_email %} - {% gravatar email.sender_email 40 %} - <br /> - {% endif %} - {{email.sender_name}} - </div> - <div class="inline-block thread_email"> - <span class="expander"> - {{email.content|wordwrap:90|urlizetrunc:76|escapeemail}} - </span> - </div> - </div> - <div class="thread_info"> - <ul class="tags inline"> - <li> - Tags: - </li> - {% for tag in email.tags %} - <li> - <a href="{% url search_tag mlist_fqdn=list_address, tag=tag %}">{{tag}}</a> - </li> - {% endfor %} - </ul> - <ul class="inline-block"> - <li class="participant"> - {{email.participants|length}} participants - </li> - <li class="discussion"> - {{email.answers}} comments - </li> - </ul> - <ul class="inline-block"> - {% include "messages/like_form.html" with message_id_hash=email.message_id_hash object=email %} - </ul> - </div> -</div> -<!-- End of thread --> -{% empty %} -Sorry no emails could be found for your search. -{% endfor %} - -{% if threads.object_list %} -<div class="pagination"> - <span class="step-links"> {% if threads.has_previous %} <a href="{{ threads.previous_page_number }}">previous</a> {% endif %} <span class="current"> Page {{ threads.number }} of {{ threads.paginator.num_pages }}. </span> {% if threads.has_next %} <a href="{{ threads.next_page_number }}">next</a> {% endif %} </span> -</div> -{% endif %} - -</div> - -{% endblock %} - -{% block additionaljs %} -<script src="{{ STATIC_URL }}libs/jquery.expander.js"></script> -<script> - $(document).ready(function() { - $('span.expander').expander({ - userCollapseText : 'View Less', - expandText : 'View More' - }); - }); -</script> -{% endblock %} - -{# vim: set noet: #} diff --git a/hyperkitty/templates/thread.html b/hyperkitty/templates/thread.html index 71e9da2..41cee97 100644 --- a/hyperkitty/templates/thread.html +++ b/hyperkitty/templates/thread.html @@ -21,7 +21,7 @@ {% for thread in neighbors %} {% if thread %} <a class="thread-{% ifequal forloop.counter 1 %}older{% else %}newer{% endifequal %}" - href="{% url thread threadid=thread.thread_id, mlist_fqdn=list_address %}" + href="{% url thread threadid=thread.thread_id, mlist_fqdn=mlist.name %}" >{{ thread.subject|strip_subject:mlist|truncatesmart:"22" }}</a> {% endif %} {% endfor %} @@ -40,10 +40,10 @@ <p class="sort-mode"> {% if sort_mode == "date" %} - <a href="{% url thread threadid=threadid, mlist_fqdn=list_address %}?sort=thread" + <a href="{% url thread threadid=threadid, mlist_fqdn=mlist.name %}?sort=thread" >Show replies by thread</a> {% else %} - <a href="{% url thread threadid=threadid, mlist_fqdn=list_address %}?sort=date" + <a href="{% url thread threadid=threadid, mlist_fqdn=mlist.name %}?sort=date" >Show replies by date</a> {% endif %} </p> diff --git a/hyperkitty/templates/thread_list.html b/hyperkitty/templates/thread_list.html new file mode 100644 index 0000000..c7857c8 --- /dev/null +++ b/hyperkitty/templates/thread_list.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} +{% load gravatar %} +{% load hk_generic %} + + +{% block title %} +{{ list_title }} - {{ mlist.display_name|default:mlist.name|escapeemail }} - {{ app_name|title }} +{% endblock %} + +{% block content %} + +<div class="row-fluid"> + +{% include 'threads/month_list.html' %} + + <div id="thread-list" class="span8"> + + <div class="thread-list-header page-header"> + <h1>{{ mlist.display_name|default:mlist.name|escapeemail }} + <small>{{ list_title }}</small> + </h1> + <ul class="thread-list-info"> + {% if mlist.display_name %} + <li class="list-address"> + {{ mlist.name|escapeemail }} + </li> + {% endif %} + <li class="participant"> + {{ participants }} participants + </li> + <li class="discussion"> + {{ threads.paginator.count }} discussions + </li> + </ul> + </div> + + {% for thread in threads %} + {% include "threads/summary_thread_large.html" %} + {% empty %} + <p>Sorry no email threads could be found {{ no_results_text }}.</p> + {% endfor %} + + {% include "paginator.html" with pager=threads %} + + </div> + +</div> + +{% endblock %} + +{% block additionaljs %} +<script src="{{ STATIC_URL }}libs/jquery.expander.js"></script> +{% endblock %} + +{# vim: set noet: #} diff --git a/hyperkitty/templates/threads/month_list.html b/hyperkitty/templates/threads/month_list.html index 75b72d4..f7178af 100644 --- a/hyperkitty/templates/threads/month_list.html +++ b/hyperkitty/templates/threads/month_list.html @@ -1,12 +1,12 @@ {% load hk_generic %} <div id="months-list" class="span2"> - {% for year, months in archives_length|sort %} + {% for year, months in months_list|sort %} <h3>{{ year }}</h3> <ul> {% for ar_month in months %} - <li class="{% if year == month.year and ar_month == month.month %}current{% endif %}"> - <a href="{% url archives_with_month year=year, mlist_fqdn=list_address, month=ar_month %}" + <li class="{% if month and year == month.year and ar_month == month.month %}current{% endif %}"> + <a href="{% url archives_with_month year=year, mlist_fqdn=mlist.name, month=ar_month %}" >{{ ar_month|monthtodate:year|date:"F" }}</a> </li> {% endfor %} diff --git a/hyperkitty/templates/threads/right_col.html b/hyperkitty/templates/threads/right_col.html index 355663d..15a5fec 100644 --- a/hyperkitty/templates/threads/right_col.html +++ b/hyperkitty/templates/threads/right_col.html @@ -23,7 +23,7 @@ </div> </div> <form id="fav_form" name="favorite" method="post" class="favorite" - action="{% url favorite mlist_fqdn=list_address, threadid=threadid %}"> + action="{% url favorite mlist_fqdn=mlist.name, threadid=threadid %}"> {% csrf_token %} <input type="hidden" name="action" value="{{ fav_action }}" /> <p> @@ -37,7 +37,7 @@ </div> <div id="add_tag"> <form id="add_tag_form" name="addtag" method="post" - action="{% url add_tag mlist_fqdn=list_address, threadid=threadid %}"> + action="{% url add_tag mlist_fqdn=mlist.name, threadid=threadid %}"> {% csrf_token %} {{ addtag_form.as_p }} </form> diff --git a/hyperkitty/templates/threads/summary_thread.html b/hyperkitty/templates/threads/summary_thread.html index 16b6804..578b051 100644 --- a/hyperkitty/templates/threads/summary_thread.html +++ b/hyperkitty/templates/threads/summary_thread.html @@ -4,19 +4,19 @@ <div class="thread"> <span class="thread_id">#{{counter}}</span> <span class="thread_title"><a name="{{thread.thread_id}}" - href="{% url thread threadid=thread.thread_id, mlist_fqdn=list_address %}" + href="{% url thread threadid=thread.thread_id, mlist_fqdn=mlist.name %}" >{{ thread.subject|strip_subject:mlist }}</a></span> <div class="thread_stats"> <ul class="inline-block"> {% if thread.category_tag %} <li class="type type_{{thread.category_tag}}"> - <a href="{% url search_tag mlist_fqdn=list_address, tag=thread.category_tag %}" + <a href="{% url search_tag mlist_fqdn=mlist.name, tag=thread.category_tag %}" >{{thread.category}}</a> </li> {% endif %} {% if thread.category %} <li class="type type_{{thread.category|lower}}"> - <a href="{% url search_tag mlist_fqdn=list_address, tag=thread.category|lower %}" + <a href="{% url search_tag mlist_fqdn=mlist.name, tag=thread.category|lower %}" >{{thread.category}}</a> </li> {% endif %} diff --git a/hyperkitty/templates/threads/summary_thread_large.html b/hyperkitty/templates/threads/summary_thread_large.html new file mode 100644 index 0000000..43e7d10 --- /dev/null +++ b/hyperkitty/templates/threads/summary_thread_large.html @@ -0,0 +1,67 @@ +{% load gravatar %} +{% load hk_generic %} +{% load storm %} + + <div class="thread"> + <div class="{% if thread.favorite %}saved{% else %}notsaved{% endif %}"> + <span class="thread_title"><a name="{{thread.thread_id}}" + href="{% url thread threadid=thread.thread_id, mlist_fqdn=mlist.name %}" + >{{ thread.starting_email.subject|strip_subject:mlist }}</a></span> + <span class="thread_date">{{thread.date_active|timesince }}</span> + </div> + <div class="thread_content"> + {% if thread.category_tag %} + <div class="inline-block type type_{{thread.category_tag}}"> + <a href="{% url search_tag mlist_fqdn=mlist.name, tag=thread.category_tag %}" + >{{thread.category}}</a> + </div> + {% endif %} + {% if thread.category %} + <div class="inline-block type type_{{thread.category|lower}}"> + <a href="{% url search_tag mlist_fqdn=mlist.name, tag=thread.category|lower %}" + >{{thread.category}}</a> + </div> + {% endif %} + <div class="gravatar"> + {% if thread.starting_email.sender_email %} + {% gravatar thread.starting_email.sender_email 40 %} + <br /> + {% endif %} + {{ thread.starting_email.sender_name|escapeemail }} + </div> + <div class="thread_email"> + <span class="expander collapsed"> + {{ thread.starting_email.content|urlizetrunc:76|escapeemail }} + </span> + </div> + </div> + <div class="thread_info"> + <ul class="tags inline"> + {% if thread.tags|length %} + <li> + Tags: + </li> + {% for tag in thread.tags %} + <li> + <a href="{% url search_tag mlist_fqdn=mlist.name, tag=tag %}">{{tag}}</a> + </li> + {% endfor %} + {% endif %} + </ul> + <ul class="inline-block"> + <li class="participant"> + {{ thread.participants|length }} participants + </li> + <li class="discussion"> + {{ thread|length }} comments + </li> + </ul> + <ul class="inline-block"> + {% include "messages/like_form.html" with message_id_hash=thread.starting_email.message_id_hash object=thread %} + </ul> + <a href="{% url thread threadid=thread.thread_id, mlist_fqdn=mlist.name %}" + class="btn">Show discussion</a> + </div> + </div> + +{# vim: set noet: #} diff --git a/hyperkitty/templates/threads/tags.html b/hyperkitty/templates/threads/tags.html index ce162ed..6307d1f 100644 --- a/hyperkitty/templates/threads/tags.html +++ b/hyperkitty/templates/threads/tags.html @@ -3,7 +3,7 @@ <ul class="inline"> {% for tag in tags %} <li> - <a href="{% url search_tag mlist_fqdn=list_address, tag=tag.tag %}" >{{ tag.tag }}</a> + <a href="{% url search_tag mlist_fqdn=mlist.name, tag=tag.tag %}" >{{ tag.tag }}</a> {% if not forloop.last %} | {% endif %} </li> {% endfor %} diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py index f86b937..e9132cc 100644 --- a/hyperkitty/urls.py +++ b/hyperkitty/urls.py @@ -75,14 +75,10 @@ urlpatterns = patterns('hyperkitty.views', # Search Tag - url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/tag/(?P<tag>.*)/(?P<page>\d+)/$', - 'list.search_tag'), url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/tag/(?P<tag>.*)/$', 'list.search_tag', name='search_tag'), # Search - url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/search/(?P<target>.*)/(?P<keyword>.*)/(?P<page>\d+)/$', - 'list.search_keyword'), url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/search/(?P<target>.*)/(?P<keyword>.*)/$', 'list.search_keyword', name="search_keyword"), url(r'^list/(?P<mlist_fqdn>[^/@]+@[^/@]+)/search/$', diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py index 3adbebd..6efd0b3 100644 --- a/hyperkitty/views/list.py +++ b/hyperkitty/views/list.py @@ -32,6 +32,7 @@ from collections import namedtuple, defaultdict import django.utils.simplejson as simplejson from django.http import HttpResponse, HttpResponseRedirect +from django.shortcuts import render_to_response from django.template import RequestContext, loader from django.conf import settings from django.core.urlresolvers import reverse @@ -53,8 +54,6 @@ if settings.USE_MOCKUPS: def archives(request, mlist_fqdn, year=None, month=None, day=None): - # @TODO : modify url.py to account for page number - if year is None and month is None: today = datetime.date.today() return HttpResponseRedirect(reverse( @@ -64,43 +63,43 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): 'month': today.month})) begin_date, end_date = get_display_dates(year, month, day) - - search_form = SearchForm(auto_id=False) - t = loader.get_template('month_view.html') store = get_store(request) mlist = store.get_list(mlist_fqdn) - all_threads = store.get_threads(mlist_fqdn, start=begin_date, - end=end_date) + threads = store.get_threads(mlist_fqdn, start=begin_date, end=end_date) + extra_context = { + 'month': begin_date, + 'month_num': begin_date.month, + "list_title": begin_date.strftime("%B %Y").capitalize(), + "no_results_text": "for this month", + } + return _thread_list(request, mlist, threads, extra_context=extra_context) + + +def _thread_list(request, mlist, threads, template_name='thread_list.html', extra_context={}): + store = get_store(request) + search_form = SearchForm(auto_id=False) participants = set() - #cnt = 0 - for thread in all_threads: + for thread in threads: participants.update(thread.participants) - highestlike = 0 - highestdislike = 0 - + # Votes totalvotes = 0 totallikes = 0 totaldislikes = 0 - for message_id_hash in thread.email_id_hashes: - # Extract all the votes for this message likes, dislikes = get_votes(message_id_hash) totallikes = totallikes + likes totalvotes = totalvotes + likes + dislikes totaldislikes = totaldislikes + dislikes - try: thread.likes = totallikes / totalvotes except ZeroDivisionError: thread.likes = 0 - try: thread.dislikes = totaldislikes / totalvotes except ZeroDivisionError: thread.dislikes = 0 - thread.likestatus = "neutral" if thread.likes - thread.dislikes >= 10: thread.likestatus = "likealot" @@ -109,14 +108,11 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): #elif thread.likes - thread.dislikes < 0: # thread.likestatus = "dislike" - #threads[cnt] = thread - #cnt = cnt + 1 - # Favorites thread.favorite = False if request.user.is_authenticated(): try: - Favorite.objects.get(list_address=mlist_fqdn, + Favorite.objects.get(list_address=mlist.name, threadid=thread.thread_id, user=request.user) except Favorite.DoesNotExist: @@ -124,11 +120,11 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): else: thread.favorite = True - paginator = Paginator(all_threads, 10) - pageNo = request.GET.get('page') - + all_threads = threads + paginator = Paginator(threads, 10) + page_num = request.GET.get('page') try: - threads = paginator.page(pageNo) + threads = paginator.page(page_num) except PageNotAnInteger: # If page is not an integer, deliver first page. threads = paginator.page(1) @@ -136,31 +132,18 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None): # If page is out of range (e.g. 9999), deliver last page of results. threads = paginator.page(paginator.num_pages) - - archives_length = get_months(store, mlist_fqdn) - - c = RequestContext(request, { + context = { 'mlist' : mlist, - 'objects': threads.object_list, - 'page': pageNo, - 'has_previous': threads.has_previous(), - 'has_next': threads.has_next(), - 'previous': threads.previous_page_number(), - 'next': threads.next_page_number(), - 'is_first': pageNo == 1, - 'is_last': pageNo == paginator.num_pages, - 'list_address': mlist_fqdn, + 'current_page': page_num, 'search_form': search_form, - 'month': begin_date, - 'month_num': begin_date.month, - 'month_participants': len(participants), - 'month_discussions': len(all_threads), 'threads': threads, - 'pages' : paginator.object_list, - 'archives_length': archives_length, + 'participants': len(participants), + 'months_list': get_months(store, mlist.name), 'use_mockups': settings.USE_MOCKUPS, - }) - return HttpResponse(t.render(c)) + } + context.update(extra_context) + return render_to_response(template_name, context, + context_instance=RequestContext(request)) @@ -199,8 +182,6 @@ def overview(request, mlist_fqdn=None): # active threads are the ones that have the most recent posting active_threads = sorted(threads, key=lambda t: t.date_active, reverse=True) - archives_length = get_months(store, mlist_fqdn) - # top authors are the ones that have the most kudos. How do we determine # that? Most likes for their post? if settings.USE_MOCKUPS: @@ -233,16 +214,12 @@ def overview(request, mlist_fqdn=None): c = RequestContext(request, { 'mlist' : mlist, - 'list_address': mlist_fqdn, 'search_form': search_form, - 'month': None, - 'month_participants': len(participants), - 'month_discussions': len(threads), 'top_threads': top_threads[:5], 'most_active_threads': active_threads[:5], 'top_author': authors, 'threads_per_category': threads_per_category, - 'archives_length': archives_length, + 'months_list': get_months(store, mlist.name), 'evolution': evolution, 'days': days, 'use_mockups': settings.USE_MOCKUPS, @@ -250,47 +227,6 @@ def overview(request, mlist_fqdn=None): return HttpResponse(t.render(c)) -def _search_results_page(request, mlist_fqdn, threads, search_type, - page=1, num_threads=25, limit=None): - search_form = SearchForm(auto_id=False) - t = loader.get_template('search.html') - list_name = mlist_fqdn.split('@')[0] - res_num = len(threads) - - participants = set() - for msg in threads: - participants.add(msg.sender_name) - - paginator = Paginator(threads, num_threads) - - #If page request is out of range, deliver last page of results. - try: - threads = paginator.page(page) - except (EmptyPage, InvalidPage): - threads = paginator.page(paginator.num_pages) - - store = get_store(request) - cnt = 0 - for thread in threads.object_list: - #msg.email = msg.sender_email.strip() - # Statistics on how many participants and threads this month - participants.update(thread.participants) - threads.object_list[cnt] = thread - cnt = cnt + 1 - - c = RequestContext(request, { - 'list_name' : list_name, - 'list_address': mlist_fqdn, - 'search_form': search_form, - 'search_type': search_type, - 'month_participants': len(participants), - 'month_discussions': res_num, - 'threads': threads, - 'full_path': request.get_full_path(), - }) - return HttpResponse(t.render(c)) - - def search(request, mlist_fqdn): keyword = request.GET.get('keyword') target = request.GET.get('target') @@ -308,9 +244,9 @@ def search(request, mlist_fqdn): def search_keyword(request, mlist_fqdn, target, keyword, page=1): + store = get_store(request) ## Should we remove the code below? ## If urls.py does it job we should never need it - store = get_store(request) if not keyword: keyword = request.GET.get('keyword') if not target: @@ -331,21 +267,24 @@ def search_keyword(request, mlist_fqdn, target, keyword, page=1): return _search_results_page(request, mlist_fqdn, threads, 'Search', page) -def search_tag(request, mlist_fqdn, tag=None, page=1): +def search_tag(request, mlist_fqdn, tag): '''Returns threads having a particular tag''' - - store = get_store(settings.KITTYSTORE_URL) - list_name = mlist_fqdn.split('@')[0] + store = get_store(request) + mlist = store.get_list(mlist_fqdn) try: - thread_ids = Tag.objects.filter(tag=tag) + tags = Tag.objects.filter(tag=tag) except Tag.DoesNotExist: - thread_ids = {} + tags = {} threads = [] - for thread_id in thread_ids: - threads.append(store.get_thread(mlist_fqdn, thread_id)) - - return _search_results_page(request, mlist_fqdn, threads, - 'Tag search', page, limit=50) + for t in tags: + threads.append(store.get_thread(mlist_fqdn, t.threadid)) + + extra_context = { + "tag": tag, + "list_title": "Search results for tag \"%s\"" % tag, + "no_results_text": "for this tag", + } + return _thread_list(request, mlist, threads, extra_context=extra_context) diff --git a/hyperkitty/views/message.py b/hyperkitty/views/message.py index 40e1834..41e0f16 100644 --- a/hyperkitty/views/message.py +++ b/hyperkitty/views/message.py @@ -45,8 +45,6 @@ def index(request, mlist_fqdn, message_id_hash): Displays a single message identified by its message_id_hash (derived from message_id) ''' - list_name = mlist_fqdn.split('@')[0] - search_form = SearchForm(auto_id=False) t = loader.get_template('message.html') store = get_store(request) @@ -69,11 +67,9 @@ def index(request, mlist_fqdn, message_id_hash): c = RequestContext(request, { 'mlist' : mlist, - 'list_name' : list_name, - 'list_address': mlist_fqdn, 'message': message, 'message_id_hash' : message_id_hash, - 'archives_length': get_months(store, mlist_fqdn), + 'months_list': get_months(store, mlist.name), 'use_mockups': settings.USE_MOCKUPS, 'reply_form': ReplyForm(), }) diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index 2e4f768..c819792 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -78,7 +78,6 @@ def thread_index(request, mlist_fqdn, threadid, month=None, year=None): if email.level > 5: email.level = 5 - archives_length = get_months(store, mlist_fqdn) from_url = reverse("thread", kwargs={"mlist_fqdn":mlist_fqdn, "threadid":threadid}) # Tags @@ -112,7 +111,6 @@ def thread_index(request, mlist_fqdn, threadid, month=None, year=None): 'threadid' : threadid, 'subject': subject, 'tags' : tags, - 'list_address': mlist_fqdn, 'search_form': search_form, 'addtag_form': tag_form, 'month': thread.date_active, @@ -120,7 +118,7 @@ def thread_index(request, mlist_fqdn, threadid, month=None, year=None): 'first_mail': thread.starting_email, 'replies': list(emails)[1:], 'neighbors': (prev_thread, next_thread), - 'archives_length': archives_length, + 'months_list': get_months(store, mlist.name), 'days_inactive': days_inactive.days, 'days_old': days_old.days, 'use_mockups': settings.USE_MOCKUPS, |