unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring
@ 2014-02-14 16:48 W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 1/4] nmbug-status: Color threads in HTML output W. Trevor King
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: W. Trevor King @ 2014-02-14 16:48 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

This fixes two rebase-induced typos from v3 [1]:

* Doubled meta-http-equiv entries in the color-threads patch [2].
* An extra close-paren in the HTML header format arguments [3].

The remainder of v3 has already landed in master [4].

Cheers,
Trevor

[1]: id:"cover.1392309570.git.wking@tremily.us"
     http://thread.gmane.org/gmane.mail.notmuch.general/17216
[2]: id:"20140214020537.GP7538@odin.tremily.us"
     http://article.gmane.org/gmane.mail.notmuch.general/17228
[3]: id:"20140213174252.GL7538@odin.tremily.us"
     http://article.gmane.org/gmane.mail.notmuch.general/17225
[4]: id:"87ha8127g8.fsf@zancas.localnet"
     http://article.gmane.org/gmane.mail.notmuch.general/17239

W. Trevor King (4):
  nmbug-status: Color threads in HTML output
  nmbug-status: Add inter-message padding
  nmbug-status: Encode output using the user's locale
  nmbug-status: Hardcode UTF-8 instead of using the user's locale

 devel/nmbug/nmbug-status | 68 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 53 insertions(+), 15 deletions(-)

-- 
1.8.5.2.8.g0f6c0d1

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

* [PATCH v4 1/4] nmbug-status: Color threads in HTML output
  2014-02-14 16:48 [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
@ 2014-02-14 16:48 ` W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 2/4] nmbug-status: Add inter-message padding W. Trevor King
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: W. Trevor King @ 2014-02-14 16:48 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Add tbody sections so we don't have to color every row.  Multiple
tbody sections are allowed [1].  Use CSS 3's nth-child to handle
even/odd coloring (skipping the spacer rows) [2], which is supported
on the major browsers [3].

border-spacing is from CCS 2.1 [4,5].  I'm using it to avoid
whitespace between td cells.

border-radius is from CCS 3 [6,7].  I'm using it to make the colored
sections a bit less harsh.  I tried adding rounded borders to the
tbody itself doesn't work, but I couldn't get that to work without
setting the tbody's display to 'block'.  That rounded the corners, but
collapsed the cell spacing (e.g. columns were no longer aligned).
This commit's by-corner-td approach is not particularly elegant, but
it works.  The td padding entries just ensure that the cell body is
suitably far from the edges that it doesn't fall outside of the
rounded corners.

The doubled-braces are escapes from Python's str.format.

[1]: http://www.w3.org/TR/html5/tabular-data.html#the-table-element
[2]: http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
[3]: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child#Browser_compatibility
[4]: http://www.w3.org/TR/CSS2/tables.html#propdef-border-spacing
[5]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing#Browser_compatibility
[6]: http://www.w3.org/TR/css3-background/#the-border-radius
[7]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#Browser_compatibility
---
 devel/nmbug/nmbug-status | 55 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 12 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 1c390e6..a8bacab 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -205,19 +205,22 @@ class HtmlPage (Page):
             return
         stream.write('<table>\n')
         for thread in threads:
+            stream.write('  <tbody>\n')
             for message_display_data in thread:
                 stream.write((
-                    '<tr>\n'
-                    '  <td>{date}</td>\n'
-                    '  <td><code>{message-id-term}</code></td>\n'
-                    '</tr>\n'
-                    '<tr>\n'
-                    '  <td>{from}</td>\n'
-                    '  <td>{subject}</td>\n'
-                    '</tr>\n'
+                    '    <tr>\n'
+                    '      <td>{date}</td>\n'
+                    '      <td><code>{message-id-term}</code></td>\n'
+                    '    </tr>\n'
+                    '    <tr>\n'
+                    '      <td>{from}</td>\n'
+                    '      <td>{subject}</td>\n'
+                    '    </tr>\n'
                     ).format(**message_display_data))
+            stream.write('  </tbody>\n')
             if thread != threads[-1]:
-                stream.write('<tr><td colspan="2"><br /></td></tr>\n')
+                stream.write(
+                    '  <tbody><tr><td colspan="2"><br /></td></tr></tbody>\n')
         stream.write('</table>\n')
 
     def _message_display_data(self, *args, **kwargs):
@@ -246,8 +249,35 @@ _PAGES['html'] = HtmlPage(
     header='''<!DOCTYPE html>
 <html lang="en">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Notmuch Patches</title>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <title>Notmuch Patches</title>
+  <style media="screen" type="text/css">
+    table {{
+      border-spacing: 0;
+    }}
+    td {{
+      padding-left: {border_radius};
+      padding-right: {border_radius};
+    }}
+    tr:first-child td:first-child {{
+      border-top-left-radius: {border_radius};
+    }}
+    tr:first-child td:last-child {{
+      border-top-right-radius: {border_radius};
+    }}
+    tr:last-child td:first-child {{
+      border-bottom-left-radius: {border_radius};
+    }}
+    tr:last-child td:last-child {{
+      border-bottom-right-radius: {border_radius};
+    }}
+    tbody:nth-child(4n+1) tr td {{
+      background-color: #ffd96e;
+    }}
+    tbody:nth-child(4n+3) tr td {{
+      background-color: #bce;
+    }}
+  </style>
 </head>
 <body>
 <h2>Notmuch Patches</h2>
@@ -256,7 +286,8 @@ Generated: {date}<br />
 For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>
 </p>
 <h3>Views</h3>
-'''.format(date=datetime.datetime.utcnow().date()),
+'''.format(date=datetime.datetime.utcnow().date(),
+           border_radius='0.5em'),
     footer='</body>\n</html>\n',
     )
 
-- 
1.8.5.2.8.g0f6c0d1

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

* [PATCH v4 2/4] nmbug-status: Add inter-message padding
  2014-02-14 16:48 [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 1/4] nmbug-status: Color threads in HTML output W. Trevor King
@ 2014-02-14 16:48 ` W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 3/4] nmbug-status: Encode output using the user's locale W. Trevor King
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: W. Trevor King @ 2014-02-14 16:48 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

