site

package
v0.0.0-...-a1877fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: Unlicense Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NarrativeSequenceIntro     = 0
	NarrativeSequenceEarlyLife = 1
	NarrativeSequenceLifeStory = 2
	NarrativeSequenceDeath     = 3
	NarrativeSequencePostDeath = 4
)
View Source
const (
	PageSectionPerson = "person"
	PageSectionPlace  = "place"
	PageSectionSource = "source"
	PageSectionList   = "list"
	PageSectionChart  = "chart"
	PageSectionMedia  = "media"
)
View Source
const (
	PageCategoryPerson = "person"
	PageCategorySource = "source"
	PageCategoryPlace  = "place"
)

Variables

View Source
var Command = &cli.Command{
	Name:   "gen",
	Usage:  "Generate a website from a gedcom file",
	Action: gen,
	Flags: append([]cli.Flag{
		&cli.StringFlag{
			Name:        "gedcom",
			Aliases:     []string{"g"},
			Usage:       "GEDCOM file to read from",
			Destination: &genopts.gedcomFile,
		},
		&cli.StringFlag{
			Name:        "gramps",
			Usage:       "Gramps xml file to read from",
			Destination: &genopts.grampsFile,
		},
		&cli.StringFlag{
			Name:        "gramps-dbname",
			Usage:       "Name of the gramps database, used to keep IDs consistent between versions of the same database",
			Destination: &genopts.grampsDatabaseName,
		},
		&cli.StringFlag{
			Name:        "id",
			Usage:       "Identifier to give this tree",
			Destination: &genopts.treeID,
		},
		&cli.StringFlag{
			Name:        "site",
			Aliases:     []string{"s"},
			Usage:       "Directory in which to write generated site",
			Destination: &genopts.rootDir,
		},
		&cli.StringFlag{
			Name:        "media",
			Usage:       "Directory in which to copy media files",
			Destination: &genopts.mediaDir,
		},
		&cli.StringFlag{
			Name:        "basepath",
			Aliases:     []string{"b"},
			Usage:       "Base URL path to use as a prefix to all links.",
			Value:       "/",
			Destination: &genopts.basePath,
		},
		&cli.StringFlag{
			Name:    "identity-map",
			Aliases: []string{"m"},
			Usage:   "Filename of identity mapping file",
		},
		&cli.StringFlag{
			Name:        "key",
			Aliases:     []string{"k"},
			Usage:       "Identifier of the key individual",
			Destination: &genopts.keyIndividual,
		},
		&cli.BoolFlag{
			Name:        "include-private",
			Usage:       "Include living people and people who died less than 20 years ago.",
			Value:       false,
			Destination: &genopts.includePrivate,
		},
		&cli.StringFlag{
			Name:        "config",
			Aliases:     []string{"c"},
			Value:       tree.DefaultConfigDir(),
			Usage:       "Path to the folder where config should be stored.",
			Destination: &genopts.configDir,
		},
		&cli.StringFlag{
			Name:        "inspect",
			Usage:       "Type and ID of an object to inspect. The internal data structure of the object will be printed to stdout. Use format '{object}/{id}' where object can be 'person', 'place' or 'source'.",
			Destination: &genopts.inspect,
		},
		&cli.BoolFlag{
			Name:        "wikitree",
			Usage:       "Generate pages that include wikitree markup for copy and paste.",
			Value:       false,
			Destination: &genopts.generateWikiTree,
		},
		&cli.BoolFlag{
			Name:        "hugo",
			Usage:       "Generate Hugo-specific markup and index pages.",
			Value:       true,
			Destination: &genopts.generateHugo,
		},
		&cli.StringFlag{
			Name:        "notes",
			Usage:       "Path to the folder where research notes are stored (in markdown format).",
			Destination: &genopts.notesDir,
		},
		&cli.StringFlag{
			Name:        "relation",
			Usage:       "Only include people who are related to the key person. One of 'direct' (must be a direct ancestor), 'common' (must have a common ancestor) or 'any' (any relation). Ignored if no key person is specified.",
			Value:       "any",
			Destination: &genopts.relation,
		},
	}, logging.Flags...),
}

Functions

func AgeQualifier

func AgeQualifier(age int) string

