1- package app
1+ package gitbucket . gist . controller
22
33import java .io .File
44import 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+
622import 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 ._
1223import org .eclipse .jgit .api .Git
1324import org .eclipse .jgit .lib ._
1425import org .eclipse .jgit .dircache .DirCache
15- import util .Implicits ._
16- import util .Configurations ._
1726
1827class 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
0 commit comments