1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Aggiunti embed di YouTube alla Wiki

(Non attivi nelle bio)
This commit is contained in:
Steffo 2018-09-07 18:31:42 +02:00
parent d9f12b5427
commit c42950f733

View file

@ -9,6 +9,7 @@ import telegram
import query_discord_music
import random
import difflib
import re
app = Flask(__name__)
@ -227,9 +228,15 @@ def page_wiki(key: str):
db_session.close()
if wiki_page is None:
return render_template("wiki.html", key=key, config=config)
converted_md = Markup(markdown2.markdown(wiki_page.content.replace("<", "&lt;"),
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"]))
return render_template("wiki.html", key=key, wiki_page=wiki_page, converted_md=converted_md,
# Embed YouTube videos
converted_md = markdown2.markdown(wiki_page.content.replace("<", "&lt;"),
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])
converted_md = re.sub(r"{https?:\/\/(?:www\.)?(?:youtube\.com\/watch\?.*?&?v=|youtu.be\/)([0-9A-Za-z-]+).*?}",
r'<div class="youtube-embed">'
r' <iframe src="https://www.youtube-nocookie.com/embed/\1?rel=0&amp;showinfo=0" frameborder="0"'
r' allow="autoplay; encrypted-media" allowfullscreen width="640px" height="320px"></iframe>'
r'</div>', converted_md)
return render_template("wiki.html", key=key, wiki_page=wiki_page, converted_md=Markup(converted_md),
wiki_log=wiki_latest_edit, config=config)
elif request.method == "POST":
user_id = fl_session.get('user_id')