mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-06-05 22:09:23 +02:00
Choos. log level + threads num.; Add HTML <pre> fix; Add md. extension
This commit is contained in:
@ -20,11 +20,12 @@ try:
|
|||||||
from Modules.ActivityPub import *
|
from Modules.ActivityPub import *
|
||||||
ActivityPub = True
|
ActivityPub = True
|
||||||
except:
|
except:
|
||||||
print("[W] ⚠ Can't load the ActivityPub module. Its use is disabled. Make sure the 'requests' library is installed.")
|
logging.warning("⚠ Can't load the ActivityPub module. Its use is disabled. Make sure the 'requests' library is installed.")
|
||||||
ActivityPub = False
|
ActivityPub = False
|
||||||
|
|
||||||
from Modules.Config import *
|
from Modules.Config import *
|
||||||
from Modules.Gemini import *
|
from Modules.Gemini import *
|
||||||
|
from Modules.Logging import *
|
||||||
from Modules.Markdown import *
|
from Modules.Markdown import *
|
||||||
from Modules.Site import *
|
from Modules.Site import *
|
||||||
from Modules.Sitemap import *
|
from Modules.Sitemap import *
|
||||||
@ -74,10 +75,10 @@ def CheckSafeOutDir(OutDir):
|
|||||||
OutDir = os.path.realpath(OutDir)
|
OutDir = os.path.realpath(OutDir)
|
||||||
OutFolder = OutDir.split('/')[-1]
|
OutFolder = OutDir.split('/')[-1]
|
||||||
if InDir == OutDir:
|
if InDir == OutDir:
|
||||||
print(f"[E] ⛔ Output and Input directories ({OutDir}) can't be the same. Exiting.")
|
logging.error(f"⛔ Output and Input directories ({OutDir}) can't be the same. Exiting.")
|
||||||
exit(1)
|
exit(1)
|
||||||
elif OutFolder in ReservedPaths and f"{InDir}/{OutFolder}" == OutDir:
|
elif OutFolder in ReservedPaths and f"{InDir}/{OutFolder}" == OutDir:
|
||||||
print(f"[E] ⛔ Output directory {OutDir} can't be a reserved subdirectory of the Input. Exiting.")
|
logging.error(f"⛔ Output directory {OutDir} can't be a reserved subdirectory of the Input. Exiting.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def GetModifiedFiles(OutDir):
|
def GetModifiedFiles(OutDir):
|
||||||
@ -113,16 +114,15 @@ def Main(Args, FeedEntries):
|
|||||||
|
|
||||||
SiteName = Flags['SiteName'] = OptionChoose('', Args.SiteName, ReadConf(SiteConf, 'Site', 'Name'))
|
SiteName = Flags['SiteName'] = OptionChoose('', Args.SiteName, ReadConf(SiteConf, 'Site', 'Name'))
|
||||||
if SiteName:
|
if SiteName:
|
||||||
print(f"[I] Compiling: {SiteName}")
|
logging.info(f"Compiling: {SiteName}")
|
||||||
|
|
||||||
OutDir = Flags['OutDir'] = OptionChoose('public', Args.OutputDir, ReadConf(SiteConf, 'Site', 'OutputDir'))
|
OutDir = Flags['OutDir'] = OptionChoose('public', Args.OutputDir, ReadConf(SiteConf, 'Site', 'OutputDir'))
|
||||||
OutDir = Flags['OutDir'] = OutDir.removesuffix('/')
|
OutDir = Flags['OutDir'] = OutDir.removesuffix('/')
|
||||||
CheckSafeOutDir(OutDir)
|
CheckSafeOutDir(OutDir)
|
||||||
print(f"[I] Outputting to: {OutDir}/")
|
logging.info(f"Outputting to: {OutDir}/")
|
||||||
|
|
||||||
Logging = Args.Logging
|
Threads = Args.Threads if Args.Threads else 0
|
||||||
Threads = Args.Threads
|
DiffBuild = Args.DiffBuild if Args.DiffBuild else False
|
||||||
DiffBuild = Args.DiffBuild
|
|
||||||
|
|
||||||
BlogName = Flags['BlogName'] = OptionChoose('', Args.BlogName, ReadConf(SiteConf, 'Site', 'BlogName'))
|
BlogName = Flags['BlogName'] = OptionChoose('', Args.BlogName, ReadConf(SiteConf, 'Site', 'BlogName'))
|
||||||
SiteTagline = Flags['SiteTagline'] = OptionChoose('', Args.SiteTagline, ReadConf(SiteConf, 'Site', 'Tagline'))
|
SiteTagline = Flags['SiteTagline'] = OptionChoose('', Args.SiteTagline, ReadConf(SiteConf, 'Site', 'Tagline'))
|
||||||
@ -151,6 +151,7 @@ def Main(Args, FeedEntries):
|
|||||||
|
|
||||||
ImgAltToTitle = Flags['ImgAltToTitle'] = StringBoolChoose(True, Args.ImgAltToTitle, ReadConf(SiteConf, 'Site', 'ImgAltToTitle'))
|
ImgAltToTitle = Flags['ImgAltToTitle'] = StringBoolChoose(True, Args.ImgAltToTitle, ReadConf(SiteConf, 'Site', 'ImgAltToTitle'))
|
||||||
ImgTitleToAlt = Flags['ImgTitleToAlt'] = StringBoolChoose(False, Args.ImgTitleToAlt, ReadConf(SiteConf, 'Site', 'ImgTitleToAlt'))
|
ImgTitleToAlt = Flags['ImgTitleToAlt'] = StringBoolChoose(False, Args.ImgTitleToAlt, ReadConf(SiteConf, 'Site', 'ImgTitleToAlt'))
|
||||||
|
HTMLFixPre = Flags['HTMLFixPre'] = StringBoolChoose(False, Args.HTMLFixPre, ReadConf(SiteConf, 'Site', 'HTMLFixPre'))
|
||||||
|
|
||||||
CategoriesAutomatic = Flags['CategoriesAutomatic'] = StringBoolChoose(False, Args.CategoriesAutomatic, ReadConf(SiteConf, 'Categories', 'Automatic'))
|
CategoriesAutomatic = Flags['CategoriesAutomatic'] = StringBoolChoose(False, Args.CategoriesAutomatic, ReadConf(SiteConf, 'Categories', 'Automatic'))
|
||||||
CategoriesUncategorized = Flags['CategoriesUncategorized'] = OptionChoose('Uncategorized', Args.CategoriesUncategorized, ReadConf(SiteConf, 'Categories', 'Uncategorized'))
|
CategoriesUncategorized = Flags['CategoriesUncategorized'] = OptionChoose('Uncategorized', Args.CategoriesUncategorized, ReadConf(SiteConf, 'Categories', 'Uncategorized'))
|
||||||
@ -176,10 +177,10 @@ def Main(Args, FeedEntries):
|
|||||||
Locale = LoadLocale(SiteLang)
|
Locale = LoadLocale(SiteLang)
|
||||||
|
|
||||||
if DiffBuild:
|
if DiffBuild:
|
||||||
print("[I] Build mode: Differential")
|
logging.info("Build mode: Differential")
|
||||||
LimitFiles = GetModifiedFiles(OutDir)
|
LimitFiles = GetModifiedFiles(OutDir)
|
||||||
else:
|
else:
|
||||||
print("[I] Build mode: Clean")
|
logging.info("Build mode: Clean")
|
||||||
ResetOutDir(OutDir)
|
ResetOutDir(OutDir)
|
||||||
LimitFiles = False
|
LimitFiles = False
|
||||||
|
|
||||||
@ -195,25 +196,26 @@ def Main(Args, FeedEntries):
|
|||||||
shutil.copytree('Posts', f"{OutDir}.gmi/Posts", ignore=IgnoreFiles, dirs_exist_ok=True)
|
shutil.copytree('Posts', f"{OutDir}.gmi/Posts", ignore=IgnoreFiles, dirs_exist_ok=True)
|
||||||
|
|
||||||
if not (HavePages or HavePosts):
|
if not (HavePages or HavePosts):
|
||||||
print("[E] No Pages or posts found. Nothing to do, exiting!")
|
logging.error("⛔ No Pages or posts found. Nothing to do, exiting!")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
print("[I] Generating HTML")
|
logging.info("Generating HTML")
|
||||||
Pages = MakeSite(
|
Pages = MakeSite(
|
||||||
Flags=Flags,
|
Flags=Flags,
|
||||||
LimitFiles=LimitFiles,
|
LimitFiles=LimitFiles,
|
||||||
Snippets=Snippets,
|
Snippets=Snippets,
|
||||||
ConfMenu=ConfMenu,
|
ConfMenu=ConfMenu,
|
||||||
GlobalMacros=ReadConf(SiteConf, 'Macros'),
|
GlobalMacros=ReadConf(SiteConf, 'Macros'),
|
||||||
Locale=Locale)
|
Locale=Locale,
|
||||||
|
Threads=Threads)
|
||||||
|
|
||||||
if FeedEntries != 0:
|
if FeedEntries != 0:
|
||||||
print("[I] Generating Feeds")
|
logging.info("Generating Feeds")
|
||||||
for FeedType in (True, False):
|
for FeedType in (True, False):
|
||||||
MakeFeed(Flags, Pages, FeedType)
|
MakeFeed(Flags, Pages, FeedType)
|
||||||
|
|
||||||
if ActivityPub and MastodonURL and MastodonToken and SiteDomain:
|
if ActivityPub and MastodonURL and MastodonToken and SiteDomain:
|
||||||
print("[I] Mastodon Stuff")
|
logging.info("Mastodon Stuff")
|
||||||
MastodonPosts = MastodonShare(Flags, Pages, Locale)
|
MastodonPosts = MastodonShare(Flags, Pages, Locale)
|
||||||
else:
|
else:
|
||||||
MastodonPosts = []
|
MastodonPosts = []
|
||||||
@ -235,24 +237,24 @@ def Main(Args, FeedEntries):
|
|||||||
WriteFile(File, Content)
|
WriteFile(File, Content)
|
||||||
|
|
||||||
if Flags['GemtextOutput']:
|
if Flags['GemtextOutput']:
|
||||||
print("[I] Generating Gemtext")
|
logging.info("Generating Gemtext")
|
||||||
GemtextCompileList(Flags, Pages, LimitFiles)
|
GemtextCompileList(Flags, Pages, LimitFiles)
|
||||||
|
|
||||||
print("[I] Cleaning Temporary Files")
|
logging.info("Cleaning Temporary Files")
|
||||||
DelTmp(OutDir)
|
DelTmp(OutDir)
|
||||||
|
|
||||||
if Flags['SitemapOutput']:
|
if Flags['SitemapOutput']:
|
||||||
print("[I] Generating Sitemap")
|
logging.info("Generating Sitemap")
|
||||||
MakeSitemap(Flags, Pages)
|
MakeSitemap(Flags, Pages)
|
||||||
|
|
||||||
print("[I] Copying Assets")
|
logging.info("Copying Assets")
|
||||||
os.system(f"cp -R Assets/* {OutDir}/")
|
os.system(f"cp -R Assets/* {OutDir}/")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
StartTime = time.time()
|
StartTime = time.time()
|
||||||
|
|
||||||
Parser = argparse.ArgumentParser()
|
Parser = argparse.ArgumentParser()
|
||||||
Parser.add_argument('--Logging', type=str) # Levels: Debug, Verbose, Info, Warning, Error.
|
Parser.add_argument('--Logging', type=str) # Levels: Debug, Info, Warning, Error.
|
||||||
Parser.add_argument('--Threads', type=str)
|
Parser.add_argument('--Threads', type=str)
|
||||||
Parser.add_argument('--DiffBuild', type=str)
|
Parser.add_argument('--DiffBuild', type=str)
|
||||||
Parser.add_argument('--OutputDir', type=str)
|
Parser.add_argument('--OutputDir', type=str)
|
||||||
@ -269,6 +271,7 @@ if __name__ == '__main__':
|
|||||||
Parser.add_argument('--NoScripts', type=str)
|
Parser.add_argument('--NoScripts', type=str)
|
||||||
Parser.add_argument('--ImgAltToTitle', type=str)
|
Parser.add_argument('--ImgAltToTitle', type=str)
|
||||||
Parser.add_argument('--ImgTitleToAlt', type=str)
|
Parser.add_argument('--ImgTitleToAlt', type=str)
|
||||||
|
Parser.add_argument('--HTMLFixPre', type=str)
|
||||||
Parser.add_argument('--GemtextOutput', type=str)
|
Parser.add_argument('--GemtextOutput', type=str)
|
||||||
Parser.add_argument('--GemtextHeader', type=str)
|
Parser.add_argument('--GemtextHeader', type=str)
|
||||||
Parser.add_argument('--SiteTagline', type=str)
|
Parser.add_argument('--SiteTagline', type=str)
|
||||||
@ -286,15 +289,17 @@ if __name__ == '__main__':
|
|||||||
Parser.add_argument('--CategoriesUncategorized', type=str)
|
Parser.add_argument('--CategoriesUncategorized', type=str)
|
||||||
Args = Parser.parse_args()
|
Args = Parser.parse_args()
|
||||||
|
|
||||||
|
ConfigLogging(Args.Logging)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import lxml
|
import lxml
|
||||||
from Modules.Feed import *
|
from Modules.Feed import *
|
||||||
FeedEntries = Args.FeedEntries if Args.FeedEntries else 'Default'
|
FeedEntries = Args.FeedEntries if Args.FeedEntries else 'Default'
|
||||||
except:
|
except:
|
||||||
print("[W] ⚠ Can't load the XML libraries. XML Feeds Generation is Disabled. Make sure the 'lxml' library is installed.")
|
logging.warning("⚠ Can't load the XML libraries. XML Feeds Generation is Disabled. Make sure the 'lxml' library is installed.")
|
||||||
FeedEntries = 0
|
FeedEntries = 0
|
||||||
|
|
||||||
Main(
|
Main(
|
||||||
Args=Args,
|
Args=Args,
|
||||||
FeedEntries=FeedEntries)
|
FeedEntries=FeedEntries)
|
||||||
print(f"[I] ✅ Done! ({round(time.time()-StartTime,3)}s)")
|
logging.info(f"✅ Done! ({round(time.time()-StartTime,3)}s)")
|
||||||
|
@ -35,6 +35,18 @@ def StripTags(HTML, ToStrip): # Remove desired tags from the HTML
|
|||||||
t.replace_with('')
|
t.replace_with('')
|
||||||
return str(Soup)
|
return str(Soup)
|
||||||
|
|
||||||
|
def DoHTMLFixPre(HTML):
|
||||||
|
if not ("<pre>" in HTML or "<pre " in HTML):
|
||||||
|
return HTML
|
||||||
|
Soup = MkSoup(HTML)
|
||||||
|
Tags = Soup.find_all('pre')
|
||||||
|
for t in Tags:
|
||||||
|
FirstLine = str(t).splitlines()[0].lstrip().rstrip()
|
||||||
|
if FirstLine.endswith('>'):
|
||||||
|
New = MkSoup(str(t).replace('\n', '', 1))
|
||||||
|
t.replace_with(New.pre)
|
||||||
|
return str(Soup)
|
||||||
|
|
||||||
def WriteImgAltAndTitle(HTML, AltToTitle, TitleToAlt): # Adds alt or title attr. to <img> which only have one of them
|
def WriteImgAltAndTitle(HTML, AltToTitle, TitleToAlt): # Adds alt or title attr. to <img> which only have one of them
|
||||||
Soup = MkSoup(HTML)
|
Soup = MkSoup(HTML)
|
||||||
Tags = Soup.find_all('img')
|
Tags = Soup.find_all('img')
|
||||||
|
35
Source/Modules/Logging.py
Normal file
35
Source/Modules/Logging.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
""" ================================= |
|
||||||
|
| This file is part of |
|
||||||
|
| staticoso |
|
||||||
|
| Just a simple Static Site Generator |
|
||||||
|
| |
|
||||||
|
| Licensed under the AGPLv3 license |
|
||||||
|
| Copyright (C) 2022, OctoSpacc |
|
||||||
|
| ================================= """
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
LoggingFormat = '[%(levelname)s] %(message)s'
|
||||||
|
LoggingLevels = {
|
||||||
|
"Debug": {"Name":"D", "Num":15},
|
||||||
|
"Info": {"Name":"I", "Num":20},
|
||||||
|
"Warning": {"Name":"W", "Num":30},
|
||||||
|
"Error": {"Name":"E", "Num":40}}
|
||||||
|
|
||||||
|
def SetupLogging(Level):
|
||||||
|
logging.basicConfig(format=LoggingFormat, stream=sys.stdout, level=Level)
|
||||||
|
logging.addLevelName(15, 'D') # Standard (10) Debug level makes third-party modules spam
|
||||||
|
logging.addLevelName(20, 'I')
|
||||||
|
logging.addLevelName(30, 'W')
|
||||||
|
logging.addLevelName(40, 'E')
|
||||||
|
|
||||||
|
def ConfigLogging(Level):
|
||||||
|
Num = 20
|
||||||
|
if Level:
|
||||||
|
if Level.isdecimal():
|
||||||
|
Num = int(Level)
|
||||||
|
else:
|
||||||
|
if Level.lower() in LoggingLevels:
|
||||||
|
Num = LoggingLevels['Level']['Num']
|
||||||
|
SetupLogging(Num)
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
from Libs.markdown import markdown
|
from Libs.markdown import markdown
|
||||||
|
|
||||||
MarkdownExtsDefault = ('attr_list', 'def_list', 'footnotes', 'md_in_html', 'tables')
|
MarkdownExtsDefault = ('attr_list', 'def_list', 'fenced_code', 'footnotes', 'md_in_html', 'tables')
|
||||||
|
|
||||||
def MarkdownHTMLEscape(Str, Extensions=()): # WIP
|
def MarkdownHTMLEscape(Str, Extensions=()): # WIP
|
||||||
Text = ''
|
Text = ''
|
||||||
|
@ -13,6 +13,7 @@ from Libs.bs4 import BeautifulSoup
|
|||||||
from Modules.Config import *
|
from Modules.Config import *
|
||||||
from Modules.Elements import *
|
from Modules.Elements import *
|
||||||
from Modules.HTML import *
|
from Modules.HTML import *
|
||||||
|
from Modules.Logging import *
|
||||||
from Modules.Markdown import *
|
from Modules.Markdown import *
|
||||||
from Modules.Pug import *
|
from Modules.Pug import *
|
||||||
from Modules.Utils import *
|
from Modules.Utils import *
|
||||||
@ -128,9 +129,11 @@ def PagePreprocessor(Path, TempPath, Type, SiteTemplate, SiteRoot, GlobalMacros,
|
|||||||
if ll.startswith('#') or (ll.startswith('<') and ll[1:].startswith(Headings)):
|
if ll.startswith('#') or (ll.startswith('<') and ll[1:].startswith(Headings)):
|
||||||
if ll.startswith('#'):
|
if ll.startswith('#'):
|
||||||
Title = ll
|
Title = ll
|
||||||
#Index = Title.split(' ')[0].count('#')
|
|
||||||
elif ll.startswith('<'):
|
elif ll.startswith('<'):
|
||||||
#Index = int(ll[2])
|
if ll[3:].startswith((" class='NoTitle", ' class="NoTitle')):
|
||||||
|
Content += l + '\n'
|
||||||
|
continue
|
||||||
|
else:
|
||||||
Title = '#'*h + str(ll[3:])
|
Title = '#'*h + str(ll[3:])
|
||||||
DashTitle = DashifyTitle(MkSoup(Title.lstrip('#')).get_text(), DashyTitles)
|
DashTitle = DashifyTitle(MkSoup(Title.lstrip('#')).get_text(), DashyTitles)
|
||||||
DashyTitles += [DashTitle]
|
DashyTitles += [DashTitle]
|
||||||
@ -213,7 +216,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, LightRun):
|
def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLPagesList, PagePath, Content, Titles, Meta, SiteDomain, 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'):
|
||||||
@ -228,6 +231,15 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
|||||||
if '<a class="footnote-ref"' in Content:
|
if '<a class="footnote-ref"' in Content:
|
||||||
Content = AddToTagStartEnd(Content, '<a class="footnote-ref"', '</a>', '[', ']')
|
Content = AddToTagStartEnd(Content, '<a class="footnote-ref"', '</a>', '[', ']')
|
||||||
|
|
||||||
|
if ("<!-- noprocess />" or "<!--noprocess/>") in Content and ("</ noprocess -->" or "</noprocess-->") in Content:
|
||||||
|
Content = DictReplWithEsc(
|
||||||
|
Content, {
|
||||||
|
"<!-- noprocess />": "",
|
||||||
|
"<!--noprocess/>": "",
|
||||||
|
"</ noprocess -->": "",
|
||||||
|
"</noprocess-->": ""
|
||||||
|
})
|
||||||
|
|
||||||
Title = GetTitle(File.split('/')[-1], Meta, Titles, 'MetaTitle', BlogName)
|
Title = GetTitle(File.split('/')[-1], Meta, Titles, 'MetaTitle', BlogName)
|
||||||
Description = GetDescription(Meta, BodyDescription, 'MetaDescription')
|
Description = GetDescription(Meta, BodyDescription, 'MetaDescription')
|
||||||
Image = GetImage(Meta, BodyImage, 'MetaImage')
|
Image = GetImage(Meta, BodyImage, 'MetaImage')
|
||||||
@ -281,6 +293,7 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
|||||||
'<staticoso:PageContentInfo>': MakeContentHeader(Meta, Locale, MakeCategoryLine(File, Meta)),
|
'<staticoso:PageContentInfo>': MakeContentHeader(Meta, Locale, MakeCategoryLine(File, Meta)),
|
||||||
'[staticoso:BuildTime]': datetime.now().strftime('%Y-%m-%d %H:%M'),
|
'[staticoso:BuildTime]': datetime.now().strftime('%Y-%m-%d %H:%M'),
|
||||||
'<staticoso:BuildTime>': datetime.now().strftime('%Y-%m-%d %H:%M'),
|
'<staticoso:BuildTime>': datetime.now().strftime('%Y-%m-%d %H:%M'),
|
||||||
|
'<staticoso:SiteDomain>': SiteDomain,
|
||||||
'[staticoso:Site:Name]': SiteName,
|
'[staticoso:Site:Name]': SiteName,
|
||||||
'<staticoso:SiteName>': SiteName,
|
'<staticoso:SiteName>': SiteName,
|
||||||
'[staticoso:Site:AbsoluteRoot]': SiteRoot,
|
'[staticoso:Site:AbsoluteRoot]': SiteRoot,
|
||||||
@ -370,6 +383,7 @@ def HandlePage(Flags, Page, Pages, Categories, LimitFiles, Snippets, ConfMenu, L
|
|||||||
Content=Content,
|
Content=Content,
|
||||||
Titles=Titles,
|
Titles=Titles,
|
||||||
Meta=Meta,
|
Meta=Meta,
|
||||||
|
SiteDomain=SiteDomain,
|
||||||
SiteRoot=SiteRoot,
|
SiteRoot=SiteRoot,
|
||||||
SiteName=SiteName,
|
SiteName=SiteName,
|
||||||
BlogName=BlogName,
|
BlogName=BlogName,
|
||||||
@ -383,7 +397,7 @@ def HandlePage(Flags, Page, Pages, Categories, LimitFiles, Snippets, ConfMenu, L
|
|||||||
if not LightRun:
|
if not LightRun:
|
||||||
HTML = DoMinifyHTML(HTML, MinifyKeepComments)
|
HTML = DoMinifyHTML(HTML, MinifyKeepComments)
|
||||||
ContentHTML = DoMinifyHTML(ContentHTML, MinifyKeepComments)
|
ContentHTML = DoMinifyHTML(ContentHTML, MinifyKeepComments)
|
||||||
if Flags['NoScripts']:
|
if Flags['NoScripts'] and ("<script" in ContentHTML or "<script" in HTML):
|
||||||
if not LightRun:
|
if not LightRun:
|
||||||
HTML = StripTags(HTML, ['script'])
|
HTML = StripTags(HTML, ['script'])
|
||||||
ContentHTML = StripTags(ContentHTML, ['script'])
|
ContentHTML = StripTags(ContentHTML, ['script'])
|
||||||
@ -391,6 +405,10 @@ def HandlePage(Flags, Page, Pages, Categories, LimitFiles, Snippets, ConfMenu, L
|
|||||||
if not LightRun:
|
if not LightRun:
|
||||||
HTML = WriteImgAltAndTitle(HTML, ImgAltToTitle, ImgTitleToAlt)
|
HTML = WriteImgAltAndTitle(HTML, ImgAltToTitle, ImgTitleToAlt)
|
||||||
ContentHTML = WriteImgAltAndTitle(ContentHTML, ImgAltToTitle, ImgTitleToAlt)
|
ContentHTML = WriteImgAltAndTitle(ContentHTML, ImgAltToTitle, ImgTitleToAlt)
|
||||||
|
if Flags['HTMLFixPre']:
|
||||||
|
if not LightRun:
|
||||||
|
HTML = DoHTMLFixPre(HTML)
|
||||||
|
ContentHTML = DoHTMLFixPre(ContentHTML)
|
||||||
|
|
||||||
if LightRun:
|
if LightRun:
|
||||||
SlimHTML = None
|
SlimHTML = None
|
||||||
@ -408,9 +426,9 @@ def MultiprocHandlePage(d):
|
|||||||
def MultiprocPagePreprocessor(d):
|
def MultiprocPagePreprocessor(d):
|
||||||
return PagePreprocessor(d['Path'], d['TempPath'], d['Type'], d['Template'], d['SiteRoot'], d['GlobalMacros'], d['CategoryUncategorized'], d['LightRun'])
|
return PagePreprocessor(d['Path'], d['TempPath'], d['Type'], d['Template'], d['SiteRoot'], d['GlobalMacros'], d['CategoryUncategorized'], d['LightRun'])
|
||||||
|
|
||||||
def MakeSite(Flags, LimitFiles, Snippets, ConfMenu, GlobalMacros, Locale):
|
def MakeSite(Flags, LimitFiles, Snippets, ConfMenu, GlobalMacros, Locale, Threads):
|
||||||
PagesPaths, PostsPaths, Pages, MadePages, Categories = [], [], [], [], {}
|
PagesPaths, PostsPaths, Pages, MadePages, Categories = [], [], [], [], {}
|
||||||
PoolSize = cpu_count()
|
PoolSize = cpu_count() if Threads <= 0 else Threads
|
||||||
OutDir, MarkdownExts, Sorting, MinifyKeepComments = Flags['OutDir'], Flags['MarkdownExts'], Flags['Sorting'], Flags['MinifyKeepComments']
|
OutDir, MarkdownExts, Sorting, MinifyKeepComments = Flags['OutDir'], Flags['MarkdownExts'], Flags['Sorting'], Flags['MinifyKeepComments']
|
||||||
SiteName, BlogName, SiteTagline = Flags['SiteName'], Flags['BlogName'], Flags['SiteTagline']
|
SiteName, BlogName, SiteTagline = Flags['SiteName'], Flags['BlogName'], Flags['SiteTagline']
|
||||||
SiteTemplate, SiteLang = Flags['SiteTemplate'], Flags['SiteLang']
|
SiteTemplate, SiteLang = Flags['SiteTemplate'], Flags['SiteLang']
|
||||||
@ -432,7 +450,7 @@ def MakeSite(Flags, LimitFiles, Snippets, ConfMenu, GlobalMacros, Locale):
|
|||||||
if Sorting['Posts'] == 'Inverse':
|
if Sorting['Posts'] == 'Inverse':
|
||||||
PostsPaths.reverse()
|
PostsPaths.reverse()
|
||||||
|
|
||||||
print("[I] Preprocessing Source Pages")
|
logging.info("Preprocessing Source Pages")
|
||||||
MultiprocPages = []
|
MultiprocPages = []
|
||||||
for Type in ['Page', 'Post']:
|
for Type in ['Page', 'Post']:
|
||||||
if Type == 'Page':
|
if Type == 'Page':
|
||||||
@ -454,7 +472,7 @@ def MakeSite(Flags, LimitFiles, Snippets, ConfMenu, GlobalMacros, Locale):
|
|||||||
PugCompileList(OutDir, Pages, LimitFiles)
|
PugCompileList(OutDir, Pages, LimitFiles)
|
||||||
|
|
||||||
if Categories:
|
if Categories:
|
||||||
print("[I] Generating Category Lists")
|
logging.info("Generating Category Lists")
|
||||||
for Cat in Categories:
|
for Cat in Categories:
|
||||||
for Type in ('Page', 'Post'):
|
for Type in ('Page', 'Post'):
|
||||||
Categories[Cat] += GetHTMLPagesList(
|
Categories[Cat] += GetHTMLPagesList(
|
||||||
@ -488,7 +506,7 @@ def MakeSite(Flags, LimitFiles, Snippets, ConfMenu, GlobalMacros, Locale):
|
|||||||
if e == File:
|
if e == File:
|
||||||
ConfMenu[i] = None
|
ConfMenu[i] = None
|
||||||
|
|
||||||
print("[I] Writing Pages")
|
logging.info("Writing Pages")
|
||||||
MultiprocPages = []
|
MultiprocPages = []
|
||||||
for Page in Pages:
|
for Page in Pages:
|
||||||
MultiprocPages += [{'Flags':Flags, 'Page':Page, 'Pages':Pages, 'Categories':Categories, 'LimitFiles':LimitFiles, 'Snippets':Snippets, 'ConfMenu':ConfMenu, 'Locale':Locale}]
|
MultiprocPages += [{'Flags':Flags, 'Page':Page, 'Pages':Pages, 'Categories':Categories, 'LimitFiles':LimitFiles, 'Snippets':Snippets, 'ConfMenu':ConfMenu, 'Locale':Locale}]
|
||||||
|
9
TODO
9
TODO
@ -1,6 +1,9 @@
|
|||||||
|
- Custom path for Posts
|
||||||
|
- Support for YAML header in Markdown
|
||||||
|
- Support for HTML comment lines (<!-- -->) in any format
|
||||||
|
- Support for rST and AsciiDoc (?)
|
||||||
- Showing build percentage as dots
|
- Showing build percentage as dots
|
||||||
- Custom thread number, 0 to disable multithreading
|
- Posts in draft state (will not be compiled) / show unlisted status for posts with Index = False
|
||||||
- Posts in draft state (will not be compiled)
|
|
||||||
- Check if external tools (pug-cli, html2gmi) are installed
|
- Check if external tools (pug-cli, html2gmi) are installed
|
||||||
- Static code syntax highlighing
|
- Static code syntax highlighing
|
||||||
- Override internal HTML snippets (meta lines, page lists, ...) with config file in Templates/NAME.ini
|
- Override internal HTML snippets (meta lines, page lists, ...) with config file in Templates/NAME.ini
|
||||||
@ -8,7 +11,7 @@
|
|||||||
- 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
|
||||||
- Change staticoso service tag enclosure from [] to <>
|
- Change all staticoso service tag enclosures from [] to <>
|
||||||
- Investigate a strange bug with Macros
|
- Investigate a strange bug with Macros
|
||||||
- Handle file extensions with any case sensitivity, not just lowercase; currently the bulk of the issue is finding the files on disk
|
- Handle file extensions with any case sensitivity, not just lowercase; currently the bulk of the issue is finding the files on disk
|
||||||
- Test sorting by date for files not starting with date, and dated folders
|
- Test sorting by date for files not starting with date, and dated folders
|
||||||
|
Reference in New Issue
Block a user