mirror of https://gitlab.com/octtspacc/staticoso
Misc. fixes/improvements; Fixed DiffBuild
This commit is contained in:
parent
a1e77b8f91
commit
c4224e65a3
|
@ -71,7 +71,7 @@ Needed for Gemtext output support:
|
||||||
- [x] Generation of global website menu as a tree or as a line
|
- [x] Generation of global website menu as a tree or as a line
|
||||||
- [x] Generation of page (titles) menu as a tree
|
- [x] Generation of page (titles) menu as a tree
|
||||||
- [x] Auto-detection of titles in a page
|
- [x] Auto-detection of titles in a page
|
||||||
- [x] _HTML_, TXT, _Extended Markdown_, and _Pug_ supported for input page files
|
- [x] **HTML**, **TXT**, **Extended Markdown**, and **Pug** supported as input page files
|
||||||
- [ ] Out of heavy-WIP state
|
- [ ] Out of heavy-WIP state
|
||||||
|
|
||||||
## Known issues (might need further investigation)
|
## Known issues (might need further investigation)
|
||||||
|
|
|
@ -117,36 +117,44 @@ def Main(Args, FeedEntries):
|
||||||
OutputDir = OptionChoose('public', Args.OutputDir, ReadConf(SiteConf, 'Site', 'OutputDir'))
|
OutputDir = OptionChoose('public', Args.OutputDir, ReadConf(SiteConf, 'Site', 'OutputDir'))
|
||||||
OutputDir = OutputDir.removesuffix('/')
|
OutputDir = OutputDir.removesuffix('/')
|
||||||
CheckSafeOutputDir(OutputDir)
|
CheckSafeOutputDir(OutputDir)
|
||||||
print(f"[I] Outputting to {OutputDir}/")
|
print(f"[I] Outputting to: {OutputDir}/")
|
||||||
|
|
||||||
DiffBuild = Args.DiffBuild
|
DiffBuild = Args.DiffBuild
|
||||||
|
|
||||||
BlogName = OptionChoose('', Args.BlogName, ReadConf(SiteConf, 'Site', 'BlogName'))
|
BlogName = OptionChoose('', Args.BlogName, ReadConf(SiteConf, 'Site', 'BlogName'))
|
||||||
SiteTagline = OptionChoose('', Args.SiteTagline, ReadConf(SiteConf, 'Site', 'Tagline'))
|
SiteTagline = OptionChoose('', Args.SiteTagline, ReadConf(SiteConf, 'Site', 'Tagline'))
|
||||||
SiteTemplate = OptionChoose('Default.html', Args.SiteTemplate, ReadConf(SiteConf, 'Site', 'Template'))
|
SiteTemplate = OptionChoose('Default.html', Args.SiteTemplate, ReadConf(SiteConf, 'Site', 'Template'))
|
||||||
SiteDomain = OptionChoose('', Args.SiteDomain, ReadConf(SiteConf, 'Site', 'Domain'))
|
SiteDomain = OptionChoose('', Args.SiteDomain, ReadConf(SiteConf, 'Site', 'Domain'))
|
||||||
SiteDomain = SiteDomain.removesuffix('/')
|
|
||||||
SiteRoot = OptionChoose('/', Args.SiteRoot, ReadConf(SiteConf, 'Site', 'Root'))
|
SiteRoot = OptionChoose('/', Args.SiteRoot, ReadConf(SiteConf, 'Site', 'Root'))
|
||||||
SiteLang = OptionChoose('en', Args.SiteLang, ReadConf(SiteConf, 'Site', 'Lang'))
|
SiteLang = OptionChoose('en', Args.SiteLang, ReadConf(SiteConf, 'Site', 'Lang'))
|
||||||
Locale = LoadLocale(SiteLang)
|
|
||||||
MastodonURL = OptionChoose('', Args.MastodonURL, ReadConf(SiteConf, 'Mastodon', 'URL'))
|
Sorting = literal_eval(OptionChoose('{}', Args.Sorting, ReadConf(SiteConf, 'Site', 'Sorting')))
|
||||||
MastodonToken = OptionChoose('', Args.MastodonToken, ReadConf(SiteConf, 'Mastodon', 'Token'))
|
|
||||||
DynamicParts = literal_eval(OptionChoose('{}', Args.DynamicParts, ReadConf(SiteConf, 'Site', 'DynamicParts')))
|
DynamicParts = literal_eval(OptionChoose('{}', Args.DynamicParts, ReadConf(SiteConf, 'Site', 'DynamicParts')))
|
||||||
MarkdownExts = literal_eval(OptionChoose(str(MarkdownExtsDefault), Args.MarkdownExts, ReadConf(SiteConf, 'Markdown', 'Exts')))
|
NoScripts = StringBoolChoose(False, Args.NoScripts, ReadConf(SiteConf, 'Site', 'NoScripts'))
|
||||||
|
|
||||||
ActivityPubTypeFilter = OptionChoose('Post', Args.ActivityPubTypeFilter, ReadConf(SiteConf, 'ActivityPub', 'TypeFilter'))
|
ActivityPubTypeFilter = OptionChoose('Post', Args.ActivityPubTypeFilter, ReadConf(SiteConf, 'ActivityPub', 'TypeFilter'))
|
||||||
ActivityPubHoursLimit = OptionChoose(168, Args.ActivityPubHoursLimit, ReadConf(SiteConf, 'ActivityPub', 'HoursLimit'))
|
ActivityPubHoursLimit = OptionChoose(168, Args.ActivityPubHoursLimit, ReadConf(SiteConf, 'ActivityPub', 'HoursLimit'))
|
||||||
FeedCategoryFilter = OptionChoose('Blog', Args.FeedCategoryFilter, ReadConf(SiteConf, 'Feed', 'CategoryFilter'))
|
|
||||||
|
MastodonURL = OptionChoose('', Args.MastodonURL, ReadConf(SiteConf, 'Mastodon', 'URL'))
|
||||||
|
MastodonToken = OptionChoose('', Args.MastodonToken, ReadConf(SiteConf, 'Mastodon', 'Token'))
|
||||||
|
|
||||||
|
MarkdownExts = literal_eval(OptionChoose(str(MarkdownExtsDefault), Args.MarkdownExts, ReadConf(SiteConf, 'Markdown', 'Exts')))
|
||||||
|
SitemapOutput = StringBoolChoose(True, Args.SitemapOutput, ReadConf(SiteConf, 'Sitemap', 'Output'))
|
||||||
|
|
||||||
Minify = StringBoolChoose(False, Args.Minify, ReadConf(SiteConf, 'Minify', 'Minify'))
|
Minify = StringBoolChoose(False, Args.Minify, ReadConf(SiteConf, 'Minify', 'Minify'))
|
||||||
MinifyKeepComments = StringBoolChoose(False, Args.MinifyKeepComments, ReadConf(SiteConf, 'Minify', 'KeepComments'))
|
MinifyKeepComments = StringBoolChoose(False, Args.MinifyKeepComments, ReadConf(SiteConf, 'Minify', 'KeepComments'))
|
||||||
NoScripts = StringBoolChoose(False, Args.NoScripts, ReadConf(SiteConf, 'Site', 'NoScripts'))
|
|
||||||
ImgAltToTitle = StringBoolChoose(True, Args.ImgAltToTitle, ReadConf(SiteConf, 'Site', 'ImgAltToTitle'))
|
ImgAltToTitle = StringBoolChoose(True, Args.ImgAltToTitle, ReadConf(SiteConf, 'Site', 'ImgAltToTitle'))
|
||||||
ImgTitleToAlt = StringBoolChoose(False, Args.ImgTitleToAlt, ReadConf(SiteConf, 'Site', 'ImgTitleToAlt'))
|
ImgTitleToAlt = StringBoolChoose(False, Args.ImgTitleToAlt, ReadConf(SiteConf, 'Site', 'ImgTitleToAlt'))
|
||||||
|
|
||||||
CategoriesAutomatic = StringBoolChoose(False, Args.CategoriesAutomatic, ReadConf(SiteConf, 'Categories', 'Automatic'))
|
CategoriesAutomatic = StringBoolChoose(False, Args.CategoriesAutomatic, ReadConf(SiteConf, 'Categories', 'Automatic'))
|
||||||
CategoriesUncategorized = OptionChoose('Uncategorized', Args.CategoriesUncategorized, ReadConf(SiteConf, 'Categories', 'Uncategorized'))
|
CategoriesUncategorized = OptionChoose('Uncategorized', Args.CategoriesUncategorized, ReadConf(SiteConf, 'Categories', 'Uncategorized'))
|
||||||
|
|
||||||
GemtextOutput = StringBoolChoose(False, Args.GemtextOutput, ReadConf(SiteConf, 'Gemtext', 'Output'))
|
GemtextOutput = StringBoolChoose(False, Args.GemtextOutput, ReadConf(SiteConf, 'Gemtext', 'Output'))
|
||||||
GemtextHeader = Args.GemtextHeader if Args.GemtextHeader else ReadConf(SiteConf, 'Gemtext', 'Header') if ReadConf(SiteConf, 'Gemtext', 'Header') else f"# {SiteName}\n\n" if SiteName else ''
|
GemtextHeader = Args.GemtextHeader if Args.GemtextHeader else ReadConf(SiteConf, 'Gemtext', 'Header') if ReadConf(SiteConf, 'Gemtext', 'Header') else f"# {SiteName}\n\n" if SiteName else ''
|
||||||
SitemapOutput = StringBoolChoose(True, Args.SitemapOutput, ReadConf(SiteConf, 'Sitemap', 'Output'))
|
|
||||||
FeedEntries = int(FeedEntries) if (FeedEntries or FeedEntries == 0) and FeedEntries != 'Default' else int(ReadConf(SiteConf, 'Site', 'FeedEntries')) if ReadConf(SiteConf, 'Site', 'FeedEntries') else 10
|
FeedCategoryFilter = OptionChoose('Blog', Args.FeedCategoryFilter, ReadConf(SiteConf, 'Feed', 'CategoryFilter'))
|
||||||
Sorting = literal_eval(OptionChoose('{}', Args.Sorting, ReadConf(SiteConf, 'Site', 'Sorting')))
|
FeedEntries = int(FeedEntries) if (FeedEntries or FeedEntries == 0) and FeedEntries != 'Default' else int(ReadConf(SiteConf, 'Feed', 'Entries')) if ReadConf(SiteConf, 'Feed', 'Entries') else 10
|
||||||
|
|
||||||
MenuEntries = ReadConf(SiteConf, 'Menu')
|
MenuEntries = ReadConf(SiteConf, 'Menu')
|
||||||
if MenuEntries:
|
if MenuEntries:
|
||||||
|
@ -154,6 +162,9 @@ def Main(Args, FeedEntries):
|
||||||
else:
|
else:
|
||||||
ConfMenu = []
|
ConfMenu = []
|
||||||
|
|
||||||
|
SiteDomain = SiteDomain.removesuffix('/')
|
||||||
|
Locale = LoadLocale(SiteLang)
|
||||||
|
|
||||||
if DiffBuild:
|
if DiffBuild:
|
||||||
print("[I] Build mode: Differential")
|
print("[I] Build mode: Differential")
|
||||||
LimitFiles = GetModifiedFiles(OutputDir)
|
LimitFiles = GetModifiedFiles(OutputDir)
|
||||||
|
@ -202,7 +213,8 @@ def Main(Args, FeedEntries):
|
||||||
ImgAltToTitle=ImgAltToTitle, ImgTitleToAlt=ImgTitleToAlt,
|
ImgAltToTitle=ImgAltToTitle, ImgTitleToAlt=ImgTitleToAlt,
|
||||||
Sorting=SetSorting(Sorting),
|
Sorting=SetSorting(Sorting),
|
||||||
MarkdownExts=MarkdownExts,
|
MarkdownExts=MarkdownExts,
|
||||||
AutoCategories=CategoriesAutomatic)
|
AutoCategories=CategoriesAutomatic,
|
||||||
|
CategoryUncategorized=CategoriesUncategorized)
|
||||||
|
|
||||||
if FeedEntries != 0:
|
if FeedEntries != 0:
|
||||||
print("[I] Generating Feeds")
|
print("[I] Generating Feeds")
|
||||||
|
@ -235,6 +247,8 @@ def Main(Args, FeedEntries):
|
||||||
MastodonPosts = []
|
MastodonPosts = []
|
||||||
|
|
||||||
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
||||||
|
if IsLightRun(File, LimitFiles):
|
||||||
|
continue
|
||||||
File = f"{OutputDir}/{StripExt(File)}.html"
|
File = f"{OutputDir}/{StripExt(File)}.html"
|
||||||
Content = ReadFile(File)
|
Content = ReadFile(File)
|
||||||
Post = ''
|
Post = ''
|
||||||
|
@ -250,7 +264,7 @@ def Main(Args, FeedEntries):
|
||||||
|
|
||||||
if GemtextOutput:
|
if GemtextOutput:
|
||||||
print("[I] Generating Gemtext")
|
print("[I] Generating Gemtext")
|
||||||
GemtextCompileList(OutputDir, Pages, GemtextHeader)
|
GemtextCompileList(OutputDir, Pages, LimitFiles, GemtextHeader)
|
||||||
|
|
||||||
print("[I] Cleaning Temporary Files")
|
print("[I] Cleaning Temporary Files")
|
||||||
DelTmp(OutputDir)
|
DelTmp(OutputDir)
|
||||||
|
@ -292,8 +306,8 @@ if __name__ == '__main__':
|
||||||
Parser.add_argument('--FeedCategoryFilter', type=str)
|
Parser.add_argument('--FeedCategoryFilter', type=str)
|
||||||
Parser.add_argument('--ActivityPubTypeFilter', type=str, help=argparse.SUPPRESS)
|
Parser.add_argument('--ActivityPubTypeFilter', type=str, help=argparse.SUPPRESS)
|
||||||
Parser.add_argument('--ActivityPubHoursLimit', type=int)
|
Parser.add_argument('--ActivityPubHoursLimit', type=int)
|
||||||
Parser.add_argument('--CategoriesUncategorized', type=str)
|
|
||||||
Parser.add_argument('--CategoriesAutomatic', type=str)
|
Parser.add_argument('--CategoriesAutomatic', type=str)
|
||||||
|
Parser.add_argument('--CategoriesUncategorized', type=str)
|
||||||
Args = Parser.parse_args()
|
Args = Parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -22,9 +22,11 @@ def FixGemlogDateLine(Line):
|
||||||
Line = Words[0] + '\n' + Words[1][1:] + ' ' + ' '.join(Words[2:])
|
Line = Words[0] + '\n' + Words[1][1:] + ' ' + ' '.join(Words[2:])
|
||||||
return Line
|
return Line
|
||||||
|
|
||||||
def GemtextCompileList(OutputDir, Pages, Header=''):
|
def GemtextCompileList(OutputDir, Pages, LimitFiles, Header=''):
|
||||||
Cmd = ''
|
Cmd = ''
|
||||||
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
||||||
|
if IsLightRun(File, LimitFiles):
|
||||||
|
continue
|
||||||
Src = f"{OutputDir}.gmi/{StripExt(File)}.html.tmp"
|
Src = f"{OutputDir}.gmi/{StripExt(File)}.html.tmp"
|
||||||
Dst = f"{OutputDir}.gmi/{StripExt(File)}.gmi"
|
Dst = f"{OutputDir}.gmi/{StripExt(File)}.gmi"
|
||||||
SlimHTML = StripAttrs(SlimHTML)
|
SlimHTML = StripAttrs(SlimHTML)
|
||||||
|
@ -33,8 +35,11 @@ def GemtextCompileList(OutputDir, Pages, Header=''):
|
||||||
SlimHTML = SlimHTML.replace(j, '')
|
SlimHTML = SlimHTML.replace(j, '')
|
||||||
WriteFile(Src, SlimHTML.replace('</a>', '</a><br>').replace('.html', '.gmi')) # TODO: Adjust links properly..
|
WriteFile(Src, SlimHTML.replace('</a>', '</a><br>').replace('.html', '.gmi')) # TODO: Adjust links properly..
|
||||||
Cmd += f'cat "{Src}" | html2gmi > "{Dst}"; '
|
Cmd += f'cat "{Src}" | html2gmi > "{Dst}"; '
|
||||||
|
if Cmd:
|
||||||
os.system(Cmd)
|
os.system(Cmd)
|
||||||
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
||||||
|
if IsLightRun(File, LimitFiles):
|
||||||
|
continue
|
||||||
Dst = f"{OutputDir}.gmi/{StripExt(File)}.gmi"
|
Dst = f"{OutputDir}.gmi/{StripExt(File)}.gmi"
|
||||||
Gemtext = ''
|
Gemtext = ''
|
||||||
for Line in ReadFile(Dst).splitlines():
|
for Line in ReadFile(Dst).splitlines():
|
||||||
|
|
|
@ -149,7 +149,7 @@ def TemplatePreprocessor(Text):
|
||||||
Meta.update({i:MetaDefault[i]})
|
Meta.update({i:MetaDefault[i]})
|
||||||
return Meta
|
return Meta
|
||||||
|
|
||||||
def PagePreprocessor(Path, Type, SiteTemplate, SiteRoot, GlobalMacros, LightRun=False):
|
def PagePreprocessor(Path, Type, SiteTemplate, SiteRoot, GlobalMacros, CategoryUncategorized, LightRun=False):
|
||||||
File = ReadFile(Path)
|
File = ReadFile(Path)
|
||||||
Path = Path.lower()
|
Path = Path.lower()
|
||||||
Content, Titles, DashyTitles, HTMLTitlesFound, Macros, Meta, MetaDefault = '', [], [], False, '', '', {
|
Content, Titles, DashyTitles, HTMLTitlesFound, Macros, Meta, MetaDefault = '', [], [], False, '', '', {
|
||||||
|
@ -236,7 +236,7 @@ def PagePreprocessor(Path, Type, SiteTemplate, SiteRoot, GlobalMacros, LightRun=
|
||||||
Meta.update({i:MetaDefault[i]})
|
Meta.update({i:MetaDefault[i]})
|
||||||
if Meta['Index'] in ('Default', 'Unspecified'):
|
if Meta['Index'] in ('Default', 'Unspecified'):
|
||||||
if not Meta['Categories']:
|
if not Meta['Categories']:
|
||||||
Meta['Categories'] = ['Uncategorized']
|
Meta['Categories'] = [CategoryUncategorized]
|
||||||
if Meta['Type'] == 'Page':
|
if Meta['Type'] == 'Page':
|
||||||
Meta['Index'] = 'False'
|
Meta['Index'] = 'False'
|
||||||
elif Meta['Type'] == 'Post':
|
elif Meta['Type'] == 'Post':
|
||||||
|
@ -302,7 +302,7 @@ def CanIndex(Index, For):
|
||||||
else:
|
else:
|
||||||
return True if Index == For else False
|
return True if Index == For else False
|
||||||
|
|
||||||
def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLPagesList, PagePath, Content, Titles, Meta, SiteRoot, SiteName, BlogName, FolderRoots, Categories, SiteLang, Locale):
|
def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLPagesList, PagePath, Content, Titles, Meta, SiteRoot, SiteName, BlogName, FolderRoots, Categories, SiteLang, Locale, LightRun):
|
||||||
HTMLTitles = FormatTitles(Titles)
|
HTMLTitles = FormatTitles(Titles)
|
||||||
BodyDescription, BodyImage = '', ''
|
BodyDescription, BodyImage = '', ''
|
||||||
if not File.lower().endswith('.txt'):
|
if not File.lower().endswith('.txt'):
|
||||||
|
@ -339,6 +339,10 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
||||||
|
|
||||||
for e in StaticPartsText:
|
for e in StaticPartsText:
|
||||||
HTML = ReplWithEsc(HTML, f"[staticoso:StaticPart:{e}]", StaticPartsText[e])
|
HTML = ReplWithEsc(HTML, f"[staticoso:StaticPart:{e}]", StaticPartsText[e])
|
||||||
|
|
||||||
|
if LightRun:
|
||||||
|
HTML = None
|
||||||
|
else:
|
||||||
HTML = DictReplWithEsc(
|
HTML = DictReplWithEsc(
|
||||||
HTML, {
|
HTML, {
|
||||||
'[staticoso:Site:Menu]': HTMLPagesList,
|
'[staticoso:Site:Menu]': HTMLPagesList,
|
||||||
|
@ -368,6 +372,9 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
||||||
ContentHTML = Content
|
ContentHTML = Content
|
||||||
ContentHTML = DictReplWithEsc(
|
ContentHTML = DictReplWithEsc(
|
||||||
ContentHTML, {
|
ContentHTML, {
|
||||||
|
'[staticoso:Page:Title]': Title,
|
||||||
|
'[staticoso:Page:Description]': Description,
|
||||||
|
'[staticoso:Site:Name]': SiteName,
|
||||||
'[staticoso:Site:AbsoluteRoot]': SiteRoot,
|
'[staticoso:Site:AbsoluteRoot]': SiteRoot,
|
||||||
'[staticoso:Site:RelativeRoot]': GetPathLevels(PagePath)
|
'[staticoso:Site:RelativeRoot]': GetPathLevels(PagePath)
|
||||||
})
|
})
|
||||||
|
@ -378,11 +385,10 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
||||||
for e in Categories:
|
for e in Categories:
|
||||||
ContentHTML = ReplWithEsc(ContentHTML, f"<span>[staticoso:Category:{e}]</span>", Categories[e])
|
ContentHTML = ReplWithEsc(ContentHTML, f"<span>[staticoso:Category:{e}]</span>", Categories[e])
|
||||||
ContentHTML = ReplWithEsc(ContentHTML, f"[staticoso:Category:{e}]", Categories[e])
|
ContentHTML = ReplWithEsc(ContentHTML, f"[staticoso:Category:{e}]", Categories[e])
|
||||||
SlimHTML = HTMLPagesList + ContentHTML
|
|
||||||
|
|
||||||
return HTML, ContentHTML, SlimHTML, Description, Image
|
return HTML, ContentHTML, Description, Image
|
||||||
|
|
||||||
def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts, DynamicPartsText, ConfMenu, GlobalMacros, SiteName, BlogName, SiteTagline, SiteTemplate, SiteDomain, SiteRoot, FolderRoots, SiteLang, Locale, Minify, MinifyKeepComments, NoScripts, ImgAltToTitle, ImgTitleToAlt, Sorting, MarkdownExts, AutoCategories):
|
def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts, DynamicPartsText, ConfMenu, GlobalMacros, SiteName, BlogName, SiteTagline, SiteTemplate, SiteDomain, SiteRoot, FolderRoots, SiteLang, Locale, Minify, MinifyKeepComments, NoScripts, ImgAltToTitle, ImgTitleToAlt, Sorting, MarkdownExts, AutoCategories, CategoryUncategorized):
|
||||||
PagesPaths, PostsPaths, Pages, MadePages, Categories = [], [], [], [], {}
|
PagesPaths, PostsPaths, Pages, MadePages, Categories = [], [], [], [], {}
|
||||||
for Ext in FileExtensions['Pages']:
|
for Ext in FileExtensions['Pages']:
|
||||||
for File in Path('Pages').rglob(f"*.{Ext}"):
|
for File in Path('Pages').rglob(f"*.{Ext}"):
|
||||||
|
@ -408,7 +414,7 @@ def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts
|
||||||
for File in Files:
|
for File in Files:
|
||||||
TempPath = f"{PathPrefix}{File}"
|
TempPath = f"{PathPrefix}{File}"
|
||||||
LightRun = False if LimitFiles == False or TempPath in LimitFiles else True
|
LightRun = False if LimitFiles == False or TempPath in LimitFiles else True
|
||||||
Content, Titles, Meta = PagePreprocessor(f"{Type}s/{File}", Type, SiteTemplate, SiteRoot, GlobalMacros, LightRun=LightRun)
|
Content, Titles, Meta = PagePreprocessor(f"{Type}s/{File}", Type, SiteTemplate, SiteRoot, GlobalMacros, CategoryUncategorized, LightRun=LightRun)
|
||||||
Pages += [[TempPath, Content, Titles, Meta]]
|
Pages += [[TempPath, Content, Titles, Meta]]
|
||||||
for Cat in Meta['Categories']:
|
for Cat in Meta['Categories']:
|
||||||
Categories.update({Cat:''})
|
Categories.update({Cat:''})
|
||||||
|
@ -440,7 +446,7 @@ def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts
|
||||||
File = f"Categories/{Cat}.md"
|
File = f"Categories/{Cat}.md"
|
||||||
FilePath = f"{OutputDir}/{File}"
|
FilePath = f"{OutputDir}/{File}"
|
||||||
WriteFile(FilePath, CategoryPageTemplate.format(Title=Cat))
|
WriteFile(FilePath, CategoryPageTemplate.format(Title=Cat))
|
||||||
Content, Titles, Meta = PagePreprocessor(FilePath, SiteRoot)
|
Content, Titles, Meta = PagePreprocessor(FilePath, 'Page', SiteTemplate, SiteRoot, GlobalMacros, CategoryUncategorized, LightRun=LightRun)
|
||||||
Pages += [[File, Content, Titles, Meta]]
|
Pages += [[File, Content, Titles, Meta]]
|
||||||
|
|
||||||
for i,e in enumerate(ConfMenu):
|
for i,e in enumerate(ConfMenu):
|
||||||
|
@ -451,6 +457,8 @@ def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts
|
||||||
|
|
||||||
print("[I] Writing Pages")
|
print("[I] Writing Pages")
|
||||||
for File, Content, Titles, Meta in Pages:
|
for File, Content, Titles, Meta in Pages:
|
||||||
|
LightRun = False if LimitFiles == False or File in LimitFiles else True
|
||||||
|
|
||||||
PagePath = f"{OutputDir}/{StripExt(File)}.html"
|
PagePath = f"{OutputDir}/{StripExt(File)}.html"
|
||||||
if File.lower().endswith(FileExtensions['Markdown']):
|
if File.lower().endswith(FileExtensions['Markdown']):
|
||||||
Content = markdown(PagePostprocessor('md', Content, Meta), extensions=MarkdownExts)
|
Content = markdown(PagePostprocessor('md', Content, Meta), extensions=MarkdownExts)
|
||||||
|
@ -461,6 +469,9 @@ def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts
|
||||||
elif File.lower().endswith(FileExtensions['HTML']):
|
elif File.lower().endswith(FileExtensions['HTML']):
|
||||||
Content = ReadFile(PagePath)
|
Content = ReadFile(PagePath)
|
||||||
|
|
||||||
|
if LightRun:
|
||||||
|
HTMLPagesList = None
|
||||||
|
else:
|
||||||
TemplateMeta = TemplatePreprocessor(TemplatesText[Meta['Template']])
|
TemplateMeta = TemplatePreprocessor(TemplatesText[Meta['Template']])
|
||||||
HTMLPagesList = GetHTMLPagesList(
|
HTMLPagesList = GetHTMLPagesList(
|
||||||
Pages=Pages,
|
Pages=Pages,
|
||||||
|
@ -473,7 +484,7 @@ def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts
|
||||||
MarkdownExts=MarkdownExts,
|
MarkdownExts=MarkdownExts,
|
||||||
MenuStyle=TemplateMeta['MenuStyle'])
|
MenuStyle=TemplateMeta['MenuStyle'])
|
||||||
|
|
||||||
HTML, ContentHTML, SlimHTML, Description, Image = PatchHTML(
|
HTML, ContentHTML, Description, Image = PatchHTML(
|
||||||
File=File,
|
File=File,
|
||||||
HTML=TemplatesText[Meta['Template']],
|
HTML=TemplatesText[Meta['Template']],
|
||||||
StaticPartsText=StaticPartsText,
|
StaticPartsText=StaticPartsText,
|
||||||
|
@ -490,16 +501,30 @@ def MakeSite(OutputDir, LimitFiles, TemplatesText, StaticPartsText, DynamicParts
|
||||||
FolderRoots=FolderRoots,
|
FolderRoots=FolderRoots,
|
||||||
Categories=Categories,
|
Categories=Categories,
|
||||||
SiteLang=SiteLang,
|
SiteLang=SiteLang,
|
||||||
Locale=Locale)
|
Locale=Locale,
|
||||||
|
LightRun=LightRun)
|
||||||
|
|
||||||
if Minify:
|
if Minify:
|
||||||
|
if not LightRun:
|
||||||
HTML = DoMinifyHTML(HTML, MinifyKeepComments)
|
HTML = DoMinifyHTML(HTML, MinifyKeepComments)
|
||||||
|
ContentHTML = DoMinifyHTML(ContentHTML, MinifyKeepComments)
|
||||||
if NoScripts:
|
if NoScripts:
|
||||||
|
if not LightRun:
|
||||||
HTML = StripTags(HTML, ['script'])
|
HTML = StripTags(HTML, ['script'])
|
||||||
|
ContentHTML = StripTags(ContentHTML, ['script'])
|
||||||
if ImgAltToTitle or ImgTitleToAlt:
|
if ImgAltToTitle or ImgTitleToAlt:
|
||||||
|
if not LightRun:
|
||||||
HTML = WriteImgAltAndTitle(HTML, ImgAltToTitle, ImgTitleToAlt)
|
HTML = WriteImgAltAndTitle(HTML, ImgAltToTitle, ImgTitleToAlt)
|
||||||
|
ContentHTML = WriteImgAltAndTitle(ContentHTML, ImgAltToTitle, ImgTitleToAlt)
|
||||||
|
|
||||||
|
if LightRun:
|
||||||
|
SlimHTML = None
|
||||||
|
else:
|
||||||
|
SlimHTML = HTMLPagesList + ContentHTML
|
||||||
|
|
||||||
|
if not LightRun:
|
||||||
WriteFile(PagePath, HTML)
|
WriteFile(PagePath, HTML)
|
||||||
|
|
||||||
MadePages += [[File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image]]
|
MadePages += [[File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image]]
|
||||||
|
|
||||||
return MadePages
|
return MadePages
|
||||||
|
|
|
@ -154,3 +154,6 @@ def LoadLocale(Lang):
|
||||||
return json.loads(File)
|
return json.loads(File)
|
||||||
else:
|
else:
|
||||||
return json.loads(ReadFile(Folder + 'en.json'))
|
return json.loads(ReadFile(Folder + 'en.json'))
|
||||||
|
|
||||||
|
def IsLightRun(File, LimitFiles):
|
||||||
|
return False if LimitFiles == False or File in LimitFiles else True
|
||||||
|
|
3
TODO
3
TODO
|
@ -1,9 +1,8 @@
|
||||||
- Check if external tools (pug-cli, html2gmi) are installed
|
- Check if external tools (pug-cli, html2gmi) are installed
|
||||||
- Fix and optimize differential building
|
- Fix and optimize differential building
|
||||||
- Static code syntax highlighing
|
- Static code syntax highlighing
|
||||||
- Override internal HTML snippets (with config file in Templates/NAME.ini)
|
- Override internal HTML snippets (meta lines, page lists, ...) with config file in Templates/NAME.ini
|
||||||
- Specify input folder(s)
|
- Specify input folder(s)
|
||||||
- Customize HTML source code for Meta lines / page lists
|
|
||||||
- Show page size/words/time in meta line
|
- Show page size/words/time in meta line
|
||||||
- Add feed support for diary-like pages
|
- Add feed support for diary-like pages
|
||||||
- Fix excess whitespace in some section/menu titles
|
- Fix excess whitespace in some section/menu titles
|
||||||
|
|
Loading…
Reference in New Issue