move all env-getting to .const

remotes/1693045480750635534/spooky-22
Aevann1 2022-07-08 18:21:13 +02:00
parent 1549508e49
commit b617321529
23 changed files with 83 additions and 101 deletions

View File

@ -1,7 +1,6 @@
from sqlalchemy import * from sqlalchemy import *
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from files.__main__ import Base from files.__main__ import Base
from os import environ
from files.helpers.lazy import lazy from files.helpers.lazy import lazy
from files.helpers.const import * from files.helpers.const import *

View File

@ -1,7 +1,6 @@
from sqlalchemy import * from sqlalchemy import *
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from files.__main__ import Base, app from files.__main__ import Base, app
from os import environ
from files.helpers.lazy import lazy from files.helpers.lazy import lazy
from files.helpers.const import * from files.helpers.const import *
from datetime import datetime from datetime import datetime

View File

@ -1,4 +1,3 @@
from os import environ
import re import re
import time import time
from urllib.parse import urlencode, urlparse, parse_qs from urllib.parse import urlencode, urlparse, parse_qs

View File

@ -3,7 +3,6 @@ from sqlalchemy.orm import relationship
from files.__main__ import Base from files.__main__ import Base
import time import time
from files.helpers.lazy import lazy from files.helpers.lazy import lazy
from os import environ
from copy import deepcopy from copy import deepcopy
from files.helpers.const import * from files.helpers.const import *

View File

@ -2,13 +2,9 @@ from sqlalchemy import *
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from files.__main__ import Base from files.__main__ import Base
from files.helpers.lazy import lazy from files.helpers.lazy import lazy
from os import environ from files.helpers.const import *
from .sub_block import * from .sub_block import *
SITE_NAME = environ.get("SITE_NAME", '').strip()
SITE = environ.get("DOMAIN", '').strip()
if SITE == "localhost": SITE_FULL = 'http://' + SITE
else: SITE_FULL = 'https://' + SITE
class Sub(Base): class Sub(Base):
__tablename__ = "subs" __tablename__ = "subs"

View File

@ -1,4 +1,3 @@
from os import environ
import random import random
import re import re
import time import time

View File

@ -22,14 +22,7 @@ from files.__main__ import Base, cache
from files.helpers.security import * from files.helpers.security import *
from copy import deepcopy from copy import deepcopy
import random import random
from os import environ, remove, path from os import remove, path
defaulttheme = environ.get("DEFAULT_THEME", "midnight").strip()
defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
cardview = bool(int(environ.get("CARD_VIEW", 1)))
if SITE_NAME in ('Cringetopia', 'WPD'): patron_default = 7
else: patron_default = 0
class User(Base): class User(Base):
__tablename__ = "users" __tablename__ = "users"
@ -45,15 +38,15 @@ class User(Base):
customtitle = Column(String) customtitle = Column(String)
customtitleplain = deferred(Column(String)) customtitleplain = deferred(Column(String))
titlecolor = Column(String, default=DEFAULT_COLOR) titlecolor = Column(String, default=DEFAULT_COLOR)
theme = Column(String, default=defaulttheme) theme = Column(String, default=DEFAULT_THEME)
themecolor = Column(String, default=DEFAULT_COLOR) themecolor = Column(String, default=DEFAULT_COLOR)
cardview = Column(Boolean, default=cardview) cardview = Column(Boolean, default=CARD_VIEW)
song = Column(String) song = Column(String)
highres = Column(String) highres = Column(String)
profileurl = Column(String) profileurl = Column(String)
bannerurl = Column(String) bannerurl = Column(String)
house = Column(String) house = Column(String)
patron = Column(Integer, default=patron_default) patron = Column(Integer, default=PATRON_DEFAULT)
patron_utc = Column(Integer, default=0) patron_utc = Column(Integer, default=0)
verified = Column(String) verified = Column(String)
verifiedcolor = Column(String) verifiedcolor = Column(String)
@ -123,7 +116,7 @@ class User(Base):
stored_subscriber_count = Column(Integer, default=0) stored_subscriber_count = Column(Integer, default=0)
defaultsortingcomments = Column(String, default="top") defaultsortingcomments = Column(String, default="top")
defaultsorting = Column(String, default="hot") defaultsorting = Column(String, default="hot")
defaulttime = Column(String, default=defaulttimefilter) defaulttime = Column(String, default=DEFAULT_TIME_FILTER)
is_nofollow = Column(Boolean, default=False) is_nofollow = Column(Boolean, default=False)
custom_filter_list = Column(String) custom_filter_list = Column(String)
discord_id = Column(String) discord_id = Column(String)

