From: W. Trevor King Date: Sat, 31 May 2014 22:20:27 +0000 (-0700) Subject: nmbug-status: Optionally load the header and footer templates from the config X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7f2bbe93a557c22277b46ad6048742222d80ed68;p=notmuch.git nmbug-status: Optionally load the header and footer templates from the config For folks that don't like the default templates for whatever reason. --- diff --git a/NEWS b/NEWS index 33e58a13..f7aaedf9 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,21 @@ Library changes Add return status to notmuch_database_close and notmuch_database_destroy +nmbug-status +------------ + +`nmbug-status` can now optionally load header and footer templates +from the config file. Use something like: + + { + "meta": { + "header": "\n\n...", + "footer": "", + ... + }, + ... + }, + Notmuch 0.18.1 (2014-06-25) =========================== diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status index c0bdd1b6..f0809f19 100755 --- a/devel/nmbug/nmbug-status +++ b/devel/nmbug/nmbug-status @@ -275,20 +275,8 @@ parser.add_argument('--get-query', help='get query for view', args = parser.parse_args() config = read_config(path=args.config) -now = datetime.datetime.utcnow() -context = { - 'date': now, - 'datetime': now.strftime('%Y-%m-%d %H:%M:%SZ'), - 'title': config['meta']['title'], - 'blurb': config['meta']['blurb'], - 'encoding': _ENCODING, - 'inter_message_padding': '0.25em', - 'border_radius': '0.5em', - } -_PAGES['text'] = Page() -_PAGES['html'] = HtmlPage( - header=''' +header_template = config['meta'].get('header', ''' @@ -338,13 +326,30 @@ _PAGES['html'] = HtmlPage( {blurb}

Views

-'''.format(**context), - footer=''' +''') + +footer_template = config['meta'].get('footer', '''

Generated: {datetime} -'''.format(**context), +''') + +now = datetime.datetime.utcnow() +context = { + 'date': now, + 'datetime': now.strftime('%Y-%m-%d %H:%M:%SZ'), + 'title': config['meta']['title'], + 'blurb': config['meta']['blurb'], + 'encoding': _ENCODING, + 'inter_message_padding': '0.25em', + 'border_radius': '0.5em', + } + +_PAGES['text'] = Page() +_PAGES['html'] = HtmlPage( + header=header_template.format(**context), + footer=footer_template.format(**context), ) if args.list_views: