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()
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")
def single_entry(post_id): #cur = g.db.execute('select id, title, urltitle, html, author, created, published from entries where urltitle==?',[urltitle]) #result = cur.fetchone() post = Post.load(g.db, post_id) # 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 description = None if "description" in post: description = post["description"] return render_template('single_entry.html', entry=post, util=util, title=post["title"], description=description)
def category_entries(category): # We're sure we're only getting one value here results = Post.by_cat(g.db, key=category) outPosts = [] for posts in results: # Now that we finally have all of the post data, iterate through the list for post in posts: # 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, selected_cat=category, util=util, title="Sort by Category - %s" % category)
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