Unhardcode
This commit is contained in:
@@ -131,7 +131,7 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
|
||||
outputDir := wikiOutputPagesDir(p)
|
||||
statePath := wikiOutputStatePath(p)
|
||||
|
||||
digest, err := computeWikiSourceDigest(p.TopDataSourceDir())
|
||||
digest, err := computeWikiSourceDigest(p)
|
||||
if err != nil {
|
||||
return wikiResult{}, err
|
||||
}
|
||||
@@ -153,7 +153,7 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
|
||||
}
|
||||
manualSections := loadWikiManualSections(p)
|
||||
ctx.manualSections = manualSections
|
||||
ctx.templateDir = filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.TemplatesDir), "pages")
|
||||
ctx.templateDir = p.TopDataWikiPageTemplatesDir()
|
||||
ctx.alignmentLinkPattern = p.EffectiveConfig().TopData.Wiki.AlignmentLinks.TargetPattern
|
||||
ctx.wikiTablesPath = filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.TablesFile))
|
||||
tableDefinitions, err := loadWikiTableDefinitions(ctx.wikiTablesPath)
|
||||
@@ -161,7 +161,7 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
|
||||
return wikiResult{}, err
|
||||
}
|
||||
ctx.wikiTableDefinitions = tableDefinitions
|
||||
ctx.wikiDataPath = filepath.Join(p.TopDataWikiSourceDir(), "data.yaml")
|
||||
ctx.wikiDataPath = p.TopDataWikiDataPath()
|
||||
dataProviders, err := loadWikiDataProviders(ctx.wikiDataPath)
|
||||
if err != nil {
|
||||
return wikiResult{}, err
|
||||
@@ -171,7 +171,7 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
|
||||
if err := ctx.loadWikiVisibility(visibilityPath); err != nil {
|
||||
return wikiResult{}, err
|
||||
}
|
||||
pageSlugOverrides, err := loadWikiPagePathDeclarations(filepath.Join(p.TopDataWikiSourceDir(), "wiki.yaml"))
|
||||
pageSlugOverrides, err := loadWikiPagePathDeclarations(p.TopDataWikiPagePathsPath())
|
||||
if err != nil {
|
||||
return wikiResult{}, err
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
|
||||
if err := indexUnregisteredWikiPages(rootDir, outputDir, p.EffectiveConfig().TopData.Wiki.StalePages.Default, ctx, &pageIndex); err != nil {
|
||||
return wikiResult{}, err
|
||||
}
|
||||
if err := saveWikiPageIndex(filepath.Join(rootDir, "page-index.json"), pageIndex); err != nil {
|
||||
if err := saveWikiPageIndex(p.TopDataWikiPageIndexPath(), pageIndex); err != nil {
|
||||
return wikiResult{}, err
|
||||
}
|
||||
|
||||
@@ -289,8 +289,7 @@ func wikiCachedPagesAreCurrent(outputDir string, state wikiStateDocument) bool {
|
||||
|
||||
func loadWikiManualSections(p *project.Project) []wikiManualSection {
|
||||
defaults := defaultWikiManualSections()
|
||||
cfg := p.EffectiveConfig().TopData.Wiki
|
||||
path := filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(cfg.ManualSectionsDir), "default.yaml")
|
||||
path := p.TopDataWikiManualSectionsPath()
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return defaults
|
||||
@@ -451,9 +450,11 @@ func saveWikiState(path string, state wikiStateDocument) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func computeWikiSourceDigest(sourceDir string) (string, error) {
|
||||
func computeWikiSourceDigest(p *project.Project) (string, error) {
|
||||
hasher := sha256.New()
|
||||
_, _ = hasher.Write([]byte(wikiGeneratorVersion))
|
||||
sourceDir := p.TopDataSourceDir()
|
||||
wikiSourceDir := p.TopDataWikiSourceDir()
|
||||
files := []string{}
|
||||
relevantSourceDirs := []string{
|
||||
filepath.Join(sourceDir, "data", "feat"),
|
||||
@@ -462,7 +463,7 @@ func computeWikiSourceDigest(sourceDir string) (string, error) {
|
||||
filepath.Join(sourceDir, "data", "baseitems"),
|
||||
filepath.Join(sourceDir, "data", "classes"),
|
||||
filepath.Join(sourceDir, "data", "racialtypes"),
|
||||
filepath.Join(sourceDir, "wiki"),
|
||||
wikiSourceDir,
|
||||
}
|
||||
for _, dir := range relevantSourceDirs {
|
||||
_ = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
|
||||
@@ -503,9 +504,10 @@ func computeWikiSourceDigest(sourceDir string) (string, error) {
|
||||
return fmt.Sprintf("%x", hasher.Sum(nil)), nil
|
||||
}
|
||||
|
||||
func newestRelevantWikiSource(sourceDir string) (time.Time, string, error) {
|
||||
func newestRelevantWikiSource(p *project.Project) (time.Time, string, error) {
|
||||
newest := time.Time{}
|
||||
newestPath := ""
|
||||
sourceDir := p.TopDataSourceDir()
|
||||
relevantSourceDirs := []string{
|
||||
filepath.Join(sourceDir, "data", "feat"),
|
||||
filepath.Join(sourceDir, "data", "skills"),
|
||||
@@ -513,6 +515,7 @@ func newestRelevantWikiSource(sourceDir string) (time.Time, string, error) {
|
||||
filepath.Join(sourceDir, "data", "baseitems"),
|
||||
filepath.Join(sourceDir, "data", "classes"),
|
||||
filepath.Join(sourceDir, "data", "racialtypes"),
|
||||
p.TopDataWikiSourceDir(),
|
||||
}
|
||||
for _, dir := range relevantSourceDirs {
|
||||
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
|
||||
|
||||
Reference in New Issue
Block a user