forked from rDrama/rDrama
1
0
Fork 0

move live commit to the sidebar where its less annoying

master
Aevann 2023-01-21 06:27:30 +02:00
parent df803791ef
commit 9ded1cab20
7 changed files with 26 additions and 28 deletions

View File

@ -6646,12 +6646,6 @@ body > .container {
}
}
@media (max-width: 768px) {
#livecommit {
font-size: 0.8rem;
}
}
@media (min-width: 1400px) {
.awardmodal {
max-width: min(90%, 1200px) !important

View File

@ -10,21 +10,6 @@ from files.helpers.sorting_and_time import *
from files.routes.wrappers import *
from files.__main__ import app, cache, limiter
def git_head():
# Note: doing zero sanitization. Git branch names are extremely permissive.
# However, they forbid '..', so I don't see an obvious dir traversal attack.
# Also, a malicious branch name would mean someone already owned the server
# or repo, so I think this isn't a weak link.
try:
with open('.git/HEAD', encoding='utf_8') as head_f:
head_txt = head_f.read()
head_path = git_regex.match(head_txt).group(1)
with open('.git/' + head_path, encoding='utf_8') as ref_f:
gitref = ref_f.read()[:7]
except:
return '<unable to read>', ''
return (gitref, head_txt)
@app.get("/")
@app.get("/h/<sub>")
@app.get("/s/<sub>")
@ -85,7 +70,7 @@ def front_all(v, sub=None, subdomain=None):
award_timers(v)
if v and v.client: return {"data": [x.json(g.db) for x in posts], "next_exists": next_exists}
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, sub=sub, home=True, pins=pins, holes=holes, gitref=git_head())
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, sub=sub, home=True, pins=pins, holes=holes)
@cache.memoize(timeout=86400)

View File

@ -11,6 +11,7 @@ from jinja2 import pass_context
from files.classes.user import User
from files.helpers.assetcache import assetcache_path
from files.helpers.config.const import *
from files.helpers.regex import *
from files.helpers.settings import get_settings
from files.helpers.sorting_and_time import make_age_string
from files.routes.routehelpers import get_alt_graph, get_formkey
@ -81,6 +82,18 @@ def calc_users():
def current_registered_users():
return "{:,}".format(g.db.query(User).count())
def git_head():
# Note: doing zero sanitization. Git branch names are extremely permissive.
# However, they forbid '..', so I don't see an obvious dir traversal attack.
# Also, a malicious branch name would mean someone already owned the server
# or repo, so I think this isn't a weak link.
with open('.git/HEAD', encoding='utf_8') as head_f:
head_txt = head_f.read()
head_path = git_regex.match(head_txt).group(1)
with open('.git/' + head_path, encoding='utf_8') as ref_f:
gitref = ref_f.read()[:7]
return (gitref, head_txt)
@app.context_processor
def inject_constants():
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL,
@ -103,5 +116,5 @@ def inject_constants():
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS),
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME,
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, "gitref":git_head()
}

View File

@ -177,8 +177,4 @@
<script defer src="{{'js/fp.js' | asset}}"></script>
{% endif %}
<div id="livecommit" class="ml-2 mt-3">
Live Commit: <a href="https://fsdfsd.net/rDrama/rDrama/commit/{{gitref[0]}}">{{gitref[0]}}</a>
</div>
{% endblock %}

View File

@ -64,4 +64,4 @@
</ul>
<br>
<p><em>This is an entertainment comedy website. Any and all posts and comments are parody with no basis in reality.</em></p>
<p style="color: hotpink;">𝐜𝐚𝐫𝐩 𝐰𝐨𝐳 𝐞𝐫𝐞</p>
<p style="color: hotpink;">𝐜𝐚𝐫𝐩 𝐰𝐨𝐳 𝐞𝐫𝐞</p>

View File

@ -78,6 +78,11 @@
{% set rules = "rules_" ~ SITE_NAME ~ ".html" %}
{% include rules %}
</div>
<hr>
<div class="mt-3">
Live commit: <a href="https://fsdfsd.net/rDrama/rDrama/commit/{{gitref[0]}}">{{gitref[0]}}</a>
</div>
</div>
{% if IS_FISTMAS() %}

View File

@ -63,6 +63,11 @@
{% set rules = "rules_" ~ SITE_NAME ~ ".html" %}
{% include rules %}
</div>
<hr>
<div class="mt-3">
Live commit: <a href="https://fsdfsd.net/rDrama/rDrama/commit/{{gitref[0]}}">{{gitref[0]}}</a>
</div>
{% endif %}
</div>