mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-06-05 22:09:23 +02:00
Add CSS minification, internal changes
This commit is contained in:
@@ -57,5 +57,5 @@ def MakeFeed(Flags, Pages, FullSite=False):
|
||||
if not os.path.exists(f"{Flags['OutDir']}/feed"):
|
||||
os.mkdir(f"{Flags['OutDir']}/feed")
|
||||
FeedType = 'site.' if FullSite else ''
|
||||
Feed.atom_file(f"{Flags['OutDir']}/feed/{FeedType}atom.xml", pretty=(not Flags['Minify']))
|
||||
Feed.rss_file(f"{Flags['OutDir']}/feed/{FeedType}rss.xml", pretty=(not Flags['Minify']))
|
||||
Feed.atom_file(f"{Flags['OutDir']}/feed/{FeedType}atom.xml", pretty=(not Flags['MinifyOutput']))
|
||||
Feed.rss_file(f"{Flags['OutDir']}/feed/{FeedType}rss.xml", pretty=(not Flags['MinifyOutput']))
|
||||
|
@@ -378,14 +378,16 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
||||
HTML = DictReplWithEsc(HTML, {
|
||||
f"[staticoso:CustomPath:{e}]": FolderRoots[e],
|
||||
f"<staticoso:CustomPath:{e}>": FolderRoots[e],
|
||||
#DEPRECATED
|
||||
f"[staticoso:Folder:{e}:AbsoluteRoot]": FolderRoots[e],
|
||||
f"<staticoso:Folder:{e}:AbsoluteRoot>": FolderRoots[e]})
|
||||
for e in Categories:
|
||||
HTML = DictReplWithEsc(HTML, {
|
||||
f"<span>[staticoso:Category:{e}]</span>": Categories[e],
|
||||
f"[staticoso:Category:{e}]": Categories[e],
|
||||
f"<staticoso:Category:{e}>": Categories[e],
|
||||
f"<staticoso:CategoryList:{e}>": Categories[e]})
|
||||
f"[staticoso:Category:{e}]": Categories[e],
|
||||
f"<staticoso:Category:{e}>": Categories[e],
|
||||
f"<staticoso:CategoryList:{e}>": Categories[e],
|
||||
#DEPRECATED
|
||||
f"<span>[staticoso:Category:{e}]</span>": Categories[e]})
|
||||
|
||||
# TODO: Clean this doubling?
|
||||
ContentHTML = Content
|
||||
@@ -407,14 +409,16 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
||||
ContentHTML = DictReplWithEsc(ContentHTML, {
|
||||
f"[staticoso:CustomPath:{e}]": FolderRoots[e],
|
||||
f"<staticoso:CustomPath:{e}>": FolderRoots[e],
|
||||
#DEPRECATED
|
||||
f"[staticoso:Folder:{e}:AbsoluteRoot]": FolderRoots[e],
|
||||
f"<staticoso:Folder:{e}:AbsoluteRoot>": FolderRoots[e]})
|
||||
for e in Categories:
|
||||
ContentHTML = DictReplWithEsc(ContentHTML, {
|
||||
f"<span>[staticoso:Category:{e}]</span>": Categories[e],
|
||||
f"[staticoso:Category:{e}]": Categories[e],
|
||||
f"<staticoso:Category:{e}>": Categories[e],
|
||||
f"<staticoso:CategoryList:{e}>": Categories[e]})
|
||||
f"<staticoso:CategoryList:{e}>": Categories[e],
|
||||
#DEPRECATED
|
||||
f"<span>[staticoso:Category:{e}]</span>": Categories[e]})
|
||||
|
||||
return HTML, ContentHTML, Description, Image
|
||||
|
||||
@@ -506,7 +510,7 @@ def HandlePage(Flags, Page, Pages, Categories, LimitFiles, Snippets, ConfMenu, L
|
||||
MenuStyle='Flat')
|
||||
HTML = ReplWithEsc(HTML, f"<staticoso:DirectoryList:{Path}>", DirectoryList)
|
||||
|
||||
if Flags['Minify']:
|
||||
if Flags['MinifyOutput']:
|
||||
if not LightRun:
|
||||
HTML = DoMinifyHTML(HTML, MinifyKeepComments)
|
||||
ContentHTML = DoMinifyHTML(ContentHTML, MinifyKeepComments)
|
||||
@@ -543,7 +547,7 @@ def MultiprocHandlePage(d):
|
||||
def MakeSite(Flags, LimitFiles, Snippets, ConfMenu, GlobalMacros, Locale, Threads):
|
||||
PagesPaths, PostsPaths, Pages, MadePages, Categories = [], [], [], [], {}
|
||||
PoolSize = cpu_count() if Threads <= 0 else Threads
|
||||
OutDir, MarkdownExts, Sorting, MinifyKeepComments = Flags['OutDir'], Flags['MarkdownExts'], Flags['Sorting'], Flags['MinifyKeepComments']
|
||||
OutDir, MarkdownExts, Sorting = Flags['OutDir'], Flags['MarkdownExts'], Flags['Sorting']
|
||||
SiteName, BlogName, SiteTagline = Flags['SiteName'], Flags['BlogName'], Flags['SiteTagline']
|
||||
SiteTemplate, SiteLang = Flags['SiteTemplate'], Flags['SiteLang']
|
||||
SiteDomain, SiteRoot, FolderRoots = Flags['SiteDomain'], Flags['SiteRoot'], Flags['FolderRoots']
|
||||
|
@@ -12,13 +12,16 @@ import os
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
ReservedPaths = ('Site.ini', 'Assets', 'Pages', 'Posts', 'Templates', 'StaticParts', 'DynamicParts')
|
||||
ReservedPaths = ('Site.ini', 'Assets', 'Resources', 'Pages', 'Posts', 'Templates', 'StaticParts', 'DynamicParts')
|
||||
FileExtensions = {
|
||||
'Pages': ('htm', 'html', 'markdown', 'md', 'pug', 'txt'),
|
||||
'HTML': ('.htm', '.html'),
|
||||
'Markdown': ('.markdown', '.md'),
|
||||
'Tmp': ('htm', 'markdown', 'md', 'pug', 'txt')}
|
||||
|
||||
def SureList(e):
|
||||
return e if type(e) == list else [e]
|
||||
|
||||
def ReadFile(p):
|
||||
try:
|
||||
with open(p, 'r') as f:
|
||||
@@ -39,14 +42,13 @@ def WriteFile(p, c):
|
||||
def FileToStr(File, Truncate=''):
|
||||
return str(File)[len(Truncate):]
|
||||
|
||||
# https://stackoverflow.com/a/15664273
|
||||
# With shutil.copytree copy only folder struct, no files; https://stackoverflow.com/a/15664273
|
||||
def IgnoreFiles(Dir, Files):
|
||||
return [f for f in Files if os.path.isfile(os.path.join(Dir, f))]
|
||||
|
||||
def LoadFromDir(Dir, Matchs):
|
||||
Contents = {}
|
||||
if type(Matchs) != list:
|
||||
Matchs = [Matchs]
|
||||
Matchs = SureList(Matchs)
|
||||
for Match in Matchs:
|
||||
for File in Path(Dir).rglob(Match):
|
||||
File = str(File)[len(Dir)+1:]
|
||||
|
Reference in New Issue
Block a user