func ChooseFrom

func ChooseFrom(n int, alternatives ...string) string

func CleanTags

func CleanTags(ss []string) []string

func CopyFile

func CopyFile(dst, src string) error

func CreateFile

func CreateFile(fname string) (*os.File, error)

func EncodePeopleListInline

func EncodePeopleListInline(ps []*model.Person, formatter func(*model.Person) string, enc InlineEncoder) string

EncodePeopleListInline encodes a list of people as a comma separated list

func EncodeRawLink(u string, enc ExtendedInlineEncoder) string

func EventNarrativeDetail

func EventNarrativeDetail(ev model.TimelineEvent) string

func GenerateOlb

func GenerateOlb(p *model.Person) error

func RenderFacts

func RenderFacts(facts []model.Fact, pov *model.POV, enc ExtendedMarkdownBuilder) error

func RenderPersonPage

func RenderPersonPage(s *Site, p *model.Person) (*md.Document, error)

func RenderPlacePage

func RenderPlacePage(s *Site, p *model.Place) (*md.Document, error)

func RenderSourcePage

func RenderSourcePage(s *Site, c *model.GeneralCitation) (*md.Document, error)

func RenderTimeline

func RenderTimeline(t *model.Timeline, pov *model.POV, enc ExtendedMarkdownBuilder) error

func RenderWikiTreePage

func RenderWikiTreePage(s *Site, p *model.Person) (*md.Document, error)

func ScanGeneralCitationForAnomalies

func ScanGeneralCitationForAnomalies(cit *model.GeneralCitation) []*model.Anomaly

func ScanTimelineEventForAnomalies

func ScanTimelineEventForAnomalies(ev model.TimelineEvent) []*model.Anomaly

func Tagify

func Tagify(s string) string

func WhatWhenWhere

func WhatWhenWhere(ev model.TimelineEvent, enc ExtendedInlineEncoder) string

func WhoWhatWhenWhere

func WhoWhatWhenWhere(ev model.TimelineEvent, enc ExtendedInlineEncoder) string

Types

type Calendar

type Calendar struct {
	Events []model.TimelineEvent
}

func (*Calendar) RenderPage

func (c *Calendar) RenderPage(s *Site) (*md.Document, error)

type CensusStatement

type CensusStatement struct {
	Principal *model.Person
	Event     *model.CensusEvent
}

func (*CensusStatement) End

func (s *CensusStatement) End() *model.Date

func (*CensusStatement) NarrativeSequence

func (s *CensusStatement) NarrativeSequence() int

func (*CensusStatement) RenderDetail

func (s *CensusStatement) RenderDetail(seq int, intro *NarrativeIntro, enc ExtendedMarkdownBuilder, hints *GrammarHints)

func (*CensusStatement) Start

func (s *CensusStatement) Start() *model.Date

type DeathStatement

type DeathStatement struct {
	Principal *model.Person
}

func (*DeathStatement) End

func (s *DeathStatement) End() *model.Date

func (*DeathStatement) NarrativeSequence

func (s *DeathStatement) NarrativeSequence() int

func (*DeathStatement) RenderDetail

func (s *DeathStatement) RenderDetail(seq int, intro *NarrativeIntro, enc ExtendedMarkdownBuilder, hints *GrammarHints)

func (*DeathStatement) Start

func (s *DeathStatement) Start() *model.Date

type ExtendedInlineEncoder

type ExtendedInlineEncoder interface {
	InlineEncoder
	EncodeModelLinkDedupe(firstText string, subsequentText string, m any) string
}

type ExtendedMarkdownBuilder

type ExtendedMarkdownBuilder interface {
	ExtendedMarkdownEncoder
	MarkdownBuilder
}

type ExtendedMarkdownEncoder

type ExtendedMarkdownEncoder interface {
	MarkdownEncoder
	EncodeModelLinkDedupe(firstText string, subsequentText string, m any) string
	// EncodeCitation(citation string, detail string, citationID string) string
	EncodeCitationDetail(c *model.GeneralCitation) string
	EncodeWithCitations(s string, citations []*model.GeneralCitation) string
}

type FamilyStatement

type FamilyStatement struct {
	Principal *model.Person
	Family    *model.Family
}

