示例#1
0
文件: app.py 项目: sagnew/Stumblr
def favorites():
    url = request.form['url']
    userid = request.form['prompt']
    tag = request.form['tag']
    title = request.form['title']
    mongoFunctions.add_to_favorites(userid, url, title)
    favList = mongoFunctions.get_favorites(userid)
    return render_template('index.html', url = url, tag = tag, user = userid, favorites = favList)
示例#2
0
文件: app.py 项目: sagnew/Stumblr
def dislike():
    url = request.form['url']
    userid = request.form['prompt']
    tag = request.form['tag']
    tags = []
    tags.append(tag)
    favList = mongoFunctions.get_favorites(userid)
    mongoFunctions.update_tags(userid, tags, -1)
    return render_template('index.html', url = url, tag = tag, user = userid, favorites = favList)
示例#3
0
文件: app.py 项目: sagnew/Stumblr
def stumbl():
    userid = request.form['prompt']
    tags = request.form['interests']
    if userid == '':
        return render_template('index.html', user = '', tag = '', url='http://tumblr.com')
    tags = tags.split(',')

    if " separated by commas" in tags and len(mongoFunctions.get_tags(userid)) <= 1:
        tags = ['hacking']
    for i in range(0,len(tags)):
        tags[i] = tags[i].strip()

    try:
        for tag in backend.retrieveLikes(userid):
            tags.append(tag)
    except urllib2.HTTPError:
        tags = tags

    mongoFunctions.insert_user(userid, tags)
    mongoFunctions.update_tags(userid, tags, 0)
    url, tag = backend.getUrl(mongoFunctions.get_tags(userid), userid)
    mongoFunctions.add_to_recently_visited(userid, url)
    favList = mongoFunctions.get_favorites(userid)
    return render_template('index.html', url = url, tag = tag, user = userid, favorites = favList)