-
Notifications
You must be signed in to change notification settings - Fork 20
/
individual_event.go
41 lines (36 loc) 路 1.11 KB
/
individual_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
package html
import (
"github.com/elliotchance/gedcom"
"github.com/elliotchance/gedcom/html/core"
"io"
)
// IndividualEvent is a row in the "Events" section of the individuals page.
type IndividualEvent struct {
date string
place string
description core.Component
event gedcom.Node
individual *gedcom.IndividualNode
}
func NewIndividualEvent(date, place string, description core.Component, individual *gedcom.IndividualNode, event gedcom.Node) *IndividualEvent {
return &IndividualEvent{
date: date,
place: place,
description: description,
individual: individual,
event: event,
}
}
func (c *IndividualEvent) WriteHTMLTo(w io.Writer) (int64, error) {
kind := c.event.Tag().String()
placeName := prettyPlaceName(c.place)
placeLink := NewPlaceLink(c.individual.Document(), placeName)
age := NewAge(c.individual.AgeAt(c.event))
return core.NewTableRow(
core.NewTableCell(age).NoWrap(),
core.NewTableCell(core.NewText(kind)).Header(),
core.NewTableCell(core.NewText(c.date)),
core.NewTableCell(placeLink),
core.NewTableCell(c.description),
).WriteHTMLTo(w)
}