示例#1
0
文件: tags.py 项目: jaheba/flask-rst
def get_posts_by_tag(name):
    posts = []
    for post in get_posts():
        post_tags = [tag.lower() for tag in post.config.get('tags', [])]
        for tag in post_tags:
            if tag == name and post not in posts:
                posts.append(post)
    return posts
示例#2
0
def get_archive():
    archive = {}
    for post in get_posts():
        if not archive.has_key(post.pub_date.year):
            archive[post.pub_date.year] = {}
        if not archive[post.pub_date.year].has_key(post.month):
            archive[post.year][post.month] = []
        archive[post.year][post.month].append(post)
    return archive
示例#3
0
文件: tags.py 项目: jaheba/flask-rst
def get_tags():
    tags = {}
    for post in get_posts():
        post_tags = [tag.lower() for tag in post.config.get('tags', [])]
        for tag in post_tags:
            if tag not in tags:
                tags[tag] = 1
            else:
                tags[tag] += 1
    return tags