diff --git a/files/assets/css/rDrama.css b/files/assets/css/rDrama.css new file mode 100644 index 000000000..d6e50d2db --- /dev/null +++ b/files/assets/css/rDrama.css @@ -0,0 +1,7 @@ +.mod:before { + content: '((('; +} + +.mod:after { + content: ')))'; +} \ No newline at end of file diff --git a/files/helpers/const.py b/files/helpers/const.py index 8bea57874..d0ec8d6c6 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -48,6 +48,11 @@ FP = environ.get("FP", "").strip() KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip() KOFI_LINK = environ.get("KOFI_LINK", "").strip() +PUSHER_ID_CSP = "" +if PUSHER_ID != "blahblahblah": + PUSHER_ID_CSP = f" {PUSHER_ID}.pushnotifications.pusher.com" +CONTENT_SECURITY_POLICY_DEFAULT = "script-src 'self' 'unsafe-inline' ajax.cloudflare.com; connect-src 'self'; object-src 'none';" +CONTENT_SECURITY_POLICY_HOME = f"script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' tls-user1.fpapi.io api.fpjs.io{PUSHER_ID_CSP}; object-src 'none';" if SITE == "localhost": SITE_FULL = 'http://' + SITE else: SITE_FULL = 'https://' + SITE diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index b6d0e00f6..b4ad87454 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -50,4 +50,6 @@ def inject_constants(): "site_settings":app.config['SETTINGS'], "EMAIL":EMAIL, "calc_users":calc_users, "TELEGRAM_LINK":TELEGRAM_LINK, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN, + "CONTENT_SECURITY_POLICY_DEFAULT":CONTENT_SECURITY_POLICY_DEFAULT, + "CONTENT_SECURITY_POLICY_HOME":CONTENT_SECURITY_POLICY_HOME, } diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 84d326a8b..acd266945 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -1,44 +1,8 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - {% block pagetitle %}{{SITE_NAME}}{% endblock %} - - - {% if v %} - - - - {% if v.agendaposter %} - - {% elif v.css %} - - {% endif %} - {% else %} - - - - {% endif %} - - - +{{html_head.html_head(false, false, false, none, none, "", "")}}
diff --git a/files/templates/chat.html b/files/templates/chat.html index a0da5e8be..d206a96db 100644 --- a/files/templates/chat.html +++ b/files/templates/chat.html @@ -1,34 +1,19 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - Chat - - - - - {% if v.css %} - - {% endif %} +{% if SITE == 'localhost' %} + {% set csp="script-src 'self' 'unsafe-inline' rdrama.net; connect-src 'self'; object-src 'none';" %} +{% else %} + {% set csp=none %} +{% endif %} +{{html_head.html_head(true, true, true, csp, "Chat", none, "", false)}} + {% if SITE == 'localhost' %} {% else %} {% endif %} - - - {% include "header.html" %} {% include "expanded_image_modal.html" %} {% include "emoji_modal.html" %} diff --git a/files/templates/default.html b/files/templates/default.html index c704a3bcc..ebf0a844e 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -1,252 +1,28 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} +{% if request.path == '/' %} + {% set csp=CONTENT_SECURITY_POLICY_HOME %} +{% endif %} +{% if not 'post/' in request.path %} + {{html_head.html_head(true, true, true, csp, none, "", "", true, 'post/' in request.path)}} +{% else %} +{# this should really be fixed at some point, prolly after 10/31 #} - - - - - - {% if request.path == '/' %} - - {% else %} - - {% endif %} - - {% if v %} - - - - - {% if v.agendaposter %} - - {% elif v.css %} - - {% endif %} - {% else %} - - - - - {% endif %} - - {% if request.path.endswith('/catalog') %} - - {% endif %} - - {% if sub and sub.css and not request.path.endswith('settings') and not request.values.get('nocss') %} - - {% endif %} - - {% if v and v.themecolor == '30409f' %} - - {% endif %} - - {% if SITE_NAME == 'rDrama' %} - - {% endif %} - - - - - - + {{html_head.javascript()}} + {{html_head.stylesheets(true, '')}} + {{html_head.meta_tags_1(csp, none, true)}} {% block title %} {{SITE_NAME}} - - - - - - - - - - - - - - - - + {{html_head.meta_tags_2(SITE_NAME, SITE_FULL)}} {% endblock %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if 'slackernews' in request.path %} - - {% elif SITE == 'rdrama.net' %} - - {% elif SITE == 'watchpeopledie.tv' %} - - {% elif SITE == 'pcmemes.net' %} - - {% endif %} - - - - + {{html_head.seo()}} + {{html_head.cf_2fa_verify()}} +{% endif %} + diff --git a/files/templates/html_head.html b/files/templates/html_head.html new file mode 100644 index 000000000..feaccc8ad --- /dev/null +++ b/files/templates/html_head.html @@ -0,0 +1,263 @@ +{% macro html_head(js, include_seo, include_user_css, csp, title2, author, extra_css, include_2fa_verify, include_seo2) %} +{# submission.py does a lot of stupid stuff with the title and we don't want to override that #} +{# remember, this is very temporary #} + + {% if js %} + {{javascript()}} + {% endif %} + {{meta_tags_1(csp, author)}} + {{stylesheets(include_user_css, extra_css)}} + {% if title2 %} + {{title2 | default(SITE_NAME, true)}} - {{SITE_NAME}} + {{meta_tags_2(title2, author)}} + {% elif not include_seo2 %} + {% block title %} + {% block pagetitle %}{{SITE_NAME}}{% endblock %} + {{meta_tags_2(self.pagetitle(), author)}} + {% endblock %} + {% else %} + {{self.title()}} + {% endif %} + {% if include_seo %} + {{seo()}} + {% endif %} + {% if include_2fa_verify %} + {{cf_2fa_verify()}} + {% endif %} + +{% endmacro %} + +{% macro cf_2fa_verify() %} + {% if SITE == 'rdrama.net' %} + + {% elif SITE == 'watchpeopledie.tv' %} + + {% elif SITE == 'pcmemes.net' %} + + {% endif %} +{% endmacro %} + +{% macro javascript() %} + + +{% endmacro %} + +{% macro meta_tags_1(csp, author, exclude_author) %} + + + + + + {% if not exclude_author %} + + {% endif %} +{% endmacro %} + +{% macro meta_tags_2(title, author) %} + + + + + + + + + + + + + + + +{% endmacro %} + +{% macro stylesheets(include_user_css, extra_css) %} + + + {% if v %} + + {% if v.agendaposter %} + + {% endif %} + {% if include_user_css %} + + + {% if v.css and not request.path.startswith('/settings/css') %} + + {% endif %} + {% if v.themecolor == '30409f' %} + + {% endif %} + {% endif %} + {% else %} + + + + {% endif %} + + {% if request.path.endswith('/catalog') %} + + {% endif %} + + {% if sub and sub.css and not request.path.endswith('settings') and not request.values.get('nocss') %} + + {% endif %} + + {% if SITE_NAME == 'rDrama' %} + + {% endif %} + {{extra_css}} +{% endmacro %} + +{% macro seo() %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endmacro %} \ No newline at end of file diff --git a/files/templates/login.html b/files/templates/login.html index 9f7991161..0028e905b 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -1,31 +1,8 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - - - - {% block title %} - Login - {{SITE_NAME}} - {% endblock %} - - - - - - - +{{html_head.html_head(true, false, false, none, 'Login', '', '', false)}}
diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 26d99a5bf..6bb3ce0ca 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -1,26 +1,9 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - +{{html_head.html_head(false, false, false, none, none, '', '', false)}} - - - - - - - - - - - 2-Step Login - {{SITE_NAME}} - - - - - - -
diff --git a/files/templates/settings.html b/files/templates/settings.html index f282f0781..57c58885e 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -1,53 +1,11 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - {% block pagetitle %}Settings - {{SITE_NAME}}{% endblock %} - - - - - - - - - - - - - - - - - - - - - {% if v.agendaposter %} - - {% elif v.css and not request.path.startswith('/settings/css') %} - - {% endif %} +{{html_head.html_head(true, false, true, none, "Settings", "", "", false)}} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 24633ed73..2eb32abd8 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -1,53 +1,8 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% block pagetitle %}{{SITE_NAME}}{% endblock %} - - - {% if v %} - - - - {% else %} - - - - {% endif %} - - +{{html_head.html_head(true, false, true, none, none, "", "")}} {% include "header.html" %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 78cb8581e..a190edabc 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -1,43 +1,13 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %} - - - - - - - +{% if ref_user %} + {% set title= ref_user.username + "invites you to " + SITE_NAME %} +{% else %} + {% set title="Sign up" %} +{% endif %} +{{html_head.html_head(true, false, false, none, title, none, "", false)}}
diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index e6f7e45f1..91a136056 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -1,44 +1,8 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %} - - - - - - - +{{html_head.html_head(true, false, false, none, none, none, false)}}
diff --git a/files/templates/submit.html b/files/templates/submit.html index ffbf43618..ddc7dca5b 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -1,53 +1,8 @@ {%- import 'util/helpers.html' as help -%} +{%- import 'html_head.html' as html_head with context -%} - - - - - - - - - - - - - - {% if SITE == 'pcmemes.net' %} - {% set cc='Splash Mountain' %} - {% else %} - {% set cc='Country Club' %} - {% endif %} - - {% block title %} - Create a post - {{SITE_NAME}} - {% endblock %} - - {% block stylesheets %} - {% if v %} - - - - {% if v.agendaposter %} - - {% elif v.css %} - - {% endif %} - {% else %} - - - - {% endif %} - {% endblock %} - - +{{html_head.html_head(true, false, true, none, "Create a post", none, "", false)}} {% include "header.html" %}