diff --git a/.gitignore b/.gitignore
index 50afe338ac..47076b486d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,3 +115,4 @@ local.txt
*.scssc
.idea/*
disablesignups
+/rules.md
diff --git a/files/routes/admin.py b/files/routes/admin.py
index 8144682a13..522196ac5d 100644
--- a/files/routes/admin.py
+++ b/files/routes/admin.py
@@ -3,6 +3,7 @@ import calendar
from sqlalchemy.orm import lazyload
import imagehash
from os import remove
+from os.path import exists
from PIL import Image as IMAGE
from files.helpers.wrappers import *
@@ -52,6 +53,35 @@ def remove_admin(v, username):
return {"message": "Admin removed!"}
+@app.get('/admin/rules')
+@admin_level_required(6)
+def get_rules(v):
+
+ try:
+ with open('./rules.md', 'r') as f:
+ rules = f.read()
+ except Exception:
+ rules = None
+
+ return render_template('admin/rules.html', v=v, rules=rules)
+
+
+@app.post('/admin/rules')
+@admin_level_required(6)
+@validate_formkey
+def post_rules(v):
+
+ text = request.form.get('rules', '')
+
+ with open('./rules.md', 'w+') as f:
+ f.write(text)
+
+ with open('./rules.md', 'r') as f:
+ rules = f.read()
+
+ return render_template('admin/rules.html', v=v, rules=rules)
+
+
@app.get("/admin/shadowbanned")
@auth_required
def shadowbanned(v):
diff --git a/files/routes/static.py b/files/routes/static.py
index 225965b807..213a9a783a 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -3,10 +3,28 @@ from files.__main__ import app, limiter
from files.helpers.alerts import *
from files.classes.award import AWARDS
from sqlalchemy import func
+from os import path
site = environ.get("DOMAIN").strip()
site_name = environ.get("SITE_NAME").strip()
+
+@app.get('/rules')
+@auth_desired
+def static_rules(v):
+
+ if not path.exists('./rules.md'):
+ if v and v.admin_level == 6:
+ return render_template('norules.html', v=v)
+ else:
+ abort(404)
+
+ with open('./rules.md', 'r') as f:
+ rules = f.read()
+
+ return render_template('rules.html', rules=rules, v=v)
+
+
@app.get("/stats")
@auth_desired
def participation_stats(v):
diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html
index 502b4ccba8..bedb6484a7 100644
--- a/files/templates/admin/admin_home.html
+++ b/files/templates/admin/admin_home.html
@@ -8,24 +8,38 @@
{% block content %}
- Admin Tools
+ Admin Tools
{% filter markdown %}
-* [Grant User Award](/admin/user_award)
-* [Advanced Stats](/admin/user_stat_data)
-* [Banned Domains](/admin/banned_domains)
-* [Shadowbanned Users](/admin/shadowbanned)
-* [Users with Agendaposter Theme](/admin/agendaposters)
+#### Content
* [Flagged Posts](/admin/flagged/posts)
* [Flagged Comments](/admin/flagged/comments)
* [Image Posts](/admin/image_posts)
* [Removed Posts](/admin/removed)
+
+#### Users
+* [Shadowbanned Users](/admin/shadowbanned)
+* [Users with Agendaposter Theme](/admin/agendaposters)
* [Users Feed](/admin/users)
+
+#### Safety
+* [Banned Domains](/admin/banned_domains)
* [Remove image from imgur and from cloudflare cache](/admin/image_purge)
* [Perceptive Hash Image Ban](/admin/image_ban)
* [Multi Vote Analysis](/admin/alt_votes)
-* [Apps](/admin/apps)
+
+#### Grant
+* [Give User Award](/admin/user_award)
* [Badges](/admin/badge_grant)
-* [Content Stats](/admin/content_stats)
+
+#### API Access Control
+* [Apps](/admin/apps)
+
+#### Statistics
+* [Content Stats](/stats)
+* [Advanced Stats](/admin/user_stat_data)
+
+#### Configuration
+* [Site Rules](/admin/rules)
{% endfilter %}
diff --git a/files/templates/admin/rules.html b/files/templates/admin/rules.html
new file mode 100644
index 0000000000..398770e057
--- /dev/null
+++ b/files/templates/admin/rules.html
@@ -0,0 +1,31 @@
+{% extends "default.html" %}
+
+{% block pagetitle %}Edit {{'SITE_NAME' | app_config}} rules{% endblock %}
+
+{% block content %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/files/templates/header.html b/files/templates/header.html
index 9fc072a0ca..6955dd13b2 100644
--- a/files/templates/header.html
+++ b/files/templates/header.html
@@ -117,8 +117,8 @@
{% if "rdrama" in request.host %}
Rules
- {% elif "pcm" in request.host %}
- Rules
+ {% else %}
+ Rules
{% endif %}
Changelog
@@ -179,8 +179,8 @@
{% if "rdrama" in request.host %}
Rules
- {% elif "pcm" in request.host %}
- Rules
+ {% else %}
+ Rules
{% endif %}
Source code
diff --git a/files/templates/norules.html b/files/templates/norules.html
new file mode 100644
index 0000000000..d0d91e20c2
--- /dev/null
+++ b/files/templates/norules.html
@@ -0,0 +1,26 @@
+{% extends "default.html" %}
+
+{% block title %}
+not configured
+{% endblock %}
+
+{% block pagetype %}message{% endblock %}
+
+{% block customPadding %}{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
+
+
You haven't set up your rules page yet
+
Your rules will be publicly available here.
+
Set up rules
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/files/templates/rules.html b/files/templates/rules.html
new file mode 100644
index 0000000000..68b378e807
--- /dev/null
+++ b/files/templates/rules.html
@@ -0,0 +1,20 @@
+{% extends "default.html" %}
+
+{% block title %}
+{{'SITE_NAME' | app_config}} Rules
+
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
{{'SITE_NAME'|app_config}} Rules{% if v and v.admin_level == 6 %} Edit rules{% endif %}
+
+
+ {{ rules|markdown }}
+
+
+{% endblock %}
\ No newline at end of file