2023-07-16 19:48:39 +00:00
|
|
|
package entrytypes
|
|
|
|
|
2023-07-19 18:54:18 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"owl-blogs/domain/model"
|
|
|
|
"owl-blogs/render"
|
|
|
|
)
|
2023-07-09 19:04:59 +00:00
|
|
|
|
|
|
|
type Note struct {
|
2023-07-16 19:48:39 +00:00
|
|
|
model.EntryBase
|
2023-07-09 19:04:59 +00:00
|
|
|
meta NoteMetaData
|
|
|
|
}
|
|
|
|
|
|
|
|
type NoteMetaData struct {
|
2024-02-21 19:04:22 +00:00
|
|
|
Content string
|
2023-07-09 19:04:59 +00:00
|
|
|
}
|
|
|
|
|
2024-02-14 20:05:50 +00:00
|
|
|
// Form implements model.EntryMetaData.
|
|
|
|
func (meta *NoteMetaData) Form(binSvc model.BinaryStorageInterface) string {
|
|
|
|
f, _ := render.RenderTemplateToString("forms/Note", meta)
|
|
|
|
return f
|
|
|
|
}
|
|
|
|
|
|
|
|
// ParseFormData implements model.EntryMetaData.
|
2024-02-21 19:24:18 +00:00
|
|
|
func (meta *NoteMetaData) ParseFormData(data model.HttpFormData, binSvc model.BinaryStorageInterface) error {
|
|
|
|
meta.Content = data.FormValue("content")
|
|
|
|
return nil
|
2024-02-14 20:05:50 +00:00
|
|
|
}
|
|
|
|
|
2023-07-09 19:04:59 +00:00
|
|
|
func (e *Note) Title() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2023-07-16 19:48:39 +00:00
|
|
|
func (e *Note) Content() model.EntryContent {
|
2023-07-19 18:54:18 +00:00
|
|
|
str, err := render.RenderTemplateToString("entry/Note", e)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
return model.EntryContent(str)
|
2023-07-09 19:04:59 +00:00
|
|
|
}
|
|
|
|
|
2024-02-13 20:43:52 +00:00
|
|
|
func (e *Note) MetaData() model.EntryMetaData {
|
2023-07-09 19:04:59 +00:00
|
|
|
return &e.meta
|
|
|
|
}
|
|
|
|
|
2024-02-13 20:43:52 +00:00
|
|
|
func (e *Note) SetMetaData(metaData model.EntryMetaData) {
|
2023-07-09 19:04:59 +00:00
|
|
|
e.meta = *metaData.(*NoteMetaData)
|
|
|
|
}
|