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
     is_rtl = lang in RTL_LANGS
18
     is_rtl = lang in RTL_LANGS
19
     title = f'@{user}@{instance} — #{tag}'
19
     title = f'@{user}@{instance} — #{tag}'
20
     og_image = None
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
     hashtag = '#' + tag.lower()
23
     hashtag = '#' + tag.lower()
23
     for e in feed['entries']:
24
     for e in feed['entries']:
24
         e['date'] = time.strftime('%Y-%m-%d', e['published_parsed'])
25
         e['date'] = time.strftime('%Y-%m-%d', e['published_parsed'])
44
         e['has_images'] = not not images
45
         e['has_images'] = not not images
45
         e['videos'] = videos
46
         e['videos'] = videos
46
         e['has_videos'] = not not videos
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
                            og_image=og_image or url_for('static', filename='hashtag.png', _external=True),
49
                            og_image=og_image or url_for('static', filename='hashtag.png', _external=True),
49
                            updated_time=int(time.time()), feed=feed)
50
                            updated_time=int(time.time()), feed=feed)

+ 5
- 0
templates/index.html View File

12
     <meta property="og:updated_time" content="{{updated_time}}" />
12
     <meta property="og:updated_time" content="{{updated_time}}" />
13
   </head>
13
   </head>
14
   <body>
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
     <div class="container">
20
     <div class="container">
16
       <div class="row" id="entries">
21
       <div class="row" id="entries">
17
         {% for entry in feed.entries %}
22
         {% for entry in feed.entries %}

Loading…
Cancel
Save