post entry

This commit is contained in:
Niko Abeler 2023-07-08 14:51:56 +02:00
parent e9e17ed263
commit 1514e7533c
3 changed files with 55 additions and 0 deletions

View File

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

View File

@ -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
}

View File

@ -0,0 +1,17 @@
{{define "title"}}{{.MetaData.Title}}{{end}}
{{define "main"}}
<h1>{{.MetaData.Title}}</h1>
<p>
{{.Content}}
</p>
<p>
Published: {{.PublishedAt}}
</p>
{{end}}