forked from rDrama/rDrama
fddf
parent
aa28e0cbfa
commit
1d6d263a67
|
@ -1,8 +1,7 @@
|
||||||
import gevent.monkey
|
import gevent.monkey
|
||||||
gevent.monkey.patch_all()
|
gevent.monkey.patch_all()
|
||||||
|
|
||||||
import os
|
from os import environ, path
|
||||||
from os import environ
|
|
||||||
import secrets
|
import secrets
|
||||||
from flask import *
|
from flask import *
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
|
@ -35,7 +34,7 @@ app.config["SITE_NAME"]=environ.get("SITE_NAME", "Drama").strip()
|
||||||
|
|
||||||
app.config["SITE_COLOR"]=environ.get("SITE_COLOR", "805ad5").strip()
|
app.config["SITE_COLOR"]=environ.get("SITE_COLOR", "805ad5").strip()
|
||||||
|
|
||||||
app.config["DRAMAPATH"]=environ.get("DRAMAPATH", os.path.dirname(os.path.realpath(__file__)))
|
app.config["DRAMAPATH"]=environ.get("DRAMAPATH", path.dirname(path.realpath(__file__)))
|
||||||
|
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
app.config['DATABASE_URL'] = environ.get(
|
app.config['DATABASE_URL'] = environ.get(
|
||||||
|
@ -300,7 +299,7 @@ def log_event(name, link):
|
||||||
|
|
||||||
text = f'> **{name}**\r> {link}'
|
text = f'> **{name}**\r> {link}'
|
||||||
|
|
||||||
url = os.environ.get("DISCORD_WEBHOOK")
|
url = environ.get("DISCORD_WEBHOOK")
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
data = {"username": "drama",
|
data = {"username": "drama",
|
||||||
"content": text
|
"content": text
|
||||||
|
|
|
@ -2,7 +2,7 @@ from .alts import *
|
||||||
from .badges import *
|
from .badges import *
|
||||||
from .clients import *
|
from .clients import *
|
||||||
from .comment import *
|
from .comment import *
|
||||||
from .domains import Domain
|
from .domains import *
|
||||||
from .flags import *
|
from .flags import *
|
||||||
from .user import *
|
from .user import *
|
||||||
from .userblock import *
|
from .userblock import *
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
#from .mix_ins import *
|
#from .mix_ins import *
|
||||||
from drama.__main__ import Base, app
|
from drama.__main__ import Base
|
||||||
|
|
||||||
AWARDS = {
|
AWARDS = {
|
||||||
"ban": {
|
"ban": {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from flask import render_template
|
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from flask import *
|
from flask import *
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship, deferred
|
from sqlalchemy.orm import relationship, deferred
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
|
||||||
from .mix_ins import *
|
from .mix_ins import *
|
||||||
from drama.helpers.base36 import *
|
from drama.helpers.base36 import *
|
||||||
from drama.helpers.lazy import lazy
|
from drama.helpers.lazy import lazy
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from flask import render_template, request, g
|
from flask import render_template, g
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship, deferred
|
from sqlalchemy.orm import relationship, deferred
|
||||||
import re, random
|
import re, random
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from os import environ, path
|
from os import environ, path
|
||||||
import calendar
|
|
||||||
from .get import *
|
from .get import *
|
||||||
from drama.__main__ import app, cache
|
from drama.__main__ import app, cache
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from bleach.linkifier import LinkifyFilter
|
||||||
from urllib.parse import ParseResult, urlunparse
|
from urllib.parse import ParseResult, urlunparse
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from .get import *
|
from .get import *
|
||||||
import os.path
|
from os import path
|
||||||
|
|
||||||
_allowed_tags = tags = ['b',
|
_allowed_tags = tags = ['b',
|
||||||
'blockquote',
|
'blockquote',
|
||||||
|
@ -189,7 +189,7 @@ def sanitize(text, linkgen=False, flair=False):
|
||||||
if flair: emojisize = 20
|
if flair: emojisize = 20
|
||||||
else: emojisize = 30
|
else: emojisize = 30
|
||||||
for i in re.finditer(':(.{1,30}?):', sanitized):
|
for i in re.finditer(':(.{1,30}?):', sanitized):
|
||||||
if os.path.isfile(f'/d/drama/assets/images/emojis/{i.group(1)}.gif'):
|
if path.isfile(f'/d/drama/assets/images/emojis/{i.group(1)}.gif'):
|
||||||
sanitized = sanitized.replace(f':{i.group(1)}:', f'<img data-toggle="tooltip" title="{i.group(1)}" delay="0" height={emojisize} src="/assets/images/emojis/{i.group(1)}.gif"<span>')
|
sanitized = sanitized.replace(f':{i.group(1)}:', f'<img data-toggle="tooltip" title="{i.group(1)}" delay="0" height={emojisize} src="/assets/images/emojis/{i.group(1)}.gif"<span>')
|
||||||
|
|
||||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/embed/").replace("https://music.youtube.com/watch?v=", "https://youtube.com/embed/").replace("/watch?v=", "/embed/").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/embed/")
|
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/embed/").replace("https://music.youtube.com/watch?v=", "https://youtube.com/embed/").replace("/watch?v=", "/embed/").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/embed/")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from werkzeug.wrappers.response import Response as RespObj
|
from werkzeug.wrappers.response import Response as RespObj
|
||||||
from .get import *
|
from .get import *
|
||||||
from .alerts import send_notification
|
from .alerts import send_notification
|
||||||
from drama.__main__ import Base, app, db_session
|
from drama.__main__ import app
|
||||||
|
|
||||||
|
|
||||||
def get_logged_in_user(db=None):
|
def get_logged_in_user(db=None):
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
from urllib.parse import urlparse
|
|
||||||
import time
|
import time
|
||||||
import calendar
|
import calendar
|
||||||
from sqlalchemy import func
|
|
||||||
from sqlalchemy.orm import lazyload
|
from sqlalchemy.orm import lazyload
|
||||||
import threading
|
|
||||||
import subprocess
|
|
||||||
import imagehash
|
import imagehash
|
||||||
from os import remove, environ
|
from os import remove, path
|
||||||
from PIL import Image as IMAGE
|
from PIL import Image as IMAGE
|
||||||
|
|
||||||
from drama.helpers.wrappers import *
|
from drama.helpers.wrappers import *
|
||||||
|
@ -545,9 +541,9 @@ def agendaposter(user_id, v):
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def disablesignups(v):
|
def disablesignups(v):
|
||||||
|
with open('./disablesignups', 'w') as f:
|
||||||
environ["DISABLESIGNUPS"] = "0" if app.config.get("DISABLESIGNUPS") else "1"
|
if f.read() == "yes": f.write("no")
|
||||||
app.config["DISABLESIGNUPS"] = not app.config.get("DISABLESIGNUPS")
|
else: f.write("yes")
|
||||||
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import threading
|
|
||||||
|
|
||||||
from drama.helpers.wrappers import *
|
from drama.helpers.wrappers import *
|
||||||
from drama.helpers.filters import *
|
from drama.helpers.filters import *
|
||||||
from drama.helpers.alerts import *
|
from drama.helpers.alerts import *
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from drama.helpers.wrappers import *
|
from drama.helpers.wrappers import *
|
||||||
from drama.helpers.security import *
|
from drama.helpers.security import *
|
||||||
from drama.helpers.discord import add_role, delete_role
|
from drama.helpers.discord import add_role
|
||||||
from drama.__main__ import app
|
from drama.__main__ import app
|
||||||
|
|
||||||
SERVER_ID = environ.get("DISCORD_SERVER_ID",'').strip()
|
SERVER_ID = environ.get("DISCORD_SERVER_ID",'').strip()
|
||||||
|
|
|
@ -134,6 +134,7 @@ def login_post():
|
||||||
|
|
||||||
|
|
||||||
@app.route("/me", methods=["GET"])
|
@app.route("/me", methods=["GET"])
|
||||||
|
@app.route("/@me", methods=["GET"])
|
||||||
@auth_required
|
@auth_required
|
||||||
def me(v):
|
def me(v):
|
||||||
return redirect(v.url)
|
return redirect(v.url)
|
||||||
|
@ -156,8 +157,8 @@ def logout(v):
|
||||||
@no_cors
|
@no_cors
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def sign_up_get(v):
|
def sign_up_get(v):
|
||||||
#if app.config.get("DISABLESIGNUPS", False):
|
with open('./disablesignups', 'r') as f:
|
||||||
# return "Signups are disable for the time being.", 403
|
if f.read() == "yes": return "Signups are disable for the time being.", 403
|
||||||
|
|
||||||
if v: return redirect("/")
|
if v: return redirect("/")
|
||||||
|
|
||||||
|
@ -213,8 +214,8 @@ def sign_up_get(v):
|
||||||
@no_cors
|
@no_cors
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def sign_up_post(v):
|
def sign_up_post(v):
|
||||||
#if app.config.get("DISABLESIGNUPS", False):
|
with open('./disablesignups', 'r') as f:
|
||||||
# return "Signups are disable for the time being.", 403
|
if f.read() == "yes": return "Signups are disable for the time being.", 403
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
|
@ -16,7 +16,7 @@ from drama.classes import *
|
||||||
from .front import frontlist
|
from .front import frontlist
|
||||||
from flask import *
|
from flask import *
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from drama.__main__ import app, limiter, cache, db_session
|
from drama.__main__ import app, limiter, cache
|
||||||
from PIL import Image as PILimage
|
from PIL import Image as PILimage
|
||||||
|
|
||||||
with open("snappy.txt", "r") as f:
|
with open("snappy.txt", "r") as f:
|
||||||
|
|
|
@ -575,7 +575,7 @@ def settings_name_change(v):
|
||||||
def settings_song_change(v):
|
def settings_song_change(v):
|
||||||
song=request.form.get("song").strip()
|
song=request.form.get("song").strip()
|
||||||
|
|
||||||
if song == "" and v.song and os.path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
||||||
os.remove(f"/songs/{v.song}.mp3")
|
os.remove(f"/songs/{v.song}.mp3")
|
||||||
v.song=None
|
v.song=None
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
@ -594,7 +594,7 @@ def settings_song_change(v):
|
||||||
if "?" in id: id = id.split("?")[0]
|
if "?" in id: id = id.split("?")[0]
|
||||||
if "&" in id: id = id.split("&")[0]
|
if "&" in id: id = id.split("&")[0]
|
||||||
|
|
||||||
if os.path.isfile(f'/songs/{id}.mp3'):
|
if path.isfile(f'/songs/{id}.mp3'):
|
||||||
v.song=id
|
v.song=id
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -619,7 +619,7 @@ def settings_song_change(v):
|
||||||
error=f"Duration of the video must not exceed 10 minutes.")
|
error=f"Duration of the video must not exceed 10 minutes.")
|
||||||
|
|
||||||
|
|
||||||
if v.song and os.path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
||||||
os.remove(f"/songs/{v.song}.mp3")
|
os.remove(f"/songs/{v.song}.mp3")
|
||||||
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
|
@ -641,8 +641,8 @@ def settings_song_change(v):
|
||||||
error=f"Age-restricted videos aren't allowed.")
|
error=f"Age-restricted videos aren't allowed.")
|
||||||
|
|
||||||
files = os.listdir("/songs/")
|
files = os.listdir("/songs/")
|
||||||
paths = [os.path.join("/songs/", basename) for basename in files]
|
paths = [path.join("/songs/", basename) for basename in files]
|
||||||
songfile = max(paths, key=os.path.getctime)
|
songfile = max(paths, key=path.getctime)
|
||||||
os.rename(songfile, f"/songs/{id}.mp3")
|
os.rename(songfile, f"/songs/{id}.mp3")
|
||||||
|
|
||||||
v.song=id
|
v.song=id
|
||||||
|
|
|
@ -9,7 +9,7 @@ from drama.helpers.sanitize import *
|
||||||
from drama.helpers.markdown import *
|
from drama.helpers.markdown import *
|
||||||
from drama.mail import *
|
from drama.mail import *
|
||||||
from flask import *
|
from flask import *
|
||||||
from drama.__main__ import app, cache, limiter, db_session
|
from drama.__main__ import app, limiter
|
||||||
from pusher_push_notifications import PushNotifications
|
from pusher_push_notifications import PushNotifications
|
||||||
|
|
||||||
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
||||||
|
|
Loading…
Reference in New Issue