View File

@ -946,6 +946,36 @@ SPAM_SIMILAR_COUNT_THRESHOLD = int(environ.get("SPAM_SIMILAR_COUNT_THRESHOLD", 1
COMMENT_SPAM_SIMILAR_THRESHOLD = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5)) COMMENT_SPAM_SIMILAR_THRESHOLD = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5))
COMMENT_SPAM_COUNT_THRESHOLD = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 10)) COMMENT_SPAM_COUNT_THRESHOLD = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 10))
DESCRIPTION = environ.get("DESCRIPTION", "rdrama.net caters to drama in all forms such as: Real life, videos, photos, gossip, rumors, news sites, Reddit, and Beyond™. There isn't drama we won't touch, and we want it all!").strip() DESCRIPTION = environ.get("DESCRIPTION", "rdrama.net caters to drama in all forms such as: Real life, videos, photos, gossip, rumors, news sites, Reddit, and Beyond™. There isn't drama we won't touch, and we want it all!").strip()
GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
GUMROAD_ID = environ.get("GUMROAD_ID", "tfcvri").strip()
DEFAULT_THEME = environ.get("DEFAULT_THEME", "midnight").strip()
DEFAULT_TIME_FILTER = environ.get("DEFAULT_TIME_FILTER", "all").strip()
CARD_VIEW = bool(int(environ.get("CARD_VIEW", 1)))
DISABLE_DOWNVOTES = bool(int(environ.get("CARD_VIEW", 0)))
DISCORD_SERVER_ID = environ.get("DISCORD_SERVER_ID",'').strip()
DISCORD_CLIENT_ID = environ.get("DISCORD_CLIENT_ID",'').strip()
DISCORD_CLIENT_SECRET = environ.get("DISCORD_CLIENT_SECRET",'').strip()
DISCORD_BOT_TOKEN = environ.get("DISCORD_BOT_TOKEN",'').strip()
DISCORD_AUTH = environ.get("DISCORD_AUTH",'').strip()
GIPHY_KEY = environ.get('GIPHY_KEY').strip()
MASTER_KEY = environ.get("MASTER_KEY")
FP = environ.get("FP")
if SITE_NAME in ('Cringetopia', 'WPD'): PATRON_DEFAULT = 7
else: PATRON_DEFAULT = 0
tiers={
"(Paypig)": 1,
"(Renthog)": 2,
"(Landchad)": 3,
"(Terminally online turboautist)": 4,
"(Marsey's Sugar Daddy)": 5,
"(JIDF Bankroller)": 6,
"(Rich Bich)": 7,
"(LlamaBean)": 1,
}
DISCORD_WELCOME_CHANNEL = "846509313941700618"
has_sidebar = path.exists(f'files/templates/sidebar_{SITE_NAME}.html') has_sidebar = path.exists(f'files/templates/sidebar_{SITE_NAME}.html')
has_logo = path.exists(f'files/assets/images/{SITE_NAME}/logo.webp') has_logo = path.exists(f'files/assets/images/{SITE_NAME}/logo.webp')

View File