func (*FamilyStatement) End

func (s *FamilyStatement) End() *model.Date

func (*FamilyStatement) EndedWithDeathOf

func (s *FamilyStatement) EndedWithDeathOf(p *model.Person) bool

func (*FamilyStatement) NarrativeSequence

func (s *FamilyStatement) NarrativeSequence() int

func (*FamilyStatement) RenderDetail

func (s *FamilyStatement) RenderDetail(seq int, intro *NarrativeIntro, enc ExtendedMarkdownBuilder, hints *GrammarHints)

func (*FamilyStatement) Start

func (s *FamilyStatement) Start() *model.Date

type GrammarHints

type GrammarHints struct {
	DateInferred bool
}

type InlineBuilder

type InlineBuilder interface {
	InlineEncoder
	Markdown() string
}

type InlineEncoder

type InlineEncoder interface {
	EncodeLink(text string, url string) string
	EncodeModelLink(text string, m any) string
	EncodeItalic(s string) string
	EncodeBold(s string) string
}

type IntroStatement

type IntroStatement struct {
	Principal        *model.Person
	Baptisms         []*model.BaptismEvent
	SuppressRelation bool
}

func (*IntroStatement) End

func (s *IntroStatement) End() *model.Date

func (*IntroStatement) NarrativeSequence

func (s *IntroStatement) NarrativeSequence() int

func (*IntroStatement) RenderDetail

func (s *IntroStatement) RenderDetail(seq int, intro *NarrativeIntro, enc ExtendedMarkdownBuilder, hints *GrammarHints)

func (*IntroStatement) Start

func (s *IntroStatement) Start() *model.Date

type MarkdownBuilder

type MarkdownBuilder interface {
	MarkdownEncoder
	Markdown() string
	Para(s string)
	EmptyPara()
	Heading2(s string)
	Heading3(s string)
	Heading4(s string)
	UnorderedList(items []string)
	OrderedList(items []string)
	DefinitionList(items [][2]string)
	BlockQuote(s string)
}

type MarkdownDoc

type MarkdownDoc interface {
	ExtendedMarkdownBuilder
	SetFrontMatterField(k, v string)
	Title(s string)
	Summary(s string)
	Layout(s string)
	Category(s string)
	ID(s string)
	AddTag(s string)
	AddTags(ss []string)
	ResetSeenLinks()
	RawMarkdown(s string)
}

type MarkdownEncoder

type MarkdownEncoder interface {
	InlineEncoder
	EncodePara(s string) string
	EncodeEmptyPara() string
	EncodeHeading4(s string) string
	EncodeUnorderedList(items []string) string
	EncodeOrderedList(items []string) string
	EncodeDefinitionList(items [][2]string) string
	EncodeBlockQuote(s string) string
}

type Narrative

type Narrative struct {
	Statements []Statement
}

func (*Narrative) Render

func (n *Narrative) Render(pov *model.POV, b ExtendedMarkdownBuilder)

type NarrativeIntro

type NarrativeIntro struct {
	Text         string // Default text to use as an intro, composed of a combination of other fields
	NameBased    string // name or he/she
	TimeBased    string // During this time, later that year, some years later
	DateInferred bool   // whether or not the TimeBased or Text intro already includes a version of the date
}

func (*NarrativeIntro) Default

func (n *NarrativeIntro) Default() string

type NoteDoc

type NoteDoc struct {
	Filename string
	Title    string
	Author   string
	Date     string
	Type     string
	Person   string
	Markdown string
	Mentions []string
}

func LoadNotes

func LoadNotes(dir string) ([]*NoteDoc, error)

func ParseNote

func ParseNote(fname string, fsys fs.FS) (*NoteDoc, error)

type PageLayout

type PageLayout string
const (
	PageLayoutPerson         PageLayout = "person"
	PageLayoutPlace          PageLayout = "place"
	PageLayoutSource         PageLayout = "source"
	PageLayoutListInferences PageLayout = "listinferences"
	PageLayoutListAnomalies  PageLayout = "listanomalies"
	PageLayoutListTodo       PageLayout = "listtodo"
	PageLayoutListPeople     PageLayout = "listpeople"
	PageLayoutListPlaces     PageLayout = "listplaces"
	PageLayoutListSources    PageLayout = "listsources"
	PageLayoutListSurnames   PageLayout = "listsurnames"
	PageLayoutCalendar       PageLayout = "calendar"
	PageLayoutTreeOverview   PageLayout = "treeoverview"
	PageLayoutChartAncestors PageLayout = "chartancestors"
	PageLayoutChartTrees     PageLayout = "charttrees"
)

