示例#1
0
文件: redirect.py 项目: mbijon/reddit
 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)
示例#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()
示例#3
0
文件: butler.py 项目: 1900/reddit
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()
示例#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)
示例#5
0
文件: redirect.py 项目: pra85/reddit
 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)
示例#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()
示例#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()
示例#8
0
 def GET_user_redirect(self, username):
     user = chkuser(username)
     if not user:
         abort(400)
     return redirect_to("/user/" + user, _code=301)
示例#9
0
 def GET_user_redirect(self, username):
     user = chkuser(username)
     if not user:
         abort(400)
     return redirect_to("/user/" + user, _code=301)