-
Notifications
You must be signed in to change notification settings - Fork 20
/
source_page.go
46 lines (40 loc) 路 1.13 KB
/
source_page.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package html
import (
"github.com/elliotchance/gedcom"
"github.com/elliotchance/gedcom/html/core"
"io"
)
type SourcePage struct {
document *gedcom.Document
source *gedcom.SourceNode
googleAnalyticsID string
options PublishShowOptions
}
func NewSourcePage(document *gedcom.Document, source *gedcom.SourceNode, googleAnalyticsID string, options PublishShowOptions) *SourcePage {
return &SourcePage{
document: document,
source: source,
googleAnalyticsID: googleAnalyticsID,
options: options,
}
}
func (c *SourcePage) WriteHTMLTo(w io.Writer) (int64, error) {
table := []core.Component{
core.NewTableHead("Key", "Value"),
}
for _, node := range c.source.Nodes() {
table = append(table, NewSourceProperty(c.document, node))
}
return core.NewPage(
c.source.Title(),
core.NewComponents(
NewPublishHeader(c.document, "Source", selectedExtraTab, c.options),
core.NewBigTitle(1, core.NewText(c.source.Title())),
core.NewSpace(),
core.NewRow(
core.NewColumn(core.EntireRow, core.NewTable("", table...)),
),
),
c.googleAnalyticsID,
).WriteHTMLTo(w)
}