func (PageLayout) String

func (p PageLayout) String() string

type Paginator

type Paginator struct {
	HugoStyle bool

	Entries []PaginatorEntry
}

func NewPaginator

func NewPaginator() *Paginator

func (*Paginator) AddEntry

func (p *Paginator) AddEntry(key string, title string, content string)

func (*Paginator) AddEntryWithGroup

func (p *Paginator) AddEntryWithGroup(key string, title string, content string, group string, groupPriority int)

func (*Paginator) WritePages

func (p *Paginator) WritePages(s *Site, baseDir string, layout PageLayout, title string, summary string) error

type PaginatorEntry

type PaginatorEntry struct {
	Key           string
	Title         string
	Group         string
	GroupPriority int
	Content       string
}

type PersonWithAge

type PersonWithAge struct {
	Person *model.Person
	Age    int
}

type PersonWithAgeHeap

type PersonWithAgeHeap []*PersonWithAge

func (PersonWithAgeHeap) Len

func (h PersonWithAgeHeap) Len() int

func (PersonWithAgeHeap) Less

func (h PersonWithAgeHeap) Less(i, j int) bool

func (*PersonWithAgeHeap) Pop

func (h *PersonWithAgeHeap) Pop() interface{}

func (*PersonWithAgeHeap) Push

func (h *PersonWithAgeHeap) Push(x interface{})

func (PersonWithAgeHeap) Swap

func (h PersonWithAgeHeap) Swap(i, j int)

type PublishSet

type PublishSet struct {
	People       map[string]*model.Person
	Citations    map[string]*model.GeneralCitation
	Sources      map[string]*model.Source
	Repositories map[string]*model.Repository
	Places       map[string]*model.Place
	Families     map[string]*model.Family
	MediaObjects map[string]*model.MediaObject
	Events       map[model.TimelineEvent]bool
}

func NewPublishSet

func NewPublishSet(t *tree.Tree, include model.PersonMatcher) (*PublishSet, error)

func (*PublishSet) AncestorSurnameDistribution

func (ps *PublishSet) AncestorSurnameDistribution() map[string]int

AncestorSurnameDistribution returns a map of surnames and the number of direct ancestors with that surname It excludes redacted people.

func (*PublishSet) Ancestors

func (ps *PublishSet) Ancestors(p *model.Person, generations int) []*model.Person

Ancestors returns the ancestors of p. The returned list is ordered such that the father of entry n is found at (n+2)*2-2, the mother of entry n is found at (n+2)*2-1 The list will always contain 2^n entries, with unknown ancestors left as nil at the appropriate index. Odd numbers are female, even numbers are male. The child of entry n is found at (n-2)/2 if n is even and (n-3)/2 if n is odd. 0: father 1: mother 2: father's father 3: father's mother 4: mother's father 5: mother's mother 6: father's father's father 7: father's father's mother 8: father's mother's father 9: father's mother's mother 10: mother's father's father 11: mother's father's mother 12: mother's mother's father 13: mother's mother's mother 14: father's father's father's father 15: father's father's father's mother 16: father's father's mother's father 17: father's father's mother's mother 18: father's mother's father's father 19: father's mother's father's mother 20: father's mother's mother's father 21: father's mother's mother's mother 22: mother's father's father's father 23: mother's father's father's mother 24: mother's father's mother's father 25: mother's father's mother's mother 26: mother's mother's father's father 27: mother's mother's father's mother 28: mother's mother's mother's father 29: mother's mother's mother's mother

func (*PublishSet) Includes

func (ps *PublishSet) Includes(v any) bool

func (*PublishSet) NumberOfPeople

func (t *PublishSet) NumberOfPeople() int

NumberOfPeople returns the number of people in the tree. It excludes redacted people.

func (*PublishSet) OldestPeople

