X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;ds=sidebyside;f=devel%2Fnmbug%2Fnmbug-status;h=cb3901f75fa8926ea6fb10cef5627460243a134d;hb=81a1aae2dc3b48c4e0dcc524455f32ca91087033;hp=6a156af28250e5309a968d1791be38da29c2e00a;hpb=aa32d2579b0aa4c8c8a31a1d6060445b254b2be2;p=notmuch diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status index 6a156af2..cb3901f7 100755 --- a/devel/nmbug/nmbug-status +++ b/devel/nmbug/nmbug-status @@ -13,7 +13,6 @@ import codecs import collections import datetime import email.utils -import locale try: # Python 3 from urllib.parse import quote except ImportError: # Python 2 @@ -24,9 +23,10 @@ import os import re import sys import subprocess +import xml.sax.saxutils -_ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding() +_ENCODING = 'UTF-8' _PAGES = {} @@ -41,7 +41,7 @@ if not hasattr(collections, 'OrderedDict'): # Python 2.6 or earlier super(_OrderedDict, self).__setitem__(key, value) self._keys.append(key) - def __values__(self): + def values(self): for key in self._keys: yield self[key] @@ -89,7 +89,7 @@ class Page (object): byte_stream = sys.stdout.buffer except AttributeError: # Python 2 byte_stream = sys.stdout - stream = codecs.getwriter(encoding='UTF-8')(stream=byte_stream) + stream = codecs.getwriter(encoding=_ENCODING)(stream=byte_stream) self._write_header(views=views, stream=stream) for view in views: self._write_view(database=database, view=view, stream=stream) @@ -204,19 +204,22 @@ class HtmlPage (Page): return stream.write('\n') for thread in threads: + stream.write(' \n') for message_display_data in thread: stream.write(( - '\n' - ' \n' - ' \n' - '\n' - '\n' - ' \n' - ' \n' - '\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' ).format(**message_display_data)) + stream.write(' \n') if thread != threads[-1]: - stream.write('\n') + stream.write( + ' \n') stream.write('
{date}{message-id-term}
{from}{subject}
{date}{message-id-term}
{from}{subject}


\n') def _message_display_data(self, *args, **kwargs): @@ -226,11 +229,14 @@ class HtmlPage (Page): if 'subject' in display_data and 'message-id' in display_data: d = { 'message-id': quote(display_data['message-id']), - 'subject': display_data['subject'], + 'subject': xml.sax.saxutils.escape(display_data['subject']), } display_data['subject'] = ( '{subject}' ).format(**d) + for key in ['message-id', 'from']: + if key in display_data: + display_data[key] = xml.sax.saxutils.escape(display_data[key]) return (running_data, display_data) def _slug(self, string): @@ -242,17 +248,55 @@ _PAGES['html'] = HtmlPage( header=''' - -Notmuch Patches + + {title} + -

Notmuch Patches

+

{title}

Generated: {date}
-For more infomation see nmbug +{blurb}

Views

-'''.format(date=datetime.datetime.utcnow().date()), +'''.format(date=datetime.datetime.utcnow().date(), + title='Notmuch Patches', + blurb='For more infomation see nmbug', + encoding=_ENCODING, + inter_message_padding='0.25em', + border_radius='0.5em'), footer='\n\n', )