Exemplo n.º 1
0
 def get(self, id):
     post = models.BlogPost.get_by_id(int(id))
     if not post:
         return self.error(404)
     if post.draft:
         resources.rm(post.path.view)
         return
     body = template.render("views/post.html", {"post": post, "recentphotos": recentphotos()})
     resources.put(post.path.view, body, "text/html")
Exemplo n.º 2
0
    def get(self):
        photos = recentphotos()

        q = models.BlogPost.all().order("-published")
        q = q.filter("draft =", False)

        for posts in util.Pager(q, "/%s", pagesize=config.postcount):
            body = template.render("views/listing.html", {"posts": posts, "recentphotos": photos})
            resources.put(posts.url, body, "text/html")
Exemplo n.º 3
0
    def get(self):
        paths = resources.Resource.all(keys_only=True)
        paths = paths.filter("indexed =", True)
        xml = template.render("views/sitemap.xml", {"paths": [key.name() for key in paths], "host": config.host})

        resources.put("/sitemap.xml", xml, "application/xml", indexed=False)

        s = StringIO()
        gzip.GzipFile(fileobj=s, mode="wb").write(xml)
        s.seek(0)
        resources.put("/sitemap.xml.gz", s.read(), "application/x-gzip", indexed=False)
        if not util.debug:
            util.pingsitemap(config.host)
Exemplo n.º 4
0
 def get(self):
     body = template.render("views/search.html", {"recentphotos": recentphotos()})
     resources.put("/search", body, "text/html")
Exemplo n.º 5
0
 def get(self):
     body = template.render("views/robots.txt", {"host": config.host})
     resources.put("/robots.txt", body, "text/plain", indexed=False)
Exemplo n.º 6
0
    def get(self):
        posts = models.BlogPost.all().order("-published")
        body = template.render("views/atom.xml", {"posts": posts, "host": config.host})

        resources.put("/feeds/atom.xml", body, "application/atom+xml", indexed=False)