Unhardcode

This commit is contained in:
2026-05-25 10:23:42 +02:00
parent e6fffdf041
commit 7714c068fe
9 changed files with 286 additions and 23 deletions
+42
View File
@@ -277,8 +277,13 @@ type TopDataWikiConfig struct {
NamespacesFile string `json:"namespaces_file" yaml:"namespaces_file"`
TablesFile string `json:"tables_file" yaml:"tables_file"`
VisibilityFile string `json:"visibility_file" yaml:"visibility_file"`
DataFile string `json:"data_file" yaml:"data_file"`
PagePathsFile string `json:"page_paths_file" yaml:"page_paths_file"`
TemplatesDir string `json:"templates_dir" yaml:"templates_dir"`
PageTemplatesDir string `json:"page_templates_dir" yaml:"page_templates_dir"`
ManualSectionsDir string `json:"manual_sections_dir" yaml:"manual_sections_dir"`
ManualSectionsFile string `json:"manual_sections_file" yaml:"manual_sections_file"`
PageIndexFile string `json:"page_index_file" yaml:"page_index_file"`
AlignmentLinks TopDataWikiAlignmentLinks `json:"alignment_links" yaml:"alignment_links"`
TitlePrefixMinLength int `json:"title_prefix_min_length" yaml:"title_prefix_min_length"`
StatusPages *bool `json:"status_pages,omitempty" yaml:"status_pages,omitempty"`
@@ -587,8 +592,17 @@ func (p *Project) ValidateLayout() error {
"topdata.wiki.state_file": p.Config.TopData.Wiki.StateFile,
"topdata.wiki.deploy_manifest": p.Config.TopData.Wiki.DeployManifest,
"topdata.wiki.deploy_edit_summary": p.Config.TopData.Wiki.DeployEditSummary,
"topdata.wiki.source": p.Config.TopData.Wiki.Source,
"topdata.wiki.namespaces_file": p.Config.TopData.Wiki.NamespacesFile,
"topdata.wiki.tables_file": p.Config.TopData.Wiki.TablesFile,
"topdata.wiki.visibility_file": p.Config.TopData.Wiki.VisibilityFile,
"topdata.wiki.data_file": p.Config.TopData.Wiki.DataFile,
"topdata.wiki.page_paths_file": p.Config.TopData.Wiki.PagePathsFile,
"topdata.wiki.templates_dir": p.Config.TopData.Wiki.TemplatesDir,
"topdata.wiki.page_templates_dir": p.Config.TopData.Wiki.PageTemplatesDir,
"topdata.wiki.manual_sections_dir": p.Config.TopData.Wiki.ManualSectionsDir,
"topdata.wiki.manual_sections_file": p.Config.TopData.Wiki.ManualSectionsFile,
"topdata.wiki.page_index_file": p.Config.TopData.Wiki.PageIndexFile,
"extract.layout": p.Config.Extract.Layout,
"extract.hak_discovery": p.Config.Extract.HAKDiscovery,
"autogen.cache.root": p.Config.Autogen.Cache.Root,
@@ -627,8 +641,13 @@ func (p *Project) ValidateLayout() error {
failures = append(failures, validateRelativePath("topdata.wiki.namespaces_file", effective.TopData.Wiki.NamespacesFile)...)
failures = append(failures, validateRelativePath("topdata.wiki.tables_file", effective.TopData.Wiki.TablesFile)...)
failures = append(failures, validateRelativePath("topdata.wiki.visibility_file", effective.TopData.Wiki.VisibilityFile)...)
failures = append(failures, validateRelativePath("topdata.wiki.data_file", effective.TopData.Wiki.DataFile)...)
failures = append(failures, validateRelativePath("topdata.wiki.page_paths_file", effective.TopData.Wiki.PagePathsFile)...)
failures = append(failures, validateTreeRootPath("topdata.wiki.templates_dir", effective.TopData.Wiki.TemplatesDir)...)
failures = append(failures, validateRelativePath("topdata.wiki.page_templates_dir", effective.TopData.Wiki.PageTemplatesDir)...)
failures = append(failures, validateTreeRootPath("topdata.wiki.manual_sections_dir", effective.TopData.Wiki.ManualSectionsDir)...)
failures = append(failures, validateRelativePath("topdata.wiki.manual_sections_file", effective.TopData.Wiki.ManualSectionsFile)...)
failures = append(failures, validateRelativePath("topdata.wiki.page_index_file", effective.TopData.Wiki.PageIndexFile)...)
failures = append(failures, validateRelativePath("autogen.cache.root", effective.Autogen.Cache.Root)...)
if err := validateOutputFileName("outputs.module_archive", filepath.Base(effective.Outputs.ModuleArchive), ".mod"); err != nil {
failures = append(failures, err)
@@ -642,6 +661,9 @@ func (p *Project) ValidateLayout() error {
if err := validateOutputFileName("topdata.wiki.deploy_manifest", filepath.Base(effective.TopData.Wiki.DeployManifest), ".json"); err != nil {
failures = append(failures, err)
}
if err := validateOutputFileName("topdata.wiki.page_index_file", filepath.Base(effective.TopData.Wiki.PageIndexFile), ".json"); err != nil {
failures = append(failures, err)
}
switch effective.TopData.Wiki.Renderer {
case "nodebb_tiptap_html":
default:
@@ -1218,6 +1240,26 @@ func (p *Project) TopDataWikiStatePath() string {
return filepath.Join(p.TopDataWikiRootDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.StateFile))
}
func (p *Project) TopDataWikiPageIndexPath() string {
return filepath.Join(p.TopDataWikiRootDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.PageIndexFile))
}
func (p *Project) TopDataWikiDataPath() string {
return filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.DataFile))
}
func (p *Project) TopDataWikiPagePathsPath() string {
return filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.PagePathsFile))
}
func (p *Project) TopDataWikiPageTemplatesDir() string {
return filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.PageTemplatesDir))
}
func (p *Project) TopDataWikiManualSectionsPath() string {
return filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.ManualSectionsFile))
}
func (p *Project) TopDataPackageHAKName() string {
return p.EffectiveConfig().TopData.PackageHAK
}