* [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring
@ 2014-02-13 16:47 W. Trevor King
2014-02-13 16:47 ` [PATCH v3 1/8] nmbug-status: Anchor with h3 ids instead of a names W. Trevor King
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
The only changes since v2 [1] are related to our discussion of
locale-based encodings vs. hardcoded UTF-8 [2,3,and descendants].
This iteration addresses those concerns by rebasing the controversial
commit (nmbug-status: Encode output using the user's locale) to the
end of the series. In order to address Tomi's hardcoded config
encoding request [4,5] now that fd29d3f (nmbug-status: Decode Popen
output using the user's locale, 2014-02-10) has landed in master, I
think we should keep the output locale patch (7/8 in v3) and add an
additional patch to hardcode _ENCODING (8/8 in v3). The commit
message for 8/8 was tricky, but I think the current wording expresses
both the motivation for the hardcoded UTF-8, my acceptance of a
hardcoded UTF-8, and my personal preference for respecting LANG ;).
Suggestions for alternative wordings are welcome, especially since I
try to explain both David and Tomi's perspectives :p.
Cheers,
Trevor
[1]: id:"cover.1392056624.git.wking@tremily.us"
http://thread.gmane.org/gmane.mail.notmuch.general/17167
[2]: id:"87eh396e6e.fsf@zancas.localnet"
http://thread.gmane.org/gmane.mail.notmuch.general/17167/focus=17190
[3]: id:"87a9dv52h4.fsf@zancas.localnet"
http://thread.gmane.org/gmane.mail.notmuch.general/17167/focus=17200
[4]: id:"m2sirpu46i.fsf@guru.guru-group.fi"
http://article.gmane.org/gmane.mail.notmuch.general/17191
[5]: id:"m2vbwj79lu.fsf@guru.guru-group.fi"
http://article.gmane.org/gmane.mail.notmuch.general/17209
W. Trevor King (8):
nmbug-status: Anchor with h3 ids instead of a names
nmbug-status: Slug the title when using it as an id
nmbug-status: Use <code> and <p> markup where appropriate
nmbug-status: Color threads in HTML output
nmbug-status: Escape &, <, and > in HTML display data
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 | 96 ++++++++++++++++++++++++++++++++++++++----------
1 file changed, 76 insertions(+), 20 deletions(-)
--
1.8.5.2.8.g0f6c0d1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 1/8] nmbug-status: Anchor with h3 ids instead of a names
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 2/8] nmbug-status: Slug the title when using it as an id W. Trevor King
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
HTML 5 allows id attributes on all HTML elements [1], but restricts
names to particular cases [2]. Attaching the id attribute to the h3
element allows us to drop the anchor a element altogether.
[1]: http://www.w3.org/TR/html5/dom.html#the-id-attribute
[2]: http://www.w3.org/TR/html5/index.html#attributes-1
---
devel/nmbug/nmbug-status | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 873a46a..40e6896 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -177,7 +177,7 @@ class HtmlPage (Page):
stream.write('</ul>\n')
def _write_view_header(self, view, stream):
- stream.write('<h3><a name="{title}" />{title}</h3>\n'.format(**view))
+ stream.write('<h3 id="{title}">{title}</h3>\n'.format(**view))
if 'comment' in view:
stream.write(view['comment'])
stream.write('\n')
--
1.8.5.2.8.g0f6c0d1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 2/8] nmbug-status: Slug the title when using it as an id
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
2014-02-13 16:47 ` [PATCH v3 1/8] nmbug-status: Anchor with h3 ids instead of a names W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 3/8] nmbug-status: Use <code> and <p> markup where appropriate W. Trevor King
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
Also allow manual id overrides from the JSON config. Sluggin avoids
errors like:
Bad value '#Possible bugs' for attribute href on element a:
Whitespace in fragment component. Use %20 in place of spaces.
from http://validator.w3.org.
I tried just quoting the titles (e.g. 'Possible%20bugs'), but that
didn't work (at least with Firefox 24.2.0). Slugging avoids any
ambiguity over when the quotes are expanded in the client. The specs
are unclear about quoting, saying only [1]:
Value: Any string, with the following restrictions:
must be at least one character long
must not contain any space characters
[1]: http://dev.w3.org/html5/markup/global-attributes.html#common.attrs.id
---
devel/nmbug/nmbug-status | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 40e6896..9fde20e 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -21,6 +21,7 @@ except ImportError: # Python 2
import json
import argparse
import os
+import re
import sys
import subprocess
@@ -168,16 +169,20 @@ class Page (object):
class HtmlPage (Page):
+ _slug_regexp = re.compile('\W+')
+
def _write_header(self, views, stream):
super(HtmlPage, self)._write_header(views=views, stream=stream)
stream.write('<ul>\n')
for view in views:
+ if 'id' not in view:
+ view['id'] = self._slug(view['title'])
stream.write(
- '<li><a href="#{title}">{title}</a></li>\n'.format(**view))
+ '<li><a href="#{id}">{title}</a></li>\n'.format(**view))
stream.write('</ul>\n')
def _write_view_header(self, view, stream):
- stream.write('<h3 id="{title}">{title}</h3>\n'.format(**view))
+ stream.write('<h3 id="{id}">{title}</h3>\n'.format(**view))
if 'comment' in view:
stream.write(view['comment'])
stream.write('\n')
@@ -224,6 +229,9 @@ class HtmlPage (Page):
).format(**d)
return (running_data, display_data)
+ def _slug(self, string):
+ return self._slug_regexp.sub('-', string)
+
_PAGES['text'] = Page()
_PAGES['html'] = HtmlPage(
--
1.8.5.2.8.g0f6c0d1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 3/8] nmbug-status: Use <code> and <p> markup where appropriate
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
2014-02-13 16:47 ` [PATCH v3 1/8] nmbug-status: Anchor with h3 ids instead of a names W. Trevor King
2014-02-13 16:47 ` [PATCH v3 2/8] nmbug-status: Slug the title when using it as an id W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 4/8] nmbug-status: Color threads in HTML output W. Trevor King
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
* Wrap free text in <p> tags.
* Convert <blockquote> to <p><code> for query strings.
* Wrap message-id-term (id:"...") in <code>.
The <code> tags get nicer default markup (smaller monospace font) for
notmuch query terms [1]. The <p> tags don't have much effect without
attached CSS, but bare text (phrasing content [2]) in <body> (which
expects flow content [3,4]) feels wrong.
[1]: http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element
[2]: http://www.w3.org/TR/html5/dom.html#phrasing-content-1
[3]: http://www.w3.org/TR/html5/dom.html#flow-content-1
[4]: http://www.w3.org/TR/html5/sections.html#the-body-element
---
devel/nmbug/nmbug-status | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 9fde20e..6a156af 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -183,14 +183,18 @@ class HtmlPage (Page):
def _write_view_header(self, view, stream):
stream.write('<h3 id="{id}">{title}</h3>\n'.format(**view))
+ stream.write('<p>\n')
if 'comment' in view:
stream.write(view['comment'])
stream.write('\n')
for line in [
'The view is generated from the following query:',
- '<blockquote>',
+ '</p>',
+ '<p>',
+ ' <code>',
view['query-string'],
- '</blockquote>',
+ ' </code>',
+ '</p>',
]:
stream.write(line)
stream.write('\n')
@@ -204,7 +208,7 @@ class HtmlPage (Page):
stream.write((
'<tr>\n'
' <td>{date}</td>\n'
- ' <td>{message-id-term}</td>\n'
+ ' <td><code>{message-id-term}</code></td>\n'
'</tr>\n'
'<tr>\n'
' <td>{from}</td>\n'
@@ -243,8 +247,10 @@ _PAGES['html'] = HtmlPage(
</head>
<body>
<h2>Notmuch Patches</h2>
+<p>
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()),
footer='</body>\n</html>\n',
--
1.8.5.2.8.g0f6c0d1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 4/8] nmbug-status: Color threads in HTML output
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
` (2 preceding siblings ...)
2014-02-13 16:47 ` [PATCH v3 3/8] nmbug-status: Use <code> and <p> markup where appropriate W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-14 1:58 ` David Bremner
2014-02-13 16:47 ` [PATCH v3 5/8] nmbug-status: Escape &, <, and > in HTML display data W. Trevor King
` (4 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 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 | 56 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 44 insertions(+), 12 deletions(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 6a156af..92552a4 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -204,19 +204,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):
@@ -242,8 +245,36 @@ _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" />
+ <meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
+ <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>
@@ -252,7 +283,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] 16+ messages in thread
* [PATCH v3 5/8] nmbug-status: Escape &, <, and > in HTML display data
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
` (3 preceding siblings ...)
2014-02-13 16:47 ` [PATCH v3 4/8] nmbug-status: Color threads in HTML output W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 6/8] nmbug-status: Add inter-message padding W. Trevor King
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
'message-id' and 'from' now have sensitive characters escaped using
xml.sax.saxutils.escape [1]. The 'subject' data was already being
converted to a link into Gmane; I've escape()d that too, so it doesn't
need to be handled ain the same block as 'message-id' and 'from'.
This prevents broken HTML by if subjects etc. contain characters that
would otherwise be interpreted as HTML markup.
[1]: http://docs.python.org/3/library/xml.sax.utils.html#xml.sax.saxutils.escape
---
devel/nmbug/nmbug-status | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 92552a4..57eec6c 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -24,6 +24,7 @@ import os
import re
import sys
import subprocess
+import xml.sax.saxutils
_ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding()
@@ -229,11 +230,14 @@ class HtmlPage (Page):
if 'subject' in display_data and 'message-id' in display_data:
d = {
'message-id': quote(display_data['message-id']),
- 'subject': display_data['subject'],
+ 'subject': xml.sax.saxutils.escape(display_data['subject']),
}
display_data['subject'] = (
'<a href="http://mid.gmane.org/{message-id}">{subject}</a>'
).format(**d)
+ for key in ['message-id', 'from']:
+ if key in display_data:
+ display_data[key] = xml.sax.saxutils.escape(display_data[key])
return (running_data, display_data)
def _slug(self, string):
--
1.8.5.2.8.g0f6c0d1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 6/8] nmbug-status: Add inter-message padding
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
` (4 preceding siblings ...)
2014-02-13 16:47 ` [PATCH v3 5/8] nmbug-status: Escape &, <, and > in HTML display data W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-14 2:13 ` David Bremner
2014-02-13 16:47 ` [PATCH v3 7/8] nmbug-status: Encode output using the user's locale W. Trevor King
` (2 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 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 57eec6c..9ad7d35 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'
@@ -256,6 +256,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};
@@ -288,6 +294,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] 16+ messages in thread
* [PATCH v3 7/8] nmbug-status: Encode output using the user's locale
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
` (5 preceding siblings ...)
2014-02-13 16:47 ` [PATCH v3 6/8] nmbug-status: Add inter-message padding W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-13 17:42 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 8/8] nmbug-status: Hardcode UTF-8 instead of " W. Trevor King
2014-02-13 17:14 ` [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring Tomi Ollila
8 siblings, 1 reply; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 9ad7d35..8cc097a 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,6 @@ _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">
@@ -294,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] 16+ messages in thread
* [PATCH v3 8/8] nmbug-status: Hardcode UTF-8 instead of using the user's locale
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
` (6 preceding siblings ...)
2014-02-13 16:47 ` [PATCH v3 7/8] nmbug-status: Encode output using the user's locale W. Trevor King
@ 2014-02-13 16:47 ` W. Trevor King
2014-02-13 17:14 ` [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring Tomi Ollila
8 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 16:47 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 8cc097a..beb2af5 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] 16+ messages in thread
* Re: [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
` (7 preceding siblings ...)
2014-02-13 16:47 ` [PATCH v3 8/8] nmbug-status: Hardcode UTF-8 instead of " W. Trevor King
@ 2014-02-13 17:14 ` Tomi Ollila
8 siblings, 0 replies; 16+ messages in thread
From: Tomi Ollila @ 2014-02-13 17:14 UTC (permalink / raw)
To: W. Trevor King, notmuch
On Thu, Feb 13 2014, "W. Trevor King" <wking@tremily.us> wrote:
> The only changes since v2 [1] are related to our discussion of
> locale-based encodings vs. hardcoded UTF-8 [2,3,and descendants].
> This iteration addresses those concerns by rebasing the controversial
> commit (nmbug-status: Encode output using the user's locale) to the
> end of the series. In order to address Tomi's hardcoded config
> encoding request [4,5] now that fd29d3f (nmbug-status: Decode Popen
> output using the user's locale, 2014-02-10) has landed in master, I
> think we should keep the output locale patch (7/8 in v3) and add an
> additional patch to hardcode _ENCODING (8/8 in v3). The commit
> message for 8/8 was tricky, but I think the current wording expresses
> both the motivation for the hardcoded UTF-8, my acceptance of a
> hardcoded UTF-8, and my personal preference for respecting LANG ;).
> Suggestions for alternative wordings are welcome, especially since I
> try to explain both David and Tomi's perspectives :p.
Good stuff -- I did not have chance to test these yet...
> Cheers,
> Trevor
Tomi
>
> [1]: id:"cover.1392056624.git.wking@tremily.us"
> http://thread.gmane.org/gmane.mail.notmuch.general/17167
> [2]: id:"87eh396e6e.fsf@zancas.localnet"
> http://thread.gmane.org/gmane.mail.notmuch.general/17167/focus=17190
> [3]: id:"87a9dv52h4.fsf@zancas.localnet"
> http://thread.gmane.org/gmane.mail.notmuch.general/17167/focus=17200
> [4]: id:"m2sirpu46i.fsf@guru.guru-group.fi"
> http://article.gmane.org/gmane.mail.notmuch.general/17191
> [5]: id:"m2vbwj79lu.fsf@guru.guru-group.fi"
> http://article.gmane.org/gmane.mail.notmuch.general/17209
>
> W. Trevor King (8):
> nmbug-status: Anchor with h3 ids instead of a names
> nmbug-status: Slug the title when using it as an id
> nmbug-status: Use <code> and <p> markup where appropriate
> nmbug-status: Color threads in HTML output
> nmbug-status: Escape &, <, and > in HTML display data
> 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 | 96 ++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 76 insertions(+), 20 deletions(-)
>
> --
> 1.8.5.2.8.g0f6c0d1
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 7/8] nmbug-status: Encode output using the user's locale
2014-02-13 16:47 ` [PATCH v3 7/8] nmbug-status: Encode output using the user's locale W. Trevor King
@ 2014-02-13 17:42 ` W. Trevor King
0 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-13 17:42 UTC (permalink / raw)
To: notmuch; +Cc: Tomi Ollila
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
On Thu, Feb 13, 2014 at 08:47:22AM -0800, W. Trevor King wrote:
> '''.format(date=datetime.datetime.utcnow().date(),
> + encoding=_ENCODING),
> inter_message_padding='0.25em',
> border_radius='0.5em'),
Oops, that should be:
encoding=_ENCODING,
not:
encoding=_ENCODING),
I can resubmit v4 or send a fixup patch, but feel free to squash this
in locally. My revised branch is still available at:
git://tremily.us/notmuch.git nmbug-status-python3
if you'd rather just pull the fixup directly (they end with commit
f994568).
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] 16+ messages in thread
* Re: [PATCH v3 4/8] nmbug-status: Color threads in HTML output
2014-02-13 16:47 ` [PATCH v3 4/8] nmbug-status: Color threads in HTML output W. Trevor King
@ 2014-02-14 1:58 ` David Bremner
2014-02-14 2:05 ` W. Trevor King
0 siblings, 1 reply; 16+ messages in thread
From: David Bremner @ 2014-02-14 1:58 UTC (permalink / raw)
To: W. Trevor King, notmuch; +Cc: Tomi Ollila
"W. Trevor King" <wking@tremily.us> writes:
> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> + <meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
looks like a bad rebase there.
d
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 4/8] nmbug-status: Color threads in HTML output
2014-02-14 1:58 ` David Bremner
@ 2014-02-14 2:05 ` W. Trevor King
0 siblings, 0 replies; 16+ messages in thread
From: W. Trevor King @ 2014-02-14 2:05 UTC (permalink / raw)
To: David Bremner; +Cc: Tomi Ollila, notmuch
[-- Attachment #1: Type: text/plain, Size: 513 bytes --]
On Thu, Feb 13, 2014 at 09:58:43PM -0400, David Bremner wrote:
> W. Trevor King writes:
> > + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> > + <meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
>
> looks like a bad rebase there.
Oops. Fixed in my branch and queued for v4.
Thanks,
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] 16+ messages in thread
* Re: [PATCH v3 6/8] nmbug-status: Add inter-message padding
2014-02-13 16:47 ` [PATCH v3 6/8] nmbug-status: Add inter-message padding W. Trevor King
@ 2014-02-14 2:13 ` David Bremner
2014-02-14 4:07 ` W. Trevor King
0 siblings, 1 reply; 16+ messages in thread
From: David Bremner @ 2014-02-14 2:13 UTC (permalink / raw)
To: W. Trevor King, notmuch; +Cc: Tomi Ollila
"W. Trevor King" <wking@tremily.us> writes:
> 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.
I tested patches 1-6, but my fix for patch 4 broke patch 7.
So maybe it's best if you regenerate the series. The concept of the last
two patches seems OK.
d
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 6/8] nmbug-status: Add inter-message padding
2014-02-14 2:13 ` David Bremner
@ 2014-02-14 4:07 ` W. Trevor King
2014-02-14 12:40 ` David Bremner
0 siblings, 1 reply; 16+ messages in thread
From: W. Trevor King @ 2014-02-14 4:07 UTC (permalink / raw)
To: David Bremner; +Cc: Tomi Ollila, notmuch
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
On Thu, Feb 13, 2014 at 10:13:42PM -0400, David Bremner wrote:
> I tested patches 1-6, but my fix for patch 4 broke patch 7.
>
> So maybe it's best if you regenerate the series. The concept of the last
> two patches seems OK.
Sure. Sorry I botched v3 :/. Do you want to nibble off patches one
through three (and maybe five, which applies cleanly on top of three)
first, or should I include them in v4?
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] 16+ messages in thread
* Re: [PATCH v3 6/8] nmbug-status: Add inter-message padding
2014-02-14 4:07 ` W. Trevor King
@ 2014-02-14 12:40 ` David Bremner
0 siblings, 0 replies; 16+ messages in thread
From: David Bremner @ 2014-02-14 12:40 UTC (permalink / raw)
To: W. Trevor King; +Cc: Tomi Ollila, notmuch
"W. Trevor King" <wking@tremily.us> writes:
>
> Sure. Sorry I botched v3 :/. Do you want to nibble off patches one
> through three (and maybe five, which applies cleanly on top of three)
> first, or should I include them in v4?
>
OK, those 4 patches are pushed.
d
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-02-14 12:40 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13 16:47 [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring W. Trevor King
2014-02-13 16:47 ` [PATCH v3 1/8] nmbug-status: Anchor with h3 ids instead of a names W. Trevor King
2014-02-13 16:47 ` [PATCH v3 2/8] nmbug-status: Slug the title when using it as an id W. Trevor King
2014-02-13 16:47 ` [PATCH v3 3/8] nmbug-status: Use <code> and <p> markup where appropriate W. Trevor King
2014-02-13 16:47 ` [PATCH v3 4/8] nmbug-status: Color threads in HTML output W. Trevor King
2014-02-14 1:58 ` David Bremner
2014-02-14 2:05 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 5/8] nmbug-status: Escape &, <, and > in HTML display data W. Trevor King
2014-02-13 16:47 ` [PATCH v3 6/8] nmbug-status: Add inter-message padding W. Trevor King
2014-02-14 2:13 ` David Bremner
2014-02-14 4:07 ` W. Trevor King
2014-02-14 12:40 ` David Bremner
2014-02-13 16:47 ` [PATCH v3 7/8] nmbug-status: Encode output using the user's locale W. Trevor King
2014-02-13 17:42 ` W. Trevor King
2014-02-13 16:47 ` [PATCH v3 8/8] nmbug-status: Hardcode UTF-8 instead of " W. Trevor King
2014-02-13 17:14 ` [PATCH v3 0/8] nmbug-status: Python-3-compatibility and general refactoring Tomi Ollila
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).