Skip to content

Commit 6131e27

Browse files
committed
Update for GitBucket 3.0
1 parent fd3c5ae commit 6131e27

19 files changed

+104
-83
lines changed

project/build.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ object MyBuild extends Build {
2525
"amateras-repo" at "http://amateras.sourceforge.jp/mvn/"
2626
),
2727
libraryDependencies ++= Seq(
28-
"jp.sf.amateras" % "gitbucket-assembly" % "0.0.1",
29-
"com.typesafe.play" %% "twirl-compiler" % "1.0.2",
30-
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
28+
"gitbucket" % "gitbucket-assembly" % "3.0.0",
29+
"com.typesafe.play" %% "twirl-compiler" % "1.0.2",
30+
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
3131
),
3232
javacOptions in compile ++= Seq("-target", "7", "-source", "7")
3333
).enablePlugins(SbtTwirl)

src/main/scala/Plugin.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import app.GistController
2-
import plugin.PluginRegistry
3-
import util.Version
1+
import gitbucket.gist.controller.GistController
2+
import gitbucket.core.plugin.PluginRegistry
3+
import gitbucket.core.util.Version
44
import java.io.File
5-
import util.Configurations._
5+
import gitbucket.gist.util.Configurations._
66

7-
class Plugin extends plugin.Plugin {
7+
class Plugin extends gitbucket.core.plugin.Plugin {
88
override val pluginId: String = "gist"
99
override val pluginName: String = "Gist Plugin"
1010
override val description: String = "Provides Gist feature on GitBucket."

src/main/scala/app/GistController.scala renamed to src/main/scala/gitbucket/gist/controller/GistController.scala

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
package app
1+
package gitbucket.gist.controller
22

33
import java.io.File
44
import jp.sf.amateras.scalatra.forms._
5-
import model.{GistUser, Gist, Account}
5+
6+
import gitbucket.core.model.Account
7+
import gitbucket.core.controller.ControllerBase
8+
import gitbucket.core.service.AccountService
9+
import gitbucket.core.util._
10+
import gitbucket.core.util.Directory._
11+
import gitbucket.core.util.ControlUtil._
12+
import gitbucket.core.util.Implicits._
13+
import gitbucket.core.view.helpers._
14+
15+
16+
import gitbucket.gist.model.{GistUser, Gist}
17+
import gitbucket.gist.service.GistService
18+
import gitbucket.gist.util._
19+
import gitbucket.gist.util.Configurations._
20+
import gitbucket.gist.html
21+
622
import org.apache.commons.io.FileUtils
7-
import org.scalatra.BadRequest
8-
import service.{RepositoryService, AccountService, GistService}
9-
import util.Directory._
10-
import util._
11-
import util.ControlUtil._
1223
import org.eclipse.jgit.api.Git
1324
import org.eclipse.jgit.lib._
1425
import org.eclipse.jgit.dircache.DirCache
15-
import util.Implicits._
16-
import util.Configurations._
1726

1827
class GistController extends GistControllerBase with GistService with AccountService
1928
with GistEditorAuthenticator with UsersAuthenticator
@@ -24,7 +33,7 @@ trait GistControllerBase extends ControllerBase {
2433
get("/gist"){
2534
if(context.loginAccount.isDefined){
2635
val gists = getRecentGists(context.loginAccount.get.userName, 0, 4)
27-
gist.html.edit(gists, None, Seq(("", JGitUtil.ContentInfo("text", None, Some("UTF-8")))))
36+
html.edit(gists, None, Seq(("", JGitUtil.ContentInfo("text", None, Some("UTF-8")))))
2837
} else {
2938
val page = request.getParameter("page") match {
3039
case ""|null => 1
@@ -48,7 +57,7 @@ trait GistControllerBase extends ControllerBase {
4857
}
4958
}
5059

51-
gist.html.list(None, gists, page, page * Limit < count)
60+
html.list(None, gists, page, page * Limit < count)
5261
}
5362
}
5463

@@ -69,7 +78,7 @@ trait GistControllerBase extends ControllerBase {
6978
val files: Seq[(String, JGitUtil.ContentInfo)] = JGitUtil.getFileList(git, "master", ".").map { file =>
7079
(if(isGistFile(file.name)) "" else file.name) -> JGitUtil.getContentInfo(git, file.name, file.id)
7180
}
72-
_root_.gist.html.edit(Nil, getGist(userName, repoName), files)
81+
html.edit(Nil, getGist(userName, repoName), files)
7382
}
7483
}
7584
})
@@ -87,7 +96,7 @@ trait GistControllerBase extends ControllerBase {
8796
val description = params("description")
8897

8998
// Create new repository
90-
val repoName = StringUtil.md5(loginAccount.userName + " " + view.helpers.datetime(new java.util.Date()))
99+
val repoName = StringUtil.md5(loginAccount.userName + " " + datetime(new java.util.Date()))
91100
val gitdir = new File(GistRepoDir, loginAccount.userName + "/" + repoName)
92101
gitdir.mkdirs()
93102
JGitUtil.initRepository(gitdir)
@@ -195,7 +204,7 @@ trait GistControllerBase extends ControllerBase {
195204
}
196205
}
197206
}
198-
gist.html.revisions("revision", getGist(userName, repoName).get, isEditable(userName), commits)
207+
html.revisions("revision", getGist(userName, repoName).get, isEditable(userName), commits)
199208
}
200209
case Left(_) => NotFound
201210
}
@@ -262,7 +271,7 @@ trait GistControllerBase extends ControllerBase {
262271

263272
get("/gist/_add"){
264273
val count = params("count").toInt
265-
gist.html.editor(count, "", JGitUtil.ContentInfo("text", None, Some("UTF-8")))
274+
html.editor(count, "", JGitUtil.ContentInfo("text", None, Some("UTF-8")))
266275
}
267276

268277
private def _gist(userName: String, repoName: Option[String] = None, revision: String = "master") = {
@@ -295,7 +304,7 @@ trait GistControllerBase extends ControllerBase {
295304
}
296305

297306
val fullName = getAccountByUserName(userName).get.fullName
298-
gist.html.list(Some(GistUser(userName, fullName)), gists, page, page * Limit < result._2)
307+
html.list(Some(GistUser(userName, fullName)), gists, page, page * Limit < result._2)
299308
}
300309
case Some(repoName) => {
301310
val gitdir = new File(GistRepoDir, userName + "/" + repoName)
@@ -307,7 +316,7 @@ trait GistControllerBase extends ControllerBase {
307316
val files: Seq[(String, String)] = JGitUtil.getFileList(git, revision, ".").map { file =>
308317
file.name -> StringUtil.convertFromByteArray(JGitUtil.getContentFromId(git, file.id, true).get)
309318
}
310-
_root_.gist.html.detail("code", gist, revision, files, isEditable(userName))
319+
html.detail("code", gist, revision, files, isEditable(userName))
311320
} else Unauthorized
312321
}
313322
} else NotFound

