[chore] format code
This commit is contained in:
parent
20b89b5139
commit
81120e8540
2 changed files with 19 additions and 1 deletions
|
@ -7,6 +7,8 @@ from BDSM.models import Toot, Tag, Media, Emoji, Poll, Settings
|
|||
import sys
|
||||
import dateutil.parser
|
||||
|
||||
|
||||
|
||||
def app_register(url):
|
||||
print("Registering app")
|
||||
Mastodon.create_app(
|
||||
|
@ -16,6 +18,7 @@ def app_register(url):
|
|||
scopes=["read"]
|
||||
)
|
||||
|
||||
|
||||
def app_login(url):
|
||||
mastodon = Mastodon(
|
||||
client_id='data/pyBDSM_clientcred.secret',
|
||||
|
@ -39,6 +42,7 @@ def app_login(url):
|
|||
|
||||
return mastodon, user
|
||||
|
||||
|
||||
def get_context(url, toot_id):
|
||||
mastodon, _ = app_login(url)
|
||||
settings = Settings.query.first()
|
||||
|
@ -50,6 +54,7 @@ def get_context(url, toot_id):
|
|||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def toot_process(statuses, my_acct, duplicates_counter=0):
|
||||
for status in statuses:
|
||||
is_reblog = False
|
||||
|
@ -212,6 +217,7 @@ def toot_process(statuses, my_acct, duplicates_counter=0):
|
|||
# poll_id,emoji_list,visibility,reblogged,favourited,bookmarked,sensitive,reblogs_count,favourites_count,language))
|
||||
return duplicates_counter
|
||||
|
||||
|
||||
def archive_toot(url, archive_match):
|
||||
mastodon, user = app_login(url)
|
||||
acct = mastodon.me().acct
|
||||
|
|
|
@ -13,11 +13,14 @@ from mastodon import Mastodon
|
|||
from types import SimpleNamespace
|
||||
from datetime import timezone
|
||||
|
||||
|
||||
|
||||
# @app.context_processor
|
||||
# def inject_setting():
|
||||
# settings = Settings.query.first()
|
||||
# return settings.__dict__
|
||||
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def index():
|
||||
settings = Settings.query.first()
|
||||
|
@ -33,6 +36,7 @@ def index():
|
|||
|
||||
return render_template('view.html', toots=toots, pagination=toots_, path=path)
|
||||
|
||||
|
||||
@app.route('/favourited', methods=['GET', 'POST'])
|
||||
def favourited():
|
||||
settings = Settings.query.first()
|
||||
|
@ -48,6 +52,7 @@ def favourited():
|
|||
|
||||
return render_template('view.html', toots=toots, pagination=toots_, path=path)
|
||||
|
||||
|
||||
@app.route('/bookmarked', methods=['GET', 'POST'])
|
||||
def bookmarked():
|
||||
settings = Settings.query.first()
|
||||
|
@ -63,6 +68,7 @@ def bookmarked():
|
|||
|
||||
return render_template('view.html', toots=toots, pagination=toots_, path=path)
|
||||
|
||||
|
||||
@app.route('/search', methods=['GET', 'POST'])
|
||||
def search():
|
||||
if request.method == 'POST':
|
||||
|
@ -117,6 +123,7 @@ def context(toot_id):
|
|||
|
||||
return render_template('view.html', toots=toots,)
|
||||
|
||||
|
||||
@app.route('/grab/<int:toot_id>', methods=['GET', 'POST'])
|
||||
def grab(toot_id):
|
||||
settings = Settings.query.first()
|
||||
|
@ -127,6 +134,7 @@ def grab(toot_id):
|
|||
flash('抓取完成……大概!')
|
||||
return redirect(url_for('context',toot_id=toot_id))
|
||||
|
||||
|
||||
@app.route('/settings', methods=['GET', 'POST'])
|
||||
def settings():
|
||||
if request.method == 'POST':
|
||||
|
@ -155,6 +163,7 @@ def settings():
|
|||
|
||||
return render_template('settings.html',settings=settings, app_init=app_init)
|
||||
|
||||
|
||||
@app.route('/register', methods=['GET', 'POST'])
|
||||
def register():
|
||||
settings = Settings.query.first()
|
||||
|
@ -189,6 +198,7 @@ def register():
|
|||
flash('已授权过!')
|
||||
return redirect(url_for('settings'))
|
||||
|
||||
|
||||
@app.route('/archive', methods=['GET', 'POST'])
|
||||
def archive():
|
||||
settings = Settings.query.first()
|
||||
|
@ -206,6 +216,7 @@ def archive():
|
|||
else:
|
||||
return render_template('archive.html')
|
||||
|
||||
|
||||
def process_toot(toots_):
|
||||
toots = []
|
||||
settings = Settings.query.first()
|
||||
|
@ -251,7 +262,7 @@ def process_toot(toots_):
|
|||
|
||||
if emoji != None:
|
||||
emoji_shortcode = ':' + emoji_shortcode + ':'
|
||||
emoji_url = emoji.url
|
||||
# emoji_url = emoji.url
|
||||
emoji_html = f'''
|
||||
<img class="emojione custom-emoji" alt="{emoji_shortcode}" title="{emoji_shortcode}" src="{emoji.url}" >
|
||||
'''
|
||||
|
@ -269,4 +280,5 @@ def process_toot(toots_):
|
|||
toot.content += poll_content
|
||||
|
||||
toots.append(toot)
|
||||
|
||||
return toots
|
||||
|
|
Loading…
Reference in a new issue