diff --git a/src/main/scala/gitbucket/core/controller/IndexController.scala b/src/main/scala/gitbucket/core/controller/IndexController.scala index 9c2758074..0188d34f8 100644 --- a/src/main/scala/gitbucket/core/controller/IndexController.scala +++ b/src/main/scala/gitbucket/core/controller/IndexController.scala @@ -13,8 +13,8 @@ import gitbucket.core.util.* import gitbucket.core.view.helpers.* import org.scalatra.Ok import org.scalatra.forms.* - import gitbucket.core.service.ActivityService.* +import gitbucket.core.view.helpers class IndexController extends IndexControllerBase @@ -92,6 +92,10 @@ trait IndexControllerBase extends ControllerBase { } } + get("/_is_renderable") { + helpers.isRenderable(params("filename")) + } + get("/signin") { if (context.loginAccount.nonEmpty) { redirect("/") diff --git a/src/main/twirl/gitbucket/core/repo/editor.scala.html b/src/main/twirl/gitbucket/core/repo/editor.scala.html index a3735a924..4aa2ce9de 100644 --- a/src/main/twirl/gitbucket/core/repo/editor.scala.html +++ b/src/main/twirl/gitbucket/core/repo/editor.scala.html @@ -208,29 +208,31 @@ $(function(){ $('#preview').show(); $('#btn-code').removeClass('active'); - @if(fileName.map(helpers.isRenderable _).getOrElse(false)) { - // update preview - $('#preview').html(' Previewing...'); - $.post('@helpers.url(repository)/_preview', { - content : editor.getValue(), - enableWikiLink : false, - filename : $('#newFileName').val(), - enableRefsLink : false, - enableLineBreaks : false, - enableTaskList : false - }, function(data){ - $('#preview').empty().append( - $('
').html(data)); - prettyPrint(); - }); - } else { - // Show diff - $('#preview').empty() - .append($('
')) - .append($('