diff --git a/src/main/scala/gitbucket/core/controller/IssuesController.scala b/src/main/scala/gitbucket/core/controller/IssuesController.scala index 912c4f9..4bdfac2 100644 --- a/src/main/scala/gitbucket/core/controller/IssuesController.scala +++ b/src/main/scala/gitbucket/core/controller/IssuesController.scala @@ -204,8 +204,7 @@ getIssue(repository.owner, repository.name, params("id")) map { x => if(isEditable(x.userName, x.repositoryName, x.openedUserName)){ params.get("dataType") collect { - case t if t == "html" => html.editissue( - x.content, x.issueId, x.userName, x.repositoryName) + case t if t == "html" => html.editissue(x.content, x.issueId, repository) } getOrElse { contentType = formats("json") org.json4s.jackson.Serialization.write( @@ -232,8 +231,7 @@ getComment(repository.owner, repository.name, params("id")) map { x => if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){ params.get("dataType") collect { - case t if t == "html" => html.editcomment( - x.content, x.commentId, x.userName, x.repositoryName) + case t if t == "html" => html.editcomment(x.content, x.commentId, repository) } getOrElse { contentType = formats("json") org.json4s.jackson.Serialization.write( diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 12ee473..2563558 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -376,8 +376,7 @@ getCommitComment(repository.owner, repository.name, params("id")) map { x => if(isEditable(x.userName, x.repositoryName, x.commentedUserName)){ params.get("dataType") collect { - case t if t == "html" => html.editcomment( - x.content, x.commentId, x.userName, x.repositoryName) + case t if t == "html" => html.editcomment(x.content, x.commentId, repository) } getOrElse { contentType = formats("json") org.json4s.jackson.Serialization.write( diff --git a/src/main/scala/gitbucket/core/plugin/CompletionProposalProvider.scala b/src/main/scala/gitbucket/core/plugin/CompletionProposalProvider.scala index f2d77a4..4bf94de 100644 --- a/src/main/scala/gitbucket/core/plugin/CompletionProposalProvider.scala +++ b/src/main/scala/gitbucket/core/plugin/CompletionProposalProvider.scala @@ -1,6 +1,7 @@ package gitbucket.core.plugin import gitbucket.core.controller.Context +import gitbucket.core.service.RepositoryService.RepositoryInfo import gitbucket.core.util.EmojiUtil trait CompletionProposalProvider { @@ -8,28 +9,29 @@ val id: String val prefix: String val suffix: String = " " - val values: Seq[String] val context: Seq[String] + def values(repository: RepositoryInfo): Seq[String] def template(implicit context: Context): String = "value" def additionalScript(implicit context: Context): String = "" + } class EmojiCompletionProposalProvider extends CompletionProposalProvider { override val id: String = "emoji" - override val values: Seq[String] = EmojiUtil.emojis.toSeq override val prefix: String = ":" override val suffix: String = ": " override val context: Seq[String] = Seq("wiki", "issues") + override def values(repository: RepositoryInfo): Seq[String] = EmojiUtil.emojis.toSeq override def template(implicit context: Context): String = s"""'' + value""" } class UserCompletionProposalProvider extends CompletionProposalProvider { override val id: String = "user" - override val values: Seq[String] = Nil override val prefix: String = "@" override val context: Seq[String] = Seq("issues") + override def values(repository: RepositoryInfo): Seq[String] = Nil override def template(implicit context: Context): String = "'@' + value" override def additionalScript(implicit context: Context): String = s"""$$.get('${context.path}/_user/proposals', { query: '' }, function (data) { user = data.options; });""" diff --git a/src/main/twirl/gitbucket/core/helper/attached.scala.html b/src/main/twirl/gitbucket/core/helper/attached.scala.html index 4620906..b2eeb0b 100644 --- a/src/main/twirl/gitbucket/core/helper/attached.scala.html +++ b/src/main/twirl/gitbucket/core/helper/attached.scala.html @@ -1,4 +1,5 @@ -@(owner: String, repository: String, completionContext: String, generateScript: Boolean = true)(textarea: Html)(implicit context: gitbucket.core.controller.Context) +@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo, + completionContext: String, generateScript: Boolean = true)(textarea: Html)(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.util.{FileUtil, EmojiUtil} @import gitbucket.core.view.helpers
@@ -10,7 +11,7 @@ $(function(){ @gitbucket.core.plugin.PluginRegistry().getCompletionProposalProviders.map { provider => @if(provider.context.contains(completionContext)){ - var @provider.id = @Html(helpers.json(provider.values)); + var @provider.id = @Html(helpers.json(provider.values(repository))); @Html(provider.additionalScript) } } @@ -46,14 +47,14 @@ @if(generateScript){ try { $([$('#@textareaId').closest('div')[0], $('#@textareaId').next('div')[0]]).dropzone({ - url: '@context.path/upload/file/@owner/@repository', + url: '@context.path/upload/file/@repository.owner/@repository.name', maxFilesize: 10, acceptedFiles: @Html(FileUtil.mimeTypeWhiteList.mkString("'", ",", "'")), dictInvalidFileType: 'Unfortunately, we don\'t support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, or PDF.', previewTemplate: "
\n
Uploading your files...
\n
\n
", success: function(file, id) { var attachFile = (file.type.match(/image\/.*/) ? '\n![' + file.name.split('.')[0] : '\n[' + file.name) + - '](@context.baseUrl/@owner/@repository/_attached/' + id + ')'; + '](@context.baseUrl/@repository.owner/@repository.name/_attached/' + id + ')'; $('#@textareaId').val($('#@textareaId').val() + attachFile); $(file.previewElement).prevAll('div.dz-preview').addBack().remove(); } diff --git a/src/main/twirl/gitbucket/core/helper/preview.scala.html b/src/main/twirl/gitbucket/core/helper/preview.scala.html index 52d74c5..e338ebc 100644 --- a/src/main/twirl/gitbucket/core/helper/preview.scala.html +++ b/src/main/twirl/gitbucket/core/helper/preview.scala.html @@ -28,8 +28,7 @@ @if(styleClass.nonEmpty){ class="@styleClass" }>@content } @gitbucket.core.helper.html.attached( - owner = repository.owner, - repository = repository.name, + repository = repository, completionContext = completionContext, generateScript = enableWikiLink )(textarea) diff --git a/src/main/twirl/gitbucket/core/issues/editcomment.scala.html b/src/main/twirl/gitbucket/core/issues/editcomment.scala.html index da96b9c..87a2a6b 100644 --- a/src/main/twirl/gitbucket/core/issues/editcomment.scala.html +++ b/src/main/twirl/gitbucket/core/issues/editcomment.scala.html @@ -1,6 +1,7 @@ -@(content: String, commentId: Int, owner: String, repository: String)(implicit context: gitbucket.core.controller.Context) +@(content: String, commentId: Int, + repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) -@gitbucket.core.helper.html.attached(owner, repository, "issues"){ +@gitbucket.core.helper.html.attached(repository, "issues"){ }
@@ -18,7 +19,7 @@ $('#update-comment-@commentId').click(function(){ $('#update-comment-@commentId, #cancel-comment-@commentId').attr('disabled', 'disabled'); $.ajax({ - url: '@context.path/@owner/@repository/issue_comments/edit/@commentId', + url: '@context.path/@repository.owner/@repository.name/issue_comments/edit/@commentId', type: 'POST', data: { issueId : 0, // TODO @@ -34,7 +35,7 @@ $('#cancel-comment-@commentId').click(function(){ $('#update-comment-@commentId, #cancel-comment-@commentId').attr('disabled', 'disabled'); - $.get('@context.path/@owner/@repository/issue_comments/_data/@commentId', callback); + $.get('@context.path/@repository.owner/@repository.name/issue_comments/_data/@commentId', callback); return false; }); }); diff --git a/src/main/twirl/gitbucket/core/issues/editissue.scala.html b/src/main/twirl/gitbucket/core/issues/editissue.scala.html index 257aa67..3ff2482 100644 --- a/src/main/twirl/gitbucket/core/issues/editissue.scala.html +++ b/src/main/twirl/gitbucket/core/issues/editissue.scala.html @@ -1,5 +1,6 @@ -@(content: Option[String], issueId: Int, owner: String, repository: String)(implicit context: gitbucket.core.controller.Context) -@gitbucket.core.helper.html.attached(owner, repository, "issues"){ +@(content: Option[String], issueId: Int, + repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) +@gitbucket.core.helper.html.attached(repository, "issues"){ }
@@ -16,7 +17,7 @@ $('#update-issue').click(function(){ $('#update, #cancel').attr('disabled', 'disabled'); $.ajax({ - url: '@context.path/@owner/@repository/issues/edit/@issueId', + url: '@context.path/@repository.owner/@repository.name/issues/edit/@issueId', type: 'POST', data: { content : $('#edit-content').val() @@ -30,7 +31,7 @@ $('#cancel-issue').click(function(){ $('#update, #cancel').attr('disabled', 'disabled'); - $.get('@context.path/@owner/@repository/issues/_data/@issueId', callback); + $.get('@context.path/@repository.owner/@repository.name/issues/_data/@issueId', callback); return false; }); }); diff --git a/src/main/twirl/gitbucket/core/repo/editcomment.scala.html b/src/main/twirl/gitbucket/core/repo/editcomment.scala.html index f278782..88e740e 100644 --- a/src/main/twirl/gitbucket/core/repo/editcomment.scala.html +++ b/src/main/twirl/gitbucket/core/repo/editcomment.scala.html @@ -1,6 +1,7 @@ -@(content: String, commentId: Int, owner: String, repository: String)(implicit context: gitbucket.core.controller.Context) +@(content: String, commentId: Int, + repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) -@gitbucket.core.helper.html.attached(owner, repository, "issues"){ +@gitbucket.core.helper.html.attached(repository, "issues"){ }
@@ -21,7 +22,7 @@ $box = $(this).closest('.commit-comment-box'); $('.update-comment-@commentId, .cancel-comment-@commentId', $box).attr('disabled', 'disabled'); $.ajax({ - url: '@context.path/@owner/@repository/commit_comments/edit/@commentId', + url: '@context.path/@repository.owner/@repository.name/commit_comments/edit/@commentId', type: 'POST', data: { content : $('#edit-content-@commentId', $box).val() @@ -37,7 +38,7 @@ $(document).on('click', '.cancel-comment-@commentId', function(){ $box = $(this).closest('.box'); $('.update-comment-@commentId, .cancel-comment-@commentId', $box).attr('disabled', 'disabled'); - $.get('@context.path/@owner/@repository/commit_comments/_data/@commentId', curriedCallback($box)); + $.get('@context.path/@repository.owner/@repository.name/commit_comments/_data/@commentId', curriedCallback($box)); return false; }); });