Skip to content

Commit 50fbb32

Browse files
committed
(refs #10)Add repository url field to side menu
1 parent cc7d01d commit 50fbb32

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/main/scala/gitbucket/gist/controller/GistController.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ trait GistControllerBase extends ControllerBase {
204204
}
205205
}
206206
}
207-
html.revisions("revision", getGist(userName, repoName).get, isEditable(userName), commits)
207+
val gist = getGist(userName, repoName).get
208+
html.revisions("revision", gist, repositoryUrl(gist), isEditable(userName), commits)
208209
}
209210
case Left(_) => NotFound
210211
}
@@ -316,14 +317,16 @@ trait GistControllerBase extends ControllerBase {
316317
val files: Seq[(String, String)] = JGitUtil.getFileList(git, revision, ".").map { file =>
317318
file.name -> StringUtil.convertFromByteArray(JGitUtil.getContentFromId(git, file.id, true).get)
318319
}
319-
html.detail("code", gist, revision, files, isEditable(userName))
320+
html.detail("code", gist, repositoryUrl(gist), revision, files, isEditable(userName))
320321
} else Unauthorized
321322
}
322323
} else NotFound
323324
}
324325
}
325326
}
326327

328+
private def repositoryUrl(gist: Gist) = s"${baseUrl}/git/gist/${gist.userName}/${gist.repositoryName}.git"
329+
327330
private def isEditable(userName: String): Boolean = {
328331
context.loginAccount.map { loginAccount =>
329332
loginAccount.isAdmin || loginAccount.userName == userName

src/main/twirl/gitbucket/gist/detail.scala.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@(active: String,
22
gist: gitbucket.gist.model.Gist,
3+
repositoryUrl: String,
34
revision: String,
45
files: Seq[(String, String)],
56
editable: Boolean)(implicit context: gitbucket.core.controller.Context)
@@ -9,7 +10,7 @@
910
@gitbucket.core.html.main(if(gist.description.isEmpty) gist.repositoryName else gist.description){
1011
@gitbucket.gist.html.header(gist, editable)
1112
<div class="container body">
12-
@gitbucket.gist.html.menu(active, gist)
13+
@gitbucket.gist.html.menu(active, gist, repositoryUrl)
1314
<div style="margin-right: 180px;">
1415
<div style="margin-bottom: 10px;">
1516
@gist.description

src/main/twirl/gitbucket/gist/menu.scala.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@(active: String,
2-
gist: gitbucket.gist.model.Gist)(implicit context: gitbucket.core.controller.Context)
2+
gist: gitbucket.gist.model.Gist,
3+
repositoryUrl: String)(implicit context: gitbucket.core.controller.Context)
34
@import context._
5+
@import gitbucket.core.helper
46
@import gitbucket.core.view.helpers._
57
@import gitbucket.core.plugin.Images._
68

@@ -39,19 +41,17 @@
3941
"Revision")
4042
<li style="height: 12px"><div class="gradient pull-left" style="height: 12px"></div></li>
4143
</ul>
42-
@*
4344
<div class="small">
4445
<strong id="repository-url-proto">HTTP</strong> <span class="mute">clone URL</span>
4546
</div>
46-
@helper.html.copy("repository-url-copy", "http://localhost:8080/"){
47-
<input type="text" value="http://localhost:8080/" id="repository-url" readonly>
47+
@helper.html.copy("repository-url-copy", repositoryUrl){
48+
<input type="text" value="@repositoryUrl" id="repository-url" readonly>
4849
}
4950
@if(settings.ssh && loginAccount.isDefined){
5051
<div class="small">
5152
<span class="mute">You can clone <a href="javascript:void(0);" id="repository-url-http">HTTP</a> or <a href="javascript:void(0);" id="repository-url-ssh">SSH</a>.</span>
5253
</div>
5354
}
54-
*@
5555
<div style="margin-top: 10px;">
5656
<a href="@path/gist/@{gist.userName}/@{gist.repositoryName}/download/@{gist.repositoryName}.zip"
5757
class="btn btn-small" style="width: 147px;"><i class="icon-download-alt"></i>Download ZIP</a>

src/main/twirl/gitbucket/gist/revisions.scala.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@(active: String,
2-
gist: gitbucket.gist.model.Gist, editable: Boolean,
2+
gist: gitbucket.gist.model.Gist,
3+
repositoryUrl: String,
4+
editable: Boolean,
35
revisions: List[(gitbucket.core.util.JGitUtil.CommitInfo, List[gitbucket.core.util.JGitUtil.DiffInfo])])(implicit context: gitbucket.core.controller.Context)
46
@import context._
57
@import gitbucket.core.helper.html._
@@ -8,7 +10,7 @@
810
@gitbucket.core.html.main(s"Revisions · ${gist.repositoryName}"){
911
@gitbucket.gist.html.header(gist, editable)
1012
<div class="container body">
11-
@gitbucket.gist.html.menu(active, gist)
13+
@gitbucket.gist.html.menu(active, gist, repositoryUrl)
1214
<div style="margin-right: 180px;">
1315
@revisions.map { case (revision, diffs) =>
1416
<div>

0 commit comments

Comments
 (0)