Ver código fonte

Add ?reverse=true, force rtl for fedi-share

master
The Dod 1 ano atrás
pai
commit
ee79b0c198
2 arquivos alterados com 4 adições e 2 exclusões
  1. 3
    1
      mymastotag.py
  2. 1
    1
      templates/index.html

+ 3
- 1
mymastotag.py Ver arquivo

@@ -1,6 +1,6 @@
1 1
 import time
2 2
 import feedparser
3
-from flask import Flask, render_template, redirect, url_for
3
+from flask import Flask, render_template, redirect, url_for, request
4 4
 from bs4 import BeautifulSoup
5 5
 
6 6
 # Source: https://lingohub.com/academy/best-practices/rtl-language-list
@@ -21,6 +21,8 @@ def my_masto_tag(lang, instance, user, tag):
21 21
     tag_url = f'https://{instance}/@{user}/tagged/{tag}'
22 22
     feed = feedparser.parse(f'{tag_url}.rss')
23 23
     hashtag = '#' + tag.lower()
24
+    if request.args.get('reverse',False):
25
+        feed['entries'] = list(reversed(feed['entries']))
24 26
     for e in feed['entries']:
25 27
         e['date'] = time.strftime('%Y-%m-%d', e['published_parsed'])
26 28
         soup = BeautifulSoup(e['description'], 'html.parser')

+ 1
- 1
templates/index.html Ver arquivo

@@ -12,7 +12,7 @@
12 12
     <meta property="og:updated_time" content="{{updated_time}}" />
13 13
   </head>
14 14
   <body>
15
-    <div style="position:absolute; left:2px; top:2px; z-index: 23">
15
+    <div style="direction:ltr; position:absolute; left:2px; top:2px; z-index: 23">
16 16
 <!--  Small Fediverse Share -->
17 17
 <!--        AGPLv3.0        -->
18 18
 <div class="fedi-share fedi-share-sm">

Carregando…
Cancelar
Salvar