def GET_user_redirect(self, username, rest=None): user = chkuser(username) if not user: abort(400) url = "/user/" + user if rest: url += "/" + rest return redirect_to(str(url), _code=301)
def extract_user_mentions(text): for url in extract_urls_from_markdown(text): if not url.startswith("/u/"): continue username = url[len("/u/"):] if chkuser(username): yield username.lower()
def GET_user_redirect(self, username, rest=None): user = chkuser(username) if not user: abort(400) url = "/user/" + user if rest: url += "/" + rest if request.query_string: url += "?" + request.query_string return self.redirect(str(url), code=301)
def extract_user_mentions(text, num=None): from r2.lib.validator import chkuser if num is None: num = g.butler_max_mentions cur_num = 0 for url in extract_urls_from_markdown(text): if num != -1 and cur_num >= num: break if not url.startswith("/u/"): continue username = url[len("/u/"):] if not chkuser(username): continue cur_num += 1 yield username.lower()
def GET_user_redirect(self, username): user = chkuser(username) if not user: abort(400) return redirect_to("/user/" + user, _code=301)