fart mode

remotes/1693045480750635534/spooky-22
Aevann1 2022-04-12 19:29:52 +02:00
parent ec661f4115
commit 17852d30e6
18 changed files with 68 additions and 21 deletions

3
.gitignore vendored
View File

@ -10,4 +10,5 @@ venv/
.sass-cache/
flask_session/
.DS_Store
disable_signups
disable_signups
fart_mode

View File

@ -17,7 +17,7 @@ from sys import stdout, argv
import faulthandler
from json import loads
for f in (f'files/templates/sidebar_{environ.get("SITE_NAME").strip()}.html', 'disable_signups'):
for f in (f'files/templates/sidebar_{environ.get("SITE_NAME").strip()}.html', 'disable_signups', 'fart_mode'):
if not path.exists(f):
with open(f, 'w', encoding="utf-8"): pass

View File

@ -175,6 +175,11 @@ ACTIONTYPES = {
"icon": 'fa-flag',
"color": 'bg-danger'
},
'disable_fart_mode': {
"str": 'disabled fart mode',
"icon": 'fa-gas-pump-slash',
"color": 'bg-danger'
},
'disable_signups': {
"str": 'disabled signups',
"icon": 'fa-users',
@ -210,6 +215,11 @@ ACTIONTYPES = {
"icon": 'fa-edit',
"color": 'bg-primary'
},
'enable_fart_mode': {
"str": 'enabled fart mode',
"icon": 'fa-gas-pump',
"color": 'bg-success'
},
'enable_signups': {
"str": 'enabled signups',
"icon": 'fa-users',

View File

@ -528,7 +528,9 @@ def admin_home(v):
x2 = response == 'under_attack'
return render_template("admin/admin_home.html", v=v, x=x, x2=x2)
with open('fart_mode', 'r') as f: x3 = f.read()
return render_template("admin/admin_home.html", v=v, x=x, x2=x2, x3=x3)
@app.post("/admin/disable_signups")
@admin_level_required(3)
@ -555,6 +557,31 @@ def disable_signups(v):
g.db.commit()
return {"message": "Signups disabled!"}
@app.post("/admin/fart_mode")
@admin_level_required(3)
def fart_mode(v):
with open('fart_mode', 'r') as f: content = f.read()
with open('fart_mode', 'w') as f:
if content == "yes":
f.write("no")
ma = ModAction(
kind="enable_fart_mode",
user_id=v.id,
)
g.db.add(ma)
g.db.commit()
return {"message": "Fart mode enabled!"}
else:
f.write("yes")
ma = ModAction(
kind="disable_fart_mode",
user_id=v.id,
)
g.db.add(ma)
g.db.commit()
return {"message": "Fart mode disabled!"}
@app.post("/admin/purge_cache")
@admin_level_required(3)

View File

@ -253,9 +253,13 @@ def post_id(pid, anything=None, v=None, sub=None):
g.db.commit()
if request.headers.get("Authorization"): return post.json
else:
with open('fart_mode', 'r') as f:
if f.read() == "yes": fart = True
else: fart = False
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
else: template = "submission.html"
return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset, sub=post.subr)
return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset, sub=post.subr, fart=fart)
@app.get("/viewmore/<pid>/<sort>/<offset>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")

View File

@ -68,6 +68,11 @@
<label class="custom-control-label" for="under_attack">Under attack mode</label>
</div>
<div class="custom-control custom-switch">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="fart_mode" name="fart_mode" {% if x3 == "yes" %}checked{% endif %} onchange="post_toast(this,'/admin/fart_mode');">
<label class="custom-control-label" for="fart_mode">Fart mode</label>
</div>
<button class="btn btn-primary mt-3" onclick="post_toast(this,'/admin/purge_cache');">PURGE CACHE</button>
{% endif %}

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
{% if v.agendaposter %}
<style>
html {
@ -39,7 +39,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
{% endif %}
</head>

View File

@ -14,7 +14,7 @@
<title>Chat</title>
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221">
<link rel="stylesheet" href="/assets/css/main.css?v=222">
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
{% if v.css %}
<link rel="stylesheet" href="/@{{v.username}}/css">

View File

@ -7,7 +7,7 @@
<script src="/assets/js/bootstrap.js?v=245"></script>
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221">
<link rel="stylesheet" href="/assets/css/main.css?v=222">
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
{% if v.agendaposter %}
<style>
@ -32,7 +32,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221">
<link rel="stylesheet" href="/assets/css/main.css?v=222">
<link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
{% endif %}

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
{% 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="/assets/css/main.css?v=221">
<link rel="stylesheet" href="/assets/css/main.css?v=222">
<link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
</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="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
</head>

View File

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

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=41">
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
{% 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="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
</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="/assets/css/main.css?v=221"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
<link rel="stylesheet" href="/assets/css/main.css?v=222"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=41">
</head>

View File

@ -36,7 +36,7 @@
</script>
{% endif %}
{% if SITE_NAME == 'rDrama' and not (v and v.has_badge(128)) %}
{% if fart and not (v and v.has_badge(128)) %}
<script>
fart = Math.floor(Math.random() * 4) + 1
let audio = new Audio(`/assets/images/${fart}.webp`);

View File

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