From a93f4cc78014df9a9bc38e10e56faba5fda700c7 Mon Sep 17 00:00:00 2001 From: KOUNOIKE Yuusuke Date: Tue, 12 Sep 2017 11:24:13 +0900 Subject: [PATCH] Transfer to URL with commit ID when select line(s). --- src/main/twirl/gitbucket/core/repo/blob.scala.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/twirl/gitbucket/core/repo/blob.scala.html b/src/main/twirl/gitbucket/core/repo/blob.scala.html index 92d361259..c7a057e2c 100644 --- a/src/main/twirl/gitbucket/core/repo/blob.scala.html +++ b/src/main/twirl/gitbucket/core/repo/blob.scala.html @@ -29,6 +29,7 @@ Older +
@gitbucket.core.helper.html.branchcontrol( branch, repository, @@ -38,6 +39,7 @@
  • @gitbucket.core.helper.html.checkicon(x == branch) @x
  • } } +
    @repository.name / @pathList.zipWithIndex.map { case (section, i) => @if(i == pathList.length - 1){ @@ -130,14 +132,18 @@ $(window).load(function(){ } var line = pos[i].id.replace(/^L/,''); var hash = location.hash; + var commitUrl = '@helpers.url(repository)/blob/@latestCommit.id/@pathList.mkString("/")'; if(e.shiftKey == true && hash.match(/#L\d+(-L\d+)?/)){ var lines = hash.split('-'); - location.hash = lines[0] + '-L' + line; + window.history.pushState('', '', commitUrl + lines[0] + '-L' + line); } else { var p = $("#L"+line).attr('id',""); - location.hash = '#L' + line; + window.history.pushState('', '', commitUrl + '#L' + line); p.attr('id','L'+line); } + $("#branchCtrlWrapper .btn .muted").text("tree:"); + $("#branchCtrlWrapper .btn .strong").text("@latestCommit.id.substring(0, 10)"); + updateHighlighting(); }).appendTo(pre); } }