bump sortign

remotes/1693045480750635534/spooky-22
Aevann1 2022-03-06 00:46:56 +02:00
parent 17d6fc3dc6
commit 1425aa0db6
13 changed files with 22 additions and 15 deletions

View File

@ -5,7 +5,7 @@ import time
from urllib.parse import urlparse
from flask import render_template
from sqlalchemy import *
from sqlalchemy.orm import relationship
from sqlalchemy.orm import relationship, deferred
from files.__main__ import Base
from files.helpers.const import *
from files.helpers.lazy import lazy
@ -61,6 +61,7 @@ class Submission(Base):
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id")
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True)
bump_utc = deferred(Column(Integer, server_default=FetchedValue()))
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())

View File

@ -164,6 +164,8 @@ def front_all(v, sub=None, subdomain=None):
sort=request.values.get("sort", defaultsorting)
t=request.values.get('t', defaulttime)
ccmode=request.values.get('ccmode', "false").lower()
if sort == 'bump': t='all'
if request.host == 'rdrama.net': defaultsubs = 'Exclude subs'
else: defaultsubs = 'Include subs'
@ -324,6 +326,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
if sort == "hot":
ti = int(time.time()) + 3600
posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5 + (func.length(Submission.body_html)-func.length(func.replace(Submission.body_html,'</a>',''))))/(func.power(((ti - Submission.created_utc)/1000), 1.23)))
elif sort == "bump":
posts = posts.order_by(Submission.bump_utc.desc())
elif sort == "new":
posts = posts.order_by(Submission.created_utc.desc())
elif sort == "old":

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
{% if v.agendaposter %}
<style>
html {

View File

@ -7,7 +7,7 @@
<script src="/static/assets/js/bootstrap.js?v=245"></script>
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174">
{% if SITE_NAME == 'Drama' and not request.path.startswith('/s/') %}
<link rel="stylesheet" href="/static/assets/css/ukraine.css?v=2">
{% endif %}
@ -35,7 +35,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174">
{% if SITE_NAME == 'Drama' and not request.path.startswith('/s/') %}
<link rel="stylesheet" href="/static/assets/css/ukraine.css?v=2">
{% endif %}

View File

@ -97,6 +97,7 @@
<div class="dropdown dropdown-actions ml-2 ddd">
<button class="btn btn-secondary dropdown-toggle text-small-m ddd" type="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% if sort=="hot" %}<i class="fas fa-fire mr-2 text-small-m"></i>{% endif %}
{% if sort=="bump" %}<i class="fas fa-arrow-up mr-2 text-small-m"></i>{% endif %}
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-2 text-small-m"></i>{% endif %}
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-2 text-small-m"></i>{% endif %}
{% if sort=="new" %}<i class="fas fa-sparkles mr-2 text-small-m"></i>{% endif %}
@ -107,6 +108,7 @@
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton2" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
{% if sort != "hot" %}<a class="dropdown-item text-small-m" href="?sort=hot&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-fire mr-2 text-small-m"></i>Hot</a>{% endif %}
{% if sort != "bump" %}<a class="dropdown-item text-small-m" href="?sort=bump&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-arrow-up mr-2 text-small-m"></i>Bump</a>{% endif %}
{% if sort != "top" %}<a class="dropdown-item text-small-m" href="?sort=top&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-arrow-alt-circle-up mr-2 text-small-m"></i>Top</a>{% endif %}
{% if sort != "bottom" %}<a class="dropdown-item text-small-m" href="?sort=bottom&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-arrow-alt-circle-down mr-2 text-small-m"></i>Bottom</a>{% endif %}
{% if sort != "new" %}<a class="dropdown-item text-small-m" href="?sort=new&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-sparkles mr-2 text-small-m"></i>New</a>{% endif %}

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
{% endif %}
<div class="row justify-content-around">

View File

@ -18,7 +18,7 @@
{% endblock %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
</head>

View File

@ -14,7 +14,7 @@
<title>2-Step Login - {{SITE_NAME}}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
</head>

View File

@ -34,7 +34,7 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
{% if v.agendaposter %}
<style>
html {

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
{% endif %}
</head>

View File

@ -31,7 +31,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
</head>

View File

@ -32,7 +32,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
</head>

View File

@ -26,7 +26,7 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=27">
{% if v.agendaposter %}
<style>
html {
@ -50,7 +50,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=173">
<link rel="stylesheet" href="/static/assets/css/main.css?v=174">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=27">
{% endif %}
{% endblock %}