From 5c63a05ed278839bfe505b09e1f93c24b30e1f09 Mon Sep 17 00:00:00 2001 From: octospacc Date: Fri, 29 Jul 2022 20:34:03 +0200 Subject: [PATCH] Change handling of page indexing, added Uncategorized autocategory --- Source/Modules/Site.py | 28 +++++++++++++++++----------- TODO | 5 +++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Source/Modules/Site.py b/Source/Modules/Site.py index c0e2faf..395af9a 100644 --- a/Source/Modules/Site.py +++ b/Source/Modules/Site.py @@ -111,13 +111,13 @@ def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, Unite=[], Type='Page List += Levels + Title + '\n' return markdown(MarkdownHTMLEscape(List, MarkdownExts), extensions=MarkdownExts) -def Preprocessor(Path, SiteRoot, GlobalMacros): +def Preprocessor(Path, Type, SiteRoot, GlobalMacros): File = ReadFile(Path) Content, Titles, DashyTitles, HTMLTitlesFound, Macros, Meta = '', [], [], False, '', { 'Template': 'Standard.html', 'Style': '', - 'Type': '', - 'Index': 'True', + 'Type': Type, + 'Index': 'Unspecified', 'Feed': 'True', 'Title': '', 'HTMLTitle': '', @@ -185,6 +185,13 @@ def Preprocessor(Path, SiteRoot, GlobalMacros): Content += MakeLinkableTitle(l, Title, DashTitle, 'pug') + '\n' else: Content += l + '\n' + if Meta['Index'] in ('Default', 'Unspecified'): + if not Meta['Categories']: + Meta['Categories'] = ['Uncategorized'] + if Meta['Type'] == 'Page': + Meta['Index'] = 'False' + elif Meta['Type'] == 'Post': + Meta['Index'] = 'True' if GlobalMacros: Meta['Macros'].update(GlobalMacros) Meta['Macros'].update(ReadConf(LoadConfStr('[Macros]\n' + Macros), 'Macros')) @@ -353,11 +360,9 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu, elif Type == 'Post': Files = PostsPaths for File in Files: - Content, Titles, Meta = Preprocessor(f"{Type}s/{File}", SiteRoot, GlobalMacros) + Content, Titles, Meta = Preprocessor(f"{Type}s/{File}", Type, SiteRoot, GlobalMacros) if Type != 'Page': File = f"{Type}s/{File}" - if not Meta['Type']: - Meta['Type'] = Type Pages += [[File, Content, Titles, Meta]] for Cat in Meta['Categories']: Categories.update({Cat:''}) @@ -388,14 +393,15 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu, if not Exists: File = f"Categories/{Cat}.md" FilePath = f"public/{File}" - WriteFile(FilePath, """\ -// Title: {Category} + WriteFile(FilePath, f"""\ +// Title: {Cat} // Type: Page +// Index: True -# {Category} +# {Cat} -
[HTML:Category:{Category}]
-""".format(Category=Cat)) +
[HTML:Category:{Cat}]
+""") Content, Titles, Meta = Preprocessor(FilePath, SiteRoot) Pages += [[File, Content, Titles, Meta]] diff --git a/TODO b/TODO index 21ab971..525cc8b 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ +- Make alt text for images also be title text +- Custom category names showing in header links - Fix arguments - some are only callable from CLI and not Site.ini +- Fix ordering menu in Site.ini (not working for inner pages) - Fix Python-Markdown is installed problem (to load our modules) -- Postprocessing markdown footnotes to add brackets - Hot-recompile - Differential recompile - Feed generation without native libraries @@ -8,4 +10,3 @@ - Full XML sitemap - SCSS support - Images in post listings -- "Uncategorized" category for posts without specified ones