[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[snapshot/master] Link bug numbers to the BTS



In removal logs, link #nnn tokens to the bug report on bugs.debian.org.

Based on work by Gerfried Fuchs <rhonda>.
---
 web/app/snapshot/lib/helpers.py                  |   37 ++++++++++++++++++++-
 web/app/snapshot/templates/removal-list-one.mako |    2 +-
 web/app/snapshot/templates/removal-list.mako     |    2 +-
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/web/app/snapshot/lib/helpers.py b/web/app/snapshot/lib/helpers.py
index 878b888..5550273 100644
--- a/web/app/snapshot/lib/helpers.py
+++ b/web/app/snapshot/lib/helpers.py
@@ -1,7 +1,40 @@
+## snapshot.debian.org - web frontend
+#
+# Copyright (c) 2010, 2011 Peter Palfrader
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
 """Helper functions
 
 Consists of functions to typically be used within templates, but also
 available to Controllers. This module is available to templates as 'h'.
 """
-# Import helpers as desired, or define your own, ie:
-#from webhelpers.html.tags import checkbox, password
+
+from webhelpers.html import escape, literal
+import re
+
+def debian_bugs_markup(s):
+       r = s
+       r = str(escape(r))
+       r = re.sub('#([0-9]+)', '<a href="http://bugs.debian.org/\\1";>#\\1</a>', r)
+       return literal(r)
+
+# vim:set et:
+# vim:set ts=4:
+# vim:set shiftwidth=4:
diff --git a/web/app/snapshot/templates/removal-list-one.mako b/web/app/snapshot/templates/removal-list-one.mako
index bba9c3e..1eac65c 100644
--- a/web/app/snapshot/templates/removal-list-one.mako
+++ b/web/app/snapshot/templates/removal-list-one.mako
@@ -3,7 +3,7 @@
 <h1>Removal log #${c.removal['removal_log_id']}</h1>
 
 <p style="font-size: small">${c.removal['entry_added']}</p>
-<pre>${c.removal['reason']}</pre>
+<pre>${h.debian_bugs_markup(c.removal['reason'])}</pre>
 
 <h1>Affected files</h1>
 
diff --git a/web/app/snapshot/templates/removal-list.mako b/web/app/snapshot/templates/removal-list.mako
index 8b55d75..3d577d3 100644
--- a/web/app/snapshot/templates/removal-list.mako
+++ b/web/app/snapshot/templates/removal-list.mako
@@ -6,7 +6,7 @@
 %for e in c.removals:
 	<dt style="font-size: small">${e['entry_added']}</dt>
 	<dd>
-		<pre>${e['reason']}</pre>
+		<pre>${h.debian_bugs_markup(e['reason'])}</pre>
 		<p style="font-size: x-small">[<a href="${e['removal_log_id']}">affected files]</a></p>
 	</dd>
 %endfor
-- 
1.7.2.3


Reply to: