Beispiel #1
0
def url(page=1, tag=None):
    type_u = request.path.split('/', 3)[1]
    # 根据请求是url还是url_follow 赋值path
    ids = None
    if type_u == 'url':
        path = 'url' if tag is None else 'url/'+tag
        follow = False
    elif type_u == 'url_follow':
        path = 'url_follow' if tag is None else 'url_follow/'+tag
        follow = True
        followers = g.user.followers()
        ids = map(lambda x: x.id, [f for f in followers])
    # 根据路径名找到标签id
    tag_id = findTag_idByEn_name(tag)
    r_a_g = request.args.get('decs')
    # str.find()判断字符串
    desc_name = Share.click_rate if r_a_g is not None and r_a_g.find('click_rate') else Share.time

    shares = find_all_share(page=page, tag_id=tag_id, desc_name=desc_name, follow=follow, ids=ids)
    tags = find_all_tag()
    # 总页数
    page_count = find_share_count(tag_id=tag_id, follow=follow, ids=ids)
    return render_template('url.html', name=session.get('name'), shares=shares, tags=tags,
                           page=page, count=page_count, path=path, tag=tag, desc_name=r_a_g, follow=follow)
Beispiel #2
0
def tags_to_chrome():
    tags = find_all_tag()
    tag_json = json.dumps(tags)
    # print tags, tag_json
    return tag_json