@ -1,14 +1,7 @@
from os import environ
import requests import requests
import threading import threading
from .const import * from .const import *
SERVER_ID = environ.get("DISCORD_SERVER_ID",'').strip()
CLIENT_ID = environ.get("DISCORD_CLIENT_ID",'').strip()
CLIENT_SECRET = environ.get("DISCORD_CLIENT_SECRET",'').strip()
BOT_TOKEN = environ.get("DISCORD_BOT_TOKEN",'').strip()
AUTH = environ.get("DISCORD_AUTH",'').strip()
def discord_wrap(f): def discord_wrap(f):
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
@ -29,32 +22,32 @@ def discord_wrap(f):
@discord_wrap @discord_wrap
def add_role(user, role_name): def add_role(user, role_name):
role_id = ROLES[role_name] role_id = ROLES[role_name]
url = f"https://discordapp.com/api/guilds/{SERVER_ID}/members/{user.discord_id}/roles/{role_id}" url = f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}/roles/{role_id}"
headers = {"Authorization": f"Bot {BOT_TOKEN}"} headers = {"Authorization": f"Bot {DISCORD_BOT_TOKEN}"}
requests.put(url, headers=headers, timeout=5) requests.put(url, headers=headers, timeout=5)
@discord_wrap @discord_wrap
def remove_role(user, role_name): def remove_role(user, role_name):
role_id = ROLES[role_name] role_id = ROLES[role_name]
url = f"https://discordapp.com/api/guilds/{SERVER_ID}/members/{user.discord_id}/roles/{role_id}" url = f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}/roles/{role_id}"
headers = {"Authorization": f"Bot {BOT_TOKEN}"} headers = {"Authorization": f"Bot {DISCORD_BOT_TOKEN}"}
requests.delete(url, headers=headers, timeout=5) requests.delete(url, headers=headers, timeout=5)
@discord_wrap @discord_wrap
def remove_user(user): def remove_user(user):
url=f"https://discordapp.com/api/guilds/{SERVER_ID}/members/{user.discord_id}" url=f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}"
headers = {"Authorization": f"Bot {BOT_TOKEN}"} headers = {"Authorization": f"Bot {DISCORD_BOT_TOKEN}"}
requests.delete(url, headers=headers, timeout=5) requests.delete(url, headers=headers, timeout=5)
@discord_wrap @discord_wrap
def set_nick(user, nick): def set_nick(user, nick):
url=f"https://discordapp.com/api/guilds/{SERVER_ID}/members/{user.discord_id}" url=f"https://discordapp.com/api/guilds/{DISCORD_SERVER_ID}/members/{user.discord_id}"
headers = {"Authorization": f"Bot {BOT_TOKEN}"} headers = {"Authorization": f"Bot {DISCORD_BOT_TOKEN}"}
data={"nick": nick} data={"nick": nick}
requests.patch(url, headers=headers, json=data, timeout=5) requests.patch(url, headers=headers, json=data, timeout=5)
def send_discord_message(message): def send_discord_message(message):
headers = {"Authorization": f"Bot {BOT_TOKEN}"} headers = {"Authorization": f"Bot {DISCORD_BOT_TOKEN}"}
data={"content": message} data={"content": message}
requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5) requests.post("https://discordapp.com/api/channels/924485611715452940/messages", headers=headers, data=data, timeout=5)
requests.post("https://discordapp.com/api/channels/924486091795484732/messages", headers=headers, data=data, timeout=5) requests.post("https://discordapp.com/api/channels/924486091795484732/messages", headers=headers, data=data, timeout=5)

View File

@ -58,4 +58,4 @@ def inject_constants():
"HOLE_NAME": HOLE_NAME, "HOLE_STYLE_FLAIR": HOLE_STYLE_FLAIR, "HOLE_REQUIRED": HOLE_REQUIRED, "HOLE_NAME": HOLE_NAME, "HOLE_STYLE_FLAIR": HOLE_STYLE_FLAIR, "HOLE_REQUIRED": HOLE_REQUIRED,
"LOTTERY_ENABLED": LOTTERY_ENABLED, "GUMROAD_LINK": GUMROAD_LINK, "LOTTERY_ENABLED": LOTTERY_ENABLED, "GUMROAD_LINK": GUMROAD_LINK,
"DEFAULT_THEME": DEFAULT_THEME, "DESCRIPTION": DESCRIPTION, "PERMS": PERMS, "DEFAULT_THEME": DEFAULT_THEME, "DESCRIPTION": DESCRIPTION, "PERMS": PERMS,
"PROCOINS_ENABLED": PROCOINS_ENABLED, "has_sidebar": has_sidebar, "has_logo": has_logo} "PROCOINS_ENABLED": PROCOINS_ENABLED, "has_sidebar": has_sidebar, "has_logo": has_logo, "FP": FP}

View File

