mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-03-12 17:20:22 +01:00
Support for Gemtext custom global header
This commit is contained in:
parent
b9d43c2a3a
commit
ab95c8171b
@ -514,7 +514,9 @@ def Main(Args, FeedEntries):
|
||||
|
||||
if Args.GemtextOut:
|
||||
print("[I] Generating Gemtext")
|
||||
GemtextCompileList(Pages, SiteName)
|
||||
GemtextCompileList(
|
||||
Pages,
|
||||
Header=Args.GemtextHeader if Args.GemtextHeader else '<h1>{}</h1><br>'.format(SiteName) if SiteName else '')
|
||||
|
||||
DelTmp()
|
||||
os.system("cp -R Assets/* public/")
|
||||
@ -529,6 +531,7 @@ if __name__ == '__main__':
|
||||
Parser.add_argument('--SiteName', type=str)
|
||||
Parser.add_argument('--SiteDomain', type=str)
|
||||
Parser.add_argument('--GemtextOut', type=bool)
|
||||
Parser.add_argument('--GemtextHeader', type=str)
|
||||
Parser.add_argument('--SiteTagline', type=str)
|
||||
Parser.add_argument('--FeedEntries', type=int)
|
||||
Parser.add_argument('--FolderRoots', type=str)
|
||||
|
@ -23,12 +23,21 @@ OpenTags = (
|
||||
'img')
|
||||
"""
|
||||
|
||||
def GemtextCompileList(Pages, SiteName):
|
||||
def StripAttrs(HTML):
|
||||
Soup = BeautifulSoup(HTML, 'html.parser')
|
||||
Tags = Soup.find_all()
|
||||
for t in Tags:
|
||||
if 'href' not in t.attrs and 'src' not in t.attrs:
|
||||
t.attrs = {}
|
||||
return str(Soup)
|
||||
|
||||
def GemtextCompileList(Pages, Header):
|
||||
Cmd = ''
|
||||
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
||||
if Header:
|
||||
SlimHTML = Header + SlimHTML
|
||||
Src = 'public.gmi/{}.html.tmp'.format(StripExt(File))
|
||||
if SiteName:
|
||||
SlimHTML = '<h1>' + SiteName + '</h1>' + SlimHTML
|
||||
SlimHTML = StripAttrs(SlimHTML)
|
||||
for i in ('ol', 'ul', 'li'):
|
||||
for j in ('<'+i+'>', '</'+i+'>'):
|
||||
SlimHTML = SlimHTML.replace(j, '')
|
||||
|
Loading…
x
Reference in New Issue
Block a user