From 5816bafb17ab16fc00a7434d74c1c135b72da3aa Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Thu, 15 Aug 2013 08:17:07 +0000 Subject: [PATCH] Removed old files --- www.i2p2/app.py | 74 -------------------------------------------- www.i2p2/generate.py | 26 ---------------- www.i2p2/generate.sh | 5 --- 3 files changed, 105 deletions(-) delete mode 100644 www.i2p2/app.py delete mode 100644 www.i2p2/generate.py delete mode 100755 www.i2p2/generate.sh diff --git a/www.i2p2/app.py b/www.i2p2/app.py deleted file mode 100644 index 76323b41d..000000000 --- a/www.i2p2/app.py +++ /dev/null @@ -1,74 +0,0 @@ -from werkzeug import BaseRequest, BaseResponse, ETagResponseMixin, escape, run_simple, SharedDataMiddleware -from werkzeug.exceptions import HTTPException -from werkzeug.routing import RequestRedirect -from jinja import Environment, FileSystemLoader, MemcachedFileSystemLoader -from jinja.exceptions import TemplateNotFound -import os -from time import time -from random import randint - -domain = "http://www.i2p2.de" - -class Request(BaseRequest): - """Useful subclass of the default request that knows how to build urls.""" - - def __init__(self, environ): - BaseRequest.__init__(self, environ) - - -class Response(BaseResponse, ETagResponseMixin): - """Subclass of base response that has a default mimetype of text/html.""" - default_mimetype = 'text/html' - - -# setup jinja -try: - env = Environment(loader=MemcachedFileSystemLoader('pages', memcache_host=['127.0.0.1:11211'], memcache_time=5*60)) -except RuntimeError: - env = Environment(loader=FileSystemLoader('pages', use_memcache=False, auto_reload=True)) - -def app(environ, start_response): - """The WSGI application that connects all together.""" - req = Request(environ) - path = req.path[1:].lower() - # do theme handling - theme = 'light' - if 'style' in req.cookies: - theme = req.cookies['style'] - if 'theme' in req.args.keys(): - theme = req.args['theme'] - if not os.path.isfile('static/styles/%s.css' % theme): - theme = 'light' - if path == '': - path = 'index' - mime_type='text/html' - try: - try: - path.index('.') - if path.split('.')[-1].isdigit() and not path.split('.')[-1].isalpha(): - raise ValueError() - tmpl = env.get_template(path) - if path[-3:] == 'txt': - mime_type='text/plain' - if path[-3:] == 'xml': - mime_type='text/xml' - except ValueError: - tmpl = env.get_template(path + '.html') - except TemplateNotFound: - tmpl = env.get_template('not_found.html') - resp = Response(tmpl.render(static=False, theme=theme, domain=domain, path=path), mimetype=mime_type) - # more theme handling - if theme == 'light' and 'style' in req.cookies: - resp.delete_cookie('style') - elif theme != 'light': - resp.set_cookie('style', theme) - resp.add_etag() - resp.make_conditional(req) - return resp(environ, start_response) - -app = SharedDataMiddleware(app, { - '/_static': os.path.join(os.path.dirname(__file__), 'static') -}) - -if __name__ == '__main__': - run_simple('localhost', 5009, app) diff --git a/www.i2p2/generate.py b/www.i2p2/generate.py deleted file mode 100644 index f37b93d7d..000000000 --- a/www.i2p2/generate.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import os -from jinja import Environment, FileSystemLoader -#from codecs import open - -env = Environment(loader=FileSystemLoader('pages'), trim_blocks=True, friendly_traceback=False) - - -def get_files(folder): - for fn in os.listdir(folder): - if fn.startswith('_'): - continue - fn = os.path.join(folder, fn) - if os.path.isdir(fn): - for item in get_files(fn): - yield item - else: - yield fn - -for filename in get_files('pages'): - print filename - filename = filename.split('/', 2)[1] - t = env.get_template(filename) - f = open(os.path.join('out', filename), 'w') - f.write(t.render(static=True).encode('utf-8')) - f.close() \ No newline at end of file diff --git a/www.i2p2/generate.sh b/www.i2p2/generate.sh deleted file mode 100755 index f56989fcc..000000000 --- a/www.i2p2/generate.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -rm -rf out -mkdir out -cp -R static out/_static -python generate.py -- GitLab