示例#1
0
def bookmarks(tags=None):
    filters = []
    if tags is not None:
        filters = [
            x.id for x in [get_tag(x) for x in tags.split(SEPARATOR)]
            if x is not None
        ]

    page = int(request.args.get('page', "1"))

    bookmarks = get_list_bookmark(filter=filters, page=page, per_page=PER_PAGE)
    total = get_list_bookmark(filters, count=True)
    bookmark_list = []

    for b in bookmarks:
        bookmark = ItemBookmark(b.id, b.tags, b.link, b.title, b.description)
        bookmark_list.append(bookmark)

    bookmark_list = map(lambda x: x.json(), bookmark_list)
    ret = {
        "bookmarks": bookmark_list,
        "page": page,
        "per_page": PER_PAGE,
        "total": total,
    }

    return jsonify(ret)
示例#2
0
def bookmarks(tags=None):
    filters = []
    if tags is not None:
        filters = [x.id for x in
            [get_tag(x) for x in tags.split(SEPARATOR)]
            if x is not None]

    page = int(request.args.get('page', "1"))

    bookmarks = get_list_bookmark(filter=filters, page=page, per_page=PER_PAGE)
    total = get_list_bookmark(filters, count=True)
    bookmark_list = []

    for b in bookmarks:
        bookmark = ItemBookmark(b.id, b.tags, b.link, b.title, b.description)
        bookmark_list.append(bookmark)

    bookmark_list = map(lambda x: x.json(), bookmark_list)
    ret = {
        "bookmarks": bookmark_list,
        "page": page,
        "per_page": PER_PAGE,
        "total": total,
    }

    return jsonify(ret)
示例#3
0
def tagcloud(tags=None):
    filters = []
    filters_tags = []
    if tags is not None:
        query_list = [get_tag(x) for x in tags.split(SEPARATOR)]
        filters_tags = map(lambda x: ItemTag(pid=x.id, pname=x.name,
            pfilter=True), query_list)
        filters = map(lambda x: x.id, query_list)

    cloud = get_tagcloud(filters)
    tags_list = [ItemTag(t.id, t.name, count).json() for t, count in cloud]
    process_tag_count(tags_list, max_percent=30, min_percent=11)
    tags_list = {"tags": [x.json() for x in filters_tags] + tags_list}

    return jsonify(tags_list)
示例#4
0
def tagcloud(tags=None):
    filters = []
    filters_tags = []
    if tags is not None:
        query_list = [get_tag(x) for x in tags.split(app.config['SEPARATOR'])]
        filters_tags = map(lambda x: ItemTag(pid=x.id, pname=x.name,
            pfilter=True), query_list)
        filters = map(lambda x: x.id, query_list)

    cloud = get_tagcloud(filters)
    tags_list = [ItemTag(t.id, t.name, count).json() for t, count in cloud]
    process_tag_count(tags_list, max_percent=30, min_percent=11)
    tags_list = {"tags": [x.json() for x in filters_tags] + tags_list}

    return jsonify(tags_list)