From 920ac8adfa5f18c79160361fd356506c4e50c6df Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 31 Jul 2021 06:48:47 +0200 Subject: [PATCH] gfgffg --- drama/helpers/wrappers.py | 53 +------ drama/mail/mail.py | 2 +- drama/routes/admin.py | 25 ++-- drama/routes/awards.py | 6 +- drama/routes/comments.py | 37 +---- drama/routes/errors.py | 20 +-- drama/routes/flagging.py | 4 +- drama/routes/front.py | 4 - drama/routes/oauth.py | 10 +- drama/routes/posts.py | 20 +-- drama/routes/search.py | 9 -- drama/routes/static.py | 5 - drama/routes/users.py | 38 +---- drama/routes/votes.py | 8 +- drama/templates/admin/admin_home.html | 2 +- drama/templates/api.html | 5 + drama/templates/award_modal.html | 2 +- drama/templates/comments.html | 16 +-- drama/templates/default.html | 16 +-- drama/templates/embeds/comment.html | 121 ---------------- drama/templates/embeds/comment_removed.html | 38 ----- drama/templates/embeds/embed_default.html | 114 --------------- drama/templates/embeds/submission.html | 145 -------------------- drama/templates/oauthhelp.html | 117 ---------------- drama/templates/settings_security.html | 2 +- drama/templates/sign_up.html | 2 +- drama/templates/submission.html | 42 +++--- drama/templates/submission_banned.html | 8 +- drama/templates/submission_listing.html | 36 ++--- drama/templates/user_listing.html | 4 +- drama/templates/userpage.html | 16 +-- 31 files changed, 112 insertions(+), 815 deletions(-) create mode 100644 drama/templates/api.html delete mode 100644 drama/templates/embeds/comment.html delete mode 100644 drama/templates/embeds/comment_removed.html delete mode 100644 drama/templates/embeds/embed_default.html delete mode 100644 drama/templates/embeds/submission.html delete mode 100644 drama/templates/oauthhelp.html diff --git a/drama/helpers/wrappers.py b/drama/helpers/wrappers.py index 8dfa035a1..b115da721 100644 --- a/drama/helpers/wrappers.py +++ b/drama/helpers/wrappers.py @@ -226,7 +226,7 @@ def validate_formkey(f): def wrapper(*args, v, **kwargs): - if not request.path.startswith("/api/v1"): + if not request.headers.get("Authorization"): submitted_key = request.values.get("formkey", None) @@ -261,53 +261,4 @@ def no_cors(f): return resp wrapper.__name__ = f.__name__ - return wrapper - -# wrapper for api-related things that discriminates between an api url -# and an html url for the same content -# f should return {'api':lambda:some_func(), 'html':lambda:other_func()} - - -def api(*scopes, no_ban=False): - - def wrapper_maker(f): - - def wrapper(*args, **kwargs): - - if request.path.startswith(('/api/v1','/api/v2')): - - v = kwargs.get('v') - - result = f(*args, **kwargs) - - if isinstance(result, dict): - resp = result['api']() - else: - resp = result - - if not isinstance(resp, RespObj): - resp = make_response(resp) - - return resp - - else: - - result = f(*args, **kwargs) - - if not isinstance(result, dict): - return result - - try: - if request.path.startswith('/inpage/'): - return result['inpage']() - elif request.path.startswith(('/api/vue/','/test/')): - return result['api']() - else: - return result['html']() - except KeyError: - return result - - wrapper.__name__ = f.__name__ - return wrapper - - return wrapper_maker \ No newline at end of file + return wrapper \ No newline at end of file diff --git a/drama/mail/mail.py b/drama/mail/mail.py index ebe5eddc6..1e6073cd2 100644 --- a/drama/mail/mail.py +++ b/drama/mail/mail.py @@ -51,7 +51,7 @@ def send_verification_email(user, email=None): ) -@app.post("/api/verify_email") +@app.post("/verify_email") @is_not_banned def api_verify_email(v): diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 82cf2d2cc..11d1673d7 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -62,7 +62,6 @@ def flagged_posts(v): @app.get("/admin/image_posts") @admin_level_required(3) -@api("read") def image_posts_listing(v): page = int(request.args.get('page', 1)) @@ -650,7 +649,7 @@ def admin_title_change(user_id, v): return (redirect(user.url), user) -@app.post("/api/ban_user/") +@app.post("/ban_user/") @admin_level_required(6) @validate_formkey def ban_user(user_id, v): @@ -707,7 +706,7 @@ def ban_user(user_id, v): return jsonify({"message": f"@{user.username} was banned"}) -@app.post("/api/unban_user/") +@app.post("/unban_user/") @admin_level_required(6) @validate_formkey def unban_user(user_id, v): @@ -738,7 +737,7 @@ def unban_user(user_id, v): if request.args.get("notoast"): return (redirect(user.url), user) return jsonify({"message": f"@{user.username} was unbanned"}) -@app.post("/api/ban_post/") +@app.post("/ban_post/") @admin_level_required(3) @validate_formkey def ban_post(post_id, v): @@ -777,7 +776,7 @@ def ban_post(post_id, v): return "", 204 -@app.post("/api/unban_post/") +@app.post("/unban_post/") @admin_level_required(3) @validate_formkey def unban_post(post_id, v): @@ -805,7 +804,7 @@ def unban_post(post_id, v): return "", 204 -@app.post("/api/distinguish/") +@app.post("/distinguish/") @admin_level_required(1) @validate_formkey def api_distinguish_post(post_id, v): @@ -828,7 +827,7 @@ def api_distinguish_post(post_id, v): return "", 204 -@app.post("/api/sticky/") +@app.post("/sticky/") @admin_level_required(3) def api_sticky_post(post_id, v): @@ -842,7 +841,7 @@ def api_sticky_post(post_id, v): return "", 204 -@app.post("/api/pin/") +@app.post("/pin/") @auth_required def api_pin_post(post_id, v): @@ -853,7 +852,7 @@ def api_pin_post(post_id, v): return "", 204 -@app.post("/api/ban_comment/") +@app.post("/ban_comment/") @admin_level_required(1) def api_ban_comment(c_id, v): @@ -874,7 +873,7 @@ def api_ban_comment(c_id, v): return "", 204 -@app.post("/api/unban_comment/") +@app.post("/unban_comment/") @admin_level_required(1) def api_unban_comment(c_id, v): @@ -898,10 +897,8 @@ def api_unban_comment(c_id, v): return "", 204 -@app.post("/api/distinguish_comment/") -@app.post("/api/v1/distinguish_comment/") +@app.post("/distinguish_comment/") @auth_required -@api("read") def admin_distinguish_comment(c_id, v): if v.admin_level == 0: abort(403) @@ -1029,7 +1026,7 @@ def admin_nunuke_user(v): return redirect(user.url) -@app.route("/api/user_stat_data", methods=['GET']) +@app.route("/user_stat_data", methods=['GET']) @admin_level_required(2) @cache.memoize(timeout=60) def user_stat_data(v): diff --git a/drama/routes/awards.py b/drama/routes/awards.py index fc01e2d06..4e9c12084 100644 --- a/drama/routes/awards.py +++ b/drama/routes/awards.py @@ -33,7 +33,7 @@ ALLOW_MULTIPLE = ( ) -@app.get("/api/awards") +@app.get("/awards") @auth_required def get_awards(v): @@ -46,7 +46,7 @@ def get_awards(v): return jsonify(return_value) -@app.put("/api/post//awards") +@app.put("/post//awards") @auth_required @validate_formkey def award_post(pid, v): @@ -108,7 +108,7 @@ def award_post(pid, v): return "", 204 -@app.put("/api/comment//awards") +@app.put("/comment//awards") @auth_required @validate_formkey def award_comment(cid, v): diff --git a/drama/routes/comments.py b/drama/routes/comments.py index d8f0950f2..bd2f5ce7a 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -19,19 +19,9 @@ beams_client = PushNotifications( secret_key=PUSHER_KEY, ) -@app.get("/api/v1/post//comment/") -def comment_cid_api_redirect(cid=None, pid=None): - redirect(f'/api/v1/comment/') - @app.get("/comment/") -@app.get("/comment/") -@app.get("/post_short//") -@app.get("/post_short///") -@app.get("/api/v1/comment/") @app.get("/post///") -@app.get("/api/vue/comment/") @auth_desired -@api("read") def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -198,12 +188,10 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): 'api': lambda: top_comment.json } -@app.post("/api/comment") -@app.post("/api/v1/comment") +@app.post("/comment") @limiter.limit("6/minute") @is_not_banned @validate_formkey -@api("create") def api_comment(v): parent_submission = request.form.get("submission") @@ -604,7 +592,6 @@ def api_comment(v): @app.post("/edit_comment/") @is_not_banned @validate_formkey -@api("edit") def edit_comment(cid, v): c = get_comment(cid, v=v) @@ -793,10 +780,8 @@ def edit_comment(cid, v): return jsonify({"html": c.body_html}) @app.post("/delete/comment/") -@app.post("/api/v1/delete/comment/") @auth_required @validate_formkey -@api("delete") def delete_comment(cid, v): c = g.db.query(Comment).filter_by(id=cid).first() @@ -818,10 +803,8 @@ def delete_comment(cid, v): "api": lambda: ("", 204)} @app.post("/undelete/comment/") -@app.post("/api/v1/undelete/comment/") @auth_required @validate_formkey -@api("delete") def undelete_comment(cid, v): c = g.db.query(Comment).filter_by(id=cid).first() @@ -841,24 +824,6 @@ def undelete_comment(cid, v): return {"html": lambda: ("", 204), "api": lambda: ("", 204)} -@app.get("/embed/comment/") -@app.get("/embed/post//comment/") -@app.get("/api/v1/embed/comment/") -@app.get("/api/v1/embed/post//comment/") -def embed_comment_cid(cid, pid=None): - - comment = get_comment(int(cid)) - - if not comment.parent: - abort(403) - - if comment.is_banned or comment.deleted_utc > 0: - return {'html': lambda: render_template("embeds/comment_removed.html", c=comment), - 'api': lambda: {'error': f'Comment {cid} has been removed'} - } - - return render_template("embeds/comment.html", c=comment) - @app.post("/comment_pin/") @auth_required @validate_formkey diff --git a/drama/routes/errors.py b/drama/routes/errors.py index c9df3910f..99c4bd070 100644 --- a/drama/routes/errors.py +++ b/drama/routes/errors.py @@ -13,7 +13,6 @@ from drama.__main__ import app @app.errorhandler(400) @auth_desired -@api() def error_400(e, v): return{"html": lambda: (render_template('errors/400.html', v=v), 400), "api": lambda: (jsonify({"error": "400 Bad Request"}), 400 ) @@ -28,15 +27,12 @@ def error_401(e): argval = quote(f"{path}?{qs}", safe='') output = f"/login?redirect={argval}" - if request.path.startswith("/api/v1/"): - return jsonify({"error": "401 Not Authorized"}), 401 - else: - return redirect(output) + if request.headers.get("Authorization"): return jsonify({"error": "401 Not Authorized"}), 401 + else: return redirect(output) @app.errorhandler(403) @auth_desired -@api() def error_403(e, v): return{"html": lambda: (render_template('errors/403.html', v=v), 403), "api": lambda: (jsonify({"error": "403 Forbidden"}), 403) @@ -45,7 +41,6 @@ def error_403(e, v): @app.errorhandler(404) @auth_desired -@api() def error_404(e, v): return{"html": lambda: (render_template('errors/404.html', v=v), 404), "api": lambda: (jsonify({"error": "404 Not Found"}), 404) @@ -54,7 +49,6 @@ def error_404(e, v): @app.errorhandler(405) @auth_desired -@api() def error_405(e, v): return{"html": lambda: (render_template('errors/405.html', v=v), 405), "api": lambda: (jsonify({"error": "405 Method Not Allowed"}), 405) @@ -63,7 +57,6 @@ def error_405(e, v): @app.errorhandler(409) @auth_desired -@api() def error_409(e, v): return{"html": lambda: (render_template('errors/409.html', v=v), 409), "api": lambda: (jsonify({"error": "409 Conflict"}), 409) @@ -72,7 +65,6 @@ def error_409(e, v): @app.errorhandler(410) @auth_desired -@api() def error_410(e, v): return{"html": lambda: (render_template('errors/410.html', v=v), 410), "api": lambda: (jsonify({"error": "410 Request Payload Too Large"}), 410) @@ -80,7 +72,6 @@ def error_410(e, v): @app.errorhandler(413) @auth_desired -@api() def error_413(e, v): return{"html": lambda: (render_template('errors/413.html', v=v), 413), "api": lambda: (jsonify({"error": "413 Image Size Too Large"}), 413) @@ -88,7 +79,6 @@ def error_413(e, v): @app.errorhandler(418) @auth_desired -@api() def error_418(e, v): return{"html": lambda: (render_template('errors/418.html', v=v), 418), "api": lambda: (jsonify({"error": "418 I'm A Teapot"}), 418) @@ -97,7 +87,6 @@ def error_418(e, v): @app.errorhandler(422) @auth_desired -@api() def error_422(e, v): return{"html": lambda: (render_template('errors/422.html', v=v), 422), "api": lambda: (jsonify({"error": "422 Unprocessable Entity"}), 422) @@ -106,7 +95,6 @@ def error_422(e, v): @app.errorhandler(429) @auth_desired -@api() def error_429(e, v): return{"html": lambda: (render_template('errors/429.html', v=v), 429), "api": lambda: (jsonify({"error": "429 Too Many Requests"}), 429) @@ -115,7 +103,6 @@ def error_429(e, v): @app.errorhandler(451) @auth_desired -@api() def error_451(e, v): return{"html": lambda: (render_template('errors/451.html', v=v), 451), "api": lambda: (jsonify({"error": "451 Unavailable For Legal Reasons"}), 451) @@ -124,7 +111,6 @@ def error_451(e, v): @app.errorhandler(500) @auth_desired -@api() def error_500(e, v): try: g.db.rollback() @@ -138,7 +124,6 @@ def error_500(e, v): @app.errorhandler(502) @auth_desired -@api() def error_502(e, v): return{"html": lambda: (render_template('errors/502.html', v=v), 502), "api": lambda: (jsonify({"error": "502 Bad Gateway"}), 502) @@ -147,7 +132,6 @@ def error_502(e, v): @app.errorhandler(503) @auth_desired -@api() def error_503(e, v): return{"html": lambda: (render_template('errors/503.html', v=v), 503), "api": lambda: (jsonify({"error": "503 Service Unavailable"}), 503) diff --git a/drama/routes/flagging.py b/drama/routes/flagging.py index 51fdadb6f..156dd072c 100644 --- a/drama/routes/flagging.py +++ b/drama/routes/flagging.py @@ -4,7 +4,7 @@ from flask import g from drama.__main__ import app -@app.post("/api/flag/post/") +@app.post("/flag/post/") @auth_desired def api_flag_post(pid, v): @@ -30,7 +30,7 @@ def api_flag_post(pid, v): return "", 204 -@app.post("/api/flag/comment/") +@app.post("/flag/comment/") @auth_desired def api_flag_comment(cid, v): diff --git a/drama/routes/front.py b/drama/routes/front.py index aacda2f6d..cfba371d3 100644 --- a/drama/routes/front.py +++ b/drama/routes/front.py @@ -289,9 +289,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs): return posts @app.get("/changelog") -@app.get("/api/v1/changelog") @auth_desired -@api("read") def changelog(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -405,9 +403,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs): return comments[:26] @app.get("/comments") -@app.get("/api/v1/front/comments") @auth_desired -@api("read") def all_comments(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") diff --git a/drama/routes/oauth.py b/drama/routes/oauth.py index aa4291198..e01d9f88c 100644 --- a/drama/routes/oauth.py +++ b/drama/routes/oauth.py @@ -274,11 +274,9 @@ def edit_oauth_app(v, aid): return redirect('/settings/apps') -@app.route("/api/v1/identity") +@app.route("/identity") @auth_required -@api("identity") def api_v1_identity(v): - return jsonify(v.json) @@ -443,9 +441,8 @@ def oauth_rescind_app(aid, v): return jsonify({"message": f"{auth.application.app_name} Revoked"}) -@app.post("/api/v1/release") +@app.post("/release") @auth_required -@api() def oauth_release_auth(v): token=request.headers.get("Authorization").split()[1] @@ -462,9 +459,8 @@ def oauth_release_auth(v): return jsonify({"message":"Authorization released"}) -@app.post("/api/v1/kill") +@app.post("/kill") @auth_required -@api() def oauth_kill_auth(v): token=request.headers.get("Authorization").split()[1] diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 526f31c9d..5ab0fb775 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -22,7 +22,7 @@ from .front import frontlist with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}") -@app.post("/api/publish/") +@app.post("/publish/") @is_not_banned @validate_formkey def publish(pid, v): @@ -44,11 +44,8 @@ def submit_get(v): v=v) @app.get("/post/") -@app.get("/post//") @app.get("/post//") -@app.get("/api/v1/post/") @auth_desired -@api("read") def post_id(pid, anything=None, v=None): try: pid = int(pid) except Exception as e: pass @@ -514,12 +511,9 @@ def archiveorg(url): @app.post("/submit") -@app.post("/api/v1/submit") -@app.post("/api/vue/submit") @limiter.limit("6/minute") @is_not_banned @validate_formkey -@api("create") def submit_post(v): @@ -1009,9 +1003,7 @@ def submit_post(v): @app.post("/delete_post/") -@app.post("/api/v1/delete_post/") @auth_required -@api("delete") @validate_formkey def delete_post_pid(pid, v): @@ -1030,9 +1022,7 @@ def delete_post_pid(pid, v): return "", 204 @app.post("/undelete_post/") -@app.post("/api/v1/undelete_post/") @auth_required -@api("delete") @validate_formkey def undelete_post_pid(pid, v): post = get_post(pid) @@ -1054,10 +1044,8 @@ def embed_post_pid(pid): return render_template("embeds/submission.html", p=post) -@app.post("/api/toggle_comment_nsfw/") -@app.post("/api/v1/toggle_comment_nsfw/") +@app.post("/toggle_comment_nsfw/") @is_not_banned -@api("update") @validate_formkey def toggle_comment_nsfw(cid, v): @@ -1067,10 +1055,8 @@ def toggle_comment_nsfw(cid, v): g.db.add(comment) return "", 204 -@app.post("/api/toggle_post_nsfw/") -@app.post("/api/v1/toggle_post_nsfw/") +@app.post("/toggle_post_nsfw/") @is_not_banned -@api("update") @validate_formkey def toggle_post_nsfw(pid, v): diff --git a/drama/routes/search.py b/drama/routes/search.py index c846a157d..a5aa751bb 100644 --- a/drama/routes/search.py +++ b/drama/routes/search.py @@ -197,10 +197,7 @@ def searchcommentlisting(criteria, v=None, page=1, t="None", sort="top"): return total, [x.id for x in comments] @app.get("/search/posts") -@app.get("/api/v1/search") -@app.route("/api/vue/search") @auth_desired -@api("read") def searchposts(v, search_type="posts"): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -243,10 +240,7 @@ def searchposts(v, search_type="posts"): } @app.get("/search/comments") -@app.get("/api/v1/search/comments") -@app.route("/api/vue/search/comments") @auth_desired -@api("read") def searchcomments(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -280,10 +274,7 @@ def searchcomments(v): } @app.get("/search/users") -@app.get("/api/v1/search/users") -@app.route("/api/vue/search/users") @auth_desired -@api("read") def searchusers(v, search_type="posts"): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") diff --git a/drama/routes/static.py b/drama/routes/static.py index 9dd698796..09121eb53 100644 --- a/drama/routes/static.py +++ b/drama/routes/static.py @@ -11,10 +11,7 @@ def patrons(v): return render_template("patrons.html", v=v, users=users) @app.get("/badmins") -@app.route("/api/vue/admins", methods=["GET"]) -@app.get("/api/v1/admins") @auth_desired -@api("read") def badmins(v): badmins = g.db.query(User).filter_by(admin_level=6).order_by(User.dramacoins.desc()).all() return { @@ -23,9 +20,7 @@ def badmins(v): } @app.get("/log") -@app.get("/api/v1/mod_log") @auth_desired -@api("read") def log(v): page=int(request.args.get("page",1)) diff --git a/drama/routes/users.py b/drama/routes/users.py index 0dee3e8ef..360e77646 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -31,13 +31,6 @@ def suicide(v, username): g.db.add(v) return "", 204 -@app.get("/api/v1/user/") -@auth_desired -@api("read") -def user_info(v, username): - user = get_user(username, v=v) - return jsonify(user.json) - @app.get("/leaderboard") @auth_desired def leaderboard(v): @@ -179,10 +172,8 @@ def mfa_qr(secret, v): return send_file(mem, mimetype="image/png", as_attachment=False) -@app.get("/api/is_available/") -@app.get("/api/v1/is_available/") +@app.get("/is_available/") @auth_desired -@api("read") def api_is_available(name, v): name=name.strip() @@ -212,18 +203,6 @@ def user_id(id): user = get_account(int(id)) return redirect(user.url) - -# Allow Id of user to be queryied, and then redirect the bot to the -# actual user api endpoint. -# So they get the data and then there will be no need to reinvent -# the wheel. -@app.get("/api/v1/uid/") -@auth_desired -@api("read") -def user_by_uid(uid, v=None): - user=get_account(uid) - - return redirect(f'/api/v1/user/{user.username}/info') @app.get("/u/") def redditor_moment_redirect(username): @@ -254,9 +233,7 @@ def visitors(v): return render_template("viewers.html", v=v, viewers=viewers) @app.get("/@") -@app.get("/api/v1/user//listing") @auth_desired -@api("read") def u_username(username, v=None): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -381,9 +358,7 @@ def u_username(username, v=None): @app.get("/@/comments") -@app.get("/api/v1/user//comments") @auth_desired -@api("read") def u_username_comments(username, v=None): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") @@ -472,9 +447,8 @@ def u_username_comments(username, v=None): "api": lambda: jsonify({"data": [c.json for c in listing]}) } -@app.get("/api/v1/user//info") +@app.get("/@/info") @auth_desired -@api("read") def u_username_info(username, v=None): user=get_user(username, v=v) @@ -487,7 +461,7 @@ def u_username_info(username, v=None): return jsonify(user.json) -@app.post("/api/follow/") +@app.post("/follow/") @auth_required def follow_user(username, v): @@ -509,7 +483,7 @@ def follow_user(username, v): return "", 204 -@app.post("/api/unfollow/") +@app.post("/unfollow/") @auth_required def unfollow_user(username, v): @@ -545,9 +519,7 @@ def user_profile_uid(uid): @app.get("/@/saved/posts") -@app.get("/api/v1/saved/posts") @auth_required -@api("read") def saved_posts(v, username): page=int(request.args.get("page",1)) @@ -572,9 +544,7 @@ def saved_posts(v, username): @app.get("/@/saved/comments") -@app.get("/api/v1/saved/comments") @auth_required -@api("read") def saved_comments(v, username): page=int(request.args.get("page",1)) diff --git a/drama/routes/votes.py b/drama/routes/votes.py index bcccd5dd5..5252762e2 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -62,10 +62,8 @@ def admin_vote_info_get(v): -@app.post("/api/v1/vote/post//") -@app.post("/api/vote/post//") +@app.post("/vote/post//") @is_not_banned -@api("vote") @validate_formkey def api_vote_post(post_id, new, v): @@ -107,10 +105,8 @@ def api_vote_post(post_id, new, v): g.db.add(post) return "", 204 -@app.post("/api/v1/vote/comment//") -@app.post("/api/vote/comment//") +@app.post("/vote/comment//") @is_not_banned -@api("vote") @validate_formkey def api_vote_comment(comment_id, new, v): diff --git a/drama/templates/admin/admin_home.html b/drama/templates/admin/admin_home.html index 0481b96a6..72ac852ac 100644 --- a/drama/templates/admin/admin_home.html +++ b/drama/templates/admin/admin_home.html @@ -11,7 +11,7 @@

 Admin Tools

