Example #1
0
    def tile(self, path, tile):
        if not mapper.exists(path):
            raise cherrypy.HTTPError(404)

        mo = tile_re.match(tile)
        if not mo:
            raise cherrypy.HTTPError(404)

        group, z, x, y = map(lambda x: int(x), mo.groups())
        cached_path = tilecache.get_cached_path(mapper._map_path(path), group, z, x, y)
        if cached_path is not None:
            return serve_file(cached_path)

        data = tilecache.get_data(mapper._map_path(path), group, z, x, y)
        cherrypy.response.headers["Content-Type"] = "image/jpeg"
        return data
Example #2
0
    def thumbnail(self, path, width=64, height=64):
        if not mapper.exists(path):
            redirect(url("/static/icons/thumbs/missing.png"))

        width = int(width)
        height = int(height)

        # Note - the path supplied is supplied as a query parameter, not as
        # part of the path info in the URL, because otherwise cherrypy strips
        # out any double slashes, making it impossible to tell if the path
        # starts with a drivename (on windows) or with an absolute path which
        # should have a / inserted before it (on unix).
        try:
            data, ctype = thumbcache.get_data(mapper._map_path(path), width, height)
            cherrypy.response.headers["Content-Type"] = ctype
            return data
        except IOError:
            redirect(url("/static/icons/thumbs/broken.png"))