src/main/scala/model/Gist.scala renamed to src/main/scala/gitbucket/gist/model/Gist.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package model
1+
package gitbucket.gist.model
22

3-
trait GistComponent { self: Profile =>
3+
trait GistComponent { self: gitbucket.core.model.Profile =>
44
import profile.simple._
55
import self._
66

src/main/scala/model/GistComment.scala renamed to src/main/scala/gitbucket/gist/model/GistComment.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package model
1+
package gitbucket.gist.model
22

3-
trait GistCommentComponent { self: Profile =>
3+
trait GistCommentComponent { self: gitbucket.core.model.Profile =>
44
import profile.simple._
55
import self._
66

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package gitbucket.gist.model
2+
3+
import gitbucket.core.model._
4+
5+
object Profile extends CoreProfile
6+
with GistComponent
7+
with GistCommentComponent
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
package model
1+
package gitbucket.gist.model
22

33
case class GistUser(userName: String, fullName: String)

src/main/scala/service/GistService.scala renamed to src/main/scala/gitbucket/gist/service/GistService.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package service
1+
package gitbucket.gist.service
22

3-
import model.Gist
4-
import model.GistProfile._
3+
import gitbucket.gist.model.Gist
4+
import gitbucket.gist.model.Profile._
55
import profile.simple._
66

77
trait GistService {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package gitbucket.gist.util
2+
3+
object Configurations {
4+
lazy val GistRepoDir = s"${gitbucket.core.util.Directory.GitBucketHome}/gist"
5+
lazy val Limit = 10
6+
}

src/main/scala/util/GistAuthenticator.scala renamed to src/main/scala/gitbucket/gist/util/GistAuthenticator.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package util
1+
package gitbucket.gist.util
22

3-
import app.ControllerBase
4-
import util.ControlUtil._
5-
import util.Implicits._
3+
import gitbucket.core.controller.ControllerBase
4+
import gitbucket.core.util.ControlUtil._
5+
import gitbucket.core.util.Implicits._
66

77
/**
88
* Allows only editor of the accessed snippet.

0 commit comments

Comments
 (0)