diff --git a/tailbone/diffs.py b/tailbone/diffs.py
index f179128f..2771b7da 100644
--- a/tailbone/diffs.py
+++ b/tailbone/diffs.py
@@ -35,11 +35,12 @@ class Diff(object):
Core diff class. In sore need of documentation.
"""
- def __init__(self, old_data, new_data, columns=None, fields=None, render_value=None, monospace=False):
+ def __init__(self, old_data, new_data, columns=None, fields=None, render_field=None, render_value=None, monospace=False):
self.old_data = old_data
self.new_data = new_data
self.columns = columns or ["field name", "old value", "new value"]
self.fields = fields or self.make_fields()
+ self._render_field = render_field or self.render_field_default
self.render_value = render_value or self.render_value_default
self.monospace = monospace
@@ -60,6 +61,12 @@ class Diff(object):
context['diff'] = self
return HTML.literal(render(template, context))
+ def render_field(self, field):
+ return self._render_field(field, self)
+
+ def render_field_default(self, field, diff):
+ return field
+
def render_value_default(self, field, value):
return repr(value)
diff --git a/tailbone/templates/diff.mako b/tailbone/templates/diff.mako
index 7f2132fd..4b8888e6 100644
--- a/tailbone/templates/diff.mako
+++ b/tailbone/templates/diff.mako
@@ -10,7 +10,7 @@
% for field in diff.fields:
- ${field} |
+ ${diff.render_field(field)} |
${diff.render_old_value(field)} |
${diff.render_new_value(field)} |
diff --git a/tailbone/views/upgrades.py b/tailbone/views/upgrades.py
index 60d5d484..c1423678 100644
--- a/tailbone/views/upgrades.py
+++ b/tailbone/views/upgrades.py
@@ -204,6 +204,7 @@ class UpgradeView(MasterView):
after = self.parse_requirements(upgrade, 'after')
diff = self.make_diff(before, after,
columns=["package", "old version", "new version"],
+ render_field=self.render_diff_field,
render_value=self.render_diff_value,
)
showing = HTML.tag('div',
@@ -216,6 +217,21 @@ class UpgradeView(MasterView):
except:
return "(not available for this upgrade)"
+ def render_diff_field(self, field, diff):
+ if field == 'rattail':
+ # TODO: use changelog from latest docs *unless* running from src
+ # url = 'https://rattailproject.org/buildbot/docs/rattail/changelog.html'
+ url = 'https://rattailproject.org/trac/log/rattail/?rev={}&stop_rev={}&limit=100'.format(
+ diff.new_value(field), diff.old_value(field))
+ return tags.link_to(field, url, target='_blank')
+ if field == 'Tailbone':
+ # TODO: use changelog from latest docs *unless* running from src
+ # url = 'https://rattailproject.org/buildbot/docs/tailbone/changelog.html'
+ url = 'https://rattailproject.org/trac/log/tailbone/?rev={}&stop_rev={}&limit=100'.format(
+ diff.new_value(field), diff.old_value(field))
+ return tags.link_to(field, url, target='_blank')
+ return field
+
def render_diff_value(self, field, value):
if value.startswith("u'") and value.endswith("'"):
return value[2:1]