[PATCH 2 of 4 v2] hgweb: apply websub filter to the changeset description in rss and atom feeds

Steven Brown stevengbrown at gmail.com
Fri May 16 09:47:13 CDT 2014


# HG changeset patch
# User Steven Brown <StevenGBrown at gmail.com>
# Date 1400245360 -28800
#      Fri May 16 21:02:40 2014 +0800
# Node ID 8515c010d3452015f92fd37693fd53be93eeb849
# Parent  79b7a531cefa9cfab4c377821a2d9fcfae9821bf
hgweb: apply websub filter to the changeset description in rss and atom feeds

For example, this is useful for linking from the feed reader to a bug tracker.

This follows the existing pattern used within the hgweb templates. All usages
of the "desc" keyword are now followed by either the "firstline" filter or the
"websub" filter. When "websub" is used, it always follows the "escape" filter.

diff --git a/mercurial/templates/atom/changelogentry.tmpl b/mercurial/templates/atom/changelogentry.tmpl
--- a/mercurial/templates/atom/changelogentry.tmpl
+++ b/mercurial/templates/atom/changelogentry.tmpl
@@ -32,7 +32,7 @@
 	</tr>
 	<tr>
 		<th style="text-align:left;vertical-align:top;">description</th>
-		<td>{desc|strip|escape|addbreaks|nonempty}</td>
+		<td>{desc|strip|escape|websub|addbreaks|nonempty}</td>
 	</tr>
 	<tr>
 		<th style="text-align:left;vertical-align:top;">files</th>
diff --git a/mercurial/templates/rss/changelogentry.tmpl b/mercurial/templates/rss/changelogentry.tmpl
--- a/mercurial/templates/rss/changelogentry.tmpl
+++ b/mercurial/templates/rss/changelogentry.tmpl
@@ -27,7 +27,7 @@
 	</tr>
 	<tr>
 		<th style="text-align:left;vertical-align:top;">description</th>
-		<td>{desc|strip|escape|addbreaks|nonempty}</td>
+		<td>{desc|strip|escape|websub|addbreaks|nonempty}</td>
 	</tr>
 	<tr>
 		<th style="text-align:left;vertical-align:top;">files</th>
diff --git a/mercurial/templates/rss/filelogentry.tmpl b/mercurial/templates/rss/filelogentry.tmpl
--- a/mercurial/templates/rss/filelogentry.tmpl
+++ b/mercurial/templates/rss/filelogentry.tmpl
@@ -1,7 +1,7 @@
 <item>
     <title>{desc|strip|firstline|strip|escape}</title>
     <link>{urlbase}{url|urlescape}log{node|short}/{file|urlescape}</link>
-    <description><![CDATA[{desc|strip|escape|addbreaks|nonempty}]]></description>
+    <description><![CDATA[{desc|strip|escape|websub|addbreaks|nonempty}]]></description>
     <author>{author|obfuscate}</author>
     <pubDate>{date|rfc822date}</pubDate>
 </item>
diff --git a/tests/test-hgweb-feeds.t b/tests/test-hgweb-feeds.t
--- a/tests/test-hgweb-feeds.t
+++ b/tests/test-hgweb-feeds.t
@@ -3,6 +3,11 @@
   $ hg init test
   $ cd test
 
+  $ cat > .hg/hgrc <<EOF
+  > [websub]
+  > issues = s|Issue(\d+)|<a href="http://bts.example.org/issue\1">Issue\1</a>|
+  > EOF
+
   $ touch foo
   $ hg add foo
   $ hg commit -d '1 0' -m 'Issue123: fixed the bug!'
@@ -103,7 +108,7 @@
   	</tr>
   	<tr>
   		<th style="text-align:left;vertical-align:top;">description</th>
-  		<td>Issue123: fixed the bug!</td>
+  		<td><a href="http://bts.example.org/issue123">Issue123</a>: fixed the bug!</td>
   	</tr>
   	<tr>
   		<th style="text-align:left;vertical-align:top;">files</th>
@@ -199,7 +204,7 @@
   	</tr>
   	<tr>
   		<th style="text-align:left;vertical-align:top;">description</th>
-  		<td>Issue123: fixed the bug!</td>
+  		<td><a href="http://bts.example.org/issue123">Issue123</a>: fixed the bug!</td>
   	</tr>
   	<tr>
   		<th style="text-align:left;vertical-align:top;">files</th>


More information about the Mercurial-devel mailing list