@ -1,5 +1,5 @@
import re import re
from files.helpers.const import * from .const import *
if SITE_NAME == 'PCM': if SITE_NAME == 'PCM':
valid_username_chars = 'a-zA-Z0-9_\-А' valid_username_chars = 'a-zA-Z0-9_\-А'

View File

@ -1,12 +1,12 @@
from werkzeug.security import * from werkzeug.security import *
from os import environ from .const import *
def generate_hash(string): def generate_hash(string):
msg = bytes(string, "utf-16") msg = bytes(string, "utf-16")
return hmac.new(key=bytes(environ.get("MASTER_KEY"), "utf-16"), return hmac.new(key=bytes(MASTER_KEY, "utf-16"),
msg=msg, msg=msg,
digestmod='md5' digestmod='md5'
).hexdigest() ).hexdigest()

View File

@ -1,4 +1,3 @@
from os import environ
import time import time
from flask import * from flask import *
from urllib.parse import quote from urllib.parse import quote
@ -12,11 +11,10 @@ from files.classes import *
from files.__main__ import app, mail, limiter from files.__main__ import app, mail, limiter
from flask_mail import Message from flask_mail import Message
name = environ.get("SITE_NAME").strip()
def send_mail(to_address, subject, html): def send_mail(to_address, subject, html):
msg = Message(html=html, subject=subject, sender=f"{name}@{SITE}", recipients=[to_address]) msg = Message(html=html, subject=subject, sender=f"{SITE_NAME}@{SITE}", recipients=[to_address])
mail.send(msg) mail.send(msg)
@ -37,7 +35,7 @@ def send_verification_email(user, email=None):
html=render_template("email/email_verify.html", html=render_template("email/email_verify.html",
action_url=link, action_url=link,
v=user), v=user),
subject=f"Validate your {name} account email." subject=f"Validate your {SITE_NAME} account email."
) )

View File

@ -4,12 +4,6 @@ from files.helpers.discord import add_role
from files.__main__ import app from files.__main__ import app
import requests import requests
SERVER_ID = environ.get("DISCORD_SERVER_ID",'').strip()
CLIENT_ID = environ.get("DISCORD_CLIENT_ID",'').strip()
CLIENT_SECRET = environ.get("DISCORD_CLIENT_SECRET",'').strip()
BOT_TOKEN = environ.get("DISCORD_BOT_TOKEN").strip()
DISCORD_ENDPOINT = "https://discordapp.com/api/v6"
WELCOME_CHANNEL="846509313941700618"
@app.get("/discord") @app.get("/discord")
@is_not_permabanned @is_not_permabanned
@ -23,7 +17,7 @@ def join_discord(v):
state=f"{now}.{state}" state=f"{now}.{state}"
return redirect(f"https://discord.com/api/oauth2/authorize?client_id={CLIENT_ID}&redirect_uri=https%3A%2F%2F{SITE}%2Fdiscord_redirect&response_type=code&scope=identify%20guilds.join&state={state}") return redirect(f"https://discord.com/api/oauth2/authorize?client_id={DISCORD_CLIENT_ID}&redirect_uri=https%3A%2F%2F{SITE}%2Fdiscord_redirect&response_type=code&scope=identify%20guilds.join&state={state}")
@app.get("/discord_redirect") @app.get("/discord_redirect")
@ -49,8 +43,8 @@ def discord_redirect(v):
abort(400) abort(400)
data={ data={
"client_id":CLIENT_ID, "client_id": DISCORD_CLIENT_ID,
'client_secret': CLIENT_SECRET, 'client_secret': DISCORD_CLIENT_SECRET,
'grant_type': 'authorization_code', 'grant_type': 'authorization_code',
'code': code, 'code': code,
'redirect_uri': f"https://{SITE}/discord_redirect", 'redirect_uri': f"https://{SITE}/discord_redirect",
@ -80,12 +74,12 @@ def discord_redirect(v):
headers={ headers={
'Authorization': f"Bot {BOT_TOKEN}", 'Authorization': f"Bot {DISCORD_BOT_TOKEN}",
'Content-Type': "application/json" 'Content-Type': "application/json"
} }
if v.discord_id and v.discord_id != x['id']: if v.discord_id and v.discord_id != x['id']:
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}" url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{v.discord_id}"
requests.delete(url, headers=headers, timeout=5) requests.delete(url, headers=headers, timeout=5)
if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).one_or_none(): if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).one_or_none():
@ -94,7 +88,7 @@ def discord_redirect(v):
v.discord_id=x["id"] v.discord_id=x["id"]
g.db.add(v) g.db.add(v)
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{x['id']}" url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{x['id']}"
name=v.username name=v.username
@ -133,7 +127,7 @@ def discord_redirect(v):
if x.status_code==204: if x.status_code==204:
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}" url=f"https://discord.com/api/guilds/{DISCORD_SERVER_ID}/members/{v.discord_id}"
data={ data={
"nick": name "nick": name
} }
@ -141,4 +135,4 @@ def discord_redirect(v):
requests.patch(url, headers=headers, json=data, timeout=5) requests.patch(url, headers=headers, json=data, timeout=5)
return redirect(f"https://discord.com/channels/{SERVER_ID}/{WELCOME_CHANNEL}") return redirect(f"https://discord.com/channels/{DISCORD_SERVER_ID}/{DISCORD_WELCOME_CHANNEL}")

