Beispiel #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'))
Beispiel #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)
Beispiel #3
0
def author(address):
    author = Author(address)
    li = author.articlelist()
    l = sorted(li, key=lambda s: s[3], reverse=True)
    b = Blacklist.query()
    blacklist = []
    for i in b:
        blacklist.append(i[1])
    articles = []
    for i in l:
        article = Article(i[0])
        i = list(i)
        i.append(actions.addr_protect(i[2]))
        i.append(article.score())
        articles.append(i)
    c1 = author.commentlist()
    c = sorted(c1, key=lambda s: s[7], reverse=True)
    comments = []
    for i in c:
        i = list(i)
        i.append(actions.addr_protect(i[5]))
        comments.append(i)
    addr = actions.addr_protect(address)
    return render_template('author.html',
                           articles=articles,
                           addr=addr,
                           blacklist=blacklist,
                           comments=comments)
Beispiel #4
0
def index():
    ip = IP()
    ip.add_ip()
    f = Forums.query()
    top = actions.popularity()
    article = Article(top[0][0])
    t = list(top[0])
    t.append(actions.addr_protect(t[2]))
    t.append(article.score())
    forums = []
    for i in f:
        l = list(i)
        l.append(Sub_Forums.sub_forum_list(i[1]))
        forums.append(l)
    return render_template('index.html', forums=forums, top=t)
Beispiel #5
0
def forum(forum):
    art = Article.query(forum)
    a = sorted(art, key=lambda s: s[3], reverse=True)
    articles = []
    for i in a:
        article = Article(i[0])
        i = list(i)
        i.append(actions.addr_protect(i[2]))
        i.append(article.score())
        articles.append(i)
    b = Blacklist.query()
    blacklist = []
    for i in b:
        blacklist.append(i[1])
    a1 = sorted(articles, key=lambda s: s[11], reverse=True)
    if a1 == []:
        top = []
    else:
        top = a1[0]
    return render_template('forum.html',
                           articles=articles,
                           forum=forum,
                           blacklist=blacklist,
                           top=top)