|
@@ -1,6 +1,6 @@
|
1
|
1
|
import time
|
2
|
2
|
import feedparser
|
3
|
|
-from flask import Flask, render_template, redirect
|
|
3
|
+from flask import Flask, render_template, redirect, url_for
|
4
|
4
|
from bs4 import BeautifulSoup
|
5
|
5
|
|
6
|
6
|
# Source: https://lingohub.com/academy/best-practices/rtl-language-list
|
|
@@ -17,6 +17,7 @@ def my_masto_tag(lang, instance, user, tag):
|
17
|
17
|
lang = lang.lower()
|
18
|
18
|
is_rtl = lang in RTL_LANGS
|
19
|
19
|
title = f'@{user}@{instance} — #{tag}'
|
|
20
|
+ og_image = None
|
20
|
21
|
feed = feedparser.parse(f'https://{instance}/@{user}/tagged/{tag}.rss')
|
21
|
22
|
for e in feed['entries']:
|
22
|
23
|
e['date'] = time.strftime('%Y-%m-%d', e['published_parsed'])
|
|
@@ -31,10 +32,12 @@ def my_masto_tag(lang, instance, user, tag):
|
31
|
32
|
mtype = m['type'].split('/')[0]
|
32
|
33
|
if mtype=='image':
|
33
|
34
|
images.append(m)
|
|
35
|
+ if not og_image:
|
|
36
|
+ og_image = m.get('url')
|
34
|
37
|
elif mtype=='video':
|
35
|
38
|
videos.append(m)
|
36
|
39
|
e['images'] = images
|
37
|
40
|
e['has_images'] = not not images
|
38
|
41
|
e['videos'] = videos
|
39
|
42
|
e['has_videos'] = not not videos
|
40
|
|
- return render_template('index.html', lang=lang, is_rtl=is_rtl, title=title, feed=feed)
|
|
43
|
+ return render_template('index.html', lang=lang, is_rtl=is_rtl, title=title, og_image=og_image or url_for('static', filename='hashtag.png', _external=True), feed=feed)
|