Example #1
0
 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)
Example #2
0
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()
Example #3
0
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()
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
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()
Example #7
0
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()
Example #8
0
 def GET_user_redirect(self, username):
     user = chkuser(username)
     if not user:
         abort(400)
     return redirect_to("/user/" + user, _code=301)
Example #9
0
 def GET_user_redirect(self, username):
     user = chkuser(username)
     if not user:
         abort(400)
     return redirect_to("/user/" + user, _code=301)