View File

@ -1,11 +1,11 @@
from files.helpers.wrappers import * from files.helpers.wrappers import *
from files.helpers.get import * from files.helpers.get import *
from files.helpers.discord import * from files.helpers.discord import *
from files.helpers.const import *
from files.__main__ import app, cache, limiter from files.__main__ import app, cache, limiter
from files.classes.submission import Submission from files.classes.submission import Submission
from files.helpers.awards import award_timers from files.helpers.awards import award_timers
defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
@app.post("/clear") @app.post("/clear")
@auth_required @auth_required
@ -207,7 +207,7 @@ def front_all(v, sub=None, subdomain=None):
else: else:
defaultsorting = "hot" defaultsorting = "hot"
if sub or SITE_NAME != 'rDrama': defaulttime = 'all' if sub or SITE_NAME != 'rDrama': defaulttime = 'all'
else: defaulttime = defaulttimefilter else: defaulttime = DEFAULT_TIME_FILTER
sort=request.values.get("sort", defaultsorting) sort=request.values.get("sort", defaultsorting)
t=request.values.get('t', defaulttime) t=request.values.get('t', defaulttime)
@ -431,7 +431,7 @@ def all_comments(v):
except: page = 1 except: page = 1
sort=request.values.get("sort", "new") sort=request.values.get("sort", "new")
t=request.values.get("t", defaulttimefilter) t=request.values.get("t", DEFAULT_TIME_FILTER)
try: gt=int(request.values.get("after", 0)) try: gt=int(request.values.get("after", 0))
except: gt=0 except: gt=0

View File

@ -1,12 +1,10 @@
from flask import * from flask import *
from os import environ
import requests import requests
from files.helpers.wrappers import * from files.helpers.wrappers import *
from files.helpers.const import *
from files.__main__ import app from files.__main__ import app
GIPHY_KEY = environ.get('GIPHY_KEY').rstrip()
@app.get("/giphy") @app.get("/giphy")
@app.get("/giphy<path>") @app.get("/giphy<path>")

View File

@ -201,7 +201,7 @@ def sign_up_get(v):
formkey_hashstr = str(now) + token + g.agent formkey_hashstr = str(now) + token + g.agent
formkey = hmac.new(key=bytes(environ.get("MASTER_KEY"), "utf-16"), formkey = hmac.new(key=bytes(MASTER_KEY, "utf-16"),
msg=bytes(formkey_hashstr, "utf-16"), msg=bytes(formkey_hashstr, "utf-16"),
digestmod='md5' digestmod='md5'
).hexdigest() ).hexdigest()
@ -234,7 +234,7 @@ def sign_up_post(v):
correct_formkey_hashstr = form_timestamp + submitted_token + g.agent correct_formkey_hashstr = form_timestamp + submitted_token + g.agent
correct_formkey = hmac.new(key=bytes(environ.get("MASTER_KEY"), "utf-16"), correct_formkey = hmac.new(key=bytes(MASTER_KEY, "utf-16"),
msg=bytes(correct_formkey_hashstr, "utf-16"), msg=bytes(correct_formkey_hashstr, "utf-16"),
digestmod='md5' digestmod='md5'
).hexdigest() ).hexdigest()

