mirror of https://gitlab.com/octtspacc/staticoso
Express Gemini header in Gemtext
This commit is contained in:
parent
ab95c8171b
commit
b71525223b
|
@ -516,7 +516,7 @@ def Main(Args, FeedEntries):
|
|||
print("[I] Generating Gemtext")
|
||||
GemtextCompileList(
|
||||
Pages,
|
||||
Header=Args.GemtextHeader if Args.GemtextHeader else '<h1>{}</h1><br>'.format(SiteName) if SiteName else '')
|
||||
Header=Args.GemtextHeader if Args.GemtextHeader else '# {}\n\n'.format(SiteName) if SiteName else '')
|
||||
|
||||
DelTmp()
|
||||
os.system("cp -R Assets/* public/")
|
||||
|
|
|
@ -31,20 +31,21 @@ def StripAttrs(HTML):
|
|||
t.attrs = {}
|
||||
return str(Soup)
|
||||
|
||||
def GemtextCompileList(Pages, Header):
|
||||
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))
|
||||
Dst = 'public.gmi/{}.gmi'.format(StripExt(File))
|
||||
SlimHTML = StripAttrs(SlimHTML)
|
||||
for i in ('ol', 'ul', 'li'):
|
||||
for j in ('<'+i+'>', '</'+i+'>'):
|
||||
SlimHTML = SlimHTML.replace(j, '')
|
||||
WriteFile(Src, SlimHTML.replace('</a>', '</a><br>').replace('.html', '.gmi')) # TODO: Adjust links properly..
|
||||
Dst = 'public.gmi/{}.gmi'.format(StripExt(File))
|
||||
Cmd += 'cat "{}" | html2gmi > "{}"; '.format(Src, Dst)
|
||||
os.system(Cmd)
|
||||
for File, Content, Titles, Meta, ContentHTML, SlimHTML, Description, Image in Pages:
|
||||
Dst = 'public.gmi/{}.gmi'.format(StripExt(File))
|
||||
WriteFile(Dst, Header + ReadFile(Dst))
|
||||
|
||||
def FindEarliest(Str, Items):
|
||||
Pos, Item = 0, ''
|
||||
|
|
Loading…
Reference in New Issue