Преглед на файлове

Add link to tag archive at top

master
The Dod преди 1 година
родител
ревизия
ffe3957733
променени са 2 файла, в които са добавени 8 реда и са изтрити 2 реда
  1. 3
    2
      mymastotag.py
  2. 5
    0
      templates/index.html

+ 3
- 2
mymastotag.py Целия файл

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 Целия файл

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…
Отказ
Запис