diff --git a/cmd/owl/main.go b/cmd/owl/main.go index a51435d..00bce55 100644 --- a/cmd/owl/main.go +++ b/cmd/owl/main.go @@ -31,6 +31,7 @@ func App(db infra.Database) *web.WebApp { registry := app.NewEntryTypeRegistry() registry.Register(&model.ImageEntry{}) + registry.Register(&model.PostEntry{}) entryRepo := infra.NewEntryRepository(db, registry) binRepo := infra.NewBinaryFileRepo(db) diff --git a/domain/model/post_entry.go b/domain/model/post_entry.go new file mode 100644 index 0000000..ad4c336 --- /dev/null +++ b/domain/model/post_entry.go @@ -0,0 +1,37 @@ +package model + +import "time" + +type PostEntry struct { + id string + publishedAt *time.Time + meta PostEntryMetaData +} + +type PostEntryMetaData struct { + Title string `owl:"inputType=text"` + Content string `owl:"inputType=text widget=textarea"` +} + +func (e *PostEntry) ID() string { + return e.id +} + +func (e *PostEntry) Content() EntryContent { + return EntryContent(e.meta.Content) +} + +func (e *PostEntry) PublishedAt() *time.Time { + return e.publishedAt +} + +func (e *PostEntry) MetaData() interface{} { + return &e.meta +} + +func (e *PostEntry) Create(id string, publishedAt *time.Time, metaData EntryMetaData) error { + e.id = id + e.publishedAt = publishedAt + e.meta = *metaData.(*PostEntryMetaData) + return nil +} diff --git a/web/templates/views/entry/PostEntry.tmpl b/web/templates/views/entry/PostEntry.tmpl new file mode 100644 index 0000000..2ddd89e --- /dev/null +++ b/web/templates/views/entry/PostEntry.tmpl @@ -0,0 +1,17 @@ +{{define "title"}}{{.MetaData.Title}}{{end}} + +{{define "main"}} + +

{{.MetaData.Title}}

+ +

+{{.Content}} +

+ +

+ Published: {{.PublishedAt}} +

+ + +{{end}} +