Working at least
parent
ae8e97a43e
commit
46fdd869a5
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -286,6 +287,10 @@ func (m *FileManager) SetBaseURL(url string) {
|
||||||
// ActivatePlugin activates a plugin to a File Manager instance and
|
// ActivatePlugin activates a plugin to a File Manager instance and
|
||||||
// loads its options from the database.
|
// loads its options from the database.
|
||||||
func (m *FileManager) ActivatePlugin(name string, options interface{}) error {
|
func (m *FileManager) ActivatePlugin(name string, options interface{}) error {
|
||||||
|
if reflect.TypeOf(options).Kind() != reflect.Ptr {
|
||||||
|
return errors.New("options should be a pointer to interface, not interface")
|
||||||
|
}
|
||||||
|
|
||||||
var plugin Plugin
|
var plugin Plugin
|
||||||
|
|
||||||
if p, ok := plugins[name]; !ok {
|
if p, ok := plugins[name]; !ok {
|
||||||
|
@ -379,6 +384,7 @@ func (m *FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Print(err)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
} else {
|
} else {
|
||||||
w.Write([]byte(http.StatusText(code)))
|
w.Write([]byte(http.StatusText(code)))
|
||||||
|
|
|
@ -117,7 +117,7 @@ func (h Hugo) undraft(file string) error {
|
||||||
type hugo struct{}
|
type hugo struct{}
|
||||||
|
|
||||||
func (h hugo) Before(c *filemanager.RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
func (h hugo) Before(c *filemanager.RequestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
o := c.FM.Plugins["hugo"].(Hugo)
|
o := c.FM.Plugins["hugo"].(*Hugo)
|
||||||
|
|
||||||
// If we are using the 'magic url' for the settings, we should redirect the
|
// If we are using the 'magic url' for the settings, we should redirect the
|
||||||
// request for the acutual path.
|
// request for the acutual path.
|
||||||
|
|
Loading…
Reference in New Issue