diff --git a/README.md b/README.md index 36bf002..7575c1f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This is a GitBucket plug-in which provides code snippet repository like Gist. Plugin version | GitBucket version :--------------|:-------------------- +4.22.x | 4.37.x - 4.21.x | 4.36.x - 4.20.x | 4.35.x - 4.19.x | 4.34.x - diff --git a/build.sbt b/build.sbt index 1f7d9a4..072cec3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ organization := "io.github.gitbucket" name := "gitbucket-gist-plugin" -version := "4.21.0" -scalaVersion := "2.13.5" -gitbucketVersion := "4.36.0" +version := "4.22.0" +scalaVersion := "2.13.7" +gitbucketVersion := "4.37.0" scalacOptions := Seq("-deprecation", "-feature", "-language:postfixOps") Compile / javacOptions ++= Seq("-target", "8", "-source", "8") diff --git a/project/build.properties b/project/build.properties index b366316..da9d652 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.5.0 +sbt.version = 1.5.6 diff --git a/src/main/scala/Plugin.scala b/src/main/scala/Plugin.scala index a0a9b84..c35345a 100755 --- a/src/main/scala/Plugin.scala +++ b/src/main/scala/Plugin.scala @@ -43,7 +43,8 @@ class Plugin extends gitbucket.core.plugin.Plugin { new Version("4.18.0"), new Version("4.19.0"), new Version("4.20.0"), - new Version("4.21.0") + new Version("4.21.0"), + new Version("4.22.0") ) override def initialize(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = { diff --git a/src/main/scala/gitbucket/gist/util/GistUtils.scala b/src/main/scala/gitbucket/gist/util/GistUtils.scala index d94debe..b5f7f93 100644 --- a/src/main/scala/gitbucket/gist/util/GistUtils.scala +++ b/src/main/scala/gitbucket/gist/util/GistUtils.scala @@ -55,14 +55,14 @@ object GistUtils { case class GistRepositoryURL(gist: Gist, baseUrl: String, settings: SystemSettings){ def httpUrl: String = s"${baseUrl}/git/gist/${gist.userName}/${gist.repositoryName}.git" - + def embedUrl: String = s"${baseUrl}/gist/${gist.userName}/${gist.repositoryName}.js" - def sshUrl(loginUser: String): String = { - val host = """^https?://(.+?)(:\d+)?/""".r.findFirstMatchIn(httpUrl).get.group(1) - s"ssh://${loginUser}@${host}:${settings.ssh.sshPort.getOrElse(SystemSettingsService.DefaultSshPort)}/gist/${gist.userName}/${gist.repositoryName}.git" + def sshUrl: Option[String] = { + settings.sshUrl.map { sshUrl => + s"${sshUrl}/gist/${gist.userName}/${gist.repositoryName}.git" + } } - } } diff --git a/src/main/twirl/gitbucket/gist/edit.scala.html b/src/main/twirl/gitbucket/gist/edit.scala.html index dd056fc..968e94c 100644 --- a/src/main/twirl/gitbucket/gist/edit.scala.html +++ b/src/main/twirl/gitbucket/gist/edit.scala.html @@ -35,9 +35,9 @@

New snippet

- @files.zipWithIndex.map { case ((fileName, content), i) => { + @files.zipWithIndex.map { case ((fileName, content), i) => @gitbucket.gist.html.editor(i, fileName, content) - }} + }
diff --git a/src/main/twirl/gitbucket/gist/menu.scala.html b/src/main/twirl/gitbucket/gist/menu.scala.html index feb600f..e82566f 100644 --- a/src/main/twirl/gitbucket/gist/menu.scala.html +++ b/src/main/twirl/gitbucket/gist/menu.scala.html @@ -116,12 +116,14 @@ $('#repository-url').val('@repositoryUrl.httpUrl'); $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); }); -@if(context.settings.ssh.enabled && context.loginAccount.isDefined){ - $('#repository-url-ssh').click(function(){ - $('#repository-url-proto').text('SSH'); - $('#repository-url').val('@repositoryUrl.sshUrl(context.loginAccount.get.userName)'); - $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); - }); -} + @if(context.settings.ssh.enabled && context.loginAccount.isDefined){ + @repositoryUrl.sshUrl.map { sshUrl => + $('#repository-url-ssh').click(function(){ + $('#repository-url-proto').text('SSH'); + $('#repository-url').val('@sshUrl'); + $('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val()); + }); + } + } });