From 5968111f3e73cf05e2f5afa685a9ebae00ce4a3d Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 29 Jul 2017 11:02:18 +0100 Subject: [PATCH] Working at least Former-commit-id: ec78da37b86f172b600dd5568196e0d3515d806d [formerly 3728442230a2e87402eca56380ef3858d14d87f2] [formerly d714694ae051f1f10b0e815d68a9e49eadfc89b7 [formerly 46fdd869a5a3c8cb132e9dcbf3ace48038a99ce8]] Former-commit-id: 05a4f1eba2f0c8d7c6f4591805222195eb849144 [formerly c813a9d09fbe2c30bda1e1ad135bdd3b35cc61f6] Former-commit-id: 12f1a7003f0a0c6c514bd72f1eee20c0e0f4453f --- filemanager.go | 6 ++++++ plugins/hugo.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/filemanager.go b/filemanager.go index c615faeb..ef14c62e 100644 --- a/filemanager.go +++ b/filemanager.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "os/exec" + "reflect" "regexp" "strings" @@ -286,6 +287,10 @@ func (m *FileManager) SetBaseURL(url string) { // ActivatePlugin activates a plugin to a File Manager instance and // loads its options from the database. 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 if p, ok := plugins[name]; !ok { @@ -379,6 +384,7 @@ func (m *FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) if err != nil { + log.Print(err) w.Write([]byte(err.Error())) } else { w.Write([]byte(http.StatusText(code))) diff --git a/plugins/hugo.go b/plugins/hugo.go index dface2b7..ca981229 100644 --- a/plugins/hugo.go +++ b/plugins/hugo.go @@ -117,7 +117,7 @@ func (h Hugo) undraft(file string) error { type hugo struct{} 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 // request for the acutual path.