func (ps *PublishSet) OldestPeople(limit int) []*model.Person

OldestPeople returns a list of the oldest people in the tree, sorted by descending age It excludes redacted people.

func (*PublishSet) TreeSurnameDistribution

func (ps *PublishSet) TreeSurnameDistribution() map[string]int

TreeSurnameDistribution returns a map of surnames and the number of people in the tree with that surname It excludes redacted people.

type Site

type Site struct {
	BaseURL   string
	Tree      *tree.Tree
	Calendars map[int]*Calendar

	PersonDir           string
	PersonLinkPattern   string
	PersonFilePattern   string
	SourceDir           string
	SourceLinkPattern   string
	SourceFilePattern   string
	FamilyLinkPattern   string
	CalendarLinkPattern string
	FamilyFilePattern   string
	PlaceDir            string
	PlaceLinkPattern    string
	PlaceFilePattern    string
	CalendarFilePattern string
	MediaDir            string
	MediaLinkPattern    string
	MediaFilePattern    string

	ListInferencesDir string
	ListAnomaliesDir  string
	ListTodoDir       string
	ListPeopleDir     string
	ListPlacesDir     string
	ListSourcesDir    string
	ListSurnamesDir   string

	ChartAncestorsDir string
	ChartTreesDir     string

	IncludePrivate     bool
	TimelineExperiment bool

	GenerateHugo bool

	GenerateWikiTree    bool
	WikiTreeDir         string
	WikiTreeLinkPattern string
	WikiTreeFilePattern string

	// PublishSet is the set of objects that will have pages written
	PublishSet *PublishSet
}

func NewSite

func NewSite(baseURL string, hugoIndexNaming bool, t *tree.Tree) *Site

func (*Site) AssignTags

func (s *Site) AssignTags(p *model.Person) error

func (*Site) BuildCalendar

func (s *Site) BuildCalendar() error

func (*Site) BuildPublishSet

func (s *Site) BuildPublishSet(m model.PersonMatcher) error

func (*Site) Generate

func (s *Site) Generate() error

func (*Site) LinkFor

func (s *Site) LinkFor(v any) string

func (*Site) LinkForFormat

func (s *Site) LinkForFormat(v any, format string) string

func (*Site) NewDocument

func (s *Site) NewDocument() *md.Document

func (*Site) NewMarkdownBuilder

func (s *Site) NewMarkdownBuilder() MarkdownBuilder

func (*Site) ScanPersonForAnomalies

func (s *Site) ScanPersonForAnomalies(p *model.Person)

func (*Site) ScanPersonTodos

func (s *Site) ScanPersonTodos(p *model.Person) []*model.ToDo

func (*Site) WriteAnomalyListPages

func (s *Site) WriteAnomalyListPages(root string) error

func (*Site) WriteChartAncestors

func (s *Site) WriteChartAncestors(root string) error

func (*Site) WriteChartTrees

func (s *Site) WriteChartTrees(root string) error

func (*Site) WriteDescendantTree

func (s *Site) WriteDescendantTree(fname string, p *model.Person, depth int) error

func (*Site) WriteInferenceListPages

func (s *Site) WriteInferenceListPages(root string) error

func (*Site) WritePages

func (s *Site) WritePages(contentDir string, mediaDir string) error

func (*Site) WritePersonListPages

func (s *Site) WritePersonListPages(root string) error

func (*Site) WritePlaceListPages

func (s *Site) WritePlaceListPages(root string) error

func (*Site) WriteSourceListPages

func (s *Site) WriteSourceListPages(root string) error

func (*Site) WriteSurnameListPages

func (s *Site) WriteSurnameListPages(root string) error

func (*Site) WriteTodoListPages

func (s *Site) WriteTodoListPages(root string) error

func (*Site) WriteTreeOverview

func (s *Site) WriteTreeOverview(root string) error

type Statement

type Statement interface {
	RenderDetail(int, *NarrativeIntro, ExtendedMarkdownBuilder, *GrammarHints)
	Start() *model.Date
	End() *model.Date
	NarrativeSequence() int
}

type TimelineEntryFormatter

type TimelineEntryFormatter struct {
	// contains filtered or unexported fields
}

