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

login
register
mail settings
Submitter Steven Brown
Date May 16, 2014, 2:47 p.m.
Message ID <8515c010d3452015f92f.1400251633@steve-debian.home>
Download mbox | patch
Permalink /patch/4784/
State Accepted
Commit 16352b34e32e40faab60fef8a0e533759e7a73fe
Headers show

Comments

Steven Brown - May 16, 2014, 2:47 p.m.
# HG changeset patch
# User Steven Brown <StevenGBrown@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.

Patch

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>