Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / c0 / f42f084bd14c239de154ecdeb84c37909bc7d7
1 Return-Path: <wking@tremily.us>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 56615431FC3\r
6         for <notmuch@notmuchmail.org>; Thu, 13 Feb 2014 08:50:51 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: 0\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
13         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001]\r
14         autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id IDLMxb92iHMn for <notmuch@notmuchmail.org>;\r
18         Thu, 13 Feb 2014 08:50:45 -0800 (PST)\r
19 Received: from qmta02.westchester.pa.mail.comcast.net\r
20         (qmta02.westchester.pa.mail.comcast.net [76.96.62.24])\r
21         by olra.theworths.org (Postfix) with ESMTP id 553A9431FB6\r
22         for <notmuch@notmuchmail.org>; Thu, 13 Feb 2014 08:50:45 -0800 (PST)\r
23 Received: from omta22.westchester.pa.mail.comcast.net ([76.96.62.73])\r
24         by qmta02.westchester.pa.mail.comcast.net with comcast\r
25         id Rrur1n0081ap0As51sqlvu; Thu, 13 Feb 2014 16:50:45 +0000\r
26 Received: from odin.tremily.us ([24.18.63.50])\r
27         by omta22.westchester.pa.mail.comcast.net with comcast\r
28         id Rsok1n005152l3L3isoljD; Thu, 13 Feb 2014 16:48:45 +0000\r
29 Received: from mjolnir.tremily.us (unknown [192.168.0.140])\r
30         by odin.tremily.us (Postfix) with ESMTPS id 1BC1F102DA02;\r
31         Thu, 13 Feb 2014 08:48:43 -0800 (PST)\r
32 Received: (nullmailer pid 17985 invoked by uid 1000);\r
33         Thu, 13 Feb 2014 16:47:29 -0000\r
34 From: "W. Trevor King" <wking@tremily.us>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v3 2/8] nmbug-status: Slug the title when using it as an id\r
37 Date: Thu, 13 Feb 2014 08:47:17 -0800\r
38 Message-Id:\r
39  <4755c683a14500c996683ef5cf271be3c7f4f9f3.1392309570.git.wking@tremily.us>\r
40 X-Mailer: git-send-email 1.8.5.2.8.g0f6c0d1\r
41 In-Reply-To: <cover.1392309570.git.wking@tremily.us>\r
42 References: <cover.1392309570.git.wking@tremily.us>\r
43 In-Reply-To: <cover.1392309570.git.wking@tremily.us>\r
44 References: <cover.1392309570.git.wking@tremily.us>\r
45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
46         s=q20121106; t=1392310245;\r
47         bh=U4aJhZgQIh74J6bF214XjQxBHvdfqkJPm6GPKWzusQc=;\r
48         h=Received:Received:Received:Received:From:To:Subject:Date:\r
49         Message-Id;\r
50         b=fpTKngdzz2RzRIbH1opy9CLlM+YrWTB/8BtLvZA8UG55+Ovj1NITj2K5oCrKt5iJ0\r
51         25BxmIppmmonfwr048MT1/sMNFczyJL5xdO2ybCKrNo0GlFIXKQhL/uXB4llsjgrVw\r
52         dIxuNNmg68Dtd9GG3u0s1g2Y5IzbPPOeo4x1aAjPOaWxYlgm5Jjpu2tLHPsKvphFGo\r
53         IAs8s6JIEqBSGwCn7mpjB0Gc1IDbE22YQL8C+v13hNbdkQU1T6sA+cmqQE7i4xCt6b\r
54         k+L4O8ZrGdZlPNomd0h3Q8JDDHZNW/76n/kAbUZhIUqkSPIr2OmwStnE9eGaT1qXiD\r
55         dc/LHROC+aOhA==\r
56 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Thu, 13 Feb 2014 16:50:51 -0000\r
70 \r
71 Also allow manual id overrides from the JSON config.  Sluggin avoids\r
72 errors like:\r
73 \r
74    Bad value '#Possible bugs' for attribute href on element a:\r
75    Whitespace in fragment component. Use %20 in place of spaces.\r
76 \r
77 from http://validator.w3.org.\r
78 \r
79 I tried just quoting the titles (e.g. 'Possible%20bugs'), but that\r
80 didn't work (at least with Firefox 24.2.0).  Slugging avoids any\r
81 ambiguity over when the quotes are expanded in the client.  The specs\r
82 are unclear about quoting, saying only [1]:\r
83 \r
84   Value: Any string, with the following restrictions:\r
85 \r
86     must be at least one character long\r
87     must not contain any space characters\r
88 \r
89 [1]: http://dev.w3.org/html5/markup/global-attributes.html#common.attrs.id\r
90 ---\r
91  devel/nmbug/nmbug-status | 12 ++++++++++--\r
92  1 file changed, 10 insertions(+), 2 deletions(-)\r
93 \r
94 diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status\r
95 index 40e6896..9fde20e 100755\r
96 --- a/devel/nmbug/nmbug-status\r
97 +++ b/devel/nmbug/nmbug-status\r
98 @@ -21,6 +21,7 @@ except ImportError:  # Python 2\r
99  import json\r
100  import argparse\r
101  import os\r
102 +import re\r
103  import sys\r
104  import subprocess\r
105  \r
106 @@ -168,16 +169,20 @@ class Page (object):\r
107  \r
108  \r
109  class HtmlPage (Page):\r
110 +    _slug_regexp = re.compile('\W+')\r
111 +\r
112      def _write_header(self, views, stream):\r
113          super(HtmlPage, self)._write_header(views=views, stream=stream)\r
114          stream.write('<ul>\n')\r
115          for view in views:\r
116 +            if 'id' not in view:\r
117 +                view['id'] = self._slug(view['title'])\r
118              stream.write(\r
119 -                '<li><a href="#{title}">{title}</a></li>\n'.format(**view))\r
120 +                '<li><a href="#{id}">{title}</a></li>\n'.format(**view))\r
121          stream.write('</ul>\n')\r
122  \r
123      def _write_view_header(self, view, stream):\r
124 -        stream.write('<h3 id="{title}">{title}</h3>\n'.format(**view))\r
125 +        stream.write('<h3 id="{id}">{title}</h3>\n'.format(**view))\r
126          if 'comment' in view:\r
127              stream.write(view['comment'])\r
128              stream.write('\n')\r
129 @@ -224,6 +229,9 @@ class HtmlPage (Page):\r
130                  ).format(**d)\r
131          return (running_data, display_data)\r
132  \r
133 +    def _slug(self, string):\r
134 +        return self._slug_regexp.sub('-', string)\r
135 +\r
136  \r
137  _PAGES['text'] = Page()\r
138  _PAGES['html'] = HtmlPage(\r
139 -- \r
140 1.8.5.2.8.g0f6c0d1\r
141 \r