2015-09-18 15:49:53 +00:00
|
|
|
package editor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
|
2015-09-20 08:15:21 +00:00
|
|
|
"github.com/hacdias/caddy-hugo/config"
|
2015-09-18 15:49:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type editor struct {
|
|
|
|
Name string
|
|
|
|
Class string
|
2015-09-25 20:06:29 +00:00
|
|
|
IsPost bool
|
2015-09-19 13:47:59 +00:00
|
|
|
Mode string
|
2015-09-18 15:49:53 +00:00
|
|
|
Content string
|
|
|
|
FrontMatter interface{}
|
2015-09-20 08:15:21 +00:00
|
|
|
Config *config.Config
|
2015-09-18 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2015-09-20 08:15:21 +00:00
|
|
|
// ServeHTTP serves the editor page
|
|
|
|
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
2015-09-18 15:49:53 +00:00
|
|
|
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
|
|
|
|
|
2015-09-26 21:02:49 +00:00
|
|
|
switch r.Method {
|
|
|
|
case "POST":
|
|
|
|
return POST(w, r, c, filename)
|
|
|
|
case "GET":
|
|
|
|
return GET(w, r, c, filename)
|
2015-09-19 13:25:35 +00:00
|
|
|
default:
|
|
|
|
return 400, nil
|
|
|
|
}
|
2015-09-19 13:47:59 +00:00
|
|
|
}
|