예제 #1
0
def show_entries():
    
    print _app.config["blog_title"]
    
    #cur = g.db.execute('select id, title, urltitle, html, author, created, published from entries order by id desc')
    #Post.by_date.sync(g.db)
    #Post.by_tag.sync(g.db)
    posts = Post.by_date(g.db, descending=True)
    #results = g.db.view("blog/by_title")
    outPosts = []
    for post in posts:
    #for row in cur.fetchall():
        # skip if not published
        if not post["published"]:
            continue
        
        # Create a datetime object from our timestamp.
        d = iso8601.parse_date( post["date"] )
        """
        months = ["jan", "feb", "mar", "apr",
                  "may", "jun", "jul", "aug", 
                  "sep", "oct", "nov", "dec"]
        
        post["created_month"] = months[d.month - 1]
        post["created_day"] = d.day
        """
        
        post["date_str"] = d.strftime("%B %d, %Y")
        # Build entry url
        url = "%s/p/%s" % (_app.config["SITE_BASE"], post["_id"])
        post["url"] = url
        
        outPosts.append(post)

    return render_template('show_entries.html', entries=outPosts, util=util, title="View Recent Posts")
예제 #2
0
def feed():

    feed = AtomFeed('Mr.Voxel Articles',
                    feed_url=request.url, url=request.url_root)

    posts = Post.by_date(g.db, descending=True)

    for post in posts:
    #for row in cur.fetchall():
        # skip if not published
        if not post["published"]:
            continue

        # Build entry url
        url = "%s/p/%s" % (_app.config["SITE_BASE"], post["_id"])
        
        feed.add(post.title, 
                 unicode(post.html), 
                 content_type="html",
                 author=post.author,
                 url=url,
                 updated=post.date,
                 published=post.date
                 )

    return feed.get_response()
예제 #3
0
def getRecentEntries():
    posts = Post.by_date(g.db, limit=5, descending=True)
    #results = g.db.view("blog/by_title")
    outPosts = []
    for post in posts:
    #for row in cur.fetchall():
        # skip if not published
        if not post["published"]:
            continue
        
        # Create a datetime object from our timestamp.
        d = iso8601.parse_date( post["date"] )
        
        months = ["jan", "feb", "mar", "apr",
                  "may", "jun", "jul", "aug", 
                  "sep", "oct", "nov", "dec"]
        
        post["created_month"] = months[d.month - 1]
        post["created_day"] = d.day
        
        # Build entry url
        url = "%s/p/%s" % (flask.current_app.config["SITE_BASE"], post["_id"])
        post["url"] = url
        
        outPosts.append(post)
        
    return outPosts