From e9e878093f895aedaf1982f94f0f75f0fd113d77 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 24 Sep 2018 19:34:51 -1000 Subject: Link to git blob files with extensions --- lib/serve.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/serve.js b/lib/serve.js index 259a697..951daea 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -2325,12 +2325,20 @@ Serve.prototype.gitDiff = function (revs) { var msg1Date = new Date(msg1.value.timestamp) var msg2Date = new Date(msg2.value.timestamp) var revsShort = rev1.substr(0, 8) + '..' + rev2.substr(0, 8) + var path = self.query.path && String(self.query.path) + var ext = path && path.replace(/^[^.\/]*/, '') + var blob1Url = '/git/blob/' + rev1 + + '?msg=' + encodeURIComponent(msg1.key) + + (ext ? '&ext=' + encodeURIComponent(ext) : '') + var blob2Url = '/git/blob/' + rev2 + + '?msg=' + encodeURIComponent(msg2.key) + + (ext ? '&ext=' + encodeURIComponent(ext) : '') pull( ph('section', [ ph('h3', ph('a', {href: ''}, revsShort)), ph('div', [ ph('a', { - href: self.app.render.toUrl('/git/blob/' + rev1 + '?msg=' + encodeURIComponent(msg1.key)) + href: self.app.render.toUrl(blob1Url) }, rev1), ' ', self.phIdLink(msg1.value.author), ' ', ph('a', { @@ -2340,7 +2348,7 @@ Serve.prototype.gitDiff = function (revs) { ]), ph('div', [ ph('a', { - href: self.app.render.toUrl('/git/blob/' + rev2 + '?msg=' + encodeURIComponent(msg2.key)) + href: self.app.render.toUrl(blob2Url) }, rev2), ' ', self.phIdLink(msg2.value.author), ' ', ph('a', { -- cgit v1.2.3