form in edit template; name changes; assets.go in debug mode
parent
5d7de7902e
commit
e7e58debad
173
assets/assets.go
173
assets/assets.go
File diff suppressed because one or more lines are too long
12
edit/edit.go
12
edit/edit.go
|
@ -8,8 +8,8 @@ import (
|
||||||
"github.com/hacdias/caddy-hugo/page"
|
"github.com/hacdias/caddy-hugo/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
type editPage struct {
|
type info struct {
|
||||||
Var1 string
|
File string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute sth
|
// Execute sth
|
||||||
|
@ -27,12 +27,12 @@ func Execute(w http.ResponseWriter, r *http.Request, file string) (int, error) {
|
||||||
return 500, err
|
return 500, err
|
||||||
}
|
}
|
||||||
|
|
||||||
editInfo := new(editPage)
|
inf := new(info)
|
||||||
editInfo.Var1 = string(file)
|
inf.File = string(file)
|
||||||
|
|
||||||
page := new(page.Info)
|
page := new(page.Page)
|
||||||
page.Title = "Edit"
|
page.Title = "Edit"
|
||||||
page.Body = editInfo
|
page.Body = inf
|
||||||
return page.Render("edit", w)
|
return page.Render("edit", w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@ const (
|
||||||
footerMark = "{{#FOOTER#}}"
|
footerMark = "{{#FOOTER#}}"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Info type
|
// Page type
|
||||||
type Info struct {
|
type Page struct {
|
||||||
Title string
|
Title string
|
||||||
Body interface{}
|
Body interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the page
|
// Render the page
|
||||||
func (p *Info) Render(name string, w http.ResponseWriter) (int, error) {
|
func (p *Page) Render(name string, w http.ResponseWriter) (int, error) {
|
||||||
rawHeader, err := assets.Asset("templates/header" + templateExtension)
|
rawHeader, err := assets.Asset("templates/header" + templateExtension)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
{{#HEADER#}}
|
{{#HEADER#}}
|
||||||
|
|
||||||
<textarea>{{ .Body.Var1 }}</textarea>
|
{{ with .Body }}
|
||||||
|
|
||||||
|
<form id="editForm" method="POST" action="">
|
||||||
|
<textarea id="content">{{ .File }}</textarea>
|
||||||
|
<input type="submit" value="Send">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
{{#FOOTER#}}
|
{{#FOOTER#}}
|
||||||
|
|
Loading…
Reference in New Issue