package pgenr import ( "git.nspix.com/golang/pgenr/element" "golang.org/x/net/html/atom" "html" ) type ( Page struct { Title string Head string Intros []element.Element Entries []*element.Entry Actions []*element.Action Timelines []*element.Timeline Tables []*element.Table Outros []element.Element Copyright string } ) func (page *Page) SetHead(s string) *Page { page.Head = s return page } func (page *Page) SetCopyright(s string) *Page { page.Copyright = s return page } func (page *Page) AddPlainIntro(s string) *Page { page.Intros = append(page.Intros, element.NewText(s, element.WithTextTag(atom.P))) return page } func (page *Page) AddIntro(ele element.Element) *Page { page.Intros = append(page.Intros, ele) return page } func (page *Page) AddEntry(e *element.Entry) *Page { page.Entries = append(page.Entries, e) return page } func (page *Page) AddTable(t *element.Table) *Page { page.Tables = append(page.Tables, t) return page } func (page *Page) AddTimeline(t *element.Timeline) *Page { page.Timelines = append(page.Timelines, t) return page } func (page *Page) AddButtonAction(s string, btn *element.Button) *Page { page.Actions = append(page.Actions, &element.Action{Instructions: element.NewText(s, element.WithTextTag(atom.P)), Button: btn}) return page } func (page *Page) AddInviteCodeAction(s string, code string) *Page { page.Actions = append(page.Actions, &element.Action{Instructions: element.NewText(s, element.WithTextTag(atom.P)), InviteCode: code}) return page } func (page *Page) AddOutro(ele element.Element) *Page { page.Outros = append(page.Outros, ele) return page } func (page *Page) AddPlainOutro(s string) *Page { page.Outros = append(page.Outros, element.NewText(s, element.WithTextTag(atom.P))) return page } func (page *Page) Escape() { page.Head = html.EscapeString(page.Head) page.Copyright = html.EscapeString(page.Copyright) } func NewPage(title string) *Page { return &Page{ Title: title, Intros: make([]element.Element, 0), Entries: make([]*element.Entry, 0), Actions: make([]*element.Action, 0), Timelines: make([]*element.Timeline, 0), Outros: make([]element.Element, 0), Tables: make([]*element.Table, 0), } }