rehome plugin hyperdrive to extend instead of main in the package def
clean up plugin hyperdrive
This commit is contained in:
parent
584a50b461
commit
b67b95ce98
|
@ -1,16 +1,16 @@
|
||||||
// Highly experimental plugin for caching rendered pages for guests
|
// Highly experimental plugin for caching rendered pages for guests
|
||||||
package main
|
package extend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"log"
|
//"log"
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
"sync/atomic"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
c "github.com/Azareal/Gosora/common"
|
c "github.com/Azareal/Gosora/common"
|
||||||
"github.com/Azareal/Gosora/routes"
|
"github.com/Azareal/Gosora/routes"
|
||||||
|
@ -22,21 +22,21 @@ func init() {
|
||||||
c.Plugins.Add(&c.Plugin{UName: "hyperdrive", Name: "Hyperdrive", Author: "Azareal", Init: initHdrive, Deactivate: deactivateHdrive})
|
c.Plugins.Add(&c.Plugin{UName: "hyperdrive", Name: "Hyperdrive", Author: "Azareal", Init: initHdrive, Deactivate: deactivateHdrive})
|
||||||
}
|
}
|
||||||
|
|
||||||
func initHdrive(plugin *c.Plugin) error {
|
func initHdrive(pl *c.Plugin) error {
|
||||||
hyperspace = newHyperspace()
|
hyperspace = newHyperspace()
|
||||||
plugin.AddHook("tasks_tick_topic_list",tickHdrive)
|
pl.AddHook("tasks_tick_topic_list", tickHdrive)
|
||||||
plugin.AddHook("tasks_tick_widget_wol",tickHdriveWol)
|
pl.AddHook("tasks_tick_widget_wol", tickHdriveWol)
|
||||||
plugin.AddHook("route_topic_list_start",jumpHdriveTopicList)
|
pl.AddHook("route_topic_list_start", jumpHdriveTopicList)
|
||||||
plugin.AddHook("route_forum_list_start",jumpHdriveForumList)
|
pl.AddHook("route_forum_list_start", jumpHdriveForumList)
|
||||||
tickHdrive()
|
tickHdrive()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func deactivateHdrive(plugin *c.Plugin) {
|
func deactivateHdrive(pl *c.Plugin) {
|
||||||
plugin.RemoveHook("tasks_tick_topic_list",tickHdrive)
|
pl.RemoveHook("tasks_tick_topic_list", tickHdrive)
|
||||||
plugin.RemoveHook("tasks_tick_widget_wol",tickHdriveWol)
|
pl.RemoveHook("tasks_tick_widget_wol", tickHdriveWol)
|
||||||
plugin.RemoveHook("route_topic_list_start",jumpHdriveTopicList)
|
pl.RemoveHook("route_topic_list_start", jumpHdriveTopicList)
|
||||||
plugin.RemoveHook("route_forum_list_start",jumpHdriveForumList)
|
pl.RemoveHook("route_forum_list_start", jumpHdriveForumList)
|
||||||
hyperspace = nil
|
hyperspace = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ func tickHdrive(args ...interface{}) (skip bool, rerr c.RouteError) {
|
||||||
fListMap := make(map[string][]byte)
|
fListMap := make(map[string][]byte)
|
||||||
gfListMap := make(map[string][]byte)
|
gfListMap := make(map[string][]byte)
|
||||||
|
|
||||||
var cacheTheme = func(tname string) (skip bool, fail bool, rerr c.RouteError) {
|
cacheTheme := func(tname string) (skip, fail bool, rerr c.RouteError) {
|
||||||
|
|
||||||
themeCookie := http.Cookie{Name: "current_theme", Value: tname, Path: "/", MaxAge: c.Year}
|
themeCookie := http.Cookie{Name: "current_theme", Value: tname, Path: "/", MaxAge: c.Year}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ func tickHdrive(args ...interface{}) (skip bool, rerr c.RouteError) {
|
||||||
return true, true, rerr
|
return true, true, rerr
|
||||||
}
|
}
|
||||||
|
|
||||||
rerr = routes.TopicList(w, req, user, head)
|
rerr = routes.TopicList(w, req, &user, head)
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
return true, true, rerr
|
return true, true, rerr
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ func tickHdrive(args ...interface{}) (skip bool, rerr c.RouteError) {
|
||||||
return true, true, rerr
|
return true, true, rerr
|
||||||
}
|
}
|
||||||
|
|
||||||
rerr = routes.ForumList(w, req, user, head)
|
rerr = routes.ForumList(w, req, &user, head)
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
return true, true, rerr
|
return true, true, rerr
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ func jumpHdriveForumList(args ...interface{}) (skip bool, rerr c.RouteError) {
|
||||||
return jumpHdrive(pg[theme.Name], p[theme.Name], args)
|
return jumpHdrive(pg[theme.Name], p[theme.Name], args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jumpHdrive(pg []byte, p []byte, args []interface{}) (skip bool, rerr c.RouteError) {
|
func jumpHdrive(pg, p []byte, args []interface{}) (skip bool, rerr c.RouteError) {
|
||||||
var tList []byte
|
var tList []byte
|
||||||
w := args[0].(http.ResponseWriter)
|
w := args[0].(http.ResponseWriter)
|
||||||
var iw http.ResponseWriter
|
var iw http.ResponseWriter
|
||||||
|
|
Loading…
Reference in New Issue