v2 #43

Merged
h4kor merged 41 commits from v2 into main 2023-07-19 19:09:19 +00:00
3 changed files with 55 additions and 0 deletions
Showing only changes of commit 1514e7533c - Show all commits

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