Skip to content

Commit a109302

Browse files
committed
Use globalMenus extension point
1 parent 97f0741 commit a109302

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/scala/Plugin.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gitbucket.core.controller.Context
12
import gitbucket.core.model._
23
import gitbucket.core.service.AccountService
34
import gitbucket.core.service.SystemSettingsService.SystemSettings
@@ -44,14 +45,17 @@ class Plugin extends gitbucket.core.plugin.Plugin {
4445
"/*" -> new GistController()
4546
)
4647

48+
override val globalMenus = Seq(
49+
new GlobalMenu {
50+
override def createLink(context: Context): Option[(String, String)] = Some("Snippets" -> "gist")
51+
}
52+
)
53+
4754
override def javaScripts(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, String)] = {
4855
// Add Snippet link to the header
4956
val path = settings.baseUrl.getOrElse(context.getContextPath)
5057
Seq(
5158
".*" -> s"""
52-
|$$('a.global-header-menu:last, nav.navbar input[name=query], a.navbar-brand').last().after(
53-
| $$('<a href="${path}/gist" class="global-header-menu">Snippets</a>')
54-
|);
5559
|var accountName = $$('div.account-username').text();
5660
|if(accountName != ''){
5761
| var active = location.href.endsWith('_profile');

0 commit comments

Comments
 (0)