func (*TimelineEntryFormatter) Detail

func (*TimelineEntryFormatter) Title

type Tuple

type Tuple[K simplevalue, V simplevalue] struct {
	K K
	V V
}

func FlattenMap

func FlattenMap[M ~map[K]V, K simplevalue, V simplevalue](m M) []Tuple[K, V]

FlattenMapByKeyAsc flattens a map into a slice of Tuples

func FlattenMapByKeyAsc

func FlattenMapByKeyAsc[M ~map[K]V, K simplevalue, V simplevalue](m M) []Tuple[K, V]

FlattenMapByKeyAsc flattens a map and sorts by the key ascending

func FlattenMapByValueDesc

func FlattenMapByValueDesc[M ~map[K]V, K simplevalue, V simplevalue](m M) []Tuple[K, V]

FlattenMapByValueDesc flattens a map and sorts by the value descending

func (*Tuple[K, V]) String

func (t *Tuple[K, V]) String() string

type WikiTreeEncoder

type WikiTreeEncoder struct {
	// contains filtered or unexported fields
}

func (*WikiTreeEncoder) BlockQuote

func (w *WikiTreeEncoder) BlockQuote(s string)

func (*WikiTreeEncoder) DefinitionList

func (w *WikiTreeEncoder) DefinitionList(items [][2]string)

func (*WikiTreeEncoder) EmptyPara

func (w *WikiTreeEncoder) EmptyPara()

func (*WikiTreeEncoder) EncodeBlockQuote

func (w *WikiTreeEncoder) EncodeBlockQuote(s string) string

func (*WikiTreeEncoder) EncodeBold

func (w *WikiTreeEncoder) EncodeBold(s string) string

func (*WikiTreeEncoder) EncodeCitationDetail

func (w *WikiTreeEncoder) EncodeCitationDetail(c *model.GeneralCitation) string

func (*WikiTreeEncoder) EncodeCitationSeperator

func (w *WikiTreeEncoder) EncodeCitationSeperator() string

func (*WikiTreeEncoder) EncodeDefinitionList

func (w *WikiTreeEncoder) EncodeDefinitionList(items [][2]string) string

func (*WikiTreeEncoder) EncodeEmptyPara

func (w *WikiTreeEncoder) EncodeEmptyPara() string

func (*WikiTreeEncoder) EncodeHeading4

func (w *WikiTreeEncoder) EncodeHeading4(s string) string

func (*WikiTreeEncoder) EncodeItalic

func (w *WikiTreeEncoder) EncodeItalic(s string) string
func (w *WikiTreeEncoder) EncodeLink(text string, url string) string
func (w *WikiTreeEncoder) EncodeModelLink(text string, m any) string

func (*WikiTreeEncoder) EncodeModelLinkDedupe

func (w *WikiTreeEncoder) EncodeModelLinkDedupe(firstText string, subsequentText string, m any) string

func (*WikiTreeEncoder) EncodeOrderedList

func (w *WikiTreeEncoder) EncodeOrderedList(items []string) string

func (*WikiTreeEncoder) EncodePara

func (w *WikiTreeEncoder) EncodePara(s string) string

func (*WikiTreeEncoder) EncodeUnorderedList

func (w *WikiTreeEncoder) EncodeUnorderedList(items []string) string

func (*WikiTreeEncoder) EncodeWithCitations

func (w *WikiTreeEncoder) EncodeWithCitations(s string, citations []*model.GeneralCitation) string

func (*WikiTreeEncoder) Heading2

func (w *WikiTreeEncoder) Heading2(s string)

func (*WikiTreeEncoder) Heading3

func (w *WikiTreeEncoder) Heading3(s string)

func (*WikiTreeEncoder) Heading4

func (w *WikiTreeEncoder) Heading4(s string)

func (*WikiTreeEncoder) Markdown

func (w *WikiTreeEncoder) Markdown() string

func (*WikiTreeEncoder) OrderedList

func (w *WikiTreeEncoder) OrderedList(items []string)

func (*WikiTreeEncoder) Para

func (w *WikiTreeEncoder) Para(s string)

func (*WikiTreeEncoder) UnorderedList

func (w *WikiTreeEncoder) UnorderedList(items []string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL