Skip to content

Commit

Permalink
form in edit template; name changes; assets.go in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Sep 13, 2015
1 parent 5d7de79 commit e7e58de
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 118 deletions.
165 changes: 57 additions & 108 deletions assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions edit/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/hacdias/caddy-hugo/page"
)

type editPage struct {
Var1 string
type info struct {
File string
}

// Execute sth
Expand All @@ -27,12 +27,12 @@ func Execute(w http.ResponseWriter, r *http.Request, file string) (int, error) {
return 500, err
}

editInfo := new(editPage)
editInfo.Var1 = string(file)
inf := new(info)
inf.File = string(file)

page := new(page.Info)
page := new(page.Page)
page.Title = "Edit"
page.Body = editInfo
page.Body = inf
return page.Render("edit", w)
}

Expand Down
6 changes: 3 additions & 3 deletions page/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ const (
footerMark = "{{#FOOTER#}}"
)

// Info type
type Info struct {
// Page type
type Page struct {
Title string
Body interface{}
}

// 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)

if err != nil {
Expand Down
9 changes: 8 additions & 1 deletion templates/edit.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{{#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#}}

0 comments on commit e7e58de

Please sign in to comment.