]> git.notmuchmail.org Git - notmuch/commit
nmbug-status: Add Page and HtmlPage for modular rendering
authorW. Trevor King <wking@tremily.us>
Mon, 10 Feb 2014 18:40:31 +0000 (10:40 -0800)
committerDavid Bremner <david@tethera.net>
Tue, 11 Feb 2014 02:51:03 +0000 (22:51 -0400)
commit98cb4779c02a07c0405073ca4a1e8a9006844904
tree80ca4b3783c27699a56ecafaca0ee18afd6790d2
parent7b7a83cc32c90bc581256ea677d839adc85f1640
nmbug-status: Add Page and HtmlPage for modular rendering

I was having trouble understanding the logic of the longish print_view
function, so I refactored the output generation into modular bits.
The basic text rendering is handled by Page, which has enough hooks
that HtmlPage can borrow the logic and slot-in HTML generators.

By modularizing the logic it should also be easier to build other
renderers if folks want to customize the layout for other projects.

Timezones
=========

This commit has not effect on the output, except that some dates have
been converted from the sender's timezone to UTC due to:

  -            val = m.get_header(header)
  -            ...
  -            if header == 'date':
  -                val = str.join(' ', val.split(None)[1:4])
  -                val = str(datetime.datetime.strptime(val, '%d %b %Y').date())
  ...
  +                value = str(datetime.datetime.utcfromtimestamp(
  +                    message.get_date()).date())

I also tweaked the HTML header date to be utcnow instead of the local
now() to make all times independent of the generator's local time.
This matches Gmane, which converts all Date headers to UTC (although
they use a 'GMT' suffix).  Notmuch uses
g_mime_utils_header_decode_date to calculate the UTC timestamps, but
uses a NULL tz_offset which drops the information we'd need to get
back to the sender's local time [1].  With the generator's local time
arbitrarily different from the sender's and viewer's local time,
sticking with UTC seems the best bet.

[1]: https://developer.gnome.org/gmime/stable/gmime-gmime-utils.html#g-mime-utils-header-decode-date
devel/nmbug/nmbug-status