Skip to content

Commit e895df8

Browse files
authored
Support GitBucket 4.37.x (#68)
1 parent 9a81964 commit e895df8

File tree

7 files changed

+23
-19
lines changed

7 files changed

+23
-19
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This is a GitBucket plug-in which provides code snippet repository like Gist.
44

55
Plugin version | GitBucket version
66
:--------------|:--------------------
7+
4.22.x | 4.37.x -
78
4.21.x | 4.36.x -
89
4.20.x | 4.35.x -
910
4.19.x | 4.34.x -

build.sbt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
organization := "io.github.gitbucket"
22
name := "gitbucket-gist-plugin"
3-
version := "4.21.0"
4-
scalaVersion := "2.13.5"
5-
gitbucketVersion := "4.36.0"
3+
version := "4.22.0"
4+
scalaVersion := "2.13.7"
5+
gitbucketVersion := "4.37.0"
66

77
scalacOptions := Seq("-deprecation", "-feature", "-language:postfixOps")
88
Compile / javacOptions ++= Seq("-target", "8", "-source", "8")

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.5.0
1+
sbt.version = 1.5.6

src/main/scala/Plugin.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class Plugin extends gitbucket.core.plugin.Plugin {
4343
new Version("4.18.0"),
4444
new Version("4.19.0"),
4545
new Version("4.20.0"),
46-
new Version("4.21.0")
46+
new Version("4.21.0"),
47+
new Version("4.22.0")
4748
)
4849

4950
override def initialize(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {

src/main/scala/gitbucket/gist/util/GistUtils.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ object GistUtils {
5555
case class GistRepositoryURL(gist: Gist, baseUrl: String, settings: SystemSettings){
5656

5757
def httpUrl: String = s"${baseUrl}/git/gist/${gist.userName}/${gist.repositoryName}.git"
58-
58+
5959
def embedUrl: String = s"${baseUrl}/gist/${gist.userName}/${gist.repositoryName}.js"
6060

61-
def sshUrl(loginUser: String): String = {
62-
val host = """^https?://(.+?)(:\d+)?/""".r.findFirstMatchIn(httpUrl).get.group(1)
63-
s"ssh://${loginUser}@${host}:${settings.ssh.sshPort.getOrElse(SystemSettingsService.DefaultSshPort)}/gist/${gist.userName}/${gist.repositoryName}.git"
61+
def sshUrl: Option[String] = {
62+
settings.sshUrl.map { sshUrl =>
63+
s"${sshUrl}/gist/${gist.userName}/${gist.repositoryName}.git"
64+
}
6465
}
65-
6666
}
6767

6868
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ <h1 style="margin: 0px;">New snippet</h1>
3535
<form id="form" method="POST" action="#">
3636
<input type="text" name="description" id="description" class="form-control" style="margin-bottom: 8px;" value="@gist.map(_.description)" placeholder="Snippet descriptions..."/>
3737
<div id="editors">
38-
@files.zipWithIndex.map { case ((fileName, content), i) => {
38+
@files.zipWithIndex.map { case ((fileName, content), i) =>
3939
@gitbucket.gist.html.editor(i, fileName, content)
40-
}}
40+
}
4141
</div>
4242
<div>
4343
<input type="button" value="Add file" class="btn btn-default" id="add_file">

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@
116116
$('#repository-url').val('@repositoryUrl.httpUrl');
117117
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
118118
});
119-
@if(context.settings.ssh.enabled && context.loginAccount.isDefined){
120-
$('#repository-url-ssh').click(function(){
121-
$('#repository-url-proto').text('SSH');
122-
$('#repository-url').val('@repositoryUrl.sshUrl(context.loginAccount.get.userName)');
123-
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
124-
});
125-
}
119+
@if(context.settings.ssh.enabled && context.loginAccount.isDefined){
120+
@repositoryUrl.sshUrl.map { sshUrl =>
121+
$('#repository-url-ssh').click(function(){
122+
$('#repository-url-proto').text('SSH');
123+
$('#repository-url').val('@sshUrl');
124+
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
125+
});
126+
}
127+
}
126128
});
127129
</script>

0 commit comments

Comments
 (0)