Skip to content

Commit

Permalink
Support GitBucket 4.37.x (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe authored Dec 13, 2021
1 parent 9a81964 commit e895df8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.5.0
sbt.version = 1.5.6
3 changes: 2 additions & 1 deletion src/main/scala/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/gitbucket/gist/util/GistUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

}

}
4 changes: 2 additions & 2 deletions src/main/twirl/gitbucket/gist/edit.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ <h1 style="margin: 0px;">New snippet</h1>
<form id="form" method="POST" action="#">
<input type="text" name="description" id="description" class="form-control" style="margin-bottom: 8px;" value="@gist.map(_.description)" placeholder="Snippet descriptions..."/>
<div id="editors">
@files.zipWithIndex.map { case ((fileName, content), i) => {
@files.zipWithIndex.map { case ((fileName, content), i) =>
@gitbucket.gist.html.editor(i, fileName, content)
}}
}
</div>
<div>
<input type="button" value="Add file" class="btn btn-default" id="add_file">
Expand Down
16 changes: 9 additions & 7 deletions src/main/twirl/gitbucket/gist/menu.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
}
});
</script>

0 comments on commit e895df8

Please sign in to comment.