{% filter markdown %} * [Grant User Award](/admin/user_award) -* [Advanced Stats](/api/user_stat_data) +* [Advanced Stats](/user_stat_data) * [Ban Domain](/admin/domain/enter%20domain%20here) * [Shadowbanned Users](/admin/shadowbanned) * [Users with Agendaposter Theme](/admin/agendaposters) diff --git a/drama/templates/api.html b/drama/templates/api.html new file mode 100644 index 000000000..e6424192a --- /dev/null +++ b/drama/templates/api.html @@ -0,0 +1,5 @@ +{% extends "default.html" %} + +{% block title %} +words words words +{% endblock %} \ No newline at end of file diff --git a/drama/templates/award_modal.html b/drama/templates/award_modal.html index 15d7a6846..824260c95 100644 --- a/drama/templates/award_modal.html +++ b/drama/templates/award_modal.html @@ -140,7 +140,7 @@ } }, mounted() { - fetch('/api/awards') + fetch('/awards') .then(response => response.json()) .then(json => { this.awards = json; diff --git a/drama/templates/comments.html b/drama/templates/comments.html index d9d41208d..b0ee5563d 100644 --- a/drama/templates/comments.html +++ b/drama/templates/comments.html @@ -256,7 +256,7 @@ aria-hidden="true">Reply {% if v.id!=c.author_id %} -
  • Give Award
  • {% endif %} @@ -300,15 +300,15 @@ {% if v and v.admin_level==6 and v.id != c.author_id %} {% if c.author.is_banned %} -
  • Unban user
  • +
  • Unban user
  • {% else %} -
  • Ban user
  • +
  • Ban user
  • {% endif %} {% endif %} {% if v and c.parent_submission and (c.author_id==v.id or v.admin_level > 0) %} -
  • Toggle +18
  • +
  • Toggle +18
  • {% endif %} {% if v and v.admin_level >=4 and c.oauth_app %} @@ -343,7 +343,7 @@