Family Tree as Markdown Files - Hugo
This commit is contained in:
parent
b2fe53275f
commit
a154662b9a
@ -9,4 +9,28 @@ tags: []
|
|||||||
# Family Tree as Markdown Files
|
# Family Tree as Markdown Files
|
||||||
|
|
||||||
- [ ] Look at how I can export from ged files
|
- [ ] Look at how I can export from ged files
|
||||||
- [x] In addition to writing the *.pged maybe write *.md also
|
- [x] In addition to writing the _.pged maybe write _.md also
|
||||||
|
- [x] Host hugo
|
||||||
|
|
||||||
|
- [hugo-obsidian](https://github.com/jackyzha0/hugo-obsidian)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
l:
|
||||||
|
cd git
|
||||||
|
git clone https://github.com/jackyzha0/hugo-obsidian.git
|
||||||
|
cd hugo-obsidian
|
||||||
|
go build
|
||||||
|
```
|
||||||
|
|
||||||
|
- [quartz](https://github.com/jackyzha0/quartz)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
l:
|
||||||
|
cd git
|
||||||
|
git clone https://github.com/jackyzha0/quartz.git
|
||||||
|
cd quartz
|
||||||
|
code-insiders .
|
||||||
|
hugo-obsidian -input=content -output=assets/indices -index -root=.
|
||||||
|
hugo server --enableGitInfo --minify
|
||||||
|
hugo server --buildDrafts
|
||||||
|
```
|
||||||
|
@ -131,7 +131,7 @@ public partial class DlibDotNet
|
|||||||
TimeSpan a2LastWriteTimeTimeSpan = new(ticks - new DirectoryInfo(a2PeopleContentDirectory).LastWriteTime.Ticks);
|
TimeSpan a2LastWriteTimeTimeSpan = new(ticks - new DirectoryInfo(a2PeopleContentDirectory).LastWriteTime.Ticks);
|
||||||
if (a2LastWriteTimeTimeSpan.TotalDays > 1)
|
if (a2LastWriteTimeTimeSpan.TotalDays > 1)
|
||||||
{
|
{
|
||||||
IPersonContainer.MaybeWriteFiles(configuration.MappingDefaultName, configuration.PersonBirthdayFormat, genealogicalDataCommunicationRelations, _PersonContainers);
|
IPersonContainer.MaybeWriteFiles(configuration.MappingDefaultName, configuration.PersonBirthdayFormat, ticks, genealogicalDataCommunicationRelations, _PersonContainers, a2PeopleContentDirectory);
|
||||||
if (IGenealogicalDataCommunication.CleanDisplayDirectoryAllFilesAndWriteTicksGed(_Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, _PersonContainers, headerLines, familyGroupLines, footerLines, ticks, a2PeopleContentDirectory))
|
if (IGenealogicalDataCommunication.CleanDisplayDirectoryAllFilesAndWriteTicksGed(_Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, _PersonContainers, headerLines, familyGroupLines, footerLines, ticks, a2PeopleContentDirectory))
|
||||||
_PersonContainers = IPersonContainer.GetPersonContainers(storage, configuration.MappingDefaultName, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), _Faces.FileNameExtension, individuals);
|
_PersonContainers = IPersonContainer.GetPersonContainers(storage, configuration.MappingDefaultName, configuration.PersonBirthdayFormat, configuration.PersonCharacters.ToArray(), _Faces.FileNameExtension, individuals);
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ public interface IPersonContainer
|
|||||||
static List<Models.PersonContainer> GetPersonContainers(Properties.IStorage storage, string mappingDefaultName, string personBirthdayFormat, char[] personCharacters, string facesFileNameExtension, ReadOnlyDictionary<string, string[]> individuals) =>
|
static List<Models.PersonContainer> GetPersonContainers(Properties.IStorage storage, string mappingDefaultName, string personBirthdayFormat, char[] personCharacters, string facesFileNameExtension, ReadOnlyDictionary<string, string[]> individuals) =>
|
||||||
PersonContainer.GetPersonContainers(storage, mappingDefaultName, personBirthdayFormat, personCharacters, facesFileNameExtension, individuals);
|
PersonContainer.GetPersonContainers(storage, mappingDefaultName, personBirthdayFormat, personCharacters, facesFileNameExtension, individuals);
|
||||||
|
|
||||||
void TestStatic_MaybeWriteFiles(string mappingDefaultName, string personBirthdayFormat, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, List<Models.PersonContainer> personContainers) =>
|
void TestStatic_MaybeWriteFiles(string mappingDefaultName, string personBirthdayFormat, long ticks, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, List<Models.PersonContainer> personContainers, string a2PeopleContentDirectory) =>
|
||||||
MaybeWriteFiles(mappingDefaultName, personBirthdayFormat, genealogicalDataCommunicationRelations, personContainers);
|
MaybeWriteFiles(mappingDefaultName, personBirthdayFormat, ticks, genealogicalDataCommunicationRelations, personContainers, a2PeopleContentDirectory);
|
||||||
static void MaybeWriteFiles(string mappingDefaultName, string personBirthdayFormat, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, List<Models.PersonContainer> personContainers) =>
|
static void MaybeWriteFiles(string mappingDefaultName, string personBirthdayFormat, long ticks, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, List<Models.PersonContainer> personContainers, string a2PeopleContentDirectory) =>
|
||||||
PersonContainer.MaybeWriteFiles(mappingDefaultName, personBirthdayFormat, genealogicalDataCommunicationRelations, personContainers);
|
PersonContainer.MaybeWriteFiles(mappingDefaultName, personBirthdayFormat, ticks, genealogicalDataCommunicationRelations, personContainers, a2PeopleContentDirectory);
|
||||||
|
|
||||||
List<(long?, string)> TestStatic_GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer) =>
|
List<(long?, string)> TestStatic_GetDisplay(string personBirthdayFormat, Models.PersonContainer personContainer) =>
|
||||||
GetDisplay(personBirthdayFormat, personContainer);
|
GetDisplay(personBirthdayFormat, personContainer);
|
||||||
|
@ -8,7 +8,7 @@ internal abstract class MarkDown
|
|||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
internal static void WriteFile(string personKeyFormatted, Models.PersonName personName, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, bool isDefaultName, string directory, Models.GenealogicalDataCommunication genealogicalDataCommunication, bool first, string fullName, string lowerHyphenFullName)
|
internal static void WriteFile(string personKeyFormatted, long ticks, Models.PersonName personName, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, string a2PeopleContentDirectory, ReadOnlyDictionary<string, string> personKeyFormattedToPersonFullName, ReadOnlyDictionary<int, List<GenealogicalDataCommunicationRelation>> familyIndexToCollection, bool isDefaultName, Models.GenealogicalDataCommunication genealogicalDataCommunication, bool first, string fullName, string lowerHyphenFullName)
|
||||||
{
|
{
|
||||||
string? personFullName;
|
string? personFullName;
|
||||||
bool hasRelation = false;
|
bool hasRelation = false;
|
||||||
@ -28,12 +28,6 @@ internal abstract class MarkDown
|
|||||||
jrOrSr = string.Empty;
|
jrOrSr = string.Empty;
|
||||||
}
|
}
|
||||||
string code = IPersonBirthday.GetHour(genealogicalDataCommunication.Death is null, genealogicalDataCommunication.Sex).ToString("00");
|
string code = IPersonBirthday.GetHour(genealogicalDataCommunication.Death is null, genealogicalDataCommunication.Sex).ToString("00");
|
||||||
if (directory.EndsWith("00"))
|
|
||||||
directory = string.Concat(directory[..^2], code);
|
|
||||||
else if (directory.EndsWith("01"))
|
|
||||||
directory = string.Concat(directory[..^2], code);
|
|
||||||
if (!Directory.Exists(directory))
|
|
||||||
_ = Directory.CreateDirectory(directory);
|
|
||||||
if (first && !personKeyFormatted.EndsWith(code))
|
if (first && !personKeyFormatted.EndsWith(code))
|
||||||
personKeyFormatted = $"{personKeyFormatted[..^2]}{code}";
|
personKeyFormatted = $"{personKeyFormatted[..^2]}{code}";
|
||||||
List<string> lines = new()
|
List<string> lines = new()
|
||||||
@ -42,18 +36,21 @@ internal abstract class MarkDown
|
|||||||
"type: person",
|
"type: person",
|
||||||
$"created: {now}",
|
$"created: {now}",
|
||||||
$"updated: {now}",
|
$"updated: {now}",
|
||||||
$"{nameof(fullName)}: {fullName}",
|
$"draft: false",
|
||||||
$"name: {personName.First.Value} /{personName.Last.Value}/{jrOrSr}",
|
$"title: '{fullName}'",
|
||||||
|
$"{nameof(fullName)}: '{fullName}'",
|
||||||
|
$"name: '{personName.First.Value} /{personName.Last.Value}/{jrOrSr}'",
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(personName.First.Value))
|
if (!string.IsNullOrEmpty(personName.First.Value))
|
||||||
lines.Add($"given: {personName.First.Value}");
|
lines.Add($"given: '{personName.First.Value}'");
|
||||||
if (!string.IsNullOrEmpty(personName.Last.Value))
|
if (!string.IsNullOrEmpty(personName.Last.Value))
|
||||||
lines.Add($"surname: {personName.Last.Value}");
|
lines.Add($"surname: '{personName.Last.Value}'");
|
||||||
if (!string.IsNullOrEmpty(jrOrSr))
|
if (!string.IsNullOrEmpty(jrOrSr))
|
||||||
lines.Add($"suffix: {jrOrSr.Trim()}");
|
lines.Add($"suffix: '{jrOrSr.Trim()}'");
|
||||||
lines.Add($"sex: {genealogicalDataCommunication.Sex}");
|
lines.Add($"sex: {genealogicalDataCommunication.Sex}");
|
||||||
if (genealogicalDataCommunication.Birth is not null)
|
if (genealogicalDataCommunication.Birth is not null)
|
||||||
{
|
{
|
||||||
|
lines.Add($"date: {genealogicalDataCommunication.Birth.Value:yyyy-MM-ddT00:00:00.000Z}");
|
||||||
Models.PersonBirthday personBirthday = new(genealogicalDataCommunication.Birth.Value);
|
Models.PersonBirthday personBirthday = new(genealogicalDataCommunication.Birth.Value);
|
||||||
if (!IPersonBirthday.IsCounterPersonBirthday(personBirthday))
|
if (!IPersonBirthday.IsCounterPersonBirthday(personBirthday))
|
||||||
lines.Add($"birthDate: {genealogicalDataCommunication.Birth.Value:dd MMM yyyy}");
|
lines.Add($"birthDate: {genealogicalDataCommunication.Birth.Value:dd MMM yyyy}");
|
||||||
@ -77,6 +74,7 @@ internal abstract class MarkDown
|
|||||||
const string wife = "WIFE";
|
const string wife = "WIFE";
|
||||||
const string child = "CHIL";
|
const string child = "CHIL";
|
||||||
const string husband = "HUSB";
|
const string husband = "HUSB";
|
||||||
|
const string person = "person";
|
||||||
foreach (GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation in genealogicalDataCommunicationRelations)
|
foreach (GenealogicalDataCommunicationRelation genealogicalDataCommunicationRelation in genealogicalDataCommunicationRelations)
|
||||||
{
|
{
|
||||||
if (genealogicalDataCommunicationRelation.Relation != child)
|
if (genealogicalDataCommunicationRelation.Relation != child)
|
||||||
@ -102,22 +100,22 @@ internal abstract class MarkDown
|
|||||||
else
|
else
|
||||||
lowerHyphenRelation = Regex.Replace(personFullName.ToLower(), "[^a-z0-9-]", "-");
|
lowerHyphenRelation = Regex.Replace(personFullName.ToLower(), "[^a-z0-9-]", "-");
|
||||||
if (string.IsNullOrEmpty(genealogicalDataCommunicationRelation.LineTwo))
|
if (string.IsNullOrEmpty(genealogicalDataCommunicationRelation.LineTwo))
|
||||||
lines.Add($"- [[{lowerHyphenRelation}]]");
|
lines.Add($"- [[{person}/{lowerHyphenRelation}]]");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (genealogicalDataCommunicationRelation.LineTwo[1] == father)
|
if (genealogicalDataCommunicationRelation.LineTwo[1] == father)
|
||||||
{
|
{
|
||||||
if (relation.Relation == wife)
|
if (relation.Relation == wife)
|
||||||
lines.Add($"- [[{lowerHyphenRelation}]] {nameof(mother)}");
|
lines.Add($"- [[{person}/{lowerHyphenRelation}]] {nameof(mother)}");
|
||||||
else if (relation.Relation == husband)
|
else if (relation.Relation == husband)
|
||||||
lines.Add($"- [[{lowerHyphenRelation}]] {genealogicalDataCommunicationRelation.LineTwo.Split(' ').Last()} {nameof(father)}");
|
lines.Add($"- [[{person}/{lowerHyphenRelation}]] {genealogicalDataCommunicationRelation.LineTwo.Split(' ').Last()} {nameof(father)}");
|
||||||
}
|
}
|
||||||
else if (genealogicalDataCommunicationRelation.LineTwo[1] == mother)
|
else if (genealogicalDataCommunicationRelation.LineTwo[1] == mother)
|
||||||
{
|
{
|
||||||
if (relation.Relation == husband)
|
if (relation.Relation == husband)
|
||||||
lines.Add($"- [[{lowerHyphenRelation}]] {nameof(father)}");
|
lines.Add($"- [[{person}/{lowerHyphenRelation}]] {nameof(father)}");
|
||||||
else if (relation.Relation == wife)
|
else if (relation.Relation == wife)
|
||||||
lines.Add($"- [[{lowerHyphenRelation}]] {genealogicalDataCommunicationRelation.LineTwo.Split(' ').Last()} {nameof(mother)}");
|
lines.Add($"- [[{person}/{lowerHyphenRelation}]] {genealogicalDataCommunicationRelation.LineTwo.Split(' ').Last()} {nameof(mother)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,6 +124,9 @@ internal abstract class MarkDown
|
|||||||
if (hasRelation)
|
if (hasRelation)
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
string text = string.Join(Environment.NewLine, lines);
|
string text = string.Join(Environment.NewLine, lines);
|
||||||
|
string directory = Path.Combine(a2PeopleContentDirectory, $"content-{ticks}", person);
|
||||||
|
if (!Directory.Exists(directory))
|
||||||
|
_ = Directory.CreateDirectory(directory);
|
||||||
_ = IPath.WriteAllText(Path.Combine(directory, $"{lowerHyphenFullName}.md"), text, updateDateWhenMatches: false, compareBeforeWrite: true);
|
_ = IPath.WriteAllText(Path.Combine(directory, $"{lowerHyphenFullName}.md"), text, updateDateWhenMatches: false, compareBeforeWrite: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ internal abstract class PersonContainer
|
|||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void MaybeWriteFiles(string mappingDefaultName, string personBirthdayFormat, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, List<Models.PersonContainer> personContainers)
|
internal static void MaybeWriteFiles(string mappingDefaultName, string personBirthdayFormat, long ticks, List<GenealogicalDataCommunicationRelation> genealogicalDataCommunicationRelations, List<Models.PersonContainer> personContainers, string a2PeopleContentDirectory)
|
||||||
{
|
{
|
||||||
bool? male;
|
bool? male;
|
||||||
bool? first;
|
bool? first;
|
||||||
@ -437,7 +437,7 @@ internal abstract class PersonContainer
|
|||||||
lowerHyphenFullName = $"{Regex.Replace(fullName.ToLower(), "[^a-z0-9-]", "-")}";
|
lowerHyphenFullName = $"{Regex.Replace(fullName.ToLower(), "[^a-z0-9-]", "-")}";
|
||||||
if (distinct.Contains(lowerHyphenFullName))
|
if (distinct.Contains(lowerHyphenFullName))
|
||||||
continue;
|
continue;
|
||||||
MarkDown.WriteFile(personKeyFormatted, personContainer.Person.Name, genealogicalDataCommunicationRelations, personKeyFormattedToPersonFullName, familyIndexToCollection, isDefaultName, directory, genealogicalDataCommunication, first.Value, fullName, lowerHyphenFullName);
|
MarkDown.WriteFile(personKeyFormatted, ticks, personContainer.Person.Name, genealogicalDataCommunicationRelations, a2PeopleContentDirectory, personKeyFormattedToPersonFullName, familyIndexToCollection, isDefaultName, genealogicalDataCommunication, first.Value, fullName, lowerHyphenFullName);
|
||||||
distinct.Add(lowerHyphenFullName);
|
distinct.Add(lowerHyphenFullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user