diff --git a/files/classes/user.py b/files/classes/user.py index 00816c675..56398f3a3 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -436,7 +436,7 @@ class User(Base): @lazy def banner_url(self): if self.bannerurl: return self.bannerurl - else: return f"https://{site}/static/assets/images/{site_name}/preview.webp?a=200" + else: return f"https://{site}/static/assets/images/{site_name}/site_preview.webp?a=1" @property @lazy diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index aa601a438..071786f21 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -109,7 +109,7 @@ def sanitize(sanitized, noimages=False, alert=False): for i in re.finditer("

@((\w|-){1,25})", sanitized): u = get_user(i.group(1), graceful=True) if u: - sanitized = sanitized.replace(i.group(0), f'

@{u.username}') + sanitized = sanitized.replace(i.group(0), f'''

@{u.username}'s profile picture@{u.username}''') else: sanitized = re.sub('(^|\s|\n|

)\/?((r|u)\/\w{3,25})', r'\1\2', sanitized) @@ -120,7 +120,7 @@ def sanitize(sanitized, noimages=False, alert=False): if noimages: sanitized = sanitized.replace(i.group(0), f'{i.group(1)}@{u.username}') else: - sanitized = sanitized.replace(i.group(0), f'{i.group(1)}@{u.username}') + sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}@{u.username}'s profile picture@{u.username}''') for i in re.finditer('https://i\.imgur\.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized): @@ -160,7 +160,7 @@ def sanitize(sanitized, noimages=False, alert=False): tag["loading"] = "lazy" tag["data-src"] = tag["src"] tag["src"] = "/static/assets/images/loading.webp" - tag['alt'] = f'![]({tag["src"]})' + tag['alt'] = f'![]({tag["data-src"]})' link = soup.new_tag("a") link["href"] = tag["data-src"] @@ -203,10 +203,10 @@ def sanitize(sanitized, noimages=False, alert=False): classes = 'class="emoji-lg" ' remoji = emoji[1:] elif emoji.startswith("!"): - classes = 'height=60 class="emoji-md mirrored" ' + classes = 'class="emoji-md mirrored" ' remoji = emoji[1:] else: - classes = 'height=60 class="emoji-md" ' + classes = 'class="emoji-md" ' remoji = emoji if path.isfile(f'files/assets/images/emojis/{remoji}.webp'): @@ -221,11 +221,11 @@ def sanitize(sanitized, noimages=False, alert=False): if emoji.startswith("!"): emoji = emoji[1:] if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - sanitized = re.sub(f'(?', sanitized, flags=re.I) + sanitized = re.sub(f'(?', sanitized, flags=re.I) marseys_used.add(emoji) elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - sanitized = re.sub(f'(?', sanitized, flags=re.I) + sanitized = re.sub(f'(?', sanitized, flags=re.I) marseys_used.add(emoji) sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").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/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube") @@ -277,10 +277,10 @@ def filter_emojis_only(title): if emoji.startswith("!"): emoji = emoji[1:] if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - title = re.sub(f'(?', title, flags=re.I) + title = re.sub(f'(?', title, flags=re.I) elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - title = re.sub(f'(?', title, flags=re.I) + title = re.sub(f'(?', title, flags=re.I) if len(title) > 1500: abort(400) else: return title \ No newline at end of file diff --git a/files/routes/front.py b/files/routes/front.py index bad1917eb..01fe33589 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -256,7 +256,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' if sort == "hot": ti = int(time.time()) + 3600 - posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.35))) + posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.23))) elif sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": diff --git a/files/routes/posts.py b/files/routes/posts.py index 547c120f3..930c87a7e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1037,7 +1037,12 @@ def submit_post(v): if request.headers.get("Authorization"): return {"error": "File type not allowed"}, 400 return render_template(f"{template}submit.html", v=v, error="File type not allowed.", title=title, body=request.values.get("body", "")), 400 - if not new_post.thumburl and new_post.url and request.headers.get('cf-ipcountry')!="T1": gevent.spawn( thumbnail_thread, new_post.id) + + if not new_post.thumburl and new_post.url: + if request.host in new_post.url or new_post.url.startswith('/') or request.host == 'rdrama.net' and 'rdrama' in new_post.url: + new_post.thumburl = '/static/assets/images/{site_name}/site_preview.webp' + elif request.headers.get('cf-ipcountry')!="T1": + gevent.spawn( thumbnail_thread, new_post.id) if not new_post.private: @@ -1162,8 +1167,13 @@ def submit_post(v): g.db.commit() + if request.headers.get("Authorization"): return new_post.json - else: return redirect(new_post.permalink) + else: + if 'megathread' in new_post.title.lower(): sort = 'new' + else: sort = v.defaultsortingcomments + new_post.replies = [c] + return render_template('submission.html', v=v, p=new_post, sort=sort, render_replies=True, offset=0, success=True) @app.post("/delete_post/") diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 1260a15a7..461d26f85 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,7 +15,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 391af938c..c67a680c8 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -7,7 +7,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% endif %} - + {% block title %} @@ -47,7 +47,7 @@ - + @@ -58,7 +58,7 @@ - + {% endblock %} @@ -227,11 +227,11 @@ {% if v %} - + {% else %} - + {% endif %} {% endif %} diff --git a/files/templates/log.html b/files/templates/log.html index 74fa1987b..401e47d1e 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -6,7 +6,7 @@ {% block content %} {% if v %} - + {% if v.agendaposter %} - + {% endif %}

diff --git a/files/templates/login.html b/files/templates/login.html index a55987114..febcdd253 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -18,7 +18,7 @@ {% endblock %} - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index cecae17f8..ed4ee9fd3 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -14,7 +14,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index c34a342e2..6fce61fa1 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -18,7 +18,7 @@ - + @@ -29,12 +29,12 @@ - + - + {% if v.agendaposter %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 99d0af4f0..dc9936975 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -14,7 +14,7 @@ - + @@ -25,13 +25,13 @@ - + {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 24e852c46..599583697 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -15,7 +15,7 @@ - + @@ -26,13 +26,13 @@ - + {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/submission.html b/files/templates/submission.html index 7d1ca1386..73027848b 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -13,6 +13,14 @@ {% block title %} +{% if success %} + +{% endif %} + {% if p.award_count("wholesome") %} - + {% if v.agendaposter %} - + {% endif %} {% endblock %} @@ -199,11 +199,49 @@ document.getElementById('post-title').value = fetched_title let fetched_text = window.localStorage.getItem("post_text") document.getElementById('post-text').value = fetched_text + + function checkForRequired() { + + var title = document.getElementById("post-title"); + + var url = document.getElementById("post-URL"); + + var text = document.getElementById("post-text"); + + var button = document.getElementById("create_button"); + + var image = document.getElementById("file-upload"); + + if (url.value.length > 0 || image.value.length > 0) { + text.required = false; + url.required=false; + } else if (text.value.length > 0 || image.value.length > 0) { + url.required = false; + } else { + text.required = true; + url.required = true; + } + + var isValidTitle = title.checkValidity(); + + var isValidURL = url.checkValidity(); + + var isValidText = text.checkValidity(); + + if (isValidTitle && (isValidURL || image.value.length>0)) { + button.disabled = false; + } else if (isValidTitle && isValidText) { + button.disabled = false; + } else { + button.disabled = true; + } + } + checkForRequired() - + {% include "emoji_modal.html" %} {% include "gif_modal.html" %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 35f19291a..f97be6e5e 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -9,9 +9,6 @@ {% endif %} {{u.username}}'s profile - {{'SITE_NAME' | app_config}} -{% if u.is_private %} - -{% endif %}