Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…plugin

# Conflicts:
#	project/build.scala
  • Loading branch information
takezoe committed Dec 29, 2015
2 parents cfe0696 + 8b2e9eb commit 69442f5
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 85 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/gitbucket/gist/controller/GistController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ trait GistControllerBase extends ControllerBase {
val files = getGistFiles(userName, repoName)
val (fileName, source) = files.head

(gist, GistInfo(fileName, source, files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
(gist, GistInfo(fileName, getLines(source), files.length, getForkedCount(userName, repoName), getCommentCount(userName, repoName)))
}

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

val fullName = getAccountByUserName(userName).get.fullName
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/gitbucket/gist/util/GistUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ object GistUtils {
commitId
}

def getLines(source: String): String = source.split("\n").take(10).mkString("\n")

def isGistFile(fileName: String): Boolean = fileName.matches("gistfile[0-9]+\\.txt")

def getTitle(fileName: String, repoName: String): String = if(isGistFile(fileName)) repoName else fileName
Expand Down
6 changes: 3 additions & 3 deletions src/main/twirl/gitbucket/gist/commentedit.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@import context._
<span id="error-edit-content-@commentId" class="error"></span>
@gitbucket.core.helper.html.attached(userName, repoName){
<textarea style="width: 635px; height: 100px;" id="edit-content-@commentId">@content</textarea>
<textarea class="form-control" style="width: 635px; height: 100px;" id="edit-content-@commentId">@content</textarea>
}
<div>
<input type="button" id="cancel-comment-@commentId" class="btn btn-small btn-danger" value="Cancel"/>
<input type="button" id="update-comment-@commentId" class="btn btn-small pull-right" value="Update comment"/>
<input type="button" id="cancel-comment-@commentId" class="btn btn-lg btn-danger" value="Cancel"/>
<input type="button" id="update-comment-@commentId" class="btn btn-lg btn-default pull-right" value="Update comment"/>
</div>
<script>
$(function(){
Expand Down
6 changes: 3 additions & 3 deletions src/main/twirl/gitbucket/gist/commentform.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<hr/><br/>
<form method="POST" validate="true" action="@path/gist/@gist.userName/@gist.repositoryName/_comment">
<div class="issue-avatar-image">@avatar(loginAccount.get.userName, 48)</div>
<div class="issue-comment-box">
<div class="box-content">
<div class="panel panel-default issue-comment-box">
<div class="panel-body">
@gitbucket.gist.html.commentpreview(
gist = gist,
content = "",
style = "width: 635px; height: 100px; max-height: 150px;",
elastic = true
)
<div style="text-align: right;">
<input type="submit" class="btn btn-success" value="Comment"/>
<input type="submit" class="btn btn-lg btn-success" value="Comment"/>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/twirl/gitbucket/gist/commentpreview.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="tab-content">
<div class="tab-pane active" id="tab@uid">
<span id="error-content" class="error"></span>
<textarea id="content@uid" name="content" placeholder="@placeholder" @if(style.nonEmpty){style="@style"}>@content</textarea>
<textarea id="content@uid" name="content" class="form-control" placeholder="@placeholder" @if(style.nonEmpty){style="@style"}>@content</textarea>
</div>
<div class="tab-pane" id="tab@(uid+1)">
<div class="markdown-body" id="preview-area@uid">
Expand Down
28 changes: 15 additions & 13 deletions src/main/twirl/gitbucket/gist/detail.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@
@gist.description
</div>
@files.map { case (fileName, content) =>
<div class="box-header">
@fileName
<div class="pull-right">
<a href="@path/gist/@gist.userName/@gist.repositoryName/raw/@revision/@fileName" class="btn btn-mini">Raw</a>
<div class="panel panel-default">
<div class="panel-heading strong">
@fileName
<div class="pull-right">
<a href="@path/gist/@gist.userName/@gist.repositoryName/raw/@revision/@fileName" class="btn btn-sm btn-default">Raw</a>
</div>
</div>
@if(isRenderable(fileName)){
<div class="panel-body markdown-body" style="padding-left: 16px; padding-right: 16px;">
@renderMarkup(List(fileName), content, "master", gist.toRepositoryInfo, false, false, true)
</div>
} else {
<div class="panel-body">
<pre class="prettyprint linenums blob">@content</pre>
</div>
}
</div>
@if(isRenderable(fileName)){
<div class="box-content-bottom markdown-body" style="padding-left: 16px; padding-right: 16px;">
@renderMarkup(List(fileName), content, "master", gist.toRepositoryInfo, false, false, true)
</div>
} else {
<div class="box-content-bottom">
<pre class="prettyprint linenums blob">@content</pre>
</div>
}
}
@gitbucket.gist.html.commentlist(gist, comments, editable, gist.toRepositoryInfo)
@gitbucket.gist.html.commentform(gist)
Expand Down
24 changes: 12 additions & 12 deletions src/main/twirl/gitbucket/gist/edit.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@recent.map { gist =>
<li style="float: left; width: 200px;">
<i class="octicon octicon-gist" style="width: 24px; height: 24px;"></i>
<div style="margin-left: 26px; font-size: 80%; position: relative; top: -24px; line-height: normal; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
<div style="margin-left: 26px; font-size: 90%; position: relative; top: -24px; line-height: normal; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
<a class="strong" href="@path/gist/@gist.userName/@gist.repositoryName">@gist.title</a><br>
@if(gist.description.nonEmpty){
<span class="muted">@gist.description</span>
Expand All @@ -24,7 +24,7 @@
}
</ul>
<div class="pull-right">
<a href="@path/gist/@context.loginAccount.get.userName" class="btn">Your Snippets</a>
<a href="@path/gist/@context.loginAccount.get.userName" class="btn btn-default">Your Snippets</a>
</div>
</div>
} else {
Expand All @@ -38,11 +38,11 @@
}
<div class="pull-right">
@if(gist.get.isPrivate){
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName/public" class="btn">Make public</a>
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName/public" class="btn btn-default">Make public</a>
} else {
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName/secret" class="btn">Make secret</a>
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName/secret" class="btn btn-default">Make secret</a>
}
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName/delete" class="btn" id="delete">Delete</a>
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName/delete" class="btn btn-default" id="delete">Delete</a>
</div>
</div>
<div class="muted" style="margin-top: -10px; margin-left: 30px;">
Expand All @@ -53,22 +53,22 @@
</div>
<hr style="margin-bottom: 20px;"/>
<div class="container body">
<form id="form" method="POST" action="#">
<input type="text" name="description" id="description" style="width: 900px;" value="@gist.map(_.description)" placeholder="Snippet descriptions..."/>
<form id="form" method="POST" action="#" class="form-inline">
<input type="text" name="description" id="description" class="form-control input-lg" style="width: 900px; margin-bottom: 8px;" value="@gist.map(_.description)" placeholder="Snippet descriptions..."/>
<div id="editors">
@files.zipWithIndex.map { case ((fileName, content), i) =>
@gitbucket.gist.html.editor(i, fileName, content)
}
</div>
<div>
<input type="button" value="Add file" class="btn" id="add_file">
<input type="button" value="Add file" class="btn btn-lg btn-default" id="add_file">
<div class="pull-right">
@if(gist.isDefined){
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName" class="btn">Cancel</a>
<input type="submit" value="Update" class="btn btn-success submit_snippet" id="update_snippet">
<a href="@path/gist/@gist.get.userName/@gist.get.repositoryName" class="btn btn-lg btn-default">Cancel</a>
<input type="submit" value="Update" class="btn btn-lg btn-success submit_snippet" id="update_snippet">
} else {
<input type="submit" value="Create private Snippet" class="btn submit_snippet" id="create_private_snippet">
<input type="submit" value="Create public Snippet" class="btn submit_snippet" id="create_public_snippet">
<input type="submit" value="Create private Snippet" class="btn btn-lg btn-default submit_snippet" id="create_private_snippet">
<input type="submit" value="Create public Snippet" class="btn btn-lg btn-default submit_snippet" id="create_public_snippet">
}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/main/twirl/gitbucket/gist/editor.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<tr>
<th>
<div class="pull-right">
<select id="wrap-@i" class="input-medium" style="margin-bottom: 0px; height: 26px; padding: 0px;">
<select id="wrap-@i" class="form-control input-medium" style="margin-bottom: 0px; height: 26px; padding: 0px;">
<optgroup label="Line Wrap Mode">
<option value="false">No wrap</option>
<option value="true">Soft wrap</option>
</optgroup>
</select>
</div>
<input type="text" id="fileName-@i" name="fileName-@i" class="input-medium" value="@fileName" placeholder="Name this file..." style="margin-bottom: 0px;">
<input type="text" id="fileName-@i" name="fileName-@i" class="form-control input-medium" value="@fileName" placeholder="Name this file..." style="margin-bottom: 0px;">
</th>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion src/main/twirl/gitbucket/gist/forks.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@avatar(forkedGist.userName, 20)
<a href="@path/gist/@forkedGist.userName/@forkedGist.repositoryName">@forkedGist.userName</a>
<div class="pull-right">
<a href="@path/gist/@forkedGist.userName/@forkedGist.repositoryName" class="btn btn-small">View Fork</a>
<a href="@path/gist/@forkedGist.userName/@forkedGist.repositoryName" class="btn btn-sm btn-default">View Fork</a>
</div>
</div>
}
Expand Down
22 changes: 13 additions & 9 deletions src/main/twirl/gitbucket/gist/header.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@
}
<div class="pull-right">
@if(editable){
<a href="@path/gist/@gist.userName/@gist.repositoryName/edit" class="btn btn-small">Edit</a>
<a href="@path/gist/@gist.userName/@gist.repositoryName/delete" class="btn btn-small" id="delete">Delete</a>
<a href="@path/gist/@gist.userName/@gist.repositoryName/edit" class="btn btn-default">Edit</a>
<a href="@path/gist/@gist.userName/@gist.repositoryName/delete" class="btn btn-default" id="delete">Delete</a>
}
@if(gist.originUserName.isEmpty){
<div class="input-prepend" style="margin-bottom: 0px;">
@if(loginAccount.isEmpty){
<a title="You must be signed in to fork a repository" href="@path/signin?redirect=@urlEncode(s"${path}/gist/${gist.userName}/${gist.repositoryName}")" class="btn btn-small">Fork</a>
} else {
<a id="fork-link" href="javascript:void(0);" class="btn btn-small">Fork</a>
}
<span class="add-on count"><a href="@path/gist/@gist.userName/@gist.repositoryName/forks">@forkedCount</a></span>
<div class="input-group pull-right">
<span class="fork">
<span class="input-group-btn">
@if(loginAccount.isEmpty){
<a title="You must be signed in to fork a repository" href="@path/signin?redirect=@urlEncode(s"${path}/gist/${gist.userName}/${gist.repositoryName}")" class="btn btn-default">Fork</a>
} else {
<a id="fork-link" href="javascript:void(0);" class="btn btn-default">Fork</a>
}
</span>
<span class="count"><a href="@path/gist/@gist.userName/@gist.repositoryName/forks">@forkedCount</a></span>
</span>
</div>
@if(loginAccount.isDefined){
<form id="fork-form" method="post" action="@path/gist/@gist.userName/@gist.repositoryName/fork">
Expand Down
8 changes: 4 additions & 4 deletions src/main/twirl/gitbucket/gist/list.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@avatar(gistUser.get.userName, 24)
<span class="strong">@gistUser.get.fullName</span>
<div class="pull-right">
<a href="@path/@gistUser.get.userName" class="btn">@gistUser.get.userName on GitBucket</a>
<a href="@path/@gistUser.get.userName" class="btn btn-default">@gistUser.get.userName on GitBucket</a>
</div>
</div>
<div class="muted" style="margin-top: -10px; margin-left: 30px;">
Expand Down Expand Up @@ -59,14 +59,14 @@
@renderMarkup(List(gistInfo.fileName), gistInfo.source, "master", gist.toRepositoryInfo, false, false, false)
</div>
} else {
<pre class="list-code box-content prettyprint linenums">@Html(gistInfo.source)</pre>
<pre class="list-code box-content prettyprint linenums">@gistInfo.source</pre>
}
</div>
</div>
}
<div class="btn-group">
<button class="btn" onclick="location.href='?page=@{page - 1}'"@if(page <= 1){ disabled="true"}>Newer</button>
<button class="btn" onclick="location.href='?page=@{page + 1}'"@if(!hasNext){ disabled="true"}>Older</button>
<button class="btn btn-default" onclick="location.href='?page=@{page - 1}'"@if(page <= 1){ disabled="true"}>Newer</button>
<button class="btn btn-default" onclick="location.href='?page=@{page + 1}'"@if(!hasNext){ disabled="true"}>Older</button>
</div>
</div>
}
6 changes: 3 additions & 3 deletions src/main/twirl/gitbucket/gist/menu.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<strong id="repository-url-proto">HTTP</strong> <span class="mute">clone URL</span>
</div>
@helper.html.copy("repository-url-copy", repositoryUrl.httpUrl){
<input type="text" value="@repositoryUrl.httpUrl" id="repository-url" readonly>
<input type="text" value="@repositoryUrl.httpUrl" id="repository-url" class="form-control input-sm" readonly>
}
@if(settings.ssh && loginAccount.isDefined){
<div class="small">
Expand All @@ -53,12 +53,12 @@
}
<div style="margin-top: 10px;">
<a href="@path/gist/@{gist.userName}/@{gist.repositoryName}/download/@{gist.repositoryName}.zip"
class="btn btn-small" style="width: 147px;"><i class="icon-download-alt"></i>Download ZIP</a>
class="btn btn-default" style="width: 170px;"><i class="icon-download-alt"></i>Download ZIP</a>
</div>
@*
<div style="margin-top: 10px;">
<a href="@path/gist/@{gist.userName}/@{gist.repositoryName}/download/@{gist.repositoryName}.tar.gz"
class="btn btn-small" style="width: 147px;"><i class="icon-download-alt"></i>Download TAR.GZ</a>
class="btn btn-small" style="width: 170px;"><i class="icon-download-alt"></i>Download TAR.GZ</a>
</div>
*@
</div>
Expand Down
68 changes: 36 additions & 32 deletions src/main/twirl/gitbucket/gist/revisions.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,44 @@
<div>
@diffs.zipWithIndex.map { case (diff, i) =>
<table class="table table-bordered">
<tr>
<th style="font-weight: normal; line-height: 27px;" class="box-header">
@diff.changeType match {
case ChangeType.ADD => {
<span class="diffstat">
<i class="octicon octicon-diff-added"></i>
</span> @diff.newPath
<thead>
<tr>
<th style="font-weight: normal; line-height: 27px;" class="box-header">
@diff.changeType match {
case ChangeType.ADD => {
<span class="diffstat">
<i class="octicon octicon-diff-added"></i>
</span> @diff.newPath
}
case ChangeType.MODIFY => {
<span class="diffstat">
<i class="octicon octicon-diff-modified"></i>
</span> @diff.newPath
}
case ChangeType.DELETE => {
<span class="diffstat">
<i class="octicon octicon-diff-removed"></i>
</span> @diff.oldPath
}
case _ => {
}
}
case ChangeType.MODIFY => {
<span class="diffstat">
<i class="octicon octicon-diff-modified"></i>
</span> @diff.newPath
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding: 0;">
@if(diff.newContent != None || diff.oldContent != None){
<div id="[email protected](0, 7)-@i"></div>
<textarea id="[email protected](0, 7)-@i" style="display: none;">@diff.newContent.getOrElse("")</textarea>
<textarea id="[email protected](0, 7)-@i" style="display: none;">@diff.oldContent.getOrElse("")</textarea>
} else {
Not supported
}
case ChangeType.DELETE => {
<span class="diffstat">
<i class="octicon octicon-diff-removed"></i>
</span> @diff.oldPath
}
case _ => {
}
}
</th>
</tr>
<tr>
<td style="padding: 0;">
@if(diff.newContent != None || diff.oldContent != None){
<div id="[email protected](0, 7)-@i"></div>
<textarea id="[email protected](0, 7)-@i" style="display: none;">@diff.newContent.getOrElse("")</textarea>
<textarea id="[email protected](0, 7)-@i" style="display: none;">@diff.oldContent.getOrElse("")</textarea>
} else {
Not supported
}
</td>
</tr>
</td>
</tr>
</tbody>
</table>
}
</div>
Expand Down

0 comments on commit 69442f5

Please sign in to comment.