diff options
author | W. Trevor King <wking@tremily.us> | 2014-05-31 15:20:27 -0700 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-07-15 20:15:23 -0300 |
commit | 7f2bbe93a557c22277b46ad6048742222d80ed68 (patch) | |
tree | 4ad983be052c355f1d575f2546a0832f476d8634 /devel | |
parent | f10024f30dc907d4396fb7ef3cc8541c89e31715 (diff) |
nmbug-status: Optionally load the header and footer templates from the config
For folks that don't like the default templates for whatever reason.
Diffstat (limited to 'devel')
-rwxr-xr-x | devel/nmbug/nmbug-status | 37 |
1 files changed, 21 insertions, 16 deletions
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='''<!DOCTYPE html> +header_template = config['meta'].get('header', '''<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset={encoding}" /> @@ -338,13 +326,30 @@ _PAGES['html'] = HtmlPage( {blurb} </p> <h3>Views</h3> -'''.format(**context), - footer=''' +''') + +footer_template = config['meta'].get('footer', ''' <hr> <p>Generated: {datetime} </body> </html> -'''.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: |