Merge branch 'master' into mistletoe

remotes/1693045480750635534/spooky-22
kek7198 2021-12-04 18:36:59 -06:00
commit 43875d896b
28 changed files with 214 additions and 181 deletions

View File

@ -335,8 +335,11 @@ class Comment(Base):
maxupvotes = min(ti, 31)
rand = randint(0, maxupvotes)
if self.upvotes < rand:
self.upvotes += randint(0, 3)
amount = randint(0, 3)
self.upvotes += amount
g.db.add(self)
self.author.coins += amount
g.db.add(self.author)
g.db.commit()
return body

View File

@ -335,8 +335,11 @@ class Submission(Base):
maxupvotes = min(ti, 27)
rand = random.randint(0, maxupvotes)
if self.upvotes < rand:
self.upvotes += random.randint(0, 3)
amount = random.randint(0, 3)
self.upvotes += amount
g.db.add(self)
self.author.coins += amount
g.db.add(self.author)
g.db.commit()
return body

View File

@ -143,6 +143,7 @@ if SITE == 'rdrama.net':
CARP_ID = 995
JOAN_ID = 28
AEVANN_ID = 1
KLEN_ID = 2050
LAWLZ_ID = 3833
LLM_ID = 253
DAD_ID = 2513
@ -164,6 +165,7 @@ elif SITE == "pcmemes.net":
CARP_ID = 0
JOAN_ID = 0
AEVANN_ID = 1
KLEN_ID = 0
LAWLZ_ID = 0
LLM_ID = 0
DAD_ID = 0
@ -185,6 +187,7 @@ else:
CARP_ID = 0
JOAN_ID = 0
AEVANN_ID = 0
KLEN_ID = 0
LAWLZ_ID = 0
LLM_ID = 0
DAD_ID = 0
@ -416,6 +419,38 @@ BADGES = {
}
AWARDS = {
"snow": {
"kind": "snow",
"title": "Snow",
"description": "???",
"icon": "fas fa-snowflake",
"color": "text-gray",
"price": 300
},
"candycane": {
"kind": "candycane",
"title": "Candy Cane",
"description": "???",
"icon": "fas fa-candy-cane",
"color": "text-gray",
"price": 500
},
"mistletoe": {
"kind": "mistletoe",
"title": "Mistletoe",
"description": "???",
"icon": "fas fa-mistletoe",
"color": "text-gray",
"price": 600
},
"mariah": {
"kind": "mariah",
"title": "Mariah",
"description": "???",
"icon": "fas fa-music",
"color": "text-gray",
"price": 800
},
"haunt": {
"kind": "haunt",
"title": "Haunt",

View File

@ -130,14 +130,16 @@ def sanitize(sanitized, noimages=False):
if site not in tag["src"] and not tag["src"].startswith('/'): tag["rel"] = "nofollow noopener noreferrer"
tag["class"] = "in-comment-image"
tag["loading"] = "lazy"
tag["data-src"] = tag["src"]
tag["src"] = "/assets/images/loading.webp"
# tag["data-src"] = tag["src"]
# tag["src"] = "/assets/images/loading.webp"
link = soup.new_tag("a")
link["href"] = tag["data-src"]
# link["href"] = tag["data-src"]
link["href"] = tag["src"]
if site not in link["href"] and not link["href"].startswith('/'): link["rel"] = "nofollow noopener noreferrer"
link["target"] = "_blank"
link["onclick"] = f"expandDesktopImage('{tag['data-src']}');"
# link["onclick"] = f"expandDesktopImage('{tag['data-src']}');"
link["onclick"] = f"expandDesktopImage('{tag['src']}');"
link["data-bs-toggle"] = "modal"
link["data-bs-target"] = "#expandImageModal"

View File

@ -515,6 +515,8 @@ def buy(v, award):
@auth_required
def award_post(pid, v):
if v.shadowbanned: return render_template('errors/500.html', v=v), 500
if v.is_banned and not v.unban_utc: return {"error": "forbidden."}, 403
kind = request.values.get("kind", "").strip()
@ -670,6 +672,8 @@ def award_post(pid, v):
@auth_required
def award_comment(cid, v):
if v.shadowbanned: return render_template('errors/500.html', v=v), 500
if v.is_suspended and v.unban_utc == 0: return {"error": "forbidden"}, 403
kind = request.values.get("kind", "").strip()

View File

@ -19,7 +19,7 @@ def join_discord(v):
if v.is_suspended != 0 and v.admin_level == 0: return "Banned users cannot join the discord server!"
if SITE_NAME == 'Drama' and v.admin_level == 0 and v.patron == 0 and v.truecoins < 150: return f"You must earn 150 {COINS_NAME} before entering the Discord server. You earn {COINS_NAME} by making posts/comments and getting upvoted."
if SITE_NAME == 'Drama' and v.admin_level == 0 and v.patron == 0 and v.truecoins < 150: return f"You must receive 150 upvotes/downvotes from other users before being able to join the Discord server."
if v.shadowbanned or v.agendaposter: return ""

View File

@ -338,6 +338,17 @@ def settings_profile_post(v):
if len(bio_html) > 10000: abort(400)
if v.id == KLEN_ID:
notify_users = NOTIFY_USERS(friends_html, v.id)
soup = BeautifulSoup(friends_html, features="html.parser")
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
username = mention["href"].split("@")[1]
user = g.db.query(User).filter_by(username=username).first()
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
for x in notify_users:
message = f"@{v.username} has added you to their friends list!"
send_notification(x, message)
v.bio = bio[:1500]
v.bio_html=bio_html
g.db.add(v)

View File

@ -12,27 +12,25 @@
{% block fixedMobileBarJS %}
<script>
window.addEventListener("load",function(event) {
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
});
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
}
</script>
{% endblock %}

View File

@ -40,27 +40,25 @@
{% block fixedMobileBarJS %}
<script>
window.addEventListener("load",function(event) {
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
});
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
}
</script>
{% endblock %}

