-
Notifications
You must be signed in to change notification settings - Fork 20
/
place_event.go
55 lines (44 loc) 路 1.18 KB
/
place_event.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
47
48
49
50
51
52
53
54
55
package html
import (
"github.com/elliotchance/gedcom"
"github.com/elliotchance/gedcom/html/core"
"io"
)
type PlaceEvent struct {
node gedcom.Node
document *gedcom.Document
visibility LivingVisibility
}
func NewPlaceEvent(document *gedcom.Document, node gedcom.Node, visibility LivingVisibility) *PlaceEvent {
return &PlaceEvent{
document: document,
node: node,
visibility: visibility,
}
}
func (c *PlaceEvent) WriteHTMLTo(w io.Writer) (int64, error) {
date := ""
description := c.node.Tag().String()
d := gedcom.Dates(c.node).Minimum()
if d != nil {
date = d.Value()
}
individual := individualForNode(c.document, c.node)
var person core.Component = NewIndividualLink(c.document, individual, c.visibility)
isLiving := individual != nil && individual.IsLiving()
if isLiving {
switch c.visibility {
case LivingVisibilityHide:
return writeNothing()
case LivingVisibilityShow:
// Proceed.
case LivingVisibilityPlaceholder:
person = core.NewEmpty()
}
}
return core.NewTableRow(
core.NewTableCell(core.NewText(date)).NoWrap(),
core.NewTableCell(core.NewText(description)).NoWrap(),
core.NewTableCell(person).NoWrap(),
).WriteHTMLTo(w)
}