fd
This commit is contained in:
parent
d0f2d2f805
commit
6890aae6b9
4 changed files with 41 additions and 5 deletions
|
@ -119,7 +119,5 @@ def after_request(response):
|
||||||
response.headers.add("X-Frame-Options", "deny")
|
response.headers.add("X-Frame-Options", "deny")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if "load_chat" in argv:
|
from files.routes.chat import *
|
||||||
from files.routes.chat import *
|
from files.routes import *
|
||||||
else:
|
|
||||||
from files.routes import *
|
|
|
@ -2,6 +2,7 @@ from files.__main__ import app
|
||||||
from .get import *
|
from .get import *
|
||||||
from os import listdir, environ
|
from os import listdir, environ
|
||||||
from .const import *
|
from .const import *
|
||||||
|
import time
|
||||||
|
|
||||||
@app.template_filter("post_embed")
|
@app.template_filter("post_embed")
|
||||||
def post_embed(id, v):
|
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)
|
if p: return render_template("submission_listing.html", listing=[p], v=v)
|
||||||
return ''
|
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
|
@app.context_processor
|
||||||
def inject_constants():
|
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}
|
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,
|
"namecolor": v.namecolor,
|
||||||
"text": text,
|
"text": text,
|
||||||
"text_html": text_html,
|
"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:
|
if v.shadowbanned:
|
||||||
|
|
|
@ -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>
|
<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">
|
<div class="cdiv">
|
||||||
<span class="chat-message text-black text-break">{{text_html | safe}}</span>
|
<span class="chat-message text-black text-break">{{text_html | safe}}</span>
|
||||||
<span class="d-none">{{m['text']}}</span>
|
<span class="d-none">{{m['text']}}</span>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue