]> git.notmuchmail.org Git - notmuch/commitdiff
nmbug-status: Optionally load the header and footer templates from the config
authorW. Trevor King <wking@tremily.us>
Sat, 31 May 2014 22:20:27 +0000 (15:20 -0700)
committerDavid Bremner <david@tethera.net>
Tue, 15 Jul 2014 23:15:23 +0000 (20:15 -0300)
For folks that don't like the default templates for whatever reason.

NEWS
devel/nmbug/nmbug-status

diff --git a/NEWS b/NEWS
index 33e58a1399796ded5ab8da38a1ac855efcb65dba..f7aaedf91d07f580ba2eb7be7dacadc986c08bbe 100644 (file)
--- 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": "<!DOCTYPE html>\n<html lang="en">\n...",
+        "footer": "</body></html>",
+         ...
+      },
+      ...
+    },
+
 Notmuch 0.18.1 (2014-06-25)
 ===========================
 
index c0bdd1b6e7722936cf02df7b7a1985f064c03051..f0809f193e108fb024982524a2a56ec1c3250173 100755 (executable)
@@ -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: