Skip to content

Commit 8b2e9eb

Browse files
committed
Cut after first 10 lines at the list view of Gist
1 parent 89930c3 commit 8b2e9eb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/scala/gitbucket/gist/controller/GistController.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ trait GistControllerBase extends ControllerBase {
6161
val files = getGistFiles(userName, repoName)
6262
val (fileName, source) = files.head
6363

64-
(gist, GistInfo(fileName, source, files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
64+
(gist, GistInfo(fileName, getLines(source), files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
6565
}
6666

6767
html.list(None, gists, page, page * Limit < count)
@@ -445,7 +445,7 @@ trait GistControllerBase extends ControllerBase {
445445
val repoName = gist.repositoryName
446446
val files = getGistFiles(userName, repoName, revision)
447447
val (fileName, source) = files.head
448-
(gist, GistInfo(fileName, source, files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
448+
(gist, GistInfo(fileName, getLines(source), files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
449449
}
450450

451451
val fullName = getAccountByUserName(userName).get.fullName

src/main/scala/gitbucket/gist/util/GistUtils.scala

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ object GistUtils {
3838
commitId
3939
}
4040

41+
def getLines(source: String): String = source.split("\n").take(10).mkString("\n")
42+
4143
def isGistFile(fileName: String): Boolean = fileName.matches("gistfile[0-9]+\\.txt")
4244

4345
def getTitle(fileName: String, repoName: String): String = if(isGistFile(fileName)) repoName else fileName

0 commit comments

Comments
 (0)