@@ -45,10 +45,23 @@ trait GistControllerBase extends ControllerBase {
45
45
// //////////////////////////////////////////////////////////////////////////////
46
46
47
47
get(" /gist" ){
48
- if (context.loginAccount.isDefined){
49
- val gists = getRecentGists(context.loginAccount.get.userName, 0 , 4 )
50
- html.edit(gists, None , Seq ((" " , JGitUtil .ContentInfo (" text" , None , Some (" UTF-8" )))))
51
- } else _discoverGists()
48
+ val page = request.getParameter(" page" ) match {
49
+ case " " | null => 1
50
+ case s => s.toInt
51
+ }
52
+ val result = getVisibleGists((page - 1 ) * Limit , Limit , None )
53
+ val count = countPublicGists()
54
+
55
+ val gists : Seq [(Gist , GistInfo )] = result.map { gist =>
56
+ val userName = gist.userName
57
+ val repoName = gist.repositoryName
58
+ val files = getGistFiles(userName, repoName)
59
+ val (fileName, source) = files.head
60
+
61
+ (gist, GistInfo (fileName, getLines(source), files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
62
+ }
63
+
64
+ html.list(None , gists, page, page * Limit < count)
52
65
}
53
66
54
67
get(" /gist/:userName/:repoName" ){
@@ -265,20 +278,20 @@ trait GistControllerBase extends ControllerBase {
265
278
}
266
279
}
267
280
268
-
269
281
get(" /gist/:userName" ){
270
282
_gist(params(" userName" ))
271
283
}
272
284
285
+ get(" /gist/_new" )(usersOnly {
286
+ val gists = getRecentGists(context.loginAccount.get.userName, 0 , 4 )
287
+ html.edit(gists, None , Seq ((" " , JGitUtil .ContentInfo (" text" , None , Some (" UTF-8" )))))
288
+ })
289
+
273
290
get(" /gist/_add" ){
274
291
val count = params(" count" ).toInt
275
292
html.editor(count, " " , JGitUtil .ContentInfo (" text" , None , Some (" UTF-8" )))
276
293
}
277
294
278
- get(" /gist/discover" ){
279
- _discoverGists()
280
- }
281
-
282
295
// //////////////////////////////////////////////////////////////////////////////
283
296
//
284
297
// Fork Actions
@@ -413,25 +426,6 @@ trait GistControllerBase extends ControllerBase {
413
426
// Private Methods
414
427
//
415
428
// //////////////////////////////////////////////////////////////////////////////
416
- private def _discoverGists (): Html = {
417
- val page = request.getParameter(" page" ) match {
418
- case " " | null => 1
419
- case s => s.toInt
420
- }
421
- val result = getVisibleGists((page - 1 ) * Limit , Limit , None )
422
- val count = countPublicGists()
423
-
424
- val gists : Seq [(Gist , GistInfo )] = result.map { gist =>
425
- val userName = gist.userName
426
- val repoName = gist.repositoryName
427
- val files = getGistFiles(userName, repoName)
428
- val (fileName, source) = files.head
429
-
430
- (gist, GistInfo (fileName, getLines(source), files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
431
- }
432
-
433
- html.list(None , gists, page, page * Limit < count)
434
- }
435
429
436
430
private def _gist (userName : String , repoName : Option [String ] = None , revision : String = " master" ): Html = {
437
431
repoName match {
0 commit comments