Skip to content

Commit 959c46a

Browse files
committed
Use profileTabs extension point intead of javaScripts
1 parent a109302 commit 959c46a

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

Diff for: build.sbt

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ val Organization = "gitbucket"
22
val Name = "gitbucket-gist-plugin"
33
val Version = "3.14.0-SNAPSHOT"
44

5+
lazy val root = (project in file(".")).enablePlugins(SbtTwirl)
6+
57
organization := Organization
68
name := Name
79
version := Version
@@ -18,5 +20,5 @@ libraryDependencies ++= Seq(
1820
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
1921
)
2022

21-
scalacOptions := Seq("-deprecation", "-language:postfixOps")
23+
scalacOptions := Seq("-deprecation", "-feature", "-language:postfixOps")
2224
javacOptions in compile ++= Seq("-target", "7", "-source", "7")

Diff for: project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
logLevel := Level.Warn
22

3-
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.2")
3+
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.4")

Diff for: src/main/scala/Plugin.scala

+19-18
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,27 @@ class Plugin extends gitbucket.core.plugin.Plugin {
4646
)
4747

4848
override val globalMenus = Seq(
49-
new GlobalMenu {
50-
override def createLink(context: Context): Option[(String, String)] = Some("Snippets" -> "gist")
51-
}
49+
(context: Context) => Some(Link("snippets", "Snippets", "gist"))
50+
)
51+
override val profileTabs = Seq(
52+
(account: Account, context: Context) => Some(Link("snippets", "Snippets", s"gist/${account.userName}/_profile"))
5253
)
5354

54-
override def javaScripts(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, String)] = {
55-
// Add Snippet link to the header
56-
val path = settings.baseUrl.getOrElse(context.getContextPath)
57-
Seq(
58-
".*" -> s"""
59-
|var accountName = $$('div.account-username').text();
60-
|if(accountName != ''){
61-
| var active = location.href.endsWith('_profile');
62-
| $$('li:has(a:contains(Public Activity))').after(
63-
| $$('<li' + (active ? ' class="active"' : '') + '><a href="${path}/gist/' + accountName + '/_profile">Snippets</a></li>')
64-
| );
65-
|}
66-
""".stripMargin
67-
)
68-
}
55+
// override def javaScripts(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, String)] = {
56+
// // Add Snippet link to the header
57+
// val path = settings.baseUrl.getOrElse(context.getContextPath)
58+
// Seq(
59+
// ".*" -> s"""
60+
// |var accountName = $$('div.account-username').text();
61+
// |if(accountName != ''){
62+
// | var active = location.href.endsWith('_profile');
63+
// | $$('li:has(a:contains(Public Activity))').after(
64+
// | $$('<li' + (active ? ' class="active"' : '') + '><a href="${path}/gist/' + accountName + '/_profile">Snippets</a></li>')
65+
// | );
66+
// |}
67+
// """.stripMargin
68+
// )
69+
// }
6970
}
7071

7172
class GistRepositoryFilter extends GitRepositoryFilter with AccountService {

Diff for: src/main/scala/gitbucket/gist/service/GistCommentService.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gitbucket.gist.service
22

3+
import scala.language.reflectiveCalls
34
import gitbucket.gist.model.GistComment
45
import gitbucket.gist.model.Profile._
56
import profile.simple._

0 commit comments

Comments
 (0)