summaryrefslogtreecommitdiffstats
path: root/hyperkitty
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty')
-rw-r--r--hyperkitty/static/js/hyperkitty.js32
-rw-r--r--hyperkitty/templates/index.html26
-rw-r--r--hyperkitty/urls.py1
-rw-r--r--hyperkitty/views/pages.py28
4 files changed, 76 insertions, 11 deletions
diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js
index a06aa79..62bacf4 100644
--- a/hyperkitty/static/js/hyperkitty.js
+++ b/hyperkitty/static/js/hyperkitty.js
@@ -378,6 +378,38 @@ function update_thread_replies(url) {
/*
+ * List descriptions on the front page
+ */
+function update_list_properties(url) {
+ $.ajax({
+ dataType: "json",
+ url: url,
+ success: function(data) {
+ $(".all-lists .mailinglist").each(function() {
+ var name = $(this).find(".list-address").text();
+ if (!data[name]) {
+ return;
+ }
+ if (data[name]["display_name"]) {
+ $(this).find(".list-name").text(data[name]["display_name"]);
+ }
+ if (data[name]["description"]) {
+ $(this).find(".list-description")
+ .text(data[name]["description"]);
+ }
+ });
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ //alert(jqXHR.responseText);
+ },
+ complete: function(jqXHR, textStatus) {
+ $(".all-lists .mailinglist img.ajaxloader").remove();
+ }
+ });
+}
+
+
+/*
* Misc.
*/
diff --git a/hyperkitty/templates/index.html b/hyperkitty/templates/index.html
index aed1abb..2efe320 100644
--- a/hyperkitty/templates/index.html
+++ b/hyperkitty/templates/index.html
@@ -16,18 +16,11 @@
<div class="row-fluid">
{% for mlist in all_lists %}
<div class="span3">
- <a href="{% url 'list_overview' mlist_fqdn=mlist.name %}">
- <p class="list-name">
- {% if mlist.display_name %}
- {{ mlist.display_name }}
- {% else %}
- {{ mlist.name }}
- </p>
- {% endif %}
+ <a href="{% url 'list_overview' mlist_fqdn=mlist.name %}" class="mailinglist">
+ <p class="list-name">{{ mlist.name }}</p>
<p class="list-address">{{ mlist.name }}</p>
- {% if mlist.description %}
- <p>{{ mlist.description }}</p>
- {% endif %}
+ <p class="list-description"></p>
+ <img alt="Loading..." class="ajaxloader" src="{{ STATIC_URL }}img/ajax-loader.gif" />
</a>
</div>
{% if forloop.counter|divisibleby:"4" %}
@@ -45,4 +38,15 @@
{% endblock %}
+{% block additionaljs %}
+
+<script type="text/javascript">
+ $(document).ready(function() {
+ // Load the properties
+ update_list_properties("{% url 'list_properties' %}");
+ });
+</script>
+
+{% endblock %}
+
{# vim: set noet: #}
diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py
index 9199de0..336d84c 100644
--- a/hyperkitty/urls.py
+++ b/hyperkitty/urls.py
@@ -41,6 +41,7 @@ urlpatterns = patterns('hyperkitty.views',
# Index
url(r'^/$', 'pages.index', name='index'),
url(r'^$', 'pages.index', name='root'),
+ url(r'^lists-properties$', 'pages.list_properties', name='list_properties'),
# Account
#url(r'^accounts/login/$', login_view, {'template_name': 'login.html', 'SSL': True}, name='user_login'),
diff --git a/hyperkitty/views/pages.py b/hyperkitty/views/pages.py
index d3f2b0b..6ec7f7b 100644
--- a/hyperkitty/views/pages.py
+++ b/hyperkitty/views/pages.py
@@ -17,10 +17,18 @@
# HyperKitty. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Aamir Khan <syst3m.w0rm@gmail.com>
+# Author: Aurelien Bompard <abompard@fedoraproject.org>
#
+
+import urllib2
+
+import django.utils.simplejson as json
+
from django.shortcuts import render
from django.conf import settings
+from django.http import HttpResponse
+from mailmanclient import Client
from hyperkitty.lib import get_store
from forms import SearchForm
@@ -35,3 +43,23 @@ def index(request):
'search_form': SearchForm(auto_id=False),
}
return render(request, "index.html", context)
+
+
+def list_properties(request):
+ """Get JSON encoded list properties"""
+ store = get_store(request)
+ lists = store.get_lists()
+ client = Client('%s/3.0' % settings.MAILMAN_REST_SERVER,
+ settings.MAILMAN_API_USER, settings.MAILMAN_API_PASS)
+ props = {}
+ for ml in lists:
+ try:
+ mm_list = client.get_list(ml.name)
+ except urllib2.HTTPError:
+ continue
+ props[ml.name] = {
+ "display_name": mm_list.display_name,
+ "description": mm_list.settings["description"],
+ }
+ return HttpResponse(json.dumps(props),
+ mimetype='application/javascript')