Add Mastodon comment embedding (incomplete)

This commit is contained in:
2022-07-01 14:00:25 +02:00
parent cc7aaf19ec
commit aff9a36c4a
5 changed files with 46 additions and 16 deletions

View File

@ -483,17 +483,37 @@ def Main(Args, FeedEntries):
Lang=SiteLang,
Minify=True if Args.Minify and Args.Minify not in ('False', 'None') else False)
if Args.GemtextOut:
GemtextCompileList(Pages)
if MastodonURL and MastodonToken and SiteDomain:
MastodonShare(
MastodonPosts = MastodonShare(
MastodonURL,
MastodonToken,
Pages,
SiteDomain,
SiteLang,
Locale)
#print(MastodonPosts)
else:
MastodonPosts = []
for File, Content, Titles, Meta, HTMLContent, Description, Image in Pages:
#if Meta['Type'] == 'Post':
File = 'public/{}.html'.format(StripExt(File))
Content = ReadFile(File)
Post = ''
for p in MastodonPosts:
#print(SiteDomain + File[len('public/'):])
if p['Link'] == SiteDomain + '/' + File[len('public/'):]:
Post = '<br><h3>{StrComments}</h3><a href="{URL}" rel="noopener" target="_blank">{StrOpen} ↗️</a>'.format(
StrComments=Locale['Comments'],
StrOpen=Locale['OpenInNewTab'],
URL=p['Post'])
break
#print(Post)
Content = Content.replace('[HTML:Comments]', Post)
WriteFile(File, Content)
if Args.GemtextOut:
GemtextCompileList(Pages)
DelTmp()
os.system("cp -R Assets/* public/")