diff --git a/files/classes/user.py b/files/classes/user.py index 3a3bfbddb..7c7581dbf 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -266,7 +266,7 @@ class User(Base): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * (Submission.downvotes+1)) + posts = posts.order_by(-1 * Submission.upvotes * min(Submission.downvotes, 1)) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 4adb73e99..e4dcd5a23 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -84,8 +84,6 @@ allowed_styles =['color', 'font-weight', 'transform', '-webkit-transform'] def sanitize(sanitized, noimages=False): sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com") - sanitized = re.sub("$", "
", sanitized)
-	sanitized = re.sub("^
", "
", sanitized) for i in re.finditer('https://i.imgur.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized): sanitized = sanitized.replace(i.group(1), i.group(2) + "_d." + i.group(3) + "?maxwidth=9999") diff --git a/files/routes/front.py b/files/routes/front.py index 6650a6799..ba1db97bb 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -199,7 +199,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * (Submission.downvotes+1)) + posts = posts.order_by(-1 * Submission.upvotes * min(Submission.downvotes, 1)) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": @@ -291,7 +291,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * (Submission.downvotes+1)) + posts = posts.order_by(-1 * Submission.upvotes * min(Submission.downvotes, 1)) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": @@ -361,7 +361,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * (Comment.downvotes+1)) + comments = comments.order_by(-1 * Comment.upvotes * min(Comment.downvotes, 1)) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": diff --git a/files/routes/posts.py b/files/routes/posts.py index 435a22bed..67814215f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -143,7 +143,7 @@ def post_id(pid, anything=None, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * (Comment.downvotes+1)) + comments = comments.order_by(-1 * Comment.upvotes * min(Comment.downvotes, 1)) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": @@ -168,7 +168,7 @@ def post_id(pid, anything=None, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * (Comment.downvotes+1)) + comments = comments.order_by(-1 * Comment.upvotes * min(Comment.downvotes, 1)) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": diff --git a/files/routes/search.py b/files/routes/search.py index 96cc056d9..c3abb10f0 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -132,7 +132,7 @@ def searchposts(v): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * (Submission.downvotes+1)) + posts = posts.order_by(-1 * Submission.upvotes * min(Submission.downvotes, 1)) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": @@ -235,7 +235,7 @@ def searchcomments(v): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * (Comment.downvotes+1)) + comments = comments.order_by(-1 * Comment.upvotes * min(Comment.downvotes, 1)) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": diff --git a/files/routes/users.py b/files/routes/users.py index 1c2501a12..f2fbb1a05 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -572,7 +572,7 @@ def u_username_comments(username, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * (Comment.downvotes+1)) + comments = comments.order_by(-1 * Comment.upvotes * min(Comment.downvotes, 1)) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 04de02baf..c1816be38 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,11 +15,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index cae27b95a..3d402744f 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -250,12 +250,12 @@ {% if v %} - - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} diff --git a/files/templates/log.html b/files/templates/log.html index 51e119ace..528d067a7 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -17,11 +17,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login.html b/files/templates/login.html index 4218d9642..7311da646 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -15,7 +15,7 @@ - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index b931899f1..ce579fc32 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index b6fc656e5..f0244da6d 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -55,8 +55,8 @@ - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index debd27502..0322dcffa 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -40,10 +40,10 @@ {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index d91c940ba..af15ee71a 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -36,7 +36,7 @@ - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index e1276e869..263dbab34 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -31,7 +31,7 @@ - + diff --git a/files/templates/submit.html b/files/templates/submit.html index b21ddddfd..8f934333a 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -25,12 +25,12 @@ {% block stylesheets %} {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - - + + {% endif %} {% endblock %}