Procházet zdrojové kódy

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

master
The Dod před 1 rokem
rodič
revize
ee79b0c198
2 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 3
    1
      mymastotag.py
  2. 1
    1
      templates/index.html

+ 3
- 1
mymastotag.py Zobrazit soubor

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

+ 1
- 1
templates/index.html Zobrazit soubor

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 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
 <!--  Small Fediverse Share -->
16
 <!--  Small Fediverse Share -->
17
 <!--        AGPLv3.0        -->
17
 <!--        AGPLv3.0        -->
18
 <div class="fedi-share fedi-share-sm">
18
 <div class="fedi-share fedi-share-sm">

Načítá se…
Zrušit
Uložit