fsd
This commit is contained in:
parent
f1e2a6d6ad
commit
5d6e14b9b3
17 changed files with 53 additions and 53 deletions
|
@ -61,7 +61,7 @@ class Badge(Base):
|
|||
@property
|
||||
@lazy
|
||||
def path(self):
|
||||
return f"{SITE_FULL}/assets/images/badges/{self.badge_id}.webp"
|
||||
return f"/assets/images/badges/{self.badge_id}.webp"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -36,7 +36,7 @@ class OauthApp(Base):
|
|||
|
||||
@property
|
||||
@lazy
|
||||
def permalink(self): return f"{SITE_FULL}/admin/app/{self.id}"
|
||||
def permalink(self): return f"/admin/app/{self.id}"
|
||||
|
||||
@lazy
|
||||
def idlist(self, page=1):
|
||||
|
|
|
@ -107,7 +107,7 @@ class ModAction(Base):
|
|||
@property
|
||||
@lazy
|
||||
def permalink(self):
|
||||
return f"{SITE_FULL}/log/{self.id}"
|
||||
return f"/log/{self.id}"
|
||||
|
||||
ACTIONTYPES = {
|
||||
'agendaposter': {
|
||||
|
|
|
@ -32,13 +32,13 @@ class Sub(Base):
|
|||
@lazy
|
||||
def sidebar_url(self):
|
||||
if self.sidebarurl: return SITE_FULL + self.sidebarurl
|
||||
return f'{SITE_FULL}/assets/images/{SITE_NAME}/sidebar.webp?v=1041'
|
||||
return f'/assets/images/{SITE_NAME}/sidebar.webp?v=1041'
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def banner_url(self):
|
||||
if self.bannerurl: return SITE_FULL + self.bannerurl
|
||||
return f'{SITE_FULL}/assets/images/{SITE_NAME}/banner.webp?v=1042'
|
||||
return f'/assets/images/{SITE_NAME}/banner.webp?v=1042'
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -249,13 +249,13 @@ class Submission(Base):
|
|||
@property
|
||||
@lazy
|
||||
def thumb_url(self):
|
||||
if self.over_18: return f"{SITE_FULL}/assets/images/nsfw.webp?v=1"
|
||||
elif not self.url: return f"{SITE_FULL}/assets/images/{SITE_NAME}/default_text.webp?v=1"
|
||||
if self.over_18: return "/assets/images/nsfw.webp?v=1"
|
||||
elif not self.url: return f"/assets/images/{SITE_NAME}/default_text.webp?v=1"
|
||||
elif self.thumburl:
|
||||
if self.thumburl.startswith('/'): return SITE_FULL + self.thumburl
|
||||
return self.thumburl
|
||||
elif self.is_youtube or self.is_video: return f"{SITE_FULL}/assets/images/default_thumb_yt.webp?v=1"
|
||||
else: return f"{SITE_FULL}/assets/images/default_thumb_link.webp?v=1"
|
||||
elif self.is_youtube or self.is_video: return "/assets/images/default_thumb_yt.webp?v=1"
|
||||
else: return "/assets/images/default_thumb_link.webp?v=1"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -350,7 +350,7 @@ class User(Base):
|
|||
@property
|
||||
@lazy
|
||||
def url(self):
|
||||
return f"{SITE_FULL}/@{self.username}"
|
||||
return f"/@{self.username}"
|
||||
|
||||
def __repr__(self):
|
||||
return f"<User(id={self.id})>"
|
||||
|
@ -470,7 +470,7 @@ class User(Base):
|
|||
@lazy
|
||||
def banner_url(self):
|
||||
if self.bannerurl: return self.bannerurl
|
||||
else: return f"{SITE_FULL}/assets/images/{SITE_NAME}/site_preview.webp?v=1013"
|
||||
else: return f"/assets/images/{SITE_NAME}/site_preview.webp?v=1013"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
@ -479,7 +479,7 @@ class User(Base):
|
|||
if self.profileurl:
|
||||
if self.profileurl.startswith('/'): return SITE_FULL + self.profileurl
|
||||
return self.profileurl
|
||||
return f"{SITE_FULL}/assets/images/default-profile-pic.webp?v=1008"
|
||||
return "/assets/images/default-profile-pic.webp?v=1008"
|
||||
|
||||
@lazy
|
||||
def json_popover(self, v):
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -35,7 +35,7 @@ def merge(v, id1, id2):
|
|||
path = request.path
|
||||
qs = urlencode(dict(request.values))
|
||||
argval = quote(f"{path}?{qs}", safe='')
|
||||
return redirect(f"{SITE_FULL}/login?redirect={argval}")
|
||||
return redirect(f"/login?redirect={argval}")
|
||||
|
||||
user1 = get_account(id1)
|
||||
user2 = get_account(id2)
|
||||
|
@ -95,7 +95,7 @@ def merge_all(v, id):
|
|||
path = request.path
|
||||
qs = urlencode(dict(request.values))
|
||||
argval = quote(f"{path}?{qs}", safe='')
|
||||
return redirect(f"{SITE_FULL}/login?redirect={argval}")
|
||||
return redirect(f"/login?redirect={argval}")
|
||||
|
||||
user = get_account(id)
|
||||
|
||||
|
@ -849,7 +849,7 @@ def admin_link_accounts(v):
|
|||
g.db.add(ma)
|
||||
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
||||
return redirect(f"/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
||||
|
||||
|
||||
@app.get("/admin/removed/posts")
|
||||
|
@ -1582,7 +1582,7 @@ def admin_toggle_ban_domain(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f"{SITE_FULL}/admin/banned_domains/")
|
||||
return redirect("/admin/banned_domains/")
|
||||
|
||||
|
||||
@app.post("/admin/nuke_user")
|
||||
|
|
|
@ -19,7 +19,7 @@ def error_401(e):
|
|||
path = request.path
|
||||
qs = urlencode(dict(request.values))
|
||||
argval = quote(f"{path}?{qs}", safe='')
|
||||
return redirect(f"{SITE_FULL}/login?redirect={argval}")
|
||||
return redirect(f"/login?redirect={argval}")
|
||||
|
||||
@app.errorhandler(403)
|
||||
def error_403(e):
|
||||
|
@ -62,4 +62,4 @@ def allow_nsfw():
|
|||
if redir:
|
||||
if redir.startswith(SITE_FULL): return redirect(redir)
|
||||
if redir.startswith('/'): return redirect(f'{SITE_FULL}{redir}')
|
||||
return redirect(f'{SITE_FULL}/')
|
||||
return redirect('/')
|
|
@ -53,7 +53,7 @@ def feeds_user(v=None, sort='hot', t='all'):
|
|||
with tag("name"):
|
||||
text(post.author_name)
|
||||
with tag("uri"):
|
||||
text(f'{SITE_FULL}/@{post.author_name}')
|
||||
text(f'/@{post.author_name}')
|
||||
|
||||
doc.stag("link", href=post.permalink)
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ def front_all(v, sub=None, subdomain=None):
|
|||
session["session_id"] = secrets.token_hex(49)
|
||||
|
||||
if not v and request.path == "/" and not request.headers.get("Authorization"):
|
||||
return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
|
@ -480,7 +480,7 @@ def random_post(v):
|
|||
n = random.randint(1, total - 2)
|
||||
|
||||
post = x.offset(n).limit(1).one_or_none()
|
||||
return redirect(f"{SITE_FULL}/post/{post.id}")
|
||||
return redirect(f"/post/{post.id}")
|
||||
|
||||
@app.get("/comments")
|
||||
@auth_required
|
||||
|
|
|
@ -121,11 +121,11 @@ def login_post():
|
|||
now = int(time.time())
|
||||
|
||||
if now - int(request.values.get("time")) > 600:
|
||||
return redirect(f'{SITE_FULL}/login')
|
||||
return redirect('/login')
|
||||
|
||||
formhash = request.values.get("hash")
|
||||
if not validate_hash(f"{account.id}+{request.values.get('time')}+2fachallenge", formhash):
|
||||
return redirect(f"{SITE_FULL}/login")
|
||||
return redirect("/login")
|
||||
|
||||
if not account.validate_2fa(request.values.get("2fa_token", "").strip()):
|
||||
hash = generate_hash(f"{account.id}+{time}+2fachallenge")
|
||||
|
@ -154,7 +154,7 @@ def login_post():
|
|||
if redir:
|
||||
if redir.startswith(SITE_FULL): return redirect(redir)
|
||||
if redir.startswith('/'): return redirect(f'{SITE_FULL}{redir}')
|
||||
return redirect(f'{SITE_FULL}/')
|
||||
return redirect('/')
|
||||
|
||||
@app.get("/me")
|
||||
@app.get("/@me")
|
||||
|
@ -258,7 +258,7 @@ def sign_up_post(v):
|
|||
user = g.db.query(User).filter_by(id=request.values.get("referred_by")).one_or_none()
|
||||
if user: args["ref"] = user.username
|
||||
|
||||
return redirect(f"{SITE_FULL}/signup?{urlencode(args)}")
|
||||
return redirect(f"/signup?{urlencode(args)}")
|
||||
|
||||
if now - int(form_timestamp) < 5:
|
||||
return signup_error("There was a problem. Please try again.")
|
||||
|
@ -442,7 +442,7 @@ def get_reset():
|
|||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@auth_desired
|
||||
def post_reset(v):
|
||||
if v: return redirect(f'{SITE_FULL}/')
|
||||
if v: return redirect('/')
|
||||
|
||||
user_id = request.values.get("user_id")
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ def request_api_keys(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f'{SITE_FULL}/settings/apps')
|
||||
return redirect('/settings/apps')
|
||||
|
||||
|
||||
@app.post("/delete_app/<aid>")
|
||||
|
@ -93,7 +93,7 @@ def delete_oauth_app(v, aid):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f'{SITE_FULL}/apps')
|
||||
return redirect('/apps')
|
||||
|
||||
|
||||
@app.post("/edit_app/<aid>")
|
||||
|
@ -114,7 +114,7 @@ def edit_oauth_app(v, aid):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f'{SITE_FULL}/settings/apps')
|
||||
return redirect('/settings/apps')
|
||||
|
||||
|
||||
@app.post("/admin/app/approve/<aid>")
|
||||
|
|
|
@ -123,7 +123,7 @@ def submit_get(v, sub=None):
|
|||
@auth_desired
|
||||
def post_id(pid, anything=None, v=None, sub=None):
|
||||
if not v and not request.path.startswith('/logged_out') and not request.headers.get("Authorization"):
|
||||
return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
|
@ -990,7 +990,7 @@ def submit_post(v, sub=None):
|
|||
_note="spam"
|
||||
)
|
||||
g.db.add(ma)
|
||||
return redirect(f"{SITE_FULL}/notifications")
|
||||
return redirect("/notifications")
|
||||
|
||||
if len(str(body)) > 20000:
|
||||
return error("There's a 20000 character limit for text body.")
|
||||
|
|
|
@ -399,7 +399,7 @@ def namecolor(v):
|
|||
v.namecolor = color
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.post("/settings/themecolor")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
|
@ -412,7 +412,7 @@ def themecolor(v):
|
|||
v.themecolor = themecolor
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.post("/settings/gumroad")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
|
@ -476,7 +476,7 @@ def titlecolor(v):
|
|||
v.titlecolor = titlecolor
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.post("/settings/verifiedcolor")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
|
@ -488,7 +488,7 @@ def verifiedcolor(v):
|
|||
v.verifiedcolor = verifiedcolor
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.post("/settings/security")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
|
@ -775,7 +775,7 @@ def settings_remove_discord(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.get("/settings/content")
|
||||
@auth_required
|
||||
|
@ -825,7 +825,7 @@ def settings_name_change(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.post("/settings/song_change")
|
||||
@limiter.limit("2/second;10/day")
|
||||
|
@ -839,7 +839,7 @@ def settings_song_change(v):
|
|||
v.song = None
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
song = song.replace("https://music.youtube.com", "https://youtube.com")
|
||||
if song.startswith(("https://www.youtube.com/watch?v=", "https://youtube.com/watch?v=", "https://m.youtube.com/watch?v=")):
|
||||
|
@ -856,7 +856,7 @@ def settings_song_change(v):
|
|||
v.song = id
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
|
||||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
|
||||
|
@ -904,7 +904,7 @@ def settings_song_change(v):
|
|||
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
@app.post("/settings/title_change")
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
|
@ -925,13 +925,13 @@ def settings_title_change(v):
|
|||
g.db.add(v)
|
||||
g.db.commit()
|
||||
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
|
||||
@app.get("/settings")
|
||||
@auth_required
|
||||
def settings(v):
|
||||
return redirect(f"{SITE_FULL}/settings/profile")
|
||||
return redirect("/settings/profile")
|
||||
|
||||
|
||||
@app.get("/settings/profile")
|
||||
|
|
|
@ -41,7 +41,7 @@ def marsey_list():
|
|||
@app.get("/logged_out/terms")
|
||||
@auth_desired
|
||||
def terms(v):
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
|
@ -51,7 +51,7 @@ def terms(v):
|
|||
@app.get('/logged_out/sidebar')
|
||||
@auth_desired
|
||||
def sidebar(v):
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
|
@ -333,7 +333,7 @@ def submit_contact(v):
|
|||
|
||||
@app.get('/archives')
|
||||
def archivesindex():
|
||||
return redirect(f"{SITE_FULL}/archives/index.html")
|
||||
return redirect("/archives/index.html")
|
||||
|
||||
@app.get('/archives/<path:path>')
|
||||
def archives(path):
|
||||
|
|
|
@ -554,7 +554,7 @@ def get_profilecss(username):
|
|||
@app.get("/@<username>/song")
|
||||
def usersong(username):
|
||||
user = get_user(username)
|
||||
if user.song: return redirect(f"{SITE_FULL}/song/{user.song}.mp3")
|
||||
if user.song: return redirect(f"/song/{user.song}.mp3")
|
||||
else: abort(404)
|
||||
|
||||
@app.get("/song/<song>")
|
||||
|
@ -587,7 +587,7 @@ def unsubscribe(v, post_id):
|
|||
@app.get("/report_bugs")
|
||||
@auth_required
|
||||
def reportbugs(v):
|
||||
return redirect(f'{SITE_FULL}/post/{BUG_THREAD}')
|
||||
return redirect(f'/post/{BUG_THREAD}')
|
||||
|
||||
@app.post("/@<username>/message")
|
||||
@limiter.limit("1/second;10/minute;20/hour;50/day")
|
||||
|
@ -771,7 +771,7 @@ def user_id(id, v):
|
|||
@app.get("/u/<username>")
|
||||
@auth_required
|
||||
def redditor_moment_redirect(username, v):
|
||||
return redirect(f"{SITE_FULL}/@{username}")
|
||||
return redirect(f"/@{username}")
|
||||
|
||||
@app.get("/@<username>/followers")
|
||||
@auth_required
|
||||
|
@ -801,7 +801,7 @@ def visitors(v):
|
|||
def u_username(username, v=None):
|
||||
|
||||
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
|
@ -893,13 +893,13 @@ def u_username(username, v=None):
|
|||
def u_username_comments(username, v=None):
|
||||
|
||||
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
user = get_user(username, v=v)
|
||||
|
||||
if username != user.username: return redirect(f'{SITE_FULL}/@{user.username}/comments')
|
||||
if username != user.username: return redirect(f'/@{user.username}/comments')
|
||||
|
||||
u = user
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ def user_profile_uid(v, id):
|
|||
try: id = int(id, 36)
|
||||
except: abort(404)
|
||||
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): v = None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue