unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html
@ 2014-05-31 22:20 W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 1/6] Add explicit license information W. Trevor King
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Changes from v1 [1]

* Tweaked the license commit message (1/6) [2] with Carl's permission
  [3].
* Squashed v1's footer commits (old 2/5, 3/5, and 6/5, now 3/6) [4].
* Squashed v1's description commits (old 4/5 and 5/5, now 2/6) [4].
* Added commits 4/6, 5/6, and 6/6 to optionally load templates from
  the config file.

Cheers,
Trevor

[1]: id:cover.1399748615.git.wking@tremily.us
     http://thread.gmane.org/gmane.mail.notmuch.general/18299
[2]: id:a5f999ca7d8d20e9476ae2c747999458f491a324.1399748615.git.wking@tremily.us
     http://article.gmane.org/gmane.mail.notmuch.general/18301
[3]: id:87fvkgf87n.fsf@yoom.home.cworth.org
     http://article.gmane.org/gmane.mail.notmuch.general/18328
[4]: id:20140512003642.GW28634@odin.tremily.us
     http://article.gmane.org/gmane.mail.notmuch.general/18330

Carl Worth (3):
  Add explicit license information
  Add a docstring describing the program
  Move the generated date from the top of the page to the footer.

W. Trevor King (3):
  nmbug-status: Factor out header/footer context into a shared dict
  nmbug-status: Add the time to the footer's build-date
  nmbug-status: Optionally load the header and footer templates from the
    config

 NEWS                     | 18 +++++++++++++
 devel/nmbug/nmbug-status | 67 ++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 71 insertions(+), 14 deletions(-)

-- 
1.9.1.353.gc66d89d

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/6] Add explicit license information
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
@ 2014-05-31 22:20 ` W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 2/6] Add a docstring describing the program W. Trevor King
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

From: Carl Worth <cworth@cworth.org>

It's nice to have for situations where this script is found outside of
the notmuch source repository (e.g. after being installed).
---
 devel/nmbug/nmbug-status | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 03621bd..a7c7920 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -1,10 +1,23 @@
 #!/usr/bin/python
 #
 # Copyright (c) 2011-2012 David Bremner <david@tethera.net>
-# License: Same as notmuch
+#
 # dependencies
 #       - python 2.6 for json
 #       - argparse; either python 2.7, or install separately
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/ .
 
 from __future__ import print_function
 from __future__ import unicode_literals
-- 
1.9.1.353.gc66d89d

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/6] Add a docstring describing the program
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 1/6] Add explicit license information W. Trevor King
@ 2014-05-31 22:20 ` W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 3/6] Move the generated date from the top of the page to the footer W. Trevor King
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

From: Carl Worth <cworth@cworth.org>

Prefer a docstring to a header comment so we can use it as the
ArgumentParser description (formatted with 'nmbug-status --help').
Script readers still have it near the top of the file.  Since it's a
docstring, use PEP 257's summary-line-and-body format [1].

[1]: http://legacy.python.org/dev/peps/pep-0257/#multi-line-docstrings
---
 devel/nmbug/nmbug-status | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index a7c7920..e137a90 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -19,6 +19,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/ .
 
+"""Generate HTML for one or more notmuch searches.
+
+Messages matching each search are grouped by thread.  Each message
+that contains both a subject and message-id will have the displayed
+subject link to the Gmane view of the message.
+"""
+
 from __future__ import print_function
 from __future__ import unicode_literals
 
@@ -255,7 +262,7 @@ class HtmlPage (Page):
     def _slug(self, string):
         return self._slug_regexp.sub('-', string)
 
