mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15:51 +01:00
(refs #32)First impression of the plugin system
This commit is contained in:
35
src/main/scala/plugin/PluginSystem.scala
Normal file
35
src/main/scala/plugin/PluginSystem.scala
Normal file
@@ -0,0 +1,35 @@
|
||||
package plugin
|
||||
|
||||
import app.Context
|
||||
|
||||
/**
|
||||
* Provides extension points to plug-ins.
|
||||
*/
|
||||
object PluginSystem {
|
||||
|
||||
private val repositoryMenuList = scala.collection.mutable.ListBuffer[Menu]()
|
||||
private val globalMenuList = scala.collection.mutable.ListBuffer[Menu]()
|
||||
|
||||
case class Menu(label: String, url: String, icon: String, condition: Context => Boolean)
|
||||
|
||||
def addRepositoryMenu(label: String, url: String, icon: String = "")(condition: Context => Boolean): Unit = {
|
||||
repositoryMenuList += Menu(label, url, icon, condition)
|
||||
}
|
||||
|
||||
def addGlobalMenu(label: String, url: String, icon: String = "")(condition: Context => Boolean): Unit = {
|
||||
globalMenuList += Menu(label, url, icon, condition)
|
||||
}
|
||||
|
||||
def addAction(path: String): Unit = {
|
||||
// TODO
|
||||
}
|
||||
|
||||
def repositoryMenus: List[Menu] = repositoryMenuList.toList
|
||||
def globalMenus: List[Menu] = globalMenuList.toList
|
||||
|
||||
// TODO This is a test
|
||||
addGlobalMenu("Google", "http://www.google.co.jp/"){ context => context.loginAccount.isDefined }
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user