def _show(filename,render=True): from uliweb.utils.rst import to_html from uliweb.core.template import template # if not filename.endswith('.rst'): # filename += '.rst' _f = application.get_file(filename+'.html', dir='files') if _f: def f(): content = file(_f).read() return application.template('show_document.html', locals()) response.write(f()) return response else: _f = application.get_file(filename+'.txt', dir='files') if _f: def f(): content = file(_f).read() return application.template('show_txt.html', locals()) response.write(f()) return response else: _f = application.get_file(filename+'.rst', dir='files') if _f: def f(): content = file(_f).read() if render: content = to_html(template(content, env=application.get_view_env())) else: content = to_html(content) return application.template('show_document.html', locals()) response.write(f()) return response else: error("Can't find the file %s" % filename)
def html(self): from uliweb import application f = file(application.get_file(self.layout, dir='templates'), 'rb') text = f.read() f.close() return str(uaml.Parser(text, self.writer))
def updateip(): return filedown(request.environ, application.get_file('updateip.py'))
def robots(): return filedown(request.environ, application.get_file('robots.txt'))
def favicon(): return filedown(request.environ, application.get_file('favicon.ico'))
def jpg(filename): return filedown(request.environ, application.get_file(filename+'.jpg', dir='files'))
def rss(): return filedown(request.environ, application.get_file('rss.xml', dir='files'))
def tarbz2(filename): return filedown(request.environ, application.get_file(filename+'.tar.bz2', dir='files'), download=True)
def zip(filename): return filedown(request.environ, application.get_file(filename+'.zip', dir='files'), download=True)