Ejemplo n.º 1
0
def search():
    if request.method == 'POST':
        keyword = request.form.get('keyword')
        keyword = str(keyword)
        if keyword == '':
            return redirect(url_for('index'))
        result, c = actions.searchinfo(keyword)
        result.reverse()
        b = Blacklist.query()
        blacklist = []
        articles = []
        for i in result:
            article = Article(str(i[0]))
            i = list(i)
            i.append(actions.addr_protect(i[2]))
            i.append(article.score())
            articles.append(i)
        comments = []
        for i in c:
            comment = Comment(str(i[0]))
            i = list(i)
            i.append(actions.addr_protect(i[5]))
            i.append(comment.score())
            i.append(actions.exchange(str(i[1])))
            comments.append(i)
        for i in b:
            blacklist.append(i[1])
        return render_template('search.html',
                               keyword=keyword,
                               articles=articles,
                               blacklist=blacklist,
                               comments=comments)
    else:
        return redirect(url_for('index'))
Ejemplo n.º 2
0
def text(f, id):
    article = Article(id)
    actions.browse(id)
    score = article.score()
    aaa = Article(id)
    a = aaa.content()
    c = Comment.queryComment(id)
    e = Evil_comment.query()
    comments = []
    for i in c:
        flag = True
        for j in e:
            if j[1] in i[2]:
                flag = False
        if flag == True:
            comments.append(i)
    n = len(comments)
    c = []
    for i in comments:
        comment = Comment(str(i[0]))
        i = list(i)
        i.append(actions.addr_protect(i[5]))
        i.append(comment.score())
        c.append(i)
    com = sorted(c, key=lambda s: s[0], reverse=True)
    addr = actions.addr_protect(a[0][2])
    return render_template('article.html',
                           content=a[0],
                           comments=com,
                           num=n,
                           addr=addr,
                           score=score)
Ejemplo n.º 3
0
def comment_down():
    if request.method == 'GET':
        id = request.args.get('id')
        id = re.sub("\D", "", id)
        i = Comment.voted_down(id)
        c = Comment(id)
        score = c.score()
        result = str(i) + ',' + str(score)
        return result
    else:
        pass