Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

forgotten files added

  • Loading branch information...
commit cdb4de1ace86a6d201aa705ff21baaa452ee7bb8 1 parent 289d3ce
Fred authored
View
71 categoryview.py
@@ -0,0 +1,71 @@
+from main import *
+
+class CategoryView(TemplatePage):
+ cacheName = "CategoryView"
+ def generateSection(self,pair):
+ caption = pair[0]
+ categorylabel = pair[1]
+ output = []
+ output.append("""
+ <h2 id="%(category)s"> %(caption)s <a href="#"> (Back to top) </a> </h2>
+ <ul class="feedbox-list">
+ """ % {'category': categorylabel, 'caption': caption})
+ for feed in Feed.gql("WHERE category = :1 ORDER BY listtitle", categorylabel):
+ output.append("""
+ <li>
+ <div class="feedbox">
+ <h3> <a href="%(homepage)s">%(title)s </a> </h3>
+ <ul>
+ """ % { 'homepage': feed.homepage, 'title': feed.title })
+ for entry in Post.gql("WHERE service = :1 ORDER BY timestamp_created DESC LIMIT 7", feed.title):
+ output.append("""
+ <li><a href="%(link)s" title="%(title)s">%(title)s</a></li>
+ """ % {'link': entry.link, 'title': entry.title})
+ output.append("""
+ </ul> </div> </li>
+ """)
+ output.append("""
+ </ul>
+ """)
+ return "".join(output)
+ def generateContent(self):
+ s = """
+ <p> The categories represent what we see as roughly the primary focus of each blog -- this supplements <a href="/planettag">PlanetTAG</a>.</p>
+ <div class="tocbox">
+ <ul>
+ <li> <a href="#pure">Pure</a></li>
+ <li> <a href="#applied">Applied</a></li>
+ <li> <a href="#teacher">Teachers</a></li>
+ <li> <a href="#visual">Visualization</a></li>
+ <li> <a href="#history">History</a></li>
+ <li> <a href="#art">Art</a></li>
+ <li> <a href="#fun">Fun</a></li>
+ <li> <a href="#general">General</a></li>
+ <li> <a href="#journalism">Journalism</a></li>
+ <li> <a href="#journal">Journals</a></li>
+ <li> <a href="#commercial">Commercial</a></li>
+ <li> <a href="#community">Communities</a></li>
+ <li> <a href="#institution">Institutions</a></li>
+ <li> <a href="#news">News</a></li>
+ <li> <a href="#carnivals">Carnivals</a></li>
+ </ul>
+ </div>
+ """
+ thelist = [
+ ['Pure mathematics', 'pure'],
+ ['Applied mathematics','applied'],
+ ['Teachers and Educators','teacher'],
+ ['Visualizations','visual'],
+ ['History','history'],
+ ['Art','art'],
+ ['Comics, recreational mathematics and other fun','fun'],
+ ['General scientific interest','general'],
+ ['Journalistic Writers','journalism'],
+ ['Journals, Publishers and similar feeds','journal'],
+ ['Commercial blogs','commercial'],
+ ['Communities','community'],
+ ['Institutions','institution'],
+ ['News','news'],
+ ['Carnivals','carnival'],
+ ]
+ return s + " ".join([self.generateSection(pair) for pair in thelist])
View
29 dataexport.py
@@ -0,0 +1,29 @@
+from main import *
+
+class CsvView(CachedPage):
+ cacheName = "CsvView"
+ selfurl = "database.csv"
+ # self.response.headers['Content-Type'] = 'text/csv'
+ def generatePage(self):
+ output = []
+ output.append( """title, homepage, person, category, posts_url, comments_url, priority, favicon, listtitle, language""")
+ for feed in Feed.gql("WHERE category IN :1 ORDER BY listtitle", ['pure', 'applied', 'teacher', 'history', 'visual','art','journalism','fun','journal', 'general','institution','commercial','community']):
+ output.append(""" "%(title)s",%(homepage)s,"%(person)s",%(category)s,%(url)s,%(comments)s,1,%(favicon)s, "%(listtitle)s",%(language)s \n""" % {'title': feed.title,'homepage': feed.homepage, 'person': feed.person , 'category':feed.category, 'url': feed.posts_url,'comments': feed.comments_url, 'favicon': feed.favicon, 'listtitle': feed.listtitle, 'language' : feed.language } )
+ return "".join(output)
+
+class OPMLView(CachedPage):
+ cacheName = "OPMLView"
+ selfurl = "database-opml.xml"
+ def generatePage(self):
+ output = []
+ output.append("""<?xml version="1.0" encoding="UTF-8"?> <opml version="1.0">
+ <head>
+ <title>Mathblogging.org Database export to OPML</title>
+ </head>
+ <body><outline title="Mathblogging.org" text="Mathblogging.org">""")
+ for feed in Feed.gql("WHERE category IN :1 ORDER BY listtitle", ['pure', 'applied', 'teacher', 'history', 'visual','art','journalism','fun','journal', 'general','institution','commercial','community']):
+ output.append("""
+ <outline text="%(title)s" title="%(title)s" type="rss"
+ xmlUrl="%(url)s" htmlUrl="%(homepage)s"/>""" % {'title': feed.title,'homepage': feed.homepage, 'person': feed.person , 'category':feed.category, 'url': feed.posts_url,'comments': feed.comments_url, 'favicon': feed.favicon, 'listtitle': feed.listtitle, 'language' : feed.language } )
+ output.append("""</outline></body></opml>""")
+ return "".join(output)
View
52 dateview.py
@@ -0,0 +1,52 @@
+from main import *
+
+class DateView(TemplatePage):
+ cacheName = "DateView"
+ def generateContent(self):
+ s = """<div class="tocbox">
+ <ul>
+ <li><a href="/bydate" title="Recent posts">All</a> </li>
+ <li><a href="/byresearchdate" title="Recent posts in Research">Researchers</a>
+ </li>
+ <li><a href="/byartvishisdate" title="Recent posts in Art,Visual,History">Art/Vis/His</a>
+ </li>
+ <li><a href="/byteacherdate" title="Recent posts from Teachers">Teachers</a>
+ </li>
+ </ul>
+</div>
+ <h2> The latests posts </h2>
+<table class="bydate">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ Date
+ </th>
+ <th align="left" class="blogcolumn">
+ Blog
+ </th>
+ <th align="left" class="postcolumn">
+ Post
+ </th>
+ </tr>
+ </thead>
+ <tbody>"""
+ for post in Post.gql("WHERE category IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['history','fun','general','commercial','art','visual','pure','applied','teacher','journalism']):
+ s = s + """
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ <div>
+ %(time)s
+ </div>
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <div>
+ <a href="%(homepage)s" title="%(service)s">%(service)s</a>
+ </div>
+ </td>
+ <td valign="bottom" class="postcolumn">
+ <div>
+ <a href="%(link)s" title="%(title)s">%(title)s</a>
+ </div>
+ </td>
+ </tr>""" % {'time': post.printShortTime_created(), 'homepage': post.homepage, 'service': post.service, 'title': post.title, 'link': post.link }
+ return s + "</tbody></table>"
View
52 dateviewhisartvis.py
@@ -0,0 +1,52 @@
+from main import *
+
+class DateViewHisArtVis(TemplatePage):
+ cacheName = "DateViewHisArtVis"
+ def generateContent(self):
+ s = """<div class="tocbox">
+ <ul>
+ <li><a href="/bydate" title="Recent posts">All</a> </li>
+ <li><a href="/byresearchdate" title="Recent posts in Research">Researchers</a>
+ </li>
+ <li><a href="/byartvishisdate" title="Recent posts in Art,Visual,History">Art/Vis/His</a>
+ </li>
+ <li><a href="/byteacherdate" title="Recent posts from Teachers">Teachers</a>
+ </li>
+ </ul>
+</div>
+ <h2> The latests posts 'Art, Visual, History' </h2>
+<table class="bydate">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ Date
+ </th>
+ <th align="left" class="blogcolumn">
+ Blog
+ </th>
+ <th align="left" class="postcolumn">
+ Post
+ </th>
+ </tr>
+ </thead>
+ <tbody>"""
+ for post in Post.gql("WHERE category IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['history','art','visual']):
+ s = s + """
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ <div>
+ %(time)s
+ </div>
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <div>
+ <a href="%(homepage)s" title="%(service)s">%(service)s</a>
+ </div>
+ </td>
+ <td valign="bottom" class="postcolumn">
+ <div>
+ <a href="%(link)s" title="%(title)s">%(title)s</a>
+ </div>
+ </td>
+ </tr>""" % {'time': post.printShortTime_created(), 'homepage': post.homepage, 'service': post.service, 'title': post.title, 'link': post.link }
+ return s + "</tbody></table>"
View
52 dateviewresearch.py
@@ -0,0 +1,52 @@
+from main import *
+
+class DateViewResearch(TemplatePage):
+ cacheName = "DateViewResearch"
+ def generateContent(self):
+ s = """<div class="tocbox">
+ <ul>
+ <li><a href="/bydate" title="Recent posts">All</a> </li>
+ <li><a href="/byresearchdate" title="Recent posts in Research">Researchers</a>
+ </li>
+ <li><a href="/byartvishisdate" title="Recent posts in Art,Visual,History">Art/Vis/His</a>
+ </li>
+ <li><a href="/byteacherdate" title="Recent posts from Teachers">Teachers</a>
+ </li>
+ </ul>
+</div>
+ <h2> The latests posts 'Pure, Applied' </h2>
+<table class="bydate">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ Date
+ </th>
+ <th align="left" class="blogcolumn">
+ Blog
+ </th>
+ <th align="left" class="postcolumn">
+ Post
+ </th>
+ </tr>
+ </thead>
+ <tbody>"""
+ for post in Post.gql("WHERE category IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['pure','applied']):
+ s = s + """
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ <div>
+ %(time)s
+ </div>
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <div>
+ <a href="%(homepage)s" title="%(service)s">%(service)s</a>
+ </div>
+ </td>
+ <td valign="bottom" class="postcolumn">
+ <div>
+ <a href="%(link)s" title="%(title)s">%(title)s</a>
+ </div>
+ </td>
+ </tr>""" % {'time': post.printShortTime_created(), 'homepage': post.homepage, 'service': post.service, 'title': post.title, 'link': post.link }
+ return s + "</tbody></table>"
View
52 dateviewteacher.py
@@ -0,0 +1,52 @@
+from main import *
+
+class DateViewTeacher(TemplatePage):
+ cacheName = "DateViewTeacher"
+ def generateContent(self):
+ s = """<div class="tocbox">
+ <ul>
+ <li><a href="/bydate" title="Recent posts">All</a> </li>
+ <li><a href="/byresearchdate" title="Recent posts in Research">Researchers</a>
+ </li>
+ <li><a href="/byartvishisdate" title="Recent posts in Art,Visual,History">Art/Vis/His</a>
+ </li>
+ <li><a href="/byteacherdate" title="Recent posts from Teachers">Teachers</a>
+ </li>
+ </ul>
+</div>
+<h2> The latests posts 'Teachers, Educators' </h2>
+<table class="bydate">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ Date
+ </th>
+ <th align="left" class="blogcolumn">
+ Blog
+ </th>
+ <th align="left" class="postcolumn">
+ Post
+ </th>
+ </tr>
+ </thead>
+ <tbody>"""
+ for post in Post.gql("WHERE category IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['teacher']):
+ s = s + """
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ <div>
+ %(time)s
+ </div>
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <div>
+ <a href="%(homepage)s" title="%(service)s">%(service)s</a>
+ </div>
+ </td>
+ <td valign="bottom" class="postcolumn">
+ <div>
+ <a href="%(link)s" title="%(title)s">%(title)s</a>
+ </div>
+ </td>
+ </tr>""" % {'time': post.printShortTime_created(), 'homepage': post.homepage, 'service': post.service, 'title': post.title, 'link': post.link }
+ return s + "</tbody></table>"
View
139 feedhandler.py
@@ -0,0 +1,139 @@
+from main import *
+
+class FeedHandlerBase(CachedPage):
+ selfurl = "feed"
+ def generatePage(self):
+ output = []
+ output.append( """<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>Mathblogging.org</title>
+ <link href="http://www.mathblogging.org/%(url)s" rel="self"/>
+ <link href="http://www.mathblogging.org/"/>
+ <updated>2010-11-10T21:50:23-05:00</updated>
+ <id>http://www.mathblogging.org/</id>
+ <author>
+ <name>mathblogging.org</name>
+ <email>mathblogging.network@gmail.com</email>
+ </author>""" % {'url':self.selfurl})
+ for entry in self.query():
+ output.append(""" <entry>
+ <title> [[%(service)s]] %(title)s </title>
+ <author>
+ <name>%(service)s</name>
+ <uri>%(homepage)s</uri>
+ </author>
+
+ <link href="%(link)s"/>
+ <published>%(tcreated)s</published>
+ <updated>%(tupdated)s</updated>
+ <id>%(link)s</id>
+ <content type="html"> Length: approx %(length)d words. </content>
+ </entry>""" % {'service': entry.service,'title': entry.title, 'homepage': entry.homepage , 'link':entry.link, 'tcreated': entry.printTime_created_rfc3339(), 'tupdated':entry.printTime_updated_rfc3339(), 'length': entry.length/5} )
+ output.append("</feed>")
+ return "".join(output)
+
+
+class FeedHandlerAll(FeedHandlerBase):
+ selfurl = "feed_all"
+ cacheName = "FeedAll"
+ def query(self):
+ return Post.gql("ORDER BY timestamp_created DESC LIMIT 150")
+
+class FeedHandlerCategory(FeedHandlerBase):
+ def query(self):
+ return Post.gql("WHERE category = :1 ORDER BY timestamp_created DESC LIMIT 150", self.thecategory)
+
+class FeedHandlerCategories(FeedHandlerBase):
+ def query(self):
+ return Post.gql("WHERE category IN :1 ORDER BY timestamp_created DESC LIMIT 150", self.thecategories)
+
+class PlanetMOfeed(FeedHandlerBase):
+ selfurl = "planetmo-feed"
+ cacheName = "PlanetMOfeed"
+ def query(self):
+ return Post.gql("WHERE tags IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['Planetmo','Mathoverflow', 'Math Overflow','Mo','MO'])
+
+class FeedHandlerResearchers(FeedHandlerCategories):
+ selfurl = "feed_researchers"
+ cacheName = "FeedResearchers"
+ thecategories = ['pure','applied','history']
+
+class FeedHandlerPure(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedPure"
+ thecategory = "pure"
+
+class FeedHandlerApplied(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedApplied"
+ thecategory = "applied"
+
+class FeedHandlerHistory(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedHistory"
+ thecategory = "history"
+
+class FeedHandlerVisual(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedVisual"
+ thecategory = "visual"
+
+class FeedHandlerArt(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedArt"
+ thecategory = "art"
+
+class FeedHandlerFun(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedFun"
+ thecategory = "fun"
+
+class FeedHandlerGeneral(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedGeneral"
+ thecategory = "general"
+
+class FeedHandlerJournals(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedJournals"
+ thecategory = "journal"
+
+class FeedHandlerTeachers(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedTeachers"
+ thecategory = "teacher"
+
+class FeedHandlerJournalism(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedJournalism"
+ thecategory = "journalism"
+
+class FeedHandlerInstitutions(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedInstitutions"
+ thecategory = "institution"
+
+class FeedHandlerCommunities(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedCommunities"
+ thecategory = "community"
+
+class FeedHandlerCommercial(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedCommercial"
+ thecategory = "commercial"
+
+class FeedHandlerNewssite(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedNewssite"
+ thecategory = "news"
+
+class FeedHandlerCarnival(FeedHandlerCategory):
+ selfurl = ""
+ cacheName = "FeedCarnival"
+ thecategory = "carnival"
+
+class FeedHandlerPeople(FeedHandlerCategories):
+ selfurl = ""
+ cacheName = "FeedPeople"
+ thecategories = ["pure","applied","visual","history","fun","teacher","journalism","general","art"]
View
BIN  feedparser.pyc
Binary file not shown
View
49 grid.py
@@ -0,0 +1,49 @@
+from main import *
+
+class GridView(CachedPage):
+ cacheName = "NewCategoryView"
+ def generateSection(self,pair):
+ caption = pair[0]
+ categorylabel = pair[1]
+ output = []
+ output.append(""" <div class="info-col">
+ <h2 id="%(category)s"> %(caption)s <font size="-1"> </h2>
+ <a class="image superman" href="http://jprart.deviantart.com/art/Batman-and-Superman-64545242">View Image</a>
+ <dl>""" % {'category': categorylabel, 'caption': caption})
+ for feed in Feed.gql("WHERE category = :1 ORDER BY listtitle", categorylabel):
+ output.append(""" <dt> %(title)s </dt>""" % { 'homepage': feed.homepage, 'title': feed.title })
+ for entry in Post.gql("WHERE service = :1 ORDER BY timestamp_created DESC LIMIT 7", feed.title):
+ output.append("""<dd><a href="%(link)s" title="%(title)s">%(title)s</a></dd>""" % {'link': entry.link, 'title': entry.title})
+ output.append(" ")
+ output.append("</dl> </div>")
+ return "".join(output)
+ def generatePage(self):
+ s = """
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+ <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
+
+ <title>Categories Grid</title>
+
+ <link rel='stylesheet' type='text/css' href='content/infogrid-style.css' />
+ <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
+ <script type='text/javascript' src='content/infogrid.js'></script>
+</head> <body> <div id="page-wrap"> """
+ thelist = [
+ ['Pure mathematics', 'pure'],
+ ['Applied mathematics','applied'],
+ ['Teachers and Educators','teacher'],
+ ['Visualizations','visual'],
+ ['History','history'],
+ ['Art','art'],
+ ['Comics, recreational mathematics and other fun','fun'],
+ ['General scientific interest','general'],
+ ['Journalistic Writers','journalism'],
+ ['Journals, Publishers and similar feeds','journal'],
+ ['Commercial blogs','commercial'],
+ ['Communities','community'],
+ ['Institutions','institution']
+ ]
+ return s + " ".join([self.generateSection(pair) for pair in thelist]) + """</div> </body> </html>"""
View
31 planetmo.py
@@ -0,0 +1,31 @@
+from main import *
+
+import counter
+
+
+class PlanetMO(TemplatePage):
+ cacheName = "PlanetMO"
+ def generateContent(self):
+ output = []
+ output.append( """<h2> PlanetMO <a href="planetmo-feed"><img src="/content/rss-64.png" alt="PlanetMO feed" height="25"/></a> </h2>
+
+At PlanetMO we collect recent posts tagged "mathoverflow", "math overflow", "mo" or "planetmo".""")
+
+ for entry in Post.gql("WHERE tags IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['Planetmo','Mathoverflow', 'Math Overflow','Mo','MO']):
+ output.append( """ <div class="planetbox">
+ <div class="planethead">
+ <h2><a href="%(link)s" title="%(title)s">%(title)s</a></h2>
+ <div class="planetsubtitle">Posted on <a href="%(homepage)s" title="%(service)s">%(service)s</a> at %(tcreated)s.
+ </div>
+ <div class="planettags">
+ <i>Tags:</i> """ % {"link":entry.link, "title":entry.title, "homepage":entry.homepage, "service":entry.service, "tcreated":entry.printShortTime_created()} )
+ for tag in entry.tags:
+ output.append(tag)
+ output.append(", ")
+ output.append( """ </div>
+ </div>
+ <div class="planetbody">
+ """ )
+ output.append( entry.content )
+ output.append( """ </div> </div> """ )
+ return "".join(output)
View
78 planettag.py
@@ -0,0 +1,78 @@
+from main import *
+
+import counter
+
+memcachekey = "TagListMemCacheKey"
+
+class TagListWorker(webapp.RequestHandler):
+ def get(self):
+ try:
+ logging.info("TagListWorker: generating tag list")
+ all_tag = [ tag for entry in Post.all() for tag in entry.tags ]
+ common_tags = counter.Counter(all_tag)
+ memcache.set(memcachekey, common_tags, 10800)
+ except Exception, e:
+ self.response.set_status(200)
+ logging.warning("TagListWorker failed: \n" + str(e))
+
+class PlanetTag(TemplatePage):
+ cacheName = ""
+ def generateContent(self):
+ tagname = self.request.get('content')
+ logging.info("PlanetTag: tagname '" + tagname + "'")
+ output = []
+ output.append( """<h2> PlanetTAG </h2>
+
+<p> Click on a tag to see a list of recent posts. Right now, you chose <big>==%(tagname)s==</big>.</p>
+<p> For convenience, we filter out the dominant tags <a href="/planettag?content=Mathematics">Mathematics</a>, <a href="/planettag?content=Math">Math</a>, <a href="/planettag?content=Maths">Maths</a>, <a href="/planettag?content=Matem&#225;ticas">Matem&#225;ticas</a>, <a href="/planettag?content=Matematica">Matematica</a> and the infamous <a href="/planettag?content=Uncategorized">Uncategorized</a> (as well as some error generating tags). </p>
+
+<div id="tagcloud" style="width: 750px; height: 550px; position: relative;"></div>""" % {"tagname":tagname})
+ for entry in Post.gql("WHERE tags = :1 ORDER BY timestamp_created DESC LIMIT 20",tagname):
+ output.append( """ <div class="planetbox">
+ <div class="planethead">
+ <h2><a href="%(link)s" title="%(title)s">%(title)s</a></h2>
+ <div class="planetsubtitle">Posted on <a href="%(homepage)s" title="%(service)s">%(service)s</a> at %(tcreated)s.
+ </div>
+ <div class="planettags">
+ <i>Tags:</i> """ % {"link":entry.link, "title":entry.title, "homepage":entry.homepage, "service":entry.service, "tcreated":entry.printShortTime_created()} )
+ for tag in entry.tags:
+ output.append(tag)
+ output.append(", ")
+ output.append( """ </div>
+ </div>
+ <div class="planetbody">
+ <p> """ )
+ output.append( entry.content )
+ output.append( """ </p> </div> </div>""" )
+ output.append( """
+ <script type="text/javascript">
+ /*!
+ * Create an array of objects to be passed to jQCloud, each representing a word in the cloud and specifying
+ * the following mandatory attributes:
+ *
+ * text: a string containing the word(s)
+ * weight: a number (integer or float) defining the relative importance of the word
+ * (such as the number of occurrencies, etc.). The range of values is arbitrary, as they will
+ * be linearly mapped to a discrete scale from 1 to 10.
+ *
+ * You can also specify the following optional attributes:
+ *
+ * url: a URL to which the word will be linked. It will be used as the href attribute of an HTML anchor.
+ * title: an HTML title for the span that will contain the word(s)
+ */
+ var word_list = [ """ )
+ taglist = memcache.get(memcachekey)
+ logging.info("taglist is " + str(taglist))
+ if taglist:
+ for tag, weight in memcache.get(memcachekey).iteritems():
+ if tag != "Uncategorized" and tag != "Uncategorized>" and tag != "Mathematics" and tag != "Math" and tag != "Maths" and tag != "Http://gdata.youtube.com/schemas/2007#video" and repr(tag) != repr(u'Matem\xe1ticas') and tag != "Matematica" and weight > 10:
+ output.append(""" {text: "%(text)s", weight: %(weight)s, url: "/planettag?content=%(text)s"}, """ % {"text":tag, "weight": weight} )
+ output.append( """
+ ];
+ window.onload = function() {
+ // Call jQCloud on a jQuery object passing the word list as the first argument. Chainability of methods is maintained.
+ $("#tagcloud").jQCloud(word_list);
+ };
+ </script>
+""" )
+ return "".join(output)
View
354 sanitize.py
@@ -0,0 +1,354 @@
+"""
+sanitize: bringing sanitiy to world of messed-up data
+"""
+
+__author__ = ["Mark Pilgrim <http://diveintomark.org/>",
+ "Aaron Swartz <http://www.aaronsw.com/>"]
+__contributors__ = ["Sam Ruby <http://intertwingly.net/>"]
+__license__ = "BSD"
+__version__ = "0.25"
+
+_debug = 0
+
+# If you want sanitize to automatically run HTML markup through HTML Tidy, set
+# this to 1. Requires mxTidy <http://www.egenix.com/files/python/mxTidy.html>
+# or utidylib <http://utidylib.berlios.de/>.
+TIDY_MARKUP = 0
+
+# List of Python interfaces for HTML Tidy, in order of preference. Only useful
+# if TIDY_MARKUP = 1
+PREFERRED_TIDY_INTERFACES = ["uTidy", "mxTidy"]
+
+import sgmllib, re
+
+# chardet library auto-detects character encodings
+# Download from http://chardet.feedparser.org/
+try:
+ import chardet
+ if _debug:
+ import chardet.constants
+ chardet.constants._debug = 1
+
+ _chardet = lambda data: chardet.detect(data)['encoding']
+except:
+ chardet = None
+ _chardet = lambda data: None
+
+class _BaseHTMLProcessor(sgmllib.SGMLParser):
+ elements_no_end_tag = ['area', 'base', 'basefont', 'br', 'col', 'frame', 'hr',
+ 'img', 'input', 'isindex', 'link', 'meta', 'param']
+
+ _r_barebang = re.compile(r'<!((?!DOCTYPE|--|\[))', re.IGNORECASE)
+ _r_bareamp = re.compile("&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)")
+ _r_shorttag = re.compile(r'<([^<\s]+?)\s*/>')
+
+ def __init__(self, encoding):
+ self.encoding = encoding
+ if _debug: sys.stderr.write('entering BaseHTMLProcessor, encoding=%s\n' % self.encoding)
+ sgmllib.SGMLParser.__init__(self)
+
+ def reset(self):
+ self.pieces = []
+ sgmllib.SGMLParser.reset(self)
+
+ def _shorttag_replace(self, match):
+ tag = match.group(1)
+ if tag in self.elements_no_end_tag:
+ return '<' + tag + ' />'
+ else:
+ return '<' + tag + '></' + tag + '>'
+
+ def feed(self, data):
+ data = self._r_barebang.sub(r'&lt;!\1', data)
+ data = self._r_bareamp.sub("&amp;", data)
+ data = self._r_shorttag.sub(self._shorttag_replace, data)
+ if self.encoding and type(data) == type(u''):
+ data = data.encode(self.encoding)
+ sgmllib.SGMLParser.feed(self, data)
+
+ def normalize_attrs(self, attrs):
+ # utility method to be called by descendants
+ attrs = [(k.lower(), v) for k, v in attrs]
+ attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs]
+ return attrs
+
+ def unknown_starttag(self, tag, attrs):
+ # called for each start tag
+ # attrs is a list of (attr, value) tuples
+ # e.g. for <pre class='screen'>, tag='pre', attrs=[('class', 'screen')]
+ if _debug: sys.stderr.write('_BaseHTMLProcessor, unknown_starttag, tag=%s\n' % tag)
+ uattrs = []
+ # thanks to Kevin Marks for this breathtaking hack to deal with (valid) high-bit attribute values in UTF-8 feeds
+ for key, value in attrs:
+ if type(value) != type(u''):
+ value = unicode(value, self.encoding)
+ uattrs.append((unicode(key, self.encoding), value))
+ strattrs = u''.join([u' %s="%s"' % (key, value) for key, value in uattrs]).encode(self.encoding)
+ if tag in self.elements_no_end_tag:
+ self.pieces.append('<%(tag)s%(strattrs)s />' % locals())
+ else:
+ self.pieces.append('<%(tag)s%(strattrs)s>' % locals())
+
+ def unknown_endtag(self, tag):
+ # called for each end tag, e.g. for </pre>, tag will be 'pre'
+ # Reconstruct the original end tag.
+ if tag not in self.elements_no_end_tag:
+ self.pieces.append("</%(tag)s>" % locals())
+
+ def handle_charref(self, ref):
+ # called for each character reference, e.g. for '&#160;', ref will be '160'
+ # Reconstruct the original character reference.
+ self.pieces.append('&#%(ref)s;' % locals())
+
+ def handle_entityref(self, ref):
+ # called for each entity reference, e.g. for '&copy;', ref will be 'copy'
+ # Reconstruct the original entity reference.
+ self.pieces.append('&%(ref)s;' % locals())
+
+ def handle_data(self, text):
+ # called for each block of plain text, i.e. outside of any tag and
+ # not containing any character or entity references
+ # Store the original text verbatim.
+ if _debug: sys.stderr.write('_BaseHTMLProcessor, handle_text, text=%s\n' % text)
+ self.pieces.append(text)
+
+ def handle_comment(self, text):
+ # called for each HTML comment, e.g. <!-- insert Javascript code here -->
+ # Reconstruct the original comment.
+ self.pieces.append('<!--%(text)s-->' % locals())
+
+ def handle_pi(self, text):
+ # called for each processing instruction, e.g. <?instruction>
+ # Reconstruct original processing instruction.
+ self.pieces.append('<?%(text)s>' % locals())
+
+ def handle_decl(self, text):
+ # called for the DOCTYPE, if present, e.g.
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ # "http://www.w3.org/TR/html4/loose.dtd">
+ # Reconstruct original DOCTYPE
+ self.pieces.append('<!%(text)s>' % locals())
+
+ _new_declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9:]*\s*').match
+ def _scan_name(self, i, declstartpos):
+ rawdata = self.rawdata
+ n = len(rawdata)
+ if i == n:
+ return None, -1
+ m = self._new_declname_match(rawdata, i)
+ if m:
+ s = m.group()
+ name = s.strip()
+ if (i + len(s)) == n:
+ return None, -1 # end of buffer
+ return name.lower(), m.end()
+ else:
+ self.handle_data(rawdata)
+# self.updatepos(declstartpos, i)
+ return None, -1
+
+ def output(self):
+ '''Return processed HTML as a single string'''
+ return ''.join([str(p) for p in self.pieces])
+
+class _HTMLSanitizer(_BaseHTMLProcessor):
+ acceptable_elements = ['a', 'abbr', 'acronym', 'address', 'area', 'b', 'big',
+ 'blockquote', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col',
+ 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'fieldset',
+ 'font', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'input',
+ 'ins', 'kbd', 'label', 'legend', 'li', 'map', 'menu', 'ol', 'optgroup',
+ 'option', 'p', 'pre', 'q', 's', 'samp', 'select', 'small', 'span', 'strike',
+ 'strong', 'sub', 'sup', 'table', 'textarea', 'tbody', 'td', 'tfoot', 'th',
+ 'thead', 'tr', 'tt', 'u', 'ul', 'var']
+
+ acceptable_attributes = ['abbr', 'accept', 'accept-charset', 'accesskey',
+ 'action', 'align', 'alt', 'axis', 'border', 'cellpadding', 'cellspacing',
+ 'char', 'charoff', 'charset', 'checked', 'cite', 'class', 'clear', 'cols',
+ 'colspan', 'color', 'compact', 'coords', 'datetime', 'dir', 'disabled',
+ 'enctype', 'for', 'frame', 'headers', 'height', 'href', 'hreflang', 'hspace',
+ 'id', 'ismap', 'label', 'lang', 'longdesc', 'maxlength', 'media', 'method',
+ 'multiple', 'name', 'nohref', 'noshade', 'nowrap', 'prompt', 'readonly',
+ 'rel', 'rev', 'rows', 'rowspan', 'rules', 'scope', 'selected', 'shape', 'size',
+ 'span', 'src', 'start', 'summary', 'tabindex', 'target', 'title', 'type',
+ 'usemap', 'valign', 'value', 'vspace', 'width']
+
+ ignorable_elements = ['script', 'applet', 'style']
+
+ def reset(self):
+ _BaseHTMLProcessor.reset(self)
+ self.tag_stack = []
+ self.ignore_level = 0
+
+ def feed(self, data):
+ _BaseHTMLProcessor.feed(self, data)
+ while self.tag_stack:
+ _BaseHTMLProcessor.unknown_endtag(self, self.tag_stack.pop())
+
+ def unknown_starttag(self, tag, attrs):
+ if tag in self.ignorable_elements:
+ self.ignore_level += 1
+ return
+
+ if self.ignore_level:
+ return
+
+ if tag in self.acceptable_elements:
+ attrs = self.normalize_attrs(attrs)
+ attrs = [(key, value) for key, value in attrs if key in self.acceptable_attributes]
+ if tag not in self.elements_no_end_tag:
+ self.tag_stack.append(tag)
+ _BaseHTMLProcessor.unknown_starttag(self, tag, attrs)
+
+ def unknown_endtag(self, tag):
+ if tag in self.ignorable_elements:
+ self.ignore_level -= 1
+ return
+
+ if self.ignore_level:
+ return
+
+ if tag in self.acceptable_elements and tag not in self.elements_no_end_tag:
+ match = False
+ while self.tag_stack:
+ top = self.tag_stack.pop()
+ if top == tag:
+ match = True
+ break
+ _BaseHTMLProcessor.unknown_endtag(self, top)
+
+ if match:
+ _BaseHTMLProcessor.unknown_endtag(self, tag)
+
+ def handle_pi(self, text):
+ pass
+
+ def handle_decl(self, text):
+ pass
+
+ def handle_data(self, text):
+ if not self.ignore_level:
+ text = text.replace('<', '')
+ _BaseHTMLProcessor.handle_data(self, text)
+
+def HTML(htmlSource, encoding='utf8'):
+ p = _HTMLSanitizer(encoding)
+ p.feed(htmlSource)
+ data = p.output()
+ if TIDY_MARKUP:
+ # loop through list of preferred Tidy interfaces looking for one that's installed,
+ # then set up a common _tidy function to wrap the interface-specific API.
+ _tidy = None
+ for tidy_interface in PREFERRED_TIDY_INTERFACES:
+ try:
+ if tidy_interface == "uTidy":
+ from tidy import parseString as _utidy
+ def _tidy(data, **kwargs):
+ return str(_utidy(data, **kwargs))
+ break
+ elif tidy_interface == "mxTidy":
+ from mx.Tidy import Tidy as _mxtidy
+ def _tidy(data, **kwargs):
+ nerrors, nwarnings, data, errordata = _mxtidy.tidy(data, **kwargs)
+ return data
+ break
+ except:
+ pass
+ if _tidy:
+ utf8 = type(data) == type(u'')
+ if utf8:
+ data = data.encode('utf-8')
+ data = _tidy(data, output_xhtml=1, numeric_entities=1, wrap=0, char_encoding="utf8")
+ if utf8:
+ data = unicode(data, 'utf-8')
+ if data.count('<body'):
+ data = data.split('<body', 1)[1]
+ if data.count('>'):
+ data = data.split('>', 1)[1]
+ if data.count('</body'):
+ data = data.split('</body', 1)[0]
+ data = data.strip().replace('\r\n', '\n')
+ return data
+
+unicode_bom_map = {
+ '\x00\x00\xfe\xff': 'utf-32be',
+ '\xff\xfe\x00\x00': 'utf-32le',
+ '\xfe\xff##': 'utf-16be',
+ '\xff\xfe##': 'utf-16le',
+ '\xef\bb\bf': 'utf-8'
+}
+xml_bom_map = {
+ '\x00\x00\x00\x3c': 'utf-32be',
+ '\x3c\x00\x00\x00': 'utf-32le',
+ '\x00\x3c\x00\x3f': 'utf-16be',
+ '\x3c\x00\x3f\x00': 'utf-16le',
+ '\x3c\x3f\x78\x6d': 'utf-8', # or equivalent
+ '\x4c\x6f\xa7\x94': 'ebcdic'
+}
+
+_ebcdic_to_ascii_map = None
+def _ebcdic_to_ascii(s):
+ global _ebcdic_to_ascii_map
+ if not _ebcdic_to_ascii_map:
+ emap = (
+ 0,1,2,3,156,9,134,127,151,141,142,11,12,13,14,15,
+ 16,17,18,19,157,133,8,135,24,25,146,143,28,29,30,31,
+ 128,129,130,131,132,10,23,27,136,137,138,139,140,5,6,7,
+ 144,145,22,147,148,149,150,4,152,153,154,155,20,21,158,26,
+ 32,160,161,162,163,164,165,166,167,168,91,46,60,40,43,33,
+ 38,169,170,171,172,173,174,175,176,177,93,36,42,41,59,94,
+ 45,47,178,179,180,181,182,183,184,185,124,44,37,95,62,63,
+ 186,187,188,189,190,191,192,193,194,96,58,35,64,39,61,34,
+ 195,97,98,99,100,101,102,103,104,105,196,197,198,199,200,201,
+ 202,106,107,108,109,110,111,112,113,114,203,204,205,206,207,208,
+ 209,126,115,116,117,118,119,120,121,122,210,211,212,213,214,215,
+ 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,
+ 123,65,66,67,68,69,70,71,72,73,232,233,234,235,236,237,
+ 125,74,75,76,77,78,79,80,81,82,238,239,240,241,242,243,
+ 92,159,83,84,85,86,87,88,89,90,244,245,246,247,248,249,
+ 48,49,50,51,52,53,54,55,56,57,250,251,252,253,254,255
+ )
+ import string
+ _ebcdic_to_ascii_map = string.maketrans( \
+ ''.join(map(chr, range(256))), ''.join(map(chr, emap)))
+ return s.translate(_ebcdic_to_ascii_map)
+
+def _startswithbom(text, bom):
+ for i, c in enumerate(bom):
+ if c == '#':
+ if text[i] == '\x00':
+ return False
+ else:
+ if text[i] != c:
+ return False
+ return True
+
+def _detectbom(text, bom_map=unicode_bom_map):
+ for bom, encoding in bom_map.iteritems():
+ if _startswithbom(text, bom):
+ return encoding
+ return None
+
+def characters(text, isXML=False, guess=None):
+ """
+ Takes a string text of unknown encoding and tries to
+ provide a Unicode string for it.
+ """
+ _triedEncodings = []
+ def tryEncoding(encoding):
+ if encoding and encoding not in _triedEncodings:
+ if encoding == 'ebcdic':
+ return _ebcdic_to_ascii(text)
+ try:
+ return unicode(text, encoding)
+ except UnicodeDecodeError:
+ pass
+ _triedEncodings.append(encoding)
+
+ return (
+ tryEncoding(guess) or
+ tryEncoding(_detectbom(text)) or
+ isXML and tryEncoding(_detectbom(text, xml_bom_map)) or
+ tryEncoding(_chardet(text)) or
+ tryEncoding('utf8') or
+ tryEncoding('windows-1252') or
+ tryEncoding('iso-8859-1'))
View
114 statsview.py
@@ -0,0 +1,114 @@
+from main import *
+
+class StatsView(TemplatePage):
+ cacheName = "StatsView"
+ def generateContent(self):
+ output = []
+ output.append("""
+ <div class="content">
+ <table class="bydate" id="commentsperday">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ </th>
+ <th align="left" class="blogcolumn">
+ Comments last 24h
+ </th>
+ </tr>
+ </thead>
+ <tbody>""")
+ for feed in Feed.gql("WHERE category IN :1 ORDER BY comments_day DESC", ['history','fun','general','commercial','art','visual','pure','applied','teacher','journalism']):
+ output.append("""
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ %(comments_day)i
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <a href="%(homepage)s">%(title)s</a>
+ </td>
+ </tr>""" % {'comments_day': feed.comments_day, 'homepage': feed.homepage, 'title': feed.title })
+ output.append("""
+ </tbody>
+ </table>""")
+
+ output.append("""
+ <table class="bydate" id="commentsperweek">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ </th>
+ <th align="left" class="blogcolumn">
+ Comments last week
+ </th>
+ </tr>
+ </thead>
+ <tbody>""")
+ for feed in Feed.gql("WHERE category IN :1 ORDER BY comments_week DESC", ['history','fun','general','commercial','art','visual','pure','applied','teacher','journalism']):
+ output.append("""
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ %(comments_week)i
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <a href="%(homepage)s">%(title)s</a>
+ </td>
+ </tr>""" % {'comments_week': feed.comments_week, 'homepage': feed.homepage, 'title': feed.title })
+ output.append("""
+ </tbody>
+ </table>""")
+
+ output.append("""
+ <table class="bydate" id="postsperweek">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ </th>
+ <th align="left" class="blogcolumn">
+ Posts last week
+ </th>
+ </tr>
+ </thead>
+ <tbody>""")
+ for feed in Feed.gql("WHERE category IN :1 ORDER BY posts_day DESC", ['history','fun','general','commercial','art','visual','pure','applied','teacher','journalism']):
+ output.append("""
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ %(posts_week)i
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <a href="%(homepage)s">%(title)s</a>
+ </td>
+ </tr>""" % {'posts_week': feed.posts_week, 'homepage': feed.homepage, 'title': feed.title })
+ output.append("""
+ </tbody>
+ </table>""")
+
+ output.append("""
+ <table class="bydate" id="postspermonth">
+ <thead>
+ <tr>
+ <th align="left" class="datecolumn">
+ </th>
+ <th align="left" class="blogcolumn">
+ Posts last month
+ </th>
+ </tr>
+ </thead>
+ <tbody>""")
+ for feed in Feed.gql("WHERE category IN :1 ORDER BY posts_day DESC", ['history','fun','general','commercial','art','visual','pure','applied','teacher','journalism']):
+ output.append("""
+ <tr>
+ <td valign="bottom" class="datecolumn">
+ %(posts_month)i
+ </td>
+ <td valign="bottom" class="blogcolumn">
+ <a href="%(homepage)s">%(title)s</a>
+ </td>
+ </tr>""" % {'posts_month': feed.posts_month, 'homepage': feed.homepage, 'title': feed.title })
+ output.append("""
+ </tbody>
+ </table>""")
+ return "".join(output)
+
+
+
View
90 temp_global.py
@@ -0,0 +1,90 @@
+header = """
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
+ <link rel="stylesheet" type="text/css" href="/content/site.css"/>
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" />
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
+ <title>Mathblogging.org</title>
+ <script type="text/javascript" src="/content/jquery-1.5.2.min.js"></script>
+ <link rel="stylesheet" type="text/css" href="/content/jqcloud.css" />
+ <script type="text/javascript" src="/content/jqcloud-0.2.1.js"></script>
+ </head>
+ <body>
+ <h1> <a style="text-decoration:none;color:white;" href="/">Mathblogging.org <small style="color: #CCC">beta</small></a></h1>
+"""
+
+menu = """
+<!-- Top Navigation -->
+<div id="menu">
+<ul>
+ <li><h2><a href="/bydate" title="Recent posts">Posts</a></h2>
+ <ul>
+ <li><h2><a href="/byresearchdate" title="Recent posts in Research">Researchers</a></h2>
+ </li>
+ <li><h2><a href="/byartvishisdate" title="Recent posts in Art,Visual,History">Art/Visual/History</a></h2>
+ </li>
+ <li><h2><a href="/byteacherdate" title="Recent posts from Teachers">Teachers</a></h2>
+ </li>
+ </ul>
+ </li>
+ <li><h2><a href="/bytype" title="Blogs by Category">Blogs</a></h2>
+ </li>
+ <li><h2><a href="/bystats" title="Recent statistics">Stats</a></h2>
+ </li>
+ <li><h2><a href="/weekly-picks" title="Our weekly picks">Weekly Picks</a></h2>
+ </li>
+ <li><h2><a href="/planettag" title="PlanetTAG">PlanetTAG</a></h2>
+ </li>
+ <li><h2><a href="/planetmo" title="PlanetMO">PlanetMO</a></h2>
+ </li>
+ <li><h2><a href="/feeds" title="Feeds">Feeds</a></h2>
+ </li>
+ <li><h2><a href="https://mathblogging.wordpress.com/about" title="About us">About us</a></h2>
+ </li>
+ <li><h2><a href="/" title="Search">Search</a></h2>
+ </li>
+</ul>
+</div>
+<!-- end Top Navigation -->
+"""
+
+disqus = """
+<!-- disqus code-->
+<div class="disqus">
+<hr/>
+<div id="disqus_thread"></div>
+<script type="text/javascript">
+ /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
+ var disqus_shortname = 'mathblogging'; // required: replace example with your forum shortname
+
+ // The following are highly recommended additional parameters. Remove the slashes in front to use.
+ // var disqus_identifier = 'unique_dynamic_id_1234';
+ // var disqus_url = 'http://example.com/permalink-to-page.html';
+
+ /* * * DON'T EDIT BELOW THIS LINE * * */
+ (function() {
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+ dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+ })();
+</script>
+<noscript><p>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></p></noscript>
+<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
+</div>
+<!-- end disqus code-->
+"""
+
+footer = """
+<!-- copyright footer -->
+<div class="footer">
+<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">
+ <img alt="Creative Commons License" src="http://i.creativecommons.org/l/by-nc-sa/3.0/80x15.png"/>
+</a>
+<p>
+mathblogging.org is licensed under a <br/> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.
+</p>
+</div>
+<!-- end copyright footer -->
+"""
View
28 weeklypicks.py
@@ -0,0 +1,28 @@
+from main import *
+
+import counter
+
+
+class WeeklyPicks(TemplatePage):
+ cacheName = "WeeklyPicks"
+ def generateContent(self):
+ output = []
+ output.append( """<h2> Weekly picks <a href="https://mathblogging.wordpress.com/category/weekly-picks/feed/"><img src="/content/rss-64.png" alt="Weekly picks" height="25"/></a> </h2>
+
+Our weekly picks, crossposted from <a href="https://mathblogging.wordpress.com/category/weekly-picks/">Mathblogging.org -- the blog</a>.
+""")
+
+ for entry in Post.gql("WHERE tags IN :1 ORDER BY timestamp_created DESC LIMIT 150", ['Weekly Picks']):
+ output.append( """ <div class="planetbox">
+ <div class="planethead">
+ <h2><a href="%(link)s" title="%(title)s">%(title)s</a></h2>
+ <div class="planetsubtitle">Posted %(tcreated)s.
+ </div>
+ <div class="planettags"> """ % {"link":entry.link, "title":entry.title, "homepage":entry.homepage, "service":entry.service, "tcreated":entry.printShortTime_created()} )
+ output.append( """ </div>
+ </div>
+ <div class="planetbody">
+ <p> """ )
+ output.append( entry.content )
+ output.append( """ </p> </div> </div> """ )
+ return "".join(output)
Please sign in to comment.
Something went wrong with that request. Please try again.