diff --git a/src/main/scala/gitbucket/core/plugin/Plugin.scala b/src/main/scala/gitbucket/core/plugin/Plugin.scala index c82558e..caaf726 100644 --- a/src/main/scala/gitbucket/core/plugin/Plugin.scala +++ b/src/main/scala/gitbucket/core/plugin/Plugin.scala @@ -150,16 +150,6 @@ def dashboardTabs(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(Context) => Option[Link]] = Nil /** - * Override to add text decorators. - */ - val textDecorators: Seq[TextDecorator] = Nil - - /** - * Override to add text decorators. - */ - def textDecorators(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[TextDecorator] = Nil - - /** * This method is invoked in initialization of plugin system. * Register plugin functionality to PluginRegistry. */ @@ -203,9 +193,6 @@ (dashboardTabs ++ dashboardTabs(registry, context, settings)).foreach { dashboardTab => registry.addDashboardTab(dashboardTab) } - (textDecorators ++ textDecorators(registry, context, settings)).foreach { textDecorator => - registry.addTextDecorator(textDecorator) - } } /** diff --git a/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala b/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala index 04b9fb7..d784d87 100644 --- a/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala +++ b/src/main/scala/gitbucket/core/plugin/PluginRegistory.scala @@ -42,8 +42,6 @@ private val systemSettingMenus = new ListBuffer[(Context) => Option[Link]] private val accountSettingMenus = new ListBuffer[(Context) => Option[Link]] private val dashboardTabs = new ListBuffer[(Context) => Option[Link]] - private val textDecorators = new ListBuffer[TextDecorator] - textDecorators += new EmojiDecorator() def addPlugin(pluginInfo: PluginInfo): Unit = { plugins += pluginInfo @@ -161,12 +159,6 @@ def getDashboardTabs: Seq[(Context) => Option[Link]] = dashboardTabs.toSeq - def addTextDecorator(textDecorator: TextDecorator): Unit = { - textDecorators += textDecorator - } - - def getTextDecorators: Seq[TextDecorator] = textDecorators.toSeq - } /** diff --git a/src/main/scala/gitbucket/core/plugin/TextDecorator.scala b/src/main/scala/gitbucket/core/plugin/TextDecorator.scala deleted file mode 100644 index 2de1d0c..0000000 --- a/src/main/scala/gitbucket/core/plugin/TextDecorator.scala +++ /dev/null @@ -1,20 +0,0 @@ -package gitbucket.core.plugin - -import gitbucket.core.controller.Context -import gitbucket.core.service.RepositoryService.RepositoryInfo -import gitbucket.core.util.EmojiUtil - -trait TextDecorator { - - def decorate(text: String)(implicit context: Context): String - - def decorate(text: String, repositoryInfo: RepositoryInfo)(implicit context: Context): String = decorate(text) - -} - -class EmojiDecorator extends TextDecorator { - - override def decorate(text: String)(implicit context: Context): String = EmojiUtil.convertEmojis(text) - -} - diff --git a/src/main/scala/gitbucket/core/view/Markdown.scala b/src/main/scala/gitbucket/core/view/Markdown.scala index d30e623..49ceeed 100644 --- a/src/main/scala/gitbucket/core/view/Markdown.scala +++ b/src/main/scala/gitbucket/core/view/Markdown.scala @@ -44,7 +44,7 @@ val renderer = new GitBucketMarkedRenderer(options, repository, enableWikiLink, enableRefsLink, enableAnchor, enableTaskList, hasWritePermission, pages) - helpers.decorateHtml(Marked.marked(source, options, renderer)) + helpers.decorateHtml(Marked.marked(source, options, renderer), repository) } /** diff --git a/src/main/scala/gitbucket/core/view/helpers.scala b/src/main/scala/gitbucket/core/view/helpers.scala index a7437b6..9a64b01 100644 --- a/src/main/scala/gitbucket/core/view/helpers.scala +++ b/src/main/scala/gitbucket/core/view/helpers.scala @@ -6,8 +6,9 @@ import gitbucket.core.controller.Context import gitbucket.core.model.CommitState import gitbucket.core.plugin.{PluginRegistry, RenderRequest} +import gitbucket.core.service.RepositoryService.RepositoryInfo import gitbucket.core.service.{RepositoryService, RequestCache} -import gitbucket.core.util.{FileUtil, JGitUtil, StringUtil} +import gitbucket.core.util.{EmojiUtil, FileUtil, JGitUtil, StringUtil} import org.jsoup.Jsoup import org.jsoup.nodes.{Element, Node} import play.twirl.api.{Html, HtmlFormat} @@ -152,7 +153,7 @@ * Converts commit id, issue id and username to the link. */ def link(value: String, repository: RepositoryService.RepositoryInfo)(implicit context: Context): Html = - Html(decorateHtml(convertRefsLinks(value, repository))) + Html(decorateHtml(convertRefsLinks(value, repository), repository)) def cut(value: String, length: Int): String = if(value.length > length){ @@ -342,16 +343,17 @@ * * TODO Move to the other place. */ - def decorateHtml(text: String)(implicit context: Context): String = { - val textDecorators = PluginRegistry().getTextDecorators + def decorateHtml(text: String, repository: RepositoryInfo)(implicit context: Context): String = { +// val textDecorators = PluginRegistry().getTextDecorators def processNode(n: Node): Unit = { n match { case x: Element => { if(x.hasText && x.ownText.nonEmpty){ - val text = textDecorators.foldLeft(x.ownText){ case (text, textDecorator) => - textDecorator.decorate(text) - } + val text = EmojiUtil.convertEmojis(x.ownText) +// val text = textDecorators.foldLeft(x.ownText){ case (text, textDecorator) => +// textDecorator.decorate(text, repository) +// } x.html(text) } x.children.toArray.foreach { c =>