gosora/experimental/module_ottojs.go
Azareal bcaa646f68 Added an alternate topic layout. This might serve as the foundation of a second theme. You'll be able to switch between the two with ease once the theme system is in.
The profile route is now compiled again. A custom struct is now used for it instead of the generic Page struct.
Added the group list to the Control Panel.
Tweaked the navbar CSS.
Non-mods can no longer post in locked topics.
Locked topics now have a gray background on the topic view header, the forum view, and the topiclist,
The reply content box no longer shows up on topics which don't have any replies.
2016-12-26 04:44:07 +00:00

48 lines
912 B
Go

/* Copyright Azareal 2016 - 2017 */
package main
import "github.com/robertkrimen/otto"
var vm *Otto
var js_plugins map[string]*otto.Script = make(map[string]*otto.Script)
var js_vars map[string]*otto.Object = make(map[string]*otto.Object)
func init()
{
var err error
vm = otto.New()
js_vars["current_page"], err = vm.Object(`current_page = {}`)
if err != nil {
log.Fatal(err)
}
}
func js_add_plugin(plugin string) error
{
script, err := otto.Compile("./extend/" + plugin + ".js")
if err != nil {
return err
}
vm.Run(script)
return nil
}
func js_add_hook(hook string, plugin string)
{
hooks[hook] = func(data interface{}) interface{} {
switch d := data.(type) {
case Page:
current_page := js_vars["current_page"]
current_page.Set("Title", d.Title)
case TopicPage:
case ProfilePage:
case Reply:
default:
log.Print("Not a valid JS datatype")
}
}
}