home » zplus/clif.git
Author zPlus <zplus@peers.community> 2022-07-29 12:08:45
Committer zPlus <zplus@peers.community> 2022-07-29 12:08:45
Commit d358548 (patch)
Tree 1c55eca
Parent(s)

Add support for tags in mailing lists threads.


commits diff: bcc46e1..d358548
3 files changed, 41 insertions, 10 deletionsdownload


Diffstat
-rw-r--r-- static/css/clif.css 17
-rw-r--r-- templates/mailing_list/emails_thread.html 6
-rw-r--r-- web.py 28

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+10/-7 M   static/css/clif.css
index 1713087..dadeb6a
old size: 5K - new size: 5K
@@ -231,25 +231,23 @@ div.threads {
231 231 }
232 232
233 233 .thread .message {
234 - border-radius: .1rem;
235 - margin-bottom: 1rem;
236 234 }
237 235
238 - .thread .message:not(:last-child) {
239 - border-bottom: 1px solid #d0d0d0;
236 + .thread .message:not(:first-child) {
237 + border-top: 1px solid #d0d0d0;
238 + margin-top: 2rem;
239 + padding: 2rem 0rem 0rem 0rem;
240 240 }
241 241
242 242 .thread .message > .header {
243 243 font-size: .9rem;
244 - padding: 1rem;
245 244 }
246 245
247 246 .thread .message > .header > details > .headers {
248 - margin-top: 1rem;
249 247 }
250 248
251 249 .thread .message > .body {
252 - padding: 1rem;
250 + padding: .5rem 1rem 0 1rem;
253 251 white-space: pre-wrap;
254 252 }
255 253
@@ -257,6 +255,11 @@ div.threads {
257 255 flex: 30%;
258 256 padding: 1rem;
259 257 }
258 +
259 + .thread .info .tag {
260 + margin-bottom: 1rem;
261 + }
262 +
260 263
261 264 /* Alternate background color used when displaying table data */
262 265 .striped > *:nth-child(even) {

+6/-0 M   templates/mailing_list/emails_thread.html
index 4af90c8..babeb7d
old size: 2K - new size: 2K
@@ -40,6 +40,12 @@
40 40 </div>
41 41
42 42 <div class="info">
43 + {% for tag in tags %}
44 + <div class="tag">
45 + <b>{{ tag }}:</b> {{ tags[tag]|join(', ') }}
46 + </div>
47 + {% endfor %}
48 +
43 49 <details open>
44 50 <summary>{{ participants|length }} participants</summary>
45 51 {% for address in participants %}

+25/-3 M   web.py
index 771b355..ed063da
old size: 21K - new size: 21K
@@ -81,6 +81,21 @@ def list_repositories():
81 81 repositories.sort()
82 82 return repositories
83 83
84 + def parse_thread_tags(data):
85 + """
86 + Parse "tags" file of a mailing list thread.
87 + """
88 +
89 + tags = {}
90 +
91 + for line in data.splitlines():
92 + k, v = line.split('=', 1)
93 + k = k.strip()
94 + v = v.strip()
95 + tags[k] = tags.get(k, []) + [ v ]
96 +
97 + return tags
98 +
84 99
85 100
86 101
@@ -641,10 +656,17 @@ def thread(repository, thread_id):
641 656 # displaying purposes only)
642 657 emails = []
643 658 participants = []
659 + tags = {}
644 660
645 661 for obj in thread_tree:
646 - if obj.type != pygit2.GIT_OBJ_BLOB \
647 - or not obj.name.endswith('.email'):
662 + if obj.type != pygit2.GIT_OBJ_BLOB:
663 + continue
664 +
665 + if obj.name == 'tags':
666 + tags = parse_thread_tags(obj.data.decode('UTF-8'))
667 + continue
668 +
669 + if not obj.name.endswith('.email'):
648 670 continue
649 671
650 672 message = email.message_from_string(obj.data.decode('UTF-8'), policy=email.policy.default)
@@ -669,5 +691,5 @@ def thread(repository, thread_id):
669 691 emails.sort(key = lambda email: email['received_at'])
670 692
671 693 return template('mailing_list/emails_thread.html', thread=thread_data, emails=emails,
672 - participants=participants, list_address=list_address,
694 + participants=participants, list_address=list_address, tags=tags,
673 695 repository=repository)