<%!--=================================================== BLOG index page: show recent articles, today's articles, or articles of a specific date. ========================================================--%> <%@inputencoding="ISO-8859-1"%> <%@pagetemplate=TEMPLATE.y%> <%@import=import frog.util, frog%> <%@import=import frog.objects%> <%@import=from frog.storageerrors import StorageError%> <% import logging log=logging.getLogger("Snakelets.logger") user=self.SessionCtx.user storageEngine=self.SessionCtx.storageEngine def readArticlesFromDate(date, count=None): entryids=storageEngine.listBlogEntries(date) entryids.reverse() # descending if count: entryids=entryids[:count] try: return [ frog.objects.BlogEntry.load(storageEngine, date, Id) for Id in entryids ] except StorageError,x: log.error("Error loading articles: "+str(x)) self.abort("cannot load articles") showdate=None arg=self.Request.getArg() if arg=="today": #-------------------- TODAY'S ARTICLES self.write("

Today's articles

") showdate = frog.util.isodatestr() entries = readArticlesFromDate(showdate) elif arg=="active": #-------------------- ACTIVE ARTICLES redirect self.Yredirect("active.y") elif arg=="login": #-------------------- LOGIN PAGE redirect self.Yredirect("login.y") elif arg=="date": #-------------------- ARTICLES OF A SPECIFIC DATE showdate = self.Request.getParameter("date") self.write("

Articles written on %s

"% frog.util.mediumdatestr(showdate)) entries = readArticlesFromDate(showdate) else: #-------------------- RECENT ARTICLES self.write("

Recent articles

") dates=storageEngine.listBlogEntryDates() if dates: entries=[] SHOWAMOUNT=10 for showdate in dates: entries.extend( readArticlesFromDate(showdate, SHOWAMOUNT-len(entries)) ) if len(entries)>=SHOWAMOUNT: break