View File

@ -17,20 +17,6 @@ from shutil import copyfile
import requests import requests
import tldextract import tldextract
GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
GUMROAD_ID = environ.get("GUMROAD_ID", "tfcvri").strip()
tiers={
"(Paypig)": 1,
"(Renthog)": 2,
"(Landchad)": 3,
"(Terminally online turboautist)": 4,
"(Marsey's Sugar Daddy)": 5,
"(JIDF Bankroller)": 6,
"(Rich Bich)": 7,
"(LlamaBean)": 1,
}
@app.post("/settings/removebackground") @app.post("/settings/removebackground")
@limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day")
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}') @limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')

View File

@ -4,7 +4,6 @@ from files.helpers.const import *
from files.classes import * from files.classes import *
from flask import * from flask import *
from files.__main__ import app, limiter, cache from files.__main__ import app, limiter, cache
from os import environ
@app.get("/votes/<link>") @app.get("/votes/<link>")
@auth_required @auth_required
@ -64,7 +63,7 @@ def vote_info_get(v, link):
@is_not_permabanned @is_not_permabanned
def api_vote_post(post_id, new, v): def api_vote_post(post_id, new, v):
if new == "-1" and environ.get('DISABLE_DOWNVOTES') == '1': return {"error": "forbidden."}, 403 if new == "-1" and DISABLE_DOWNVOTES: return {"error": "forbidden."}, 403
if new not in ["-1", "0", "1"]: abort(400) if new not in ["-1", "0", "1"]: abort(400)
@ -134,7 +133,7 @@ def api_vote_post(post_id, new, v):
@is_not_permabanned @is_not_permabanned
def api_vote_comment(comment_id, new, v): def api_vote_comment(comment_id, new, v):
if new == "-1" and environ.get('DISABLE_DOWNVOTES') == '1': return {"error": "forbidden."}, 403 if new == "-1" and DISABLE_DOWNVOTES: return {"error": "forbidden."}, 403
if new not in ["-1", "0", "1"]: abort(400) if new not in ["-1", "0", "1"]: abort(400)

View File

