diff --git a/Source/Build.py b/Source/Build.py
index fb8281f..c398e36 100755
--- a/Source/Build.py
+++ b/Source/Build.py
@@ -15,7 +15,6 @@ import time
from ast import literal_eval
from datetime import datetime
from pathlib import Path
-
from Modules.Config import *
from Modules.Gemini import *
from Modules.Logging import *
@@ -23,7 +22,6 @@ from Modules.Markdown import *
from Modules.Site import *
from Modules.Sitemap import *
from Modules.Utils import *
-
try:
from Modules.ActivityPub import *
ActivityPub = True
@@ -108,7 +106,7 @@ def Main(Args, FeedEntries):
HavePages, HavePosts = False, False
SiteConf = LoadConfFile('Site.ini')
- ConfigLogging(DefConfOptChoose('Logging', Args.Logging, ReadConf(SiteConf, 'Main', 'Logging')))
+ ConfigLogging(DefConfOptChoose('Logging', Args.Logging, ReadConf(SiteConf, 'staticoso', 'Logging')))
#if Args.InputDir:
# os.chdir(Args.InputDir)
@@ -123,8 +121,8 @@ def Main(Args, FeedEntries):
CheckSafeOutDir(OutDir)
logging.info(f"Outputting to: {OutDir}/")
- Threads = Args.Threads if Args.Threads else 0
- DiffBuild = Args.DiffBuild if Args.DiffBuild else False
+ Threads = Args.Threads if Args.Threads else DefConf['Threads']
+ DiffBuild = Args.DiffBuild if Args.DiffBuild else DefConf['DiffBuild']
BlogName = Flags['BlogName'] = OptChoose('', Args.BlogName, ReadConf(SiteConf, 'Site', 'BlogName'))
SiteTagline = Flags['SiteTagline'] = OptChoose('', Args.SiteTagline, ReadConf(SiteConf, 'Site', 'Tagline'))
@@ -274,7 +272,7 @@ if __name__ == '__main__':
Parser = argparse.ArgumentParser()
Parser.add_argument('--Logging', type=str) # Levels: Debug, Info, Warning, Error.
- Parser.add_argument('--Threads', type=str)
+ Parser.add_argument('--Threads', type=str) # Set 0 to use all CPU cores
Parser.add_argument('--DiffBuild', type=str)
Parser.add_argument('--OutputDir', type=str)
#Parser.add_argument('--InputDir', type=str)
diff --git a/Source/Modules/Config.py b/Source/Modules/Config.py
index 1dcbbed..b71fda7 100644
--- a/Source/Modules/Config.py
+++ b/Source/Modules/Config.py
@@ -12,6 +12,8 @@ from ast import literal_eval
DefConf = {
'Logging': 20,
+ 'Threads': 0,
+ 'DiffBuild': False,
'OutDir': 'public',
'SiteLang': 'en',
'SiteTemplate': 'Default.html',
diff --git a/Source/Modules/Elements.py b/Source/Modules/Elements.py
index 9042d23..3e06afa 100644
--- a/Source/Modules/Elements.py
+++ b/Source/Modules/Elements.py
@@ -91,7 +91,7 @@ def MakeCategoryLine(File, Meta):
return Categories
def MakeListTitle(File, Meta, Titles, Prefer, SiteRoot, BlogName, PathPrefix=''):
- Title = GetTitle(File.split('/')[-1], Meta, Titles, Prefer, BlogName)
+ Title = GetTitle(File.split('/')[-1], Meta, Titles, Prefer, BlogName).lstrip().rstrip()
Link = False if Meta['Index'] == 'Unlinked' else True
if Link:
Title = '[{}]({})'.format(
diff --git a/Source/Modules/Site.py b/Source/Modules/Site.py
index 3c58de4..71e487e 100644
--- a/Source/Modules/Site.py
+++ b/Source/Modules/Site.py
@@ -18,8 +18,8 @@ from Modules.Markdown import *
from Modules.Pug import *
from Modules.Utils import *
-def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, CallbackFile=None, Unite=[], Type=None, PathFilter='', Category=None, For='Menu', MarkdownExts=(), MenuStyle='Default'):
- ShowPaths, Flatten, SingleLine = True, False, False
+def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, CallbackFile=None, Unite=[], Type=None, Limit=None, PathFilter='', Category=None, For='Menu', MarkdownExts=(), MenuStyle='Default'):
+ ShowPaths, Flatten, SingleLine, DoneCount = True, False, False, 0
if MenuStyle == 'Flat':
Flatten = True
elif MenuStyle == 'Line':
@@ -41,12 +41,14 @@ def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, CallbackFile=None, U
if e:
IndexPages.insert(i,[e,None,None,{'Type':Type,'Index':'True','Order':'Unite'}])
for File, Content, Titles, Meta in IndexPages:
+ # Allow for the virtual "Pages/" prefix to be used in path filtering
TmpPathFilter = PathFilter
if TmpPathFilter.startswith('Pages/'):
TmpPathFilter = TmpPathFilter[len('Pages/'):]
if File.startswith('Posts/'):
continue
- if (not Type or (Meta['Type'] == Type and CanIndex(Meta['Index'], For))) and (not Category or Category in Meta['Categories']) and File.startswith(TmpPathFilter) and File != CallbackFile:
+
+ if (not Type or (Meta['Type'] == Type and CanIndex(Meta['Index'], For))) and (not Category or Category in Meta['Categories']) and File.startswith(TmpPathFilter) and File != CallbackFile and (not Limit or Limit > DoneCount):
Depth = (File.count('/') + 1) if Meta['Order'] != 'Unite' else 1
if Depth > 1 and Meta['Order'] != 'Unite': # Folder names are handled here
CurParent = File.split('/')[:-1]
@@ -54,17 +56,21 @@ def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, CallbackFile=None, U
if LastParent != CurParent and ShowPaths:
LastParent = CurParent
Levels = '- ' * ((Depth-1+i) if not Flatten else 1)
- # Folders with else without an index file
+ # If search node endswith index, it's a page; else, it's a folder
if StripExt(File).endswith('index'):
Title = MakeListTitle(File, Meta, Titles, 'HTMLTitle', SiteRoot, BlogName, PathPrefix)
+ DoneCount += 1
else:
Title = CurParent[Depth-2+i]
if SingleLine:
List += ' ' + Title + ' '
else:
List += Levels + Title + '\n'
+
+ # Pages with any other path
if not (Depth > 1 and StripExt(File).split('/')[-1] == 'index'):
Levels = '- ' * (Depth if not Flatten else 1)
+ DoneCount += 1
if Meta['Order'] == 'Unite':
Title = File
else:
@@ -73,6 +79,7 @@ def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, CallbackFile=None, U
List += ' ' + Title + ' '
else:
List += Levels + Title + '\n'
+
return markdown(MarkdownHTMLEscape(List, MarkdownExts), extensions=MarkdownExts)
def CheckHTMLCommentLine(Line):
@@ -262,14 +269,15 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
if '