Ver código fonte

add og:image, README typo fix, list all RTL_LANGS

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

+ 1
- 1
README.md Ver arquivo

7
 For example:
7
 For example:
8
 
8
 
9
 * [/en/tooot.im/zvinj/caturday](https://mymastotag.nimrodkerrett.opalstacked.com/en/tooot.im/zvinj/caturday)
9
 * [/en/tooot.im/zvinj/caturday](https://mymastotag.nimrodkerrett.opalstacked.com/en/tooot.im/zvinj/caturday)
10
-* [/en/tooot.im/neo/קפה_ברוח_טובה](https://mymastotag.nimrodkerrett.opalstacked.com/he/tooot.im/neo/%D7%A7%D7%A4%D7%94_%D7%91%D7%A8%D7%95%D7%97_%D7%98%D7%95%D7%91%D7%94)
10
+* [/he/tooot.im/neo/קפה_ברוח_טובה](https://mymastotag.nimrodkerrett.opalstacked.com/he/tooot.im/neo/%D7%A7%D7%A4%D7%94_%D7%91%D7%A8%D7%95%D7%97_%D7%98%D7%95%D7%91%D7%94)

+ 4
- 1
mymastotag.py Ver arquivo

3
 from flask import Flask, render_template
3
 from flask import Flask, render_template
4
 from bs4 import BeautifulSoup
4
 from bs4 import BeautifulSoup
5
 
5
 
6
+# Source: https://lingohub.com/academy/best-practices/rtl-language-list
7
+RTL_LANGS = ['ar', 'arc', 'dv', 'fa', 'ha', 'he', 'khw', 'ks', 'ku', 'ps', 'ur', 'yi']
8
+
6
 application = Flask(__name__)
9
 application = Flask(__name__)
7
 
10
 
8
 @application.route('/<string:lang>/<string:instance>/<string:user>/<string:tag>')
11
 @application.route('/<string:lang>/<string:instance>/<string:user>/<string:tag>')
9
 def my_masto_tag(lang, instance, user, tag):
12
 def my_masto_tag(lang, instance, user, tag):
10
     lang = lang.lower()
13
     lang = lang.lower()
11
-    is_rtl = lang in ['he', 'ar']  # TODO: A less lame to determine rtl
14
+    is_rtl = lang in RTL_LANGS
12
     title = f'@{user}@{instance} &mdash; #{tag}'
15
     title = f'@{user}@{instance} &mdash; #{tag}'
13
     feed = feedparser.parse(f'https://{instance}/@{user}/tagged/{tag}.rss')
16
     feed = feedparser.parse(f'https://{instance}/@{user}/tagged/{tag}.rss')
14
     for e in feed['entries']:
17
     for e in feed['entries']:

+ 1
- 0
templates/index.html Ver arquivo

6
     <meta name="viewport" content="width=device-width, initial-scale=1">
6
     <meta name="viewport" content="width=device-width, initial-scale=1">
7
     <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
7
     <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
8
     <link rel="stylesheet" href="/static/css/bootstrap{% if is_rtl %}-rtl{% endif %}.min.css">
8
     <link rel="stylesheet" href="/static/css/bootstrap{% if is_rtl %}-rtl{% endif %}.min.css">
9
+    <meta property="og:image" content="{{ url_for('static', filename='hashtag.png', _external=True) }}">
9
   </head>
10
   </head>
10
   <body>
11
   <body>
11
     <div class="container">
12
     <div class="container">

Carregando…
Cancelar
Salvar