Пример #1
0
func AdminPlugin(context *GoInk.Context) {
	if context.Method == "POST" {
		action := context.String("action")
		if action == "" {
			Json(context, false).End()
			return
		}
		pln := context.String("plugin")
		if action == "activate" {
			plugin.Activate(pln)
			plugin.Update(context.App())
			Json(context, true).End()
			context.Do("plugin_activated", pln)
			return
		}
		if action == "deactivate" {
			plugin.Deactivate(pln)
			Json(context, true).End()
			context.Do("plugin_deactivated", pln)
			return
		}
		context.Status = 405
		Json(context, false).End()
		return
	}
	context.Layout("admin/admin")
	context.Render("admin/plugin", map[string]interface{}{
		"Title":   "插件",
		"Plugins": plugin.GetPlugins(),
	})
}
Пример #2
0
// Init starts Fxh.Go application preparation.
// Load models and plugins, update views.
func Init() {

	// init storage
	model.Init(VERSION)

	// load all data
	model.All()

	// init plugin
	plugin.Init()

	// update plugin handlers
	plugin.Update(App)

	App.View().FuncMap["DateInt64"] = utils.DateInt64
	App.View().FuncMap["DateString"] = utils.DateString
	App.View().FuncMap["DateTime"] = utils.DateTime
	App.View().FuncMap["Now"] = utils.Now
	App.View().FuncMap["Html2str"] = utils.Html2str
	App.View().FuncMap["FileSize"] = utils.FileSize
	App.View().FuncMap["Setting"] = model.GetSetting
	App.View().FuncMap["Navigator"] = model.GetNavigators
	App.View().FuncMap["Md2html"] = utils.Markdown2HtmlTemplate
	App.View().IsCache = (model.GetSetting("theme_cache") == "true")

	println("app version @ " + strconv.Itoa(model.GetVersion().Version))
}