View File

@ -105,6 +105,6 @@
</nav>
{% endif %}
<script defer src="/assets/js/changelog.js?v=54"></script>
<script src="/assets/js/changelog.js?v=54"></script>
{% endblock %}

View File

@ -1,8 +1,6 @@
{{p.embed_url | safe}}
<script defer src="/assets/js/twitter.js" charset="utf-8">
<script src="/assets/js/twitter.js" charset="utf-8">
</script>
<script>
window.addEventListener("load",function(event) {
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
};
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
</script>

View File

@ -1,8 +1,6 @@
{{p.embed_url | safe}}
<script defer src="https://platform.twitter.com/widgets.js" charset="utf-8">
<script src="https://platform.twitter.com/widgets.js" charset="utf-8">
</script>
<script>
window.addEventListener("load",function(event) {
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
});
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
</script>

View File

@ -84,7 +84,7 @@
</div>
</div>
<script defer src="/assets/js/emoji_modal.js?v=128"></script>
<script src="/assets/js/emoji_modal.js?v=128"></script>
<style>
a.emojitab {

View File

@ -1,13 +1,11 @@
{% extends "default.html" %}
{% block content %}
<script>
window.addEventListener("load",function(event) {
function removeFollower(event, username) {
post_toast('/remove_follow/' + username);
let table = document.getElementById("followers-table");
table.removeChild(event.target.parentElement.parentElement);
}
});
function removeFollower(event, username) {
post_toast('/remove_follow/' + username);
let table = document.getElementById("followers-table");
table.removeChild(event.target.parentElement.parentElement);
}
</script>
<pre>

View File

@ -1,13 +1,11 @@
{% extends "default.html" %}
{% block content %}
<script>
window.addEventListener("load",function(event) {
function removeFollower(event, username) {
post_toast('/unfollow/' + username);
let table = document.getElementById("followers-table");
table.removeChild(event.target.parentElement.parentElement);
}
});
function removeFollower(event, username) {
post_toast('/unfollow/' + username);
let table = document.getElementById("followers-table");
table.removeChild(event.target.parentElement.parentElement);
}
</script>
<pre>

View File

@ -26,4 +26,4 @@
</div>
</div>
<script defer src="/assets/js/gif_modal.js?v=54"></script>
<script src="/assets/js/gif_modal.js?v=54"></script>

View File

@ -218,7 +218,7 @@
function formkey() {return '{{v.formkey}}';}
</script>
{% endif %}
<script defer src="/assets/js/header.js?v=54"></script>
<script src="/assets/js/header.js?v=54"></script>
<style>
.notif-count {

View File

@ -122,15 +122,13 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
<script>
window.addEventListener("load",function(event) {
var clipboard = new ClipboardJS('.copy-link');
clipboard.on('success', function(e) {
var myToast = new bootstrap.Toast(document.getElementById('toast-success'));
myToast.show();
});
var clipboard = new ClipboardJS('.copy-link');
clipboard.on('success', function(e) {
var myToast = new bootstrap.Toast(document.getElementById('toast-success'));
myToast.show();
});
</script>

View File

@ -114,7 +114,7 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@ -168,7 +168,7 @@
{% block scripts %}
{% endblock %}
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script>
function formkey() {return '{{v.formkey}}';}

View File

@ -6,41 +6,39 @@
<script>
window.addEventListener("load",function(event) {
block_user=function() {
block_user=function() {
var exileForm = document.getElementById("exile-form");
var exileForm = document.getElementById("exile-form");
var usernameField = document.getElementById("exile-username");
var usernameField = document.getElementById("exile-username");
var isValidUsername = usernameField.checkValidity();
var isValidUsername = usernameField.checkValidity();
username = usernameField.value;
username = usernameField.value;
if (isValidUsername) {
if (isValidUsername) {
var xhr = new XMLHttpRequest();
xhr.open("post", "/settings/block");
xhr.withCredentials=true;
f=new FormData();
f.append("username", username);
f.append("formkey", formkey());
xhr.onload=function(){
if (xhr.status<300) {
location.reload(true);
}
else {
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
myToast.hide();
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show();
document.getElementById("toast-error-message").textContent = "Error. Please try again later.";
}
var xhr = new XMLHttpRequest();
xhr.open("post", "/settings/block");
xhr.withCredentials=true;
f=new FormData();
f.append("username", username);
f.append("formkey", formkey());
xhr.onload=function(){
if (xhr.status<300) {
location.reload(true);
}
else {
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
myToast.hide();
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show();
document.getElementById("toast-error-message").textContent = "Error. Please try again later.";
}
xhr.send(f)
}
xhr.send(f)
}
});
}
</script>
<div class="row">

View File

@ -38,15 +38,12 @@
</div>
{% if v.agendaposter %}
<script>
window.addEventListener("load",function(event) {
const flip = (e) => {
e.preventDefault();
document.getElementsByTagName("body")[0].setAttribute("style", "-moz-transform: scale(-1, -1);-o-transform: scale(-1, -1);-webkit-transform: scale(-1, -1);transform: scale(-1, -1);");
};
const flip = (e) => {
e.preventDefault();
document.getElementsByTagName("body")[0].setAttribute("style", "-moz-transform: scale(-1, -1);-o-transform: scale(-1, -1);-webkit-transform: scale(-1, -1);transform: scale(-1, -1);");
};
document.getElementById("submit-btn").onclick = flip;
});
document.getElementById("submit-btn").onclick = flip;
</script>
{% endif %}
</div>

View File

@ -146,12 +146,12 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script defer src="/assets/js/signup.js?v=63"></script>
<script src="/assets/js/signup.js?v=63"></script>
{% if hcaptcha %}
<script defer src="https://hcaptcha.com/1/api.js"></script>
<script src="https://hcaptcha.com/1/api.js"></script>
{% endif %}
</body>

View File

@ -96,7 +96,7 @@
</div>
</div>
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@ -4,27 +4,25 @@
{% block fixedMobileBarJS %}
<script>
window.addEventListener("load",function(event) {
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
});
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
}
</script>
{% endblock %}

View File

@ -4,27 +4,25 @@
{% block fixedMobileBarJS %}
<script>
window.addEventListener("load",function(event) {
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
});
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
}
</script>
{% endblock %}

View File

@ -33,5 +33,5 @@
{% endblock %}
{% block pagenav %}
<script defer src="/assets/js/userpage.js?v=72"></script>
<script src="/assets/js/userpage.js?v=72"></script>
{% endblock %}

View File

@ -4,27 +4,25 @@
{% block fixedMobileBarJS %}
<script>
window.addEventListener("load",function(event) {
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
else if (currentScrollPos <= 125) {
document.getElementById("fixed-bar-mobile").style.top = "48px";
document.getElementById("navbar").classList.remove("shadow");
}
});
else {
document.getElementById("fixed-bar-mobile").style.top = "-48px";
document.getElementById("dropdownMenuSortBy").classList.remove('show');
document.getElementById("dropdownMenuFrom").classList.remove('show');
document.getElementById("navbar").classList.add("shadow");
}
prevScrollpos = currentScrollPos;
}
</script>
{% endblock %}