update url routing, simplify; new templates

This commit is contained in:
Henrique Dias
2015-09-13 21:10:54 +01:00
parent 60eefa3915
commit 93b0ab8dd9
7 changed files with 32 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ import (
"io/ioutil"
"net/http"
"os"
"strings"
"github.com/hacdias/caddy-hugo/page"
"github.com/spf13/hugo/commands"
@@ -15,7 +16,9 @@ type fileInfo struct {
}
// Execute sth
func Execute(w http.ResponseWriter, r *http.Request, filename string) (int, error) {
func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
filename := strings.Replace(r.URL.Path, "edit/", "", 1)
if r.Method == "POST" {
r.ParseForm()
err := ioutil.WriteFile(filename, []byte(r.Form["content"][0]), 0666)