-
Notifications
You must be signed in to change notification settings - Fork 21
/
individual_link.go
51 lines (41 loc) · 1.36 KB
/
individual_link.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
package html
import (
"fmt"
"io"
"github.com/elliotchance/gedcom/v39"
"github.com/elliotchance/gedcom/v39/html/core"
)
// IndividualLink is a hyperlink to an individuals page. The link contains a
// coloured dot to represent their sex and their full name.
type IndividualLink struct {
individual *gedcom.IndividualNode
document *gedcom.Document
visibility LivingVisibility
placesMap map[string]*place
}
func NewIndividualLink(document *gedcom.Document, individual *gedcom.IndividualNode, visibility LivingVisibility, placesMap map[string]*place) *IndividualLink {
return &IndividualLink{
individual: individual,
document: document,
visibility: visibility,
placesMap: placesMap,
}
}
func (c *IndividualLink) WriteHTMLTo(w io.Writer) (int64, error) {
if c.individual.IsLiving() {
switch c.visibility {
case LivingVisibilityHide:
return writeNothing()
case LivingVisibilityShow, LivingVisibilityPlaceholder:
// Proceed.
}
}
dotColor := colorForIndividual(c.individual)
dotStyle := fmt.Sprintf("color: %s; font-size: 18px", dotColor)
dot := core.NewOcticon("primitive-dot", dotStyle)
individualName := NewIndividualName(c.individual, c.visibility,
UnknownEmphasis)
text := core.NewComponents(dot, individualName)
link := PageIndividual(c.document, c.individual, c.visibility, c.placesMap)
return core.NewLink(text, link).WriteHTMLTo(w)
}