add editor and frontmatter thing

This commit is contained in:
Henrique Dias
2016-06-23 23:21:44 +01:00
parent 8b7c83539a
commit ddc6839d24
13 changed files with 897 additions and 282 deletions

View File

@@ -27,6 +27,7 @@ type FileInfo struct {
Mode os.FileMode
Mimetype string
Content string
Raw []byte
Type string
}
@@ -85,6 +86,7 @@ func (fi *FileInfo) Read() error {
}
fi.Mimetype = http.DetectContentType(raw)
fi.Content = string(raw)
fi.Raw = raw
return nil
}
@@ -164,6 +166,17 @@ func (fi *FileInfo) serveSingleFile(w http.ResponseWriter, r *http.Request, c *C
},
}
if CanBeEdited(fi.Name) {
editor, err := fi.GetEditor()
if err != nil {
return http.StatusInternalServerError, err
}
page.Info.Data = editor
return page.PrintAsHTML(w, "frontmatter", "editor")
}
return page.PrintAsHTML(w, "single")
}