@ -373,7 +373,7 @@
<span class="comment-mobile-score-{{c.id}} score comment-score-{{c.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if c.controversial %} controversial{% endif %}"{% if not c.is_banned %} data-bs-toggle="tooltip" data-bs-placement="top" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span> <span class="comment-mobile-score-{{c.id}} score comment-score-{{c.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if c.controversial %} controversial{% endif %}"{% if not c.is_banned %} data-bs-toggle="tooltip" data-bs-placement="top" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span>
<span {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('comment-mobile', '{{c.id}}', '-1')" class="comment-mobile-{{c.id}}-down mx-0 pl-1 my-0 arrow-down downvote-button comment-{{c.id}}-down {% if voted==-1 %}active{% endif %}"> <span {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('comment-mobile', '{{c.id}}', '-1')" class="comment-mobile-{{c.id}}-down mx-0 pl-1 my-0 arrow-down downvote-button comment-{{c.id}}-down {% if voted==-1 %}active{% endif %}">
</span> </span>
</li> </li>
@ -426,11 +426,11 @@
<li class=" arrow-down py-0 m-0 px-3 comment-{{c.id}}-down active"></li> <li class=" arrow-down py-0 m-0 px-3 comment-{{c.id}}-down active"></li>
{% endif %} {% endif %}
{% elif v %} {% elif v %}
<button {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('comment', '{{c.id}}', '-1')" class="comment-{{c.id}}-down btn caction py-0 m-0 px-3 nobackground arrow-down downvote-button comment-{{c.id}}-down {% if voted==-1 %}active{% endif %}"></button> <button {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('comment', '{{c.id}}', '-1')" class="comment-{{c.id}}-down btn caction py-0 m-0 px-3 nobackground arrow-down downvote-button comment-{{c.id}}-down {% if voted==-1 %}active{% endif %}"></button>
{% else %} {% else %}
<button {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" class="comment-{{c.id}}-down btn caction py-0 m-0 px-3 nobackground arrow-down" onclick="location.href='/login';"></button> <button {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" class="comment-{{c.id}}-down btn caction py-0 m-0 px-3 nobackground arrow-down" onclick="location.href='/login';"></button>
{% endif %} {% endif %}

View File

@ -10,7 +10,7 @@
</style> </style>
{% endif %} {% endif %}
{% if v and environ.get("FP") %} {% if v and FP %}
{% if not v.fp %} {% if not v.fp %}
<script> <script>
function fp(fp) { function fp(fp) {
@ -30,7 +30,7 @@
script.src = "/assets/js/fp.js?v=240"; script.src = "/assets/js/fp.js?v=240";
document.head.appendChild(script); document.head.appendChild(script);
}) })
.then(() => FingerprintJS.load({token: '{{environ.get("FP")}}'})); .then(() => FingerprintJS.load({token: '{{FP}}'}));
fpPromise fpPromise
.then(fp => fp.get()) .then(fp => fp.get())

View File

@ -939,7 +939,7 @@
<div tabindex="0" role="button" onclick="vote('post', '{{p.id}}', true)" class="post-{{p.id}}-up mx-auto arrow-up upvote-button post-{{p.id}}-up {% if voted==1 %}active{% endif %}"></div> <div tabindex="0" role="button" onclick="vote('post', '{{p.id}}', true)" class="post-{{p.id}}-up mx-auto arrow-up upvote-button post-{{p.id}}-up {% if voted==1 %}active{% endif %}"></div>
<span class="post-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}" data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}">{{score}}</span> <span class="post-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}" data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}">{{score}}</span>
<div {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1')" class="post-{{p.id}}-down text-muted mx-auto arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></div> <div {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1')" class="post-{{p.id}}-down text-muted mx-auto arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></div>
</div> </div>
{% else %} {% else %}
@ -948,7 +948,7 @@
<div tabindex="0" role="button" onclick="vote('post', '{{p.id}}', true)" class="post-{{p.id}}-up arrow-up mx-auto" onclick="location.href='/login?redirect={{request.path | urlencode}}';"> <div tabindex="0" role="button" onclick="vote('post', '{{p.id}}', true)" class="post-{{p.id}}-up arrow-up mx-auto" onclick="location.href='/login?redirect={{request.path | urlencode}}';">
</div> </div>
<span class="post-{{p.id}}-score-none score text-muted{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span> <span class="post-{{p.id}}-score-none score text-muted{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span>
<div {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1')" class="post-{{p.id}}-down arrow-down mx-auto" onclick="location.href='/login?redirect={{request.path | urlencode}}';"></div> <div {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1')" class="post-{{p.id}}-down arrow-down mx-auto" onclick="location.href='/login?redirect={{request.path | urlencode}}';"></div>
</div> </div>
{% endif %} {% endif %}
@ -1010,9 +1010,9 @@
<span class="post-mobile-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}" data-bs-toggle="tooltip" data-bs-placement="top" title="+{{ups}} | -{{downs}}">{{score}}</span> <span class="post-mobile-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}" data-bs-toggle="tooltip" data-bs-placement="top" title="+{{ups}} | -{{downs}}">{{score}}</span>
{% if v %} {% if v %}
<span {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post-mobile', '{{p.id}}', '-1')" class="post-mobile-{{p.id}}-down mx-0 pl-1 my-0 arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></span> <span {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post-mobile', '{{p.id}}', '-1')" class="post-mobile-{{p.id}}-down mx-0 pl-1 my-0 arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></span>
{% else %} {% else %}
<span {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" class="arrow-{{p.id}}-mobile-down arrow-mobile-down mx-0 pl-1 my-0" onclick="location.href='/login?redirect={{request.path | urlencode}}';"> <span {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" class="arrow-{{p.id}}-mobile-down arrow-mobile-down mx-0 pl-1 my-0" onclick="location.href='/login?redirect={{request.path | urlencode}}';">
<i class="fas fa-arrow-alt-down mx-0" aria-hidden="true"></i> <i class="fas fa-arrow-alt-down mx-0" aria-hidden="true"></i>
</span> </span>
{% endif %} {% endif %}

View File

@ -97,7 +97,7 @@
<span class="post-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span> <span class="post-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span>
<div {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1', '{{v.id}}')" class="post-{{p.id}}-down text-muted mx-auto arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></div> <div {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1', '{{v.id}}')" class="post-{{p.id}}-down text-muted mx-auto arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></div>
{% else %} {% else %}
@ -105,7 +105,7 @@
<span class="post-{{p.id}}-score-none score{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span> <span class="post-{{p.id}}-score-none score{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="right" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span>
<div {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1', '{{v.id}}')" class="post-{{p.id}}-down text-muted mx-auto arrow-down" onclick="location.href='/login';"></div> <div {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post', '{{p.id}}', '-1', '{{v.id}}')" class="post-{{p.id}}-down text-muted mx-auto arrow-down" onclick="location.href='/login';"></div>
{% endif %} {% endif %}
@ -289,7 +289,7 @@
<span class="post-mobile-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="top" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span> <span class="post-mobile-score-{{p.id}} score post-score-{{p.id}} {% if voted==1 %}score-up{% elif voted==-1%}score-down{% endif %}{% if p.controversial %} controversial{% endif %}"{% if not p.is_banned %} data-bs-toggle="tooltip" data-bs-placement="top" title="+{{ups}} | -{{downs}}"{% endif %}>{{score}}</span>
<span {% if environ.get('DISABLE_DOWNVOTES') == '1' %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post-mobile', '{{p.id}}', '-1', '{{v.id}}')" class="post-mobile-{{p.id}}-down mx-0 pl-1 my-0 arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></span> <span {% if DISABLE_DOWNVOTES %}style="display:None!important"{% endif %} tabindex="0" role="button" onclick="vote('post-mobile', '{{p.id}}', '-1', '{{v.id}}')" class="post-mobile-{{p.id}}-down mx-0 pl-1 my-0 arrow-down downvote-button post-{{p.id}}-down {% if voted==-1 %}active{% endif %}"></span>
</li> </li>
{% else %} {% else %}
@ -349,24 +349,24 @@
</div> </div>
{% endif %} {% endif %}
{% if p.is_image and not p.over_18 and ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %} {% if p.is_image and not p.over_18 and ((v and v.cardview) or (not v and CARD_VIEW)) %}
<div style="text-align: center" class="mt-3 mb-4"> <div style="text-align: center" class="mt-3 mb-4">
<a {% if v and v.newtab and not g.webview %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}"> <a {% if v and v.newtab and not g.webview %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}">
<img loading="lazy" data-src="{{p.realurl(v)}}" src="/i/l.webp" class="img-fluid" style="max-height:20rem" alt="Unable to load image"> <img loading="lazy" data-src="{{p.realurl(v)}}" src="/i/l.webp" class="img-fluid" style="max-height:20rem" alt="Unable to load image">
</a> </a>
</div> </div>
{% elif p.is_video %} {% elif p.is_video %}
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-4"> <div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and CARD_VIEW)) %}d-none{% endif %} mt-4">
<video id="video2-{{p.id}}" controls preload="none"> <video id="video2-{{p.id}}" controls preload="none">
<source src="{{p.realurl(v)}}"> <source src="{{p.realurl(v)}}">
</video> </video>
</div> </div>
{% elif p.is_audio %} {% elif p.is_audio %}
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-4"> <div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and CARD_VIEW)) %}d-none{% endif %} mt-4">
<audio id="video2-{{p.id}}" controls preload="none" src="{{p.realurl(v)}}"></audio> <audio id="video2-{{p.id}}" controls preload="none" src="{{p.realurl(v)}}"></audio>
</div> </div>
{% elif p.is_youtube %} {% elif p.is_youtube %}
<div id="video-{{p.id}}" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4 youtube_embed"> <div id="video-{{p.id}}" class="{% if p.over_18 or not ((v and v.cardview) or (not v and CARD_VIEW)) %}d-none{% endif %} mt-3 mb-4 youtube_embed">
{{p.embed_url | safe}} {{p.embed_url | safe}}
</div> </div>
{% endif %} {% endif %}