We already had the tbody with a blank row separating threads (which is
not colored); this commit adds a bit of spacing to separate messages
within a thread.  It will also add a bit of colored padding above the
first message and below the final message, but the main goal is to add
padding *between* two-row message blocks.

                                               <--- new padding
  thread-1, message-1, row-1  (class="message-first")
  thread-1, message-1, row-2  (class="message-last")
                                               <--- new padding
    spacer tbody with a blank row
                                               <--- new padding
  thread-2, message-1, row-1  (class="message-first")
  thread-2, message-1, row-2  (class="message-last")
                                               <--- new padding
                                               <--- new padding
  thread-2, message-2, row-1  (class="message-first")
  thread-2, message-2, row-2  (class="message-last")
                                               <--- new padding
---
 devel/nmbug/nmbug-status | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index a8bacab..018f191 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -208,11 +208,11 @@ class HtmlPage (Page):
             stream.write('  <tbody>\n')
             for message_display_data in thread:
                 stream.write((
-                    '    <tr>\n'
+                    '    <tr class="message-first">\n'
                     '      <td>{date}</td>\n'
                     '      <td><code>{message-id-term}</code></td>\n'
                     '    </tr>\n'
-                    '    <tr>\n'
+                    '    <tr class="message-last">\n'
                     '      <td>{from}</td>\n'
                     '      <td>{subject}</td>\n'
                     '    </tr>\n'
@@ -255,6 +255,12 @@ _PAGES['html'] = HtmlPage(
     table {{
       border-spacing: 0;
     }}
+    tr.message-first td {{
+      padding-top: {inter_message_padding};
+    }}
+    tr.message-last td {{
+      padding-bottom: {inter_message_padding};
+    }}
     td {{
       padding-left: {border_radius};
       padding-right: {border_radius};
@@ -287,6 +293,7 @@ For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>
 </p>
 <h3>Views</h3>
 '''.format(date=datetime.datetime.utcnow().date(),
+           inter_message_padding='0.25em',
            border_radius='0.5em'),
     footer='</body>\n</html>\n',
     )
-- 
1.8.5.2.8.g0f6c0d1

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

* [PATCH v4 3/4] nmbug-status: Encode output using the user's locale
  2014-02-14 16:48 [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 1/4] nmbug-status: Color threads in HTML output W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 2/4] nmbug-status: Add inter-message padding W. Trevor King
@ 2014-02-14 16:48 ` W. Trevor King
  2014-02-14 16:48 ` [PATCH v4 4/4] nmbug-status: Hardcode UTF-8 instead of " W. Trevor King
  2014-02-16 23:46 ` [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring David Bremner
  4 siblings, 0 replies; 8+ messages in thread
From: W. Trevor King @ 2014-02-14 16:48 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

Instead of always writing UTF-8, allow the user to configure the
output encoding using their locale.  This is useful for previewing
output in the terminal, for poor souls that don't use UTF-8 locales
;).
---
 devel/nmbug/nmbug-status | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 018f191..c4532f1 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -90,7 +90,7 @@ class Page (object):
                 byte_stream = sys.stdout.buffer
             except AttributeError:  # Python 2
                 byte_stream = sys.stdout
-            stream = codecs.getwriter(encoding='UTF-8')(stream=byte_stream)
+            stream = codecs.getwriter(encoding=_ENCODING)(stream=byte_stream)
         self._write_header(views=views, stream=stream)
         for view in views:
             self._write_view(database=database, view=view, stream=stream)
@@ -249,7 +249,7 @@ _PAGES['html'] = HtmlPage(
     header='''<!DOCTYPE html>
 <html lang="en">
 <head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
   <title>Notmuch Patches</title>
   <style media="screen" type="text/css">
     table {{
@@ -293,6 +293,7 @@ For more infomation see <a href="http://notmuchmail.org/nmbug">nmbug</a>
 </p>
 <h3>Views</h3>
 '''.format(date=datetime.datetime.utcnow().date(),
+           encoding=_ENCODING,
            inter_message_padding='0.25em',
            border_radius='0.5em'),
     footer='</body>\n</html>\n',
-- 
1.8.5.2.8.g0f6c0d1

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

* [PATCH v4 4/4] nmbug-status: Hardcode UTF-8 instead of using the user's locale
  2014-02-14 16:48 [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
                   ` (2 preceding siblings ...)
  2014-02-14 16:48 ` [PATCH v4 3/4] nmbug-status: Encode output using the user's locale W. Trevor King
@ 2014-02-14 16:48 ` W. Trevor King
  2014-02-16 23:46 ` [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring David Bremner
  4 siblings, 0 replies; 8+ messages in thread
From: W. Trevor King @ 2014-02-14 16:48 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

David [1] and Tomi [2] both feel that the user's choice of LANG is not
explicit enough to have such a strong effect on nmbug-status.  For
example, cron jobs usually default to LANG=C, and that is going to
give you ASCII output:

  $ LANG=C python -c 'import locale; print(locale.getpreferredencoding())'
  ANSI_X3.4-1968

Trying to print Unicode author names (and other strings) in that
encoding would crash nmbug-status with a UnicodeEncodeError.  To avoid
that, this patch hardcodes UTF-8, which can handle generic Unicode,
and is the preferred encoding (regardless of LANG settings) for
everyone who has chimed in on the list so far.  I'd prefer trusting
LANG, but in the absence of any users that prefer non-UTF-8 encodings
I'm fine with this approach.

While we could achieve the same effect on the output content by
dropping the previous patch (nmbug-status: Encode output using the
user's locale), Tomi also wanted UTF-8 hardcoded as the config-file
encoding [2].  Keeping the output encoding patch and then adding this
to hardcode both the config-file and output encodings at once seems
the easiest route, now that fd29d3f (nmbug-status: Decode Popen output
using the user's locale, 2014-02-10) has landed in master.

[1]: id="877g8z4v4x.fsf@zancas.localnet"
     http://article.gmane.org/gmane.mail.notmuch.general/17202
[2]: id="m2vbwj79lu.fsf@guru.guru-group.fi"
     http://article.gmane.org/gmane.mail.notmuch.general/17209
---
 devel/nmbug/nmbug-status | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index c4532f1..ef7169a 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -13,7 +13,6 @@ import codecs
 import collections
 import datetime
 import email.utils
-import locale
 try:  # Python 3
     from urllib.parse import quote
 except ImportError:  # Python 2
@@ -27,7 +26,7 @@ import subprocess
 import xml.sax.saxutils
 
 
-_ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding()
+_ENCODING = 'UTF-8'
 _PAGES = {}
 
 
-- 
1.8.5.2.8.g0f6c0d1

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

* Re: [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring
  2014-02-14 16:48 [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
                   ` (3 preceding siblings ...)
  2014-02-14 16:48 ` [PATCH v4 4/4] nmbug-status: Hardcode UTF-8 instead of " W. Trevor King
@ 2014-02-16 23:46 ` David Bremner
  2014-04-05 14:59   ` W. Trevor King
  4 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2014-02-16 23:46 UTC (permalink / raw)
  To: W. Trevor King, notmuch; +Cc: Tomi Ollila

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

> This fixes two rebase-induced typos from v3 [1]:
>
> * Doubled meta-http-equiv entries in the color-threads patch [2].
> * An extra close-paren in the HTML header format arguments [3].
>

pushed the last 4. Actually I've been running them in production for a
few days already.

d

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

* Re: [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring
  2014-02-16 23:46 ` [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring David Bremner
@ 2014-04-05 14:59   ` W. Trevor King
  2014-04-05 15:46     ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: W. Trevor King @ 2014-04-05 14:59 UTC (permalink / raw)
  To: David Bremner; +Cc: Tomi Ollila, notmuch

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]

On Sun, Feb 16, 2014 at 07:46:29PM -0400, David Bremner wrote:
> pushed the last 4.

It looks like there's still a nmbug-status branch on
git://notmuchmail.org/git/notmuch.  It's an ancestor of debian/0.17-4,
and nmbug-status development seems to have calmed back down, so that
branch can probably be removed.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring
  2014-04-05 14:59   ` W. Trevor King
@ 2014-04-05 15:46     ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2014-04-05 15:46 UTC (permalink / raw)
  To: W. Trevor King; +Cc: Tomi Ollila, notmuch

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

> On Sun, Feb 16, 2014 at 07:46:29PM -0400, David Bremner wrote:
>> pushed the last 4.
>
> It looks like there's still a nmbug-status branch on
> git://notmuchmail.org/git/notmuch.  It's an ancestor of debian/0.17-4,
> and nmbug-status development seems to have calmed back down, so that
> branch can probably be removed.

done.

d

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

end of thread, other threads:[~2014-04-05 15:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 16:48 [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
2014-02-14 16:48 ` [PATCH v4 1/4] nmbug-status: Color threads in HTML output W. Trevor King
2014-02-14 16:48 ` [PATCH v4 2/4] nmbug-status: Add inter-message padding W. Trevor King
2014-02-14 16:48 ` [PATCH v4 3/4] nmbug-status: Encode output using the user's locale W. Trevor King
2014-02-14 16:48 ` [PATCH v4 4/4] nmbug-status: Hardcode UTF-8 instead of " W. Trevor King
2014-02-16 23:46 ` [PATCH v4 0/4] nmbug-status: Python-3-compatibility and general refactoring David Bremner
2014-04-05 14:59   ` W. Trevor King
2014-04-05 15:46     ` 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).