dir2opds/opds/entry_builder.go

50 lines
1.3 KiB
Go
Raw Normal View History

package opds
2017-05-11 23:06:21 +00:00
import (
2018-03-03 20:12:41 +00:00
"time"
2017-05-11 23:06:21 +00:00
"github.com/lann/builder"
"golang.org/x/tools/blog/atom"
)
type entryBuilder builder.Builder
func (e entryBuilder) Title(title string) entryBuilder {
return builder.Set(e, "Title", title).(entryBuilder)
}
2018-03-03 20:12:41 +00:00
func (e entryBuilder) ID(id string) entryBuilder {
2017-05-11 23:06:21 +00:00
return builder.Set(e, "ID", id).(entryBuilder)
}
func (e entryBuilder) AddLink(link atom.Link) entryBuilder {
return builder.Append(e, "Link", link).(entryBuilder)
}
func (e entryBuilder) Published(published time.Time) entryBuilder {
return builder.Set(e, "Published", atom.Time(published)).(entryBuilder)
}
func (e entryBuilder) Updated(updated time.Time) entryBuilder {
return builder.Set(e, "Updated", atom.Time(updated)).(entryBuilder)
}
func (e entryBuilder) Author(author *atom.Person) entryBuilder {
return builder.Set(e, "Author", author).(entryBuilder)
}
func (e entryBuilder) Summary(summary *atom.Text) entryBuilder {
return builder.Set(e, "Summary", summary).(entryBuilder)
}
func (e entryBuilder) Content(content *atom.Text) entryBuilder {
return builder.Set(e, "Content", content).(entryBuilder)
}
func (e entryBuilder) Build() atom.Entry {
return builder.GetStruct(e).(atom.Entry)
}
2018-03-03 20:12:41 +00:00
// EntryBuilder is a fluent immutable builder to build OPDS entries
2017-05-11 23:06:21 +00:00
var EntryBuilder = builder.Register(entryBuilder{}, atom.Entry{}).(entryBuilder)