From 309e1ca86b5455fb7f8f66bee0e92b40f2116131 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 1 Jun 2014 15:20:27 +1700 Subject: [PATCH] [PATCH v2 6/6] nmbug-status: Optionally load the header and footer templates from the config --- 03/f48dc618062eaf0739b79c26171ede59b69291 | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 03/f48dc618062eaf0739b79c26171ede59b69291 diff --git a/03/f48dc618062eaf0739b79c26171ede59b69291 b/03/f48dc618062eaf0739b79c26171ede59b69291 new file mode 100644 index 000000000..aeae255a4 --- /dev/null +++ b/03/f48dc618062eaf0739b79c26171ede59b69291 @@ -0,0 +1,166 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2851F431FAE + for ; Sat, 31 May 2014 15:21:19 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id DQgtdVI3Elzl for ; + Sat, 31 May 2014 15:21:15 -0700 (PDT) +Received: from qmta03.westchester.pa.mail.comcast.net + (qmta03.westchester.pa.mail.comcast.net [76.96.62.32]) + by olra.theworths.org (Postfix) with ESMTP id 7C01E431FD8 + for ; Sat, 31 May 2014 15:21:03 -0700 (PDT) +Received: from omta24.westchester.pa.mail.comcast.net ([76.96.62.76]) + by qmta03.westchester.pa.mail.comcast.net with comcast + id 8mL81o0031ei1Bg53mM33L; Sat, 31 May 2014 22:21:03 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta24.westchester.pa.mail.comcast.net with comcast + id 8mM11o00f152l3L3kmM2LP; Sat, 31 May 2014 22:21:03 +0000 +Received: from mjolnir.tremily.us (unknown [192.168.0.140]) + by odin.tremily.us (Postfix) with ESMTPS id 3DC1311F065C; + Sat, 31 May 2014 15:21:01 -0700 (PDT) +Received: (nullmailer pid 13199 invoked by uid 1000); + Sat, 31 May 2014 22:20:38 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH v2 6/6] nmbug-status: Optionally load the header and footer + templates from the config +Date: Sat, 31 May 2014 15:20:27 -0700 +Message-Id: + <1d1e7c71bb4b55fc501411381fda5e2421ca6fe2.1401574293.git.wking@tremily.us> +X-Mailer: git-send-email 1.9.1.353.gc66d89d +In-Reply-To: +References: +In-Reply-To: +References: +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1401574863; + bh=iqON0OSdx9Fr65Ee3et5C5RrRmOatQ04fRvSTNG6heY=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=htGwYK9t/18IWypQqH+M/crGfgKX+h8liMzVx7pxpumBnY2wo8d/QygEYoL2Kvcut + mWu7QVRlOCqVK7rptHgOrh5OVF/lkjBFZ2HIFB69ecWaj9cKDEr+Kg2I/2dNppBDIq + 95Uoj337zN/x/7R6D1hT86e5khQshwShX1DPJWfUTLXwSR+z5sJp10ExeLMDjJ5mAa + G5U+eX1VQ9oEmMY0LGW7m7k+mQz/R3YsqByT5zEWr79Ntb0+iElaSkdXjQuQPyt2fS + eTltNyUiyWhze5qyRGKZOMyvOnWdfTe1fuzD41vs3kodoXBi0WEm/THI1h+GT7+bQJ + qgI5SoB4bkPBA== +Cc: Tomi Ollila +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 31 May 2014 22:21:19 -0000 + +For folks that don't like the default templates for whatever reason. +--- + NEWS | 18 ++++++++++++++++++ + devel/nmbug/nmbug-status | 37 +++++++++++++++++++++---------------- + 2 files changed, 39 insertions(+), 16 deletions(-) + +diff --git a/NEWS b/NEWS +index 5d85733..ab6f9e4 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,3 +1,21 @@ ++Notmuch 0.19 (UNRELEASED) ++========================= ++ ++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 (2014-05-06) + ========================= + +diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status +index c0bdd1b..f0809f1 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: +-- +1.9.1.353.gc66d89d + -- 2.26.2