diff --git a/static/css/clif.css b/static/css/clif.css
index be2516c..cf4bc31 100644
--- a/static/css/clif.css
+++ b/static/css/clif.css
@@ -31,6 +31,10 @@ blockquote cite:before {
content: "\2014 \2009";
}
+details > summary {
+ cursor: pointer;
+}
+
p {
margin: 0 0 10px 0;
}
@@ -199,7 +203,7 @@ div.threads {
}
div.threads div.title {
- font-weight: bold;
+
}
div.threads div.subtitle {
@@ -215,6 +219,19 @@ div.threads {
padding: .1rem .5rem;
}
+/* Filters in a mailing list page. */
+.filters {
+ margin-bottom: 1rem;
+}
+
+ .filters .tag {
+ margin-top: .1rem;
+ }
+
+ .filters .buttons {
+ margin-top: 1rem;
+ }
+
.thread {
}
diff --git a/templates/mailing_list/emails.html b/templates/mailing_list/emails.html
index ac36efc..4d957db 100644
--- a/templates/mailing_list/emails.html
+++ b/templates/mailing_list/emails.html
@@ -1,7 +1,27 @@
{% extends "mailing_list/mailing_list.html" %}
{% block content %}
-
+
+
+ Filters
+
+
+
+
{% for thread in threads %}
@@ -10,6 +30,7 @@
#{{ thread.id }}
+
Created {{ thread.datetime|ago }}
{% if 'label' in thread['tags'] %}
diff --git a/web.py b/web.py
index 662f336..86d3073 100644
--- a/web.py
+++ b/web.py
@@ -586,6 +586,9 @@ def threads(repository):
:param repository: Match repository name NOT ending with ".git"
"""
+ # List of seletected tags, retrieved from the query string
+ query_tags = { k: request.query.getall(k) for k in request.query.keys() }
+
repository += '.mlist.git'
path = os.path.join(GITOLITE_REPOSITORIES_ROOT, repository)
list_address = '{}@{}'.format(repository[:-10], INSTANCE_DOMAIN)
@@ -597,34 +600,48 @@ def threads(repository):
tree = repo.revparse_single('HEAD').tree
threads_list = []
+ tags = {}
for obj in tree:
if obj.type != pygit2.GIT_OBJ_TREE:
continue
- threads_list.append(obj)
-
- for i in range(0, len(threads_list)):
- thread_date, thread_time, thread_id, thread_title = threads_list[i].name.split(' ', 3)
+ thread_date, thread_time, thread_id, thread_title = obj.name.split(' ', 3)
thread_tags = {}
try:
- thread_tags = parse_thread_tags(threads_list[i]['tags'].data.decode('UTF-8'))
+ thread_tags = parse_thread_tags(obj['tags'].data.decode('UTF-8'))
+
+ # Collect tags for filters
+ for k, v in thread_tags.items():
+ tags[k] = tags.get(k, []) + v
except:
pass
- threads_list[i] = {
- 'datetime': thread_date + ' ' + thread_time,
- 'id': thread_id,
- 'title': thread_title,
- 'tags': thread_tags
- }
+ # Check if we should filter out this thread from the list
+ keep = True
+ for key in query_tags.keys():
+ for value in query_tags[key]:
+ if value not in thread_tags.get(key, []):
+ keep = False
+ break
+
+ if not keep: break
+
+ if keep:
+ threads_list.append({
+ 'datetime': thread_date + ' ' + thread_time,
+ 'id': thread_id,
+ 'title': thread_title,
+ 'tags': thread_tags
+ })
threads_list.reverse()
return template('mailing_list/emails.html', threads=threads_list,
list_address=list_address,
- repository=repository)
+ repository=repository,
+ tags=tags, query_tags=query_tags)
@bottle.get('/.mlist/', name='thread')
def thread(repository, thread_id):