expand IS_LOCALHOST
parent
35f6b39d27
commit
caabaf0c6f
|
@ -26,12 +26,12 @@ app.jinja_env.auto_reload = True
|
||||||
app.jinja_env.add_extension('jinja2.ext.do')
|
app.jinja_env.add_extension('jinja2.ext.do')
|
||||||
faulthandler.enable()
|
faulthandler.enable()
|
||||||
|
|
||||||
is_localhost = SITE == "localhost"
|
IS_LOCALHOST = SITE == "localhost" or SITE == "127.0.0.1" or SITE.startswith("192.168")
|
||||||
|
|
||||||
app.config['SERVER_NAME'] = SITE
|
app.config['SERVER_NAME'] = SITE
|
||||||
app.config['SECRET_KEY'] = environ.get('SECRET_KEY').strip()
|
app.config['SECRET_KEY'] = environ.get('SECRET_KEY').strip()
|
||||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3153600
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3153600
|
||||||
if not is_localhost:
|
if not IS_LOCALHOST:
|
||||||
app.config['SESSION_COOKIE_DOMAIN'] = f'.{SITE}'
|
app.config['SESSION_COOKIE_DOMAIN'] = f'.{SITE}'
|
||||||
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower()
|
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower()
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024
|
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024
|
||||||
|
|
|
@ -7,14 +7,10 @@ from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
|
from files.helpers.const import *
|
||||||
|
|
||||||
from .sub_relationship import *
|
from .sub_relationship import *
|
||||||
|
|
||||||
SITE_NAME = environ.get("SITE_NAME", '').strip()
|
|
||||||
SITE = environ.get("SITE", '').strip()
|
|
||||||
if SITE == "localhost": SITE_FULL = 'http://' + SITE
|
|
||||||
else: SITE_FULL = 'https://' + SITE
|
|
||||||
|
|
||||||
class Sub(Base):
|
class Sub(Base):
|
||||||
__tablename__ = "subs"
|
__tablename__ = "subs"
|
||||||
name = Column(String, primary_key=True)
|
name = Column(String, primary_key=True)
|
||||||
|
|
|
@ -58,7 +58,9 @@ DEFAULT_RATELIMIT_USER = DEFAULT_RATELIMIT_SLOWER
|
||||||
|
|
||||||
PUSHER_LIMIT = 1000 # API allows 10 KB but better safe than sorry
|
PUSHER_LIMIT = 1000 # API allows 10 KB but better safe than sorry
|
||||||
|
|
||||||
if SITE == "localhost": SITE_FULL = 'http://' + SITE
|
IS_LOCALHOST = SITE == "localhost" or SITE == "127.0.0.1" or SITE.startswith("192.168.")
|
||||||
|
|
||||||
|
if IS_LOCALHOST: SITE_FULL = 'http://' + SITE
|
||||||
else: SITE_FULL = 'https://' + SITE
|
else: SITE_FULL = 'https://' + SITE
|
||||||
|
|
||||||
|
|
||||||
|
@ -1418,7 +1420,7 @@ REDDIT_NOTIFS_USERS = {}
|
||||||
if len(SITE_NAME) > 5:
|
if len(SITE_NAME) > 5:
|
||||||
REDDIT_NOTIFS_SITE.add(SITE_NAME.lower())
|
REDDIT_NOTIFS_SITE.add(SITE_NAME.lower())
|
||||||
|
|
||||||
if SITE != 'localhost':
|
if not IS_LOCALHOST:
|
||||||
REDDIT_NOTIFS_SITE.add(SITE)
|
REDDIT_NOTIFS_SITE.add(SITE)
|
||||||
|
|
||||||
if SITE == 'rdrama.net':
|
if SITE == 'rdrama.net':
|
||||||
|
|
|
@ -13,7 +13,7 @@ from files.routes.wrappers import *
|
||||||
|
|
||||||
from files.__main__ import app, cache, limiter
|
from files.__main__ import app, cache, limiter
|
||||||
|
|
||||||
if SITE == 'localhost':
|
if IS_LOCALHOST:
|
||||||
socketio = SocketIO(
|
socketio = SocketIO(
|
||||||
app,
|
app,
|
||||||
async_mode='gevent',
|
async_mode='gevent',
|
||||||
|
|
|
@ -66,5 +66,5 @@ def inject_constants():
|
||||||
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":IMAGE_FORMATS,
|
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":IMAGE_FORMATS,
|
||||||
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
|
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
|
||||||
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME,
|
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME,
|
||||||
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE,
|
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST,
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,7 +731,7 @@ def submit_post(v, sub=None):
|
||||||
if not url and not body and not request.files.get("file") and not request.files.get("file-url"):
|
if not url and not body and not request.files.get("file") and not request.files.get("file-url"):
|
||||||
return error("Please enter a url or some text.")
|
return error("Please enter a url or some text.")
|
||||||
|
|
||||||
if SITE != 'localhost':
|
if not IS_LOCALHOST:
|
||||||
dup = g.db.query(Submission).filter(
|
dup = g.db.query(Submission).filter(
|
||||||
Submission.author_id == v.id,
|
Submission.author_id == v.id,
|
||||||
Submission.deleted_utc == 0,
|
Submission.deleted_utc == 0,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{%- import 'html_head.html' as html_head with context -%}
|
{%- import 'html_head.html' as html_head with context -%}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
{% if SITE == 'localhost' %}
|
{% if IS_LOCALHOST %}
|
||||||
{% set csp="script-src 'self' 'unsafe-inline' rdrama.net; connect-src 'self'; object-src 'none';" %}
|
{% set csp="script-src 'self' 'unsafe-inline' rdrama.net; connect-src 'self'; object-src 'none';" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set csp=none %}
|
{% set csp=none %}
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
data-hat="{{v.hat_active}}">
|
data-hat="{{v.hat_active}}">
|
||||||
</div>
|
</div>
|
||||||
<script>window.global = window</script>
|
<script>window.global = window</script>
|
||||||
{% if SITE == 'localhost' %}
|
{% if IS_LOCALHOST %}
|
||||||
<script defer src="https://rdrama.net/assets/js/chat_done.js"></script>
|
<script defer src="https://rdrama.net/assets/js/chat_done.js"></script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<script defer src="{{'js/chat_done.js' | asset}}"></script>
|
<script defer src="{{'js/chat_done.js' | asset}}"></script>
|
||||||
|
|
|
@ -155,7 +155,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'chat' in request.path %}
|
{% if 'chat' in request.path %}
|
||||||
{% if SITE == 'localhost' %}
|
{% if IS_LOCALHOST %}
|
||||||
<link rel="stylesheet" href="https://rdrama.net/assets/css/chat_done.css">
|
<link rel="stylesheet" href="https://rdrama.net/assets/css/chat_done.css">
|
||||||
{% else %}
|
{% else %}
|
||||||
<link rel="stylesheet" href="{{'css/chat_done.css' | asset}}">
|
<link rel="stylesheet" href="{{'css/chat_done.css' | asset}}">
|
||||||
|
|
Loading…
Reference in New Issue