Browse Source

Add link to tag archive at top

master
The Dod 1 year ago
parent
commit
ffe3957733
2 changed files with 8 additions and 2 deletions
  1. 3
    2
      mymastotag.py
  2. 5
    0
      templates/index.html

+ 3
- 2
mymastotag.py View File

@@ -18,7 +18,8 @@ def my_masto_tag(lang, instance, user, tag):
18 18
     is_rtl = lang in RTL_LANGS
19 19
     title = f'@{user}@{instance} — #{tag}'
20 20
     og_image = None
21
-    feed = feedparser.parse(f'https://{instance}/@{user}/tagged/{tag}.rss')
21
+    tag_url = f'https://{instance}/@{user}/tagged/{tag}'
22
+    feed = feedparser.parse(f'{tag_url}.rss')
22 23
     hashtag = '#' + tag.lower()
23 24
     for e in feed['entries']:
24 25
         e['date'] = time.strftime('%Y-%m-%d', e['published_parsed'])
@@ -44,6 +45,6 @@ def my_masto_tag(lang, instance, user, tag):
44 45
         e['has_images'] = not not images
45 46
         e['videos'] = videos
46 47
         e['has_videos'] = not not videos
47
-    return render_template('index.html', lang=lang, is_rtl=is_rtl, title=title,
48
+    return render_template('index.html', lang=lang, is_rtl=is_rtl, title=title, tag_url=tag_url,
48 49
                            og_image=og_image or url_for('static', filename='hashtag.png', _external=True),
49 50
                            updated_time=int(time.time()), feed=feed)

+ 5
- 0
templates/index.html View File

@@ -12,6 +12,11 @@
12 12
     <meta property="og:updated_time" content="{{updated_time}}" />
13 13
   </head>
14 14
   <body>
15
+    <div class="container-fluid">
16
+        <ul class="nav nav-tabs justify-content-center">
17
+          <li class="nav-item"><a target="_blank" href="{{tag_url}}" class="nav-link active text-capitalize">{{title|safe}}</a></li>
18
+        </ul>
19
+    </div>
15 20
     <div class="container">
16 21
       <div class="row" id="entries">
17 22
         {% for entry in feed.entries %}

Loading…
Cancel
Save