From 8e2e1261c5e94ec2dbdb04166f331c4af7a64cc2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 25 Jul 2012 20:30:50 +0200 Subject: [PATCH] Integrate boot.ipfire.org application with the main webapp. --- boot/backend | 1 - boot/static | 1 - boot/templates | 1 - www/translations/de_DE/LC_MESSAGES/webapp.po | 6 +- www/translations/webapp.pot | 6 +- www/webapp/__init__.py | 15 +++++ www/webapp/handlers.py | 1 + boot/boot.py => www/webapp/handlers_boot.py | 63 ++------------------ 8 files changed, 22 insertions(+), 72 deletions(-) delete mode 120000 boot/backend delete mode 120000 boot/static delete mode 120000 boot/templates rename boot/boot.py => www/webapp/handlers_boot.py (62%) diff --git a/boot/backend b/boot/backend deleted file mode 120000 index e57052c2..00000000 --- a/boot/backend +++ /dev/null @@ -1 +0,0 @@ -../www/webapp/backend/ \ No newline at end of file diff --git a/boot/static b/boot/static deleted file mode 120000 index 80b70392..00000000 --- a/boot/static +++ /dev/null @@ -1 +0,0 @@ -../www/static/netboot/ \ No newline at end of file diff --git a/boot/templates b/boot/templates deleted file mode 120000 index b5c72a45..00000000 --- a/boot/templates +++ /dev/null @@ -1 +0,0 @@ -../www/templates/netboot \ No newline at end of file diff --git a/www/translations/de_DE/LC_MESSAGES/webapp.po b/www/translations/de_DE/LC_MESSAGES/webapp.po index 33ba16ac..06c97274 100644 --- a/www/translations/de_DE/LC_MESSAGES/webapp.po +++ b/www/translations/de_DE/LC_MESSAGES/webapp.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-07-25 20:08+0200\n" +"POT-Creation-Date: 2012-07-25 20:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1272,10 +1272,6 @@ msgstr "Vor mehr als einem Tag" msgid "Profile not found" msgstr "Profil nicht gefunden" -#: templates/news-item.html:7 -msgid "Show all news entries" -msgstr "" - #: webapp/handlers_news.py:44 webapp/ui_modules.py:54 msgid "Unknown author" msgstr "Unbekannter Autor" diff --git a/www/translations/webapp.pot b/www/translations/webapp.pot index 9015277e..23a93995 100644 --- a/www/translations/webapp.pot +++ b/www/translations/webapp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-07-25 20:08+0200\n" +"POT-Creation-Date: 2012-07-25 20:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1264,10 +1264,6 @@ msgstr "" msgid "Profile not found" msgstr "" -#: templates/news-item.html:7 -msgid "Show all news entries" -msgstr "" - #: webapp/handlers_news.py:44 webapp/ui_modules.py:54 msgid "Unknown author" msgstr "" diff --git a/www/webapp/__init__.py b/www/webapp/__init__.py index 0bc72936..69e03e30 100644 --- a/www/webapp/__init__.py +++ b/www/webapp/__init__.py @@ -151,6 +151,21 @@ class Application(tornado.web.Application): (r"/torrent/([0-9a-f]+)", TrackerDetailHandler), ] + static_handlers) + # boot.ipfire.org + BOOT_STATIC_PATH = os.path.join(self.settings["static_path"], "netboot") + self.add_handlers(r"boot\.ipfire\.org", [ + (r"/", tornado.web.RedirectHandler, { "url" : "http://www.ipfire.org/download" }), + + # Configurations + (r"/menu.gpxe", MenuGPXEHandler), + (r"/menu.cfg", MenuCfgHandler), + (r"/config/([0-9]+)/boot.gpxe", BootGPXEHandler), + + # Static files + (r"/(boot.png|custom.gpxe|premenu.cfg|vesamenu.c32|menu.c32)", + tornado.web.StaticFileHandler, { "path" : BOOT_STATIC_PATH }), + ]) + # nopaste.ipfire.org self.add_handlers(r"nopaste\.ipfire\.org", [ (r"/", NopasteIndexHandler), diff --git a/www/webapp/handlers.py b/www/webapp/handlers.py index 67e42e0d..f954f50a 100644 --- a/www/webapp/handlers.py +++ b/www/webapp/handlers.py @@ -17,6 +17,7 @@ import backend from handlers_admin import * from handlers_base import * +from handlers_boot import * from handlers_download import * from handlers_iuse import * from handlers_mirrors import * diff --git a/boot/boot.py b/www/webapp/handlers_boot.py similarity index 62% rename from boot/boot.py rename to www/webapp/handlers_boot.py index 00c59b9a..22acce5a 100644 --- a/boot/boot.py +++ b/www/webapp/handlers_boot.py @@ -25,13 +25,13 @@ def word_wrap(s, width=45): lines.append(paragraph.lstrip()) return '\n'.join(lines) -class BaseHandler(tornado.web.RequestHandler): +class BootBaseHandler(tornado.web.RequestHandler): @property def netboot(self): return backend.NetBoot() -class MenuGPXEHandler(BaseHandler): +class MenuGPXEHandler(BootBaseHandler): """ menu.gpxe """ @@ -44,7 +44,7 @@ class MenuGPXEHandler(BaseHandler): self.write("chain menu.c32 premenu.cfg\n") -class MenuCfgHandler(BaseHandler): +class MenuCfgHandler(BootBaseHandler): def _menu_string(self, menu, level=0): s = "" @@ -93,7 +93,7 @@ class MenuCfgHandler(BaseHandler): self.render("menu.cfg", menu=menu) -class BootGPXEHandler(BaseHandler): +class BootGPXEHandler(BootBaseHandler): def get(self, id): config = self.netboot.get_config(id) if not config: @@ -115,58 +115,3 @@ class BootGPXEHandler(BaseHandler): for line in lines: self.write("%s\n" % line) - - -class Application(tornado.web.Application): - def __init__(self): - settings = dict( - debug = True, - gzip = True, - static_path = os.path.join(BASEDIR, "static"), - template_path = os.path.join(BASEDIR, "templates"), - ) - - tornado.web.Application.__init__(self, **settings) - - self.add_handlers(r"boot.ipfire.org", [ - # Configurations - (r"/menu.gpxe", MenuGPXEHandler), - (r"/menu.cfg", MenuCfgHandler), - (r"/config/([0-9]+)/boot.gpxe", BootGPXEHandler), - - # Static files - (r"/(boot.png|custom.gpxe|premenu.cfg|vesamenu.c32|menu.c32)", - tornado.web.StaticFileHandler, { "path" : self.settings["static_path"] }), - ]) - - @property - def ioloop(self): - return tornado.ioloop.IOLoop.instance() - - def shutdown(self, *args): - logging.debug("Caught shutdown signal") - self.ioloop.stop() - - def run(self, port=8002): - logging.debug("Going to background") - - # All requests should be done after 30 seconds or they will be killed. - self.ioloop.set_blocking_log_threshold(30) - - http_server = tornado.httpserver.HTTPServer(self, xheaders=True) - - # If we are not running in debug mode, we can actually run multiple - # frontends to get best performance out of our service. - if not self.settings["debug"]: - http_server.bind(port) - http_server.start(num_processes=4) - else: - http_server.listen(port) - - self.ioloop.start() - -if __name__ == "__main__": - a = Application() - - a.run() - -- 2.47.3