Skip to content

Commit 3ad7472

Browse files
committed
Fix prefix path of the header link
1 parent ebed1e3 commit 3ad7472

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/scala/Plugin.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
import gitbucket.core.service.SystemSettingsService
12
import gitbucket.gist.controller.GistController
23
import gitbucket.core.plugin.PluginRegistry
34
import gitbucket.core.util.Version
45
import java.io.File
56
import javax.servlet.ServletContext
67
import gitbucket.gist.util.Configurations._
78

8-
class Plugin extends gitbucket.core.plugin.Plugin {
9+
class Plugin extends gitbucket.core.plugin.Plugin with SystemSettingsService {
910
override val pluginId: String = "gist"
1011
override val pluginName: String = "Gist Plugin"
1112
override val description: String = "Provides Gist feature on GitBucket."
1213
override val versions: List[Version] = List(Version(1, 0))
1314

1415
override def initialize(registry: PluginRegistry, context: ServletContext): Unit = {
1516
// Add Snippet link to the header
17+
val settings = loadSystemSettings()
18+
val path = settings.baseUrl.getOrElse(context.getContextPath)
1619
registry.addJavaScript(".*",
1720
s"""
1821
|$$('a.brand').after(
19-
| $$('<span style="float: left; margin-top: 10px;">|&nbsp;&nbsp;&nbsp;&nbsp;<a href="${context.getContextPath}/gist" style="color: black;">Snippet</a></span>')
22+
| $$('<span style="float: left; margin-top: 10px;">|&nbsp;&nbsp;&nbsp;&nbsp;<a href="${path}/gist" style="color: black;">Snippet</a></span>')
2023
|);
2124
""".stripMargin)
2225

0 commit comments

Comments
 (0)