Beispiel #1
0
 def downloads(self, directory="."):
     filepath = []
     stuff = []
     for filename in glob.glob(directory + "/n3wbl0g/downloadable/*"):
         absPath = os.path.abspath(filename)
         filepath.append(os.path.basename(filename))
         stuff.append(absPath)
     return template.render(stuff=stuff, filepath=filepath)
Beispiel #2
0
 def interesting(self):
     return template.render()
Beispiel #3
0
 def join(self):
     return template.render()
Beispiel #4
0
 def blog(self):
     return template.render()
Beispiel #5
0
 def tutorials(self):
     return template.render()
Beispiel #6
0
 def info(self, id):
     link = self.data.get(id)
     if not link:
         raise cherrypy.NotFound()
     return template.render(link=link)
Beispiel #7
0
 def index(self):
     links = sorted(self.data.values(), key=operator.attrgetter("time"), reverse=True)
     return template.render(links=links)
Beispiel #8
0
    def submit(self, cancel=False, **data):
        if cherrypy.request.method == "POST":
            if cancel:
                raise cherrypy.HTTPRedirect("/")
            form = LinkForm()
            try:
                data = form.to_python(data)
                link = Link(**data)
                self.data[link.id] = link
                raise cherrypy.HTTPRedirect("/")
            except Invalid, e:
                errors = e.unpack_errors()
        else:
            errors = {}

        return template.render(errors=errors) | HTMLFormFiller(data=data)

    @cherrypy.expose
    @template.output("info.html")
    def info(self, id):
        link = self.data.get(id)
        if not link:
            raise cherrypy.NotFound()
        return template.render(link=link)

    @cherrypy.expose
    @template.output("comment.html")
    def comment(self, id, cancel=False, **data):
        link = self.data.get(id)
        if not link:
            raise cherrypy.NotFound()