forked from rDrama/rDrama
fdMerge branch 'frost' of https://github.com/Aevann1/Drama into frost
commit
802b86fa28
|
@ -2,6 +2,7 @@ from files.__main__ import app
|
|||
from .get import *
|
||||
from os import listdir, environ
|
||||
from .const import *
|
||||
import time
|
||||
|
||||
@app.template_filter("post_embed")
|
||||
def post_embed(id, v):
|
||||
|
@ -14,6 +15,38 @@ def post_embed(id, v):
|
|||
if p: return render_template("submission_listing.html", listing=[p], v=v)
|
||||
return ''
|
||||
|
||||
|
||||
@app.template_filter("timestamp")
|
||||
def timestamp(timestamp):
|
||||
|
||||
age = int(time.time()) - timestamp
|
||||
|
||||
if age < 60:
|
||||
return "just now"
|
||||
elif age < 3600:
|
||||
minutes = int(age / 60)
|
||||
return f"{minutes}m ago"
|
||||
elif age < 86400:
|
||||
hours = int(age / 3600)
|
||||
return f"{hours}hr ago"
|
||||
elif age < 2678400:
|
||||
days = int(age / 86400)
|
||||
return f"{days}d ago"
|
||||
|
||||
now = time.gmtime()
|
||||
ctd = time.gmtime(timestamp)
|
||||
|
||||
months = now.tm_mon - ctd.tm_mon + 12 * (now.tm_year - ctd.tm_year)
|
||||
if now.tm_mday < ctd.tm_mday:
|
||||
months -= 1
|
||||
|
||||
if months < 12:
|
||||
return f"{months}mo ago"
|
||||
else:
|
||||
years = int(months / 12)
|
||||
return f"{years}yr ago"
|
||||
|
||||
|
||||
@app.context_processor
|
||||
def inject_constants():
|
||||
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "PIZZASHILL_ID":PIZZASHILL_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "ADMIGGERS":ADMIGGERS}
|
|
@ -55,7 +55,8 @@ def speak(data, v):
|
|||
"namecolor": v.namecolor,
|
||||
"text": text,
|
||||
"text_html": text_html,
|
||||
"text_censored": censor_slurs(text_html, 'chat')
|
||||
"text_censored": censor_slurs(text_html, 'chat'),
|
||||
"time": int(time.time())
|
||||
}
|
||||
|
||||
if v.shadowbanned:
|
||||
|
|
|
@ -709,7 +709,10 @@ def settings_block_user(v):
|
|||
|
||||
if not user: return {"error": "That user doesn't exist."}, 404
|
||||
|
||||
if user.unblockable: return {"error": "This user is unblockable."}, 403
|
||||
if user.unblockable:
|
||||
send_repeatable_notification(user.id, f"@{v.username} has tried to block you and failed because of your unblockable status!")
|
||||
g.db.commit()
|
||||
return {"error": "This user is unblockable."}, 403
|
||||
|
||||
if user.id == v.id:
|
||||
return {"error": "You can't block yourself."}, 409
|
||||
|
|
|
@ -1023,7 +1023,10 @@ def unfollow_user(username, v):
|
|||
|
||||
target = get_user(username)
|
||||
|
||||
if target.fish: return {"error": "You can't unfollow this user!"}
|
||||
if target.fish:
|
||||
send_repeatable_notification(target.id, f"@{v.username} has tried to unfollow you and failed because of your fish award!")
|
||||
g.db.commit()
|
||||
return {"error": "You can't unfollow this user!"}
|
||||
|
||||
follow = g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).one_or_none()
|
||||
|
||||
|
|
|
@ -149,6 +149,10 @@
|
|||
|
||||
<a class="{% if same %}d-none{% endif %} font-weight-bold text-black userlink" style="color:#{{m['namecolor']}}" target="_blank" href="/@{{m['username']}}">{{m['username']}}</a>
|
||||
|
||||
{% if not same %}
|
||||
<span class="text-black time ml-2">{{m['time'] | timestamp}}</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="cdiv">
|
||||
<span class="chat-message text-black text-break">{{text_html | safe}}</span>
|
||||
<span class="d-none">{{m['text']}}</span>
|
||||
|
|
|
@ -856,7 +856,7 @@
|
|||
{% include "expanded_image_modal.html" %}
|
||||
|
||||
<script src="/assets/js/comments+submission_listing.js?v=255"></script>
|
||||
<script src="/assets/js/comments.js?v=254"></script>
|
||||
<script src="/assets/js/comments.js?v=255"></script>
|
||||
|
||||
<script>
|
||||
{% if p and (not v or v.highlightcomments) %}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{% if v.id!=u.id and not u.is_private and not u.is_nofollow %}
|
||||
<div id="button-sub-{{u.id}}" style="z-index: 2" class="{% if u.has_follower(v) %}d-none{% endif %}"><a class="btn btn-primary" role="button" onclick="post_toast2(this,'/follow/{{u.username}}','button-sub-{{u.id}}','button-unsub-{{u.id}}')">Follow</a></div>
|
||||
|
||||
{% if not u.fish %}<div id="button-unsub-{{u.id}}" style="z-index: 2" class="{% if not u.has_follower(v) %} d-none{% endif %}"><a class="btn btn-secondary" role="button" onclick="post_toast2(this,'/unfollow/{{u.username}}','button-sub-{{u.id}}','button-unsub-{{u.id}}')">Unfollow</a></div>{% endif %}
|
||||
<div id="button-unsub-{{u.id}}" style="z-index: 2" class="{% if not u.has_follower(v) %} d-none{% endif %}"><a class="btn btn-secondary" role="button" onclick="post_toast2(this,'/unfollow/{{u.username}}','button-sub-{{u.id}}','button-unsub-{{u.id}}')">Unfollow</a></div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div id="button-sub-{{u.id}}" style="z-index: 2"><a class="btn btn-primary" href="/signup">Follow</a></div>
|
||||
|
|
|
@ -168,7 +168,8 @@
|
|||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
{% if v and v.id != u.id %}
|
||||
{% if not u.fish %}<a id="button-unsub" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" role="button" onclick="post_toast2(this,'/unfollow/{{u.username}}','button-unsub','button-sub')">Unfollow</a>{% endif %}
|
||||
<a id="button-unsub" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" role="button" onclick="post_toast2(this,'/unfollow/{{u.username}}','button-unsub','button-sub')">Unfollow</a>
|
||||
|
||||
<a id="button-sub" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" role="button" onclick="post_toast2(this,'/follow/{{u.username}}','button-unsub','button-sub')">Follow</a>
|
||||
<a class="btn btn-primary" role="button" onclick="toggleElement('message', 'input-message')">Message</a>
|
||||
|
||||
|
@ -479,7 +480,8 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v and v.id != u.id %}
|
||||
{% if not u.fish %}<a id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" role="button" onclick="post_toast2(this,'/unfollow/{{u.username}}','button-unsub2','button-sub2')">Unfollow</a>{% endif %}
|
||||
<a id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" role="button" onclick="post_toast2(this,'/unfollow/{{u.username}}','button-unsub2','button-sub2')">Unfollow</a>
|
||||
|
||||
<a id="button-sub2" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" role="button" onclick="post_toast2(this,'/follow/{{u.username}}','button-unsub2','button-sub2')">Follow</a>
|
||||
<a class="btn btn-primary" role="button" onclick="toggleElement('message-mobile', 'input-message-mobile')">Message</a>
|
||||
<a class="btn btn-primary" role="button" onclick="post_toast(this,'/@{{u.username}}/suicide')">Get them help</a>
|
||||
|
|
Loading…
Reference in New Issue