-parser = argparse.ArgumentParser()
+parser = argparse.ArgumentParser(description=__doc__)
 parser.add_argument('--text', help='output plain text format',
                     action='store_true')
 parser.add_argument('--config', help='load config from given file',
-- 
1.9.1.353.gc66d89d

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/6] Move the generated date from the top of the page to the footer.
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 1/6] Add explicit license information W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 2/6] Add a docstring describing the program W. Trevor King
@ 2014-05-31 22:20 ` W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 4/6] nmbug-status: Factor out header/footer context into a shared dict W. Trevor King
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

From: Carl Worth <cworth@cworth.org>

It's useful reference information, but anyone who wants it will look
for and find it.  We don't need this front-and-center.  Follow the
pattern set by our header template with a triple-quoted string.

The gray <hr> styling is less agressive.  IE uses 'color' for drawing
the rule, while Gecko and Opera use the border or 'background-color'
[1].

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=239386
---
 devel/nmbug/nmbug-status | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index e137a90..c92d268 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -315,22 +315,30 @@ _PAGES['html'] = HtmlPage(
     tbody:nth-child(4n+3) tr td {{
       background-color: #bce;
     }}
+    hr {{
+      border: 0;
+      height: 1px;
+      color: #ccc;
+      background-color: #ccc;
+    }}
   </style>
 </head>
 <body>
 <h2>{title}</h2>
-<p>
-Generated: {date}<br />
 {blurb}
 </p>
 <h3>Views</h3>
-'''.format(date=datetime.datetime.utcnow().date(),
-           title=config['meta']['title'],
+'''.format(title=config['meta']['title'],
            blurb=config['meta']['blurb'],
            encoding=_ENCODING,
            inter_message_padding='0.25em',
            border_radius='0.5em'),
-    footer='</body>\n</html>\n',
+    footer='''
+<hr>
+<p>Generated: {date}
+</body>
+</html>
+'''.format(date=datetime.datetime.utcnow().date())
     )
 
 if args.list_views:
-- 
1.9.1.353.gc66d89d

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/6] nmbug-status: Factor out header/footer context into a shared dict
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
                   ` (2 preceding siblings ...)
  2014-05-31 22:20 ` [PATCH v2 3/6] Move the generated date from the top of the page to the footer W. Trevor King
@ 2014-05-31 22:20 ` W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 5/6] nmbug-status: Add the time to the footer's build-date W. Trevor King
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Rather than splitting this context into header-only and footer-only
groups, just dump it all in a shared dict.  This will make it easier
to eventually split the header/footer templates out of this script
(e.g. if we want to load them from the config file).
---
 devel/nmbug/nmbug-status | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index c92d268..b7c2f80 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -275,6 +275,14 @@ parser.add_argument('--get-query', help='get query for view',
 args = parser.parse_args()
 
 config = read_config(path=args.config)
+context = {
+    'date': datetime.datetime.utcnow(),
+    '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(
@@ -328,17 +336,13 @@ _PAGES['html'] = HtmlPage(
 {blurb}
 </p>
 <h3>Views</h3>
-'''.format(title=config['meta']['title'],
-           blurb=config['meta']['blurb'],
-           encoding=_ENCODING,
-           inter_message_padding='0.25em',
-           border_radius='0.5em'),
+'''.format(**context),
     footer='''
 <hr>
 <p>Generated: {date}
 </body>
 </html>
-'''.format(date=datetime.datetime.utcnow().date())
+'''.format(**context),
     )
 
 if args.list_views:
-- 
1.9.1.353.gc66d89d

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 5/6] nmbug-status: Add the time to the footer's build-date
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
                   ` (3 preceding siblings ...)
  2014-05-31 22:20 ` [PATCH v2 4/6] nmbug-status: Factor out header/footer context into a shared dict W. Trevor King
@ 2014-05-31 22:20 ` W. Trevor King
  2014-05-31 22:20 ` [PATCH v2 6/6] nmbug-status: Optionally load the header and footer templates from the config W. Trevor King
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Our repository [1] has a post-update hook that rebuilds the status
page after each push.  Since that may happen several times a day, we
might as well show the build time (as well as the date) in the footer.

The trailing 'Z' is the ISO 8601 designator for UTC.  Now that we're
showing times, it's nice to be explicit about the timezone we're
using.

The rename from date -> datetime gives us backward-compatibility for
folks that *do* only want the date.  We keep the old date formatting
to support those folks.

[1]: http://nmbug.tethera.net/git/nmbug-tags.git
---
 devel/nmbug/nmbug-status | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index b7c2f80..c0bdd1b 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -275,8 +275,10 @@ 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': datetime.datetime.utcnow(),
+    'date': now,
+    'datetime': now.strftime('%Y-%m-%d %H:%M:%SZ'),
     'title': config['meta']['title'],
     'blurb': config['meta']['blurb'],
     'encoding': _ENCODING,
@@ -339,7 +341,7 @@ _PAGES['html'] = HtmlPage(
 '''.format(**context),
     footer='''
 <hr>
-<p>Generated: {date}
+<p>Generated: {datetime}
 </body>
 </html>
 '''.format(**context),
-- 
1.9.1.353.gc66d89d

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 6/6] nmbug-status: Optionally load the header and footer templates from the config
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
                   ` (4 preceding siblings ...)
  2014-05-31 22:20 ` [PATCH v2 5/6] nmbug-status: Add the time to the footer's build-date W. Trevor King
@ 2014-05-31 22:20 ` W. Trevor King
  2014-06-01  8:22 ` [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html Tomi Ollila
  2014-07-15 23:12 ` David Bremner
  7 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2014-05-31 22:20 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

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": "<!DOCTYPE html>\n<html lang="en">\n...",
+        "footer": "</body></html>",
+         ...
+      },
+      ...
+    },
+
 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='''<!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:
-- 
1.9.1.353.gc66d89d

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
                   ` (5 preceding siblings ...)
  2014-05-31 22:20 ` [PATCH v2 6/6] nmbug-status: Optionally load the header and footer templates from the config W. Trevor King
@ 2014-06-01  8:22 ` Tomi Ollila
  2014-07-15 23:12 ` David Bremner
  7 siblings, 0 replies; 9+ messages in thread
From: Tomi Ollila @ 2014-06-01  8:22 UTC (permalink / raw)
  To: W. Trevor King, notmuch

On Sun, Jun 01 2014, "W. Trevor King" <wking@tremily.us> wrote:

> Changes from v1 [1]
>
> * Tweaked the license commit message (1/6) [2] with Carl's permission
>   [3].
> * Squashed v1's footer commits (old 2/5, 3/5, and 6/5, now 3/6) [4].
> * Squashed v1's description commits (old 4/5 and 5/5, now 2/6) [4].
> * Added commits 4/6, 5/6, and 6/6 to optionally load templates from
>   the config file.

Series (and generated output) LGTM.

Tomi

>
> Cheers,
> Trevor
>
> [1]: id:cover.1399748615.git.wking@tremily.us
>      http://thread.gmane.org/gmane.mail.notmuch.general/18299
> [2]: id:a5f999ca7d8d20e9476ae2c747999458f491a324.1399748615.git.wking@tremily.us
>      http://article.gmane.org/gmane.mail.notmuch.general/18301
> [3]: id:87fvkgf87n.fsf@yoom.home.cworth.org
>      http://article.gmane.org/gmane.mail.notmuch.general/18328
> [4]: id:20140512003642.GW28634@odin.tremily.us
>      http://article.gmane.org/gmane.mail.notmuch.general/18330
>
> Carl Worth (3):
>   Add explicit license information
>   Add a docstring describing the program
>   Move the generated date from the top of the page to the footer.
>
> W. Trevor King (3):
>   nmbug-status: Factor out header/footer context into a shared dict
>   nmbug-status: Add the time to the footer's build-date
>   nmbug-status: Optionally load the header and footer templates from the
>     config
>
>  NEWS                     | 18 +++++++++++++
>  devel/nmbug/nmbug-status | 67 ++++++++++++++++++++++++++++++++++++++----------
>  2 files changed, 71 insertions(+), 14 deletions(-)
>
> -- 
> 1.9.1.353.gc66d89d
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html
  2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
                   ` (6 preceding siblings ...)
  2014-06-01  8:22 ` [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html Tomi Ollila
@ 2014-07-15 23:12 ` David Bremner
  7 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2014-07-15 23:12 UTC (permalink / raw)
  To: W. Trevor King, notmuch; +Cc: Tomi Ollila, Carl Worth

"W. Trevor King" <wking@tremily.us> writes:

> Changes from v1 [1]
>
> * Tweaked the license commit message (1/6) [2] with Carl's permission
>   [3].
> * Squashed v1's footer commits (old 2/5, 3/5, and 6/5, now 3/6) [4].
> * Squashed v1's description commits (old 4/5 and 5/5, now 2/6) [4].
> * Added commits 4/6, 5/6, and 6/6 to optionally load templates from
>   the config file.

Series pushed.

> Carl Worth (3):
>   Add explicit license information
>   Add a docstring describing the program
>   Move the generated date from the top of the page to the footer.

Yay, patches from Carl ;).

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-07-15 23:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-31 22:20 [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html W. Trevor King
2014-05-31 22:20 ` [PATCH v2 1/6] Add explicit license information W. Trevor King
2014-05-31 22:20 ` [PATCH v2 2/6] Add a docstring describing the program W. Trevor King
2014-05-31 22:20 ` [PATCH v2 3/6] Move the generated date from the top of the page to the footer W. Trevor King
2014-05-31 22:20 ` [PATCH v2 4/6] nmbug-status: Factor out header/footer context into a shared dict W. Trevor King
2014-05-31 22:20 ` [PATCH v2 5/6] nmbug-status: Add the time to the footer's build-date W. Trevor King
2014-05-31 22:20 ` [PATCH v2 6/6] nmbug-status: Optionally load the header and footer templates from the config W. Trevor King
2014-06-01  8:22 ` [PATCH v2 0/6] nmbug-status fixups from notmuch-to-html Tomi Ollila
2014-07-15 23:12 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).