-
Notifications
You must be signed in to change notification settings - Fork 21
/
place_event.go
59 lines (47 loc) · 1.29 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
56
57
58
59
package html
import (
"io"
"github.com/elliotchance/gedcom/v39"
"github.com/elliotchance/gedcom/v39/html/core"
)
type PlaceEvent struct {
node gedcom.Node
document *gedcom.Document
visibility LivingVisibility
placesMap map[string]*place
}
func NewPlaceEvent(document *gedcom.Document, node gedcom.Node, visibility LivingVisibility, placesMap map[string]*place) *PlaceEvent {
return &PlaceEvent{
document: document,
node: node,
visibility: visibility,
placesMap: placesMap,
}
}
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, c.placesMap)
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)
}