mirror of https://gitlab.com/octtspacc/staticoso
Add stripping scripts
This commit is contained in:
parent
aa08327f28
commit
ee981f2d57
|
@ -63,18 +63,10 @@ def GetConfMenu(Entries, MarkdownExts):
|
||||||
Menu += [[]]
|
Menu += [[]]
|
||||||
for i in Entries:
|
for i in Entries:
|
||||||
e = Entries[i]
|
e = Entries[i]
|
||||||
#if not (e.startswith('<') or e.endswith('>') or e.startswith('[') or e.endswith(')')):
|
|
||||||
if not ((e.startswith('<') or e.startswith('[') or e.startswith('- ')) and (e.endswith('>') or e.endswith(')') or e.endswith(' }'))):
|
if not ((e.startswith('<') or e.startswith('[') or e.startswith('- ')) and (e.endswith('>') or e.endswith(')') or e.endswith(' }'))):
|
||||||
if not e.lower().endswith('.html'):
|
if not e.lower().endswith('.html'):
|
||||||
e += '.html'
|
e += '.html'
|
||||||
Menu[int(i)] = e
|
Menu[int(i)] = e
|
||||||
#if (e.startswith('<') and e.endswith('>')) or (e.startswith('[') and (e.endswith(')') or e.endswith('}'))):
|
|
||||||
# Menu[int(i)] = markdown(e, extensions=MarkdownExts)
|
|
||||||
#else:
|
|
||||||
# if not e.lower().endswith('.html'):
|
|
||||||
# e += '.html'
|
|
||||||
# Menu[int(i)] = e
|
|
||||||
#print(Menu)
|
|
||||||
return Menu
|
return Menu
|
||||||
|
|
||||||
def Main(Args, FeedEntries):
|
def Main(Args, FeedEntries):
|
||||||
|
@ -148,6 +140,7 @@ def Main(Args, FeedEntries):
|
||||||
SiteLang=SiteLang,
|
SiteLang=SiteLang,
|
||||||
Locale=Locale,
|
Locale=Locale,
|
||||||
Minify=Minify,
|
Minify=Minify,
|
||||||
|
NoScripts=True if Args.NoScripts else False,
|
||||||
Sorting=SetSorting(literal_eval(Args.ContextParts) if Args.ContextParts else {}),
|
Sorting=SetSorting(literal_eval(Args.ContextParts) if Args.ContextParts else {}),
|
||||||
MarkdownExts=MarkdownExts,
|
MarkdownExts=MarkdownExts,
|
||||||
AutoCategories=AutoCategories)
|
AutoCategories=AutoCategories)
|
||||||
|
@ -216,6 +209,7 @@ if __name__ == '__main__':
|
||||||
Parser.add_argument('--SiteName', type=str)
|
Parser.add_argument('--SiteName', type=str)
|
||||||
Parser.add_argument('--BlogName', type=str)
|
Parser.add_argument('--BlogName', type=str)
|
||||||
Parser.add_argument('--SiteDomain', type=str)
|
Parser.add_argument('--SiteDomain', type=str)
|
||||||
|
Parser.add_argument('--NoScripts', type=bool)
|
||||||
Parser.add_argument('--GemtextOut', type=bool)
|
Parser.add_argument('--GemtextOut', type=bool)
|
||||||
Parser.add_argument('--GemtextHeader', type=str)
|
Parser.add_argument('--GemtextHeader', type=str)
|
||||||
Parser.add_argument('--SiteTagline', type=str)
|
Parser.add_argument('--SiteTagline', type=str)
|
||||||
|
|
|
@ -293,7 +293,7 @@ def DoMinifyHTML(HTML):
|
||||||
convert_charrefs=True,
|
convert_charrefs=True,
|
||||||
keep_pre=True)
|
keep_pre=True)
|
||||||
|
|
||||||
def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu, SiteName, BlogName, SiteTagline, SiteDomain, SiteRoot, FolderRoots, SiteLang, Locale, Minify, Sorting, MarkdownExts, AutoCategories):
|
def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu, SiteName, BlogName, SiteTagline, SiteDomain, SiteRoot, FolderRoots, SiteLang, Locale, Minify, NoScripts, Sorting, MarkdownExts, AutoCategories):
|
||||||
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('*.{}'.format(Ext)):
|
for File in Path('Pages').rglob('*.{}'.format(Ext)):
|
||||||
|
@ -363,13 +363,10 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu,
|
||||||
Pages += [[File, Content, Titles, Meta]]
|
Pages += [[File, Content, Titles, Meta]]
|
||||||
|
|
||||||
for i,e in enumerate(ConfMenu):
|
for i,e in enumerate(ConfMenu):
|
||||||
#print(e,i)
|
|
||||||
for File, Content, Titles, Meta in Pages:
|
for File, Content, Titles, Meta in Pages:
|
||||||
File = StripExt(File)+'.html'
|
File = StripExt(File)+'.html'
|
||||||
if e == File:
|
if e == File:
|
||||||
ConfMenu[i] = None
|
ConfMenu[i] = None
|
||||||
#print(File)
|
|
||||||
#print(ConfMenu)
|
|
||||||
|
|
||||||
print("[I] Writing Pages")
|
print("[I] Writing Pages")
|
||||||
for File, Content, Titles, Meta in Pages:
|
for File, Content, Titles, Meta in Pages:
|
||||||
|
@ -405,6 +402,11 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu,
|
||||||
Categories=Categories,
|
Categories=Categories,
|
||||||
SiteLang=SiteLang,
|
SiteLang=SiteLang,
|
||||||
Locale=Locale)
|
Locale=Locale)
|
||||||
|
if NoScripts:
|
||||||
|
HTML = (HTML
|
||||||
|
).replace('<script>', '<!-- script >'
|
||||||
|
).replace('<script ', '<!-- script '
|
||||||
|
).replace('</script>', '</ script -->')
|
||||||
if Minify:
|
if Minify:
|
||||||
HTML = DoMinifyHTML(HTML)
|
HTML = DoMinifyHTML(HTML)
|
||||||
WriteFile(PagePath, HTML)
|
WriteFile(PagePath, HTML)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
| Copyright (C) 2022, OctoSpacc |
|
| Copyright (C) 2022, OctoSpacc |
|
||||||
| ================================= """
|
| ================================= """
|
||||||
|
|
||||||
import urllib
|
from urllib.parse import quote as URLEncode
|
||||||
from Modules.Utils import *
|
from Modules.Utils import *
|
||||||
|
|
||||||
def MakeSitemap(Pages, SiteDomain=''):
|
def MakeSitemap(Pages, SiteDomain=''):
|
||||||
|
@ -15,5 +15,5 @@ def MakeSitemap(Pages, SiteDomain=''):
|
||||||
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
||||||
File = '{}.html'.format(StripExt(File))
|
File = '{}.html'.format(StripExt(File))
|
||||||
Domain = SiteDomain + '/' if SiteDomain else ' '
|
Domain = SiteDomain + '/' if SiteDomain else ' '
|
||||||
Map += Domain + urllib.parse.quote(File) + '\n'
|
Map += Domain + URLEncode(File) + '\n'
|
||||||
WriteFile('public/sitemap.txt', Map)
|
WriteFile('public/sitemap.txt', Map)
|
||||||
|
|
Loading…
Reference in New Issue