From 47658f2897ec2b1b8a6b53de5bc4800368789a8b Mon Sep 17 00:00:00 2001 From: geese-suck <16601315+geese-suck@users.noreply.github.com> Date: Thu, 17 Nov 2022 13:08:39 -0800 Subject: [PATCH] clean up html head (#461) * init (not done) * asdf * :marseymop: * unnecesary * remove * Update html_head.html --- files/templates/authforms.html | 2 +- files/templates/chat.html | 2 +- files/templates/default.html | 14 +-- files/templates/home.html | 2 +- files/templates/html_head.html | 154 +++++++++++++++--------- files/templates/login.html | 2 +- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 2 +- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 2 +- files/templates/submission.html | 55 --------- files/templates/submit.html | 2 +- files/templates/userpage.html | 18 --- 14 files changed, 108 insertions(+), 153 deletions(-) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 1b6d57c64..b3fe208de 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -2,7 +2,7 @@ {%- import 'html_head.html' as html_head with context -%} -{{html_head.html_head(false, false, false, none, none, "", "")}} +{{html_head.html_head(false, false, false, none, none)}}
diff --git a/files/templates/chat.html b/files/templates/chat.html index ec6b5edc4..08704b07a 100644 --- a/files/templates/chat.html +++ b/files/templates/chat.html @@ -7,7 +7,7 @@ {% else %} {% set csp=none %} {% endif %} -{{html_head.html_head(true, true, true, csp, "Chat", none, "", false)}} +{{html_head.html_head(true, true, true, csp, "Chat", false)}} {% include "header.html" %} {% include "modals/expanded_image.html" %} diff --git a/files/templates/default.html b/files/templates/default.html index 3f17cfea0..cf4e281d0 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -5,23 +5,11 @@ {% if request.path == '/' %} {% set csp=CONTENT_SECURITY_POLICY_HOME %} {% endif %} -{% if not 'post/' in request.path and not '@' 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 #} - {{html_head.javascript()}} - {{html_head.stylesheets(true, '')}} - {{html_head.meta_tags_1(csp, none, true)}} - + {{html_head.html_head(true, true, true, csp, none, true)}} {% block title %} - {{SITE_NAME}} - {{html_head.meta_tags_2(SITE_NAME, SITE_FULL)}} {% endblock %} - {{html_head.seo()}} - {{html_head.cf_2fa_verify()}} -{% endif %} diff --git a/files/templates/home.html b/files/templates/home.html index 6e3458774..847791d71 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -12,7 +12,7 @@ {% endif %} /h/{{sub}} - + diff --git a/files/templates/html_head.html b/files/templates/html_head.html index aa9bc1c69..10aa4969c 100644 --- a/files/templates/html_head.html +++ b/files/templates/html_head.html @@ -1,36 +1,12 @@ -{% 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 #} +{% macro html_head(js, include_seo, include_user_css, csp, title, include_2fa_verify) %} - {% 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 %} - {% if 'chat' in request.path %} - {% if SITE == 'localhost' %} - - {% else %} - - {% endif %} - {% endif %} + + + {{ page_meta(title) }} + {{ stylesheets(include_user_css) }} + {{ javascript() if js}} + {{ seo() if include_seo }} + {{ cf_2fa_verify() if include_2fa_verify }} {% endmacro %} @@ -49,36 +25,93 @@ {% endmacro %} -{% macro meta_tags_1(csp, author, exclude_author) %} - - - - - - {% if not exclude_author %} - +{% macro page_meta (title) %} + {% set title = SITE_NAME if not title %} + + {% if 'post/' in request.path %} + {% set title = [p.plaintitle(v), ' - ', title] | join %} + + {% if not v_forbid_deleted -%} + {% set image = p.thumb_url if p.has_thumb %} + {% set image = p.realurl(v) if p.is_image %} + {% set video = p.realurl(v) if p.is_video %} + {% set audio = p.realurl(v) if p.is_audio %} + {% endif %} + + {% if comment_info and not comment_info.is_banned and not comment_info.deleted_utc %} + {% set p, title = comment_info, ['@', comment_info.author_name, ' comments on ', + '"', title, '"'] | join %} + {% endif %} + + {% set author, description, a_author, published, modified, url = + '@'+p.author_name, p.plainbody(v), '@'+p.author_name, + p.created_datetime, p.edited_string, p.permalink %} + + {% elif '@' in request.path %} + {% set author, a_author, published, url, title, image, section = + '@'+u.username, '@'+u.username, u.created_date, + u.url, u.username, u.banner_url + [u.username, "'s profile - ", SITE_NAME] | join %} + + {% set description %} + "{{u.coins}} coins - Joined {{u.created_date}} - + {% if u.stored_subscriber_count >=1 and not u.is_private %} + {{u.stored_subscriber_count}} Followers - + {% endif %} + {% if not u.is_private %} + {{0 if u.shadowbanned else u.post_count}} + Posts - + {{0 if u.shadowbanned else u.comment_count}} + Comments + {% endif %} + {% if u.bio %} + - {{u.bio}} + {% endif %}" + {% endset %} + + {% elif sub %} + {% set title, description = + '/h/'+sub, sub.sidebar if sub.sidebar %} {% endif %} + + {{title}} + + {{ meta_tags(title, author, description, image, + video, audio, a_author, published, modified, section, url) }} {% endmacro %} -{% macro meta_tags_2(title, author) %} +{% macro meta_tags(title, author, description, image, video, audio, a_author, published, modified, section, url ) %} + + + + - - - + + + + + + + + + + + - - - - - + + + + + + {% endmacro %} -{% macro stylesheets(include_user_css, extra_css) %} +{% macro stylesheets(include_user_css) %} {% if v %} @@ -119,21 +152,28 @@ {% if SITE_NAME == 'rDrama' %} {% endif %} - {{extra_css}} + + {% if 'chat' in request.path %} + {% if SITE == 'localhost' %} + + {% else %} + + {% endif %} + {% endif %} {% endmacro %} {% macro default_theme() %} - + {% endmacro %} {% macro seo() %} - - - - + + + + - + diff --git a/files/templates/login.html b/files/templates/login.html index 17bd874f0..8e212c5d7 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -2,7 +2,7 @@ {%- import 'html_head.html' as html_head with context -%} -{{html_head.html_head(true, false, false, none, 'Login', '', '', false)}} +{{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 c7be3cc63..88706a8b2 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -2,7 +2,7 @@ {%- import 'html_head.html' as html_head with context -%} -{{html_head.html_head(false, false, false, none, none, '', '', false)}} +{{html_head.html_head(false, false, false, none, none, false)}} diff --git a/files/templates/settings.html b/files/templates/settings.html index a274dcc96..3393572b5 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -5,7 +5,7 @@ {% block pagetitle %}Settings - {{SITE_NAME}}{% endblock %} -{{html_head.html_head(true, false, true, none, "Settings", "", "", false)}} +{{html_head.html_head(true, false, true, none, "Settings", false)}} {% include "header.html" %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 143c622a2..090681e4f 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -2,7 +2,7 @@ {%- import 'html_head.html' as html_head with context -%} -{{html_head.html_head(true, false, true, none, none, "", "")}} +{{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 ac336faca..96de3e22f 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -7,7 +7,7 @@ {% else %} {% set title="Sign up" %} {% endif %} -{{html_head.html_head(true, false, false, none, title, none, "", false)}} +{{html_head.html_head(true, false, false, none, title, false)}}
diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 238b84026..aec38a19b 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -2,7 +2,7 @@ {%- import 'html_head.html' as html_head with context -%} -{{html_head.html_head(true, false, false, none, none, none, false)}} +{{html_head.html_head(true, false, false, none, none, false)}}
diff --git a/files/templates/submission.html b/files/templates/submission.html index fc26a91ab..cb1599527 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -24,61 +24,6 @@ {% if SITE_NAME == 'PCM' %} {% include "awards_PCM.html" %} {% endif %} - - - - - - - -{% if not v_forbid_deleted -%} - - {% if p.is_video %} - - {% elif p.is_audio %} - - {% endif %} - -{% endif %} - - -{% if comment_info and not comment_info.is_banned and not comment_info.deleted_utc %} - {{'@'+comment_info.author_name}} comments on "{{p.plaintitle(v)}} - {{SITE_NAME}}" - - - - - - - - - {% if comment_info.edited_utc %} - - {% endif %} - - - - - -{% else %} - {{p.plaintitle(v)}} - {{SITE_NAME}} - - - - - - - - - {% if p.edited_utc %} - - {% endif %} - - - - - -{%- endif %} {% endblock %} {% block pagetype %}thread{% endblock %} diff --git a/files/templates/submit.html b/files/templates/submit.html index 4296fbd6b..42e268bd9 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -2,7 +2,7 @@ {%- import 'html_head.html' as html_head with context -%} -{{html_head.html_head(true, false, true, none, "Create a post", none, "", false)}} +{{html_head.html_head(true, false, true, none, "Create a post", false)}} {% include "header.html" %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 0ddfe13fa..f676f1b2c 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -9,24 +9,6 @@ {% endif %} -{{u.username}}'s profile - {{SITE_NAME}} - - - - - - - - - - - - - - - - - {% endblock %} {% import 'userpage/admintools.html' as userpage_admintools with context %}