Exemplo n.º 1
0
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)
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
 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))
Exemplo n.º 4
0
def updateip():
    return filedown(request.environ, application.get_file('updateip.py'))
Exemplo n.º 5
0
def robots():
    return filedown(request.environ, application.get_file('robots.txt'))
Exemplo n.º 6
0
def favicon():
    return filedown(request.environ, application.get_file('favicon.ico'))
Exemplo n.º 7
0
def jpg(filename):
    return filedown(request.environ, application.get_file(filename+'.jpg', dir='files'))
Exemplo n.º 8
0
def rss():
    return filedown(request.environ, application.get_file('rss.xml', dir='files'))
Exemplo n.º 9
0
def tarbz2(filename):
    return filedown(request.environ, application.get_file(filename+'.tar.bz2', dir='files'), download=True)
Exemplo n.º 10
0
def zip(filename):
    return filedown(request.environ, application.get_file(filename+'.zip', dir='files'), download=True)