From dba657a84b11e491b39ee4566f7ff17d0b9938f1 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 8 Jul 2009 20:53:53 +0200 Subject: [PATCH] Changes on the CMS. There is a new Javascript class and the web module is derived into many files. ipfire.py behaves different and there is a new info.json file that should make some things easier. I also hope that it will be faster or even as fast as it has been before these changes. --- www/include/{jquery.js => jquery.min.js} | 0 www/info.json | 7 + www/ipfire.py | 22 ++- www/pages/cluster/__init__.py | 58 +++--- www/pages/news.rss/__init__.py | 15 +- www/pages/source/__init__.py | 9 +- www/pages/static/__init__.py | 23 ++- www/pages/static/download.xml | 6 +- www/pages/static/index.xml | 15 +- www/template.inc | 1 + www/web/__init__.py | 215 ++++++----------------- www/web/banners.py | 15 ++ www/web/elements.py | 50 ++++++ www/web/info.py | 14 ++ www/web/javascript.py | 22 +++ www/web/json.py | 12 ++ www/web/lang.py | 22 +++ www/web/menu.py | 30 ++++ www/web/news.py | 42 +++++ 19 files changed, 338 insertions(+), 240 deletions(-) rename www/include/{jquery.js => jquery.min.js} (100%) create mode 100644 www/info.json mode change 100644 => 100755 www/ipfire.py create mode 100644 www/web/banners.py create mode 100644 www/web/elements.py create mode 100644 www/web/info.py create mode 100644 www/web/javascript.py create mode 100644 www/web/json.py create mode 100644 www/web/lang.py create mode 100644 www/web/menu.py create mode 100644 www/web/news.py diff --git a/www/include/jquery.js b/www/include/jquery.min.js similarity index 100% rename from www/include/jquery.js rename to www/include/jquery.min.js diff --git a/www/info.json b/www/info.json new file mode 100644 index 00000000..0ff83a0a --- /dev/null +++ b/www/info.json @@ -0,0 +1,7 @@ +{ + "name" : "IPFire", + "sname" : "ipfire", + "slogan" : "Security now!", + "releases" : { "stable" : "IPFire 2.5 - Core 28", + "testing" : "IPFire 3.0 alpha 1" } +} diff --git a/www/ipfire.py b/www/ipfire.py old mode 100644 new mode 100755 index 830bb155..6296b925 --- a/www/ipfire.py +++ b/www/ipfire.py @@ -1,26 +1,24 @@ #!/usr/bin/python +import cgitb +cgitb.enable() + import sys import cgi import imputil -from web import Page - -site = cgi.FieldStorage().getfirst("site") or "main" +site = cgi.FieldStorage().getfirst("site") or "index" sys.path = [ "pages",] + sys.path -for page in (site, "static"): +for s in (site, "static"): try: - found = imputil.imp.find_module(page) - loaded = imputil.imp.load_module(page, found[0], found[1], found[2]) - content = loaded.__dict__["Content"] - sidebar = loaded.__dict__["Sidebar"] + found = imputil.imp.find_module(s) + loaded = imputil.imp.load_module(s, found[0], found[1], found[2]) + + p = loaded.__dict__["page"] + break except ImportError, e: pass -c = content(site) -s = sidebar(site) - -p = Page(site, c, s) p() diff --git a/www/pages/cluster/__init__.py b/www/pages/cluster/__init__.py index d8f787c7..f4d5fcf2 100644 --- a/www/pages/cluster/__init__.py +++ b/www/pages/cluster/__init__.py @@ -1,22 +1,43 @@ #!/usr/bin/python import web -import web.cluster +import web.elements +from web.javascript import Javascript class Content(web.Content): - def __init__(self, name): - web.Content.__init__(self, name) - - self.cluster = web.cluster.Cluster("minerva.ipfire.org") + def __init__(self): + web.Content.__init__(self) def __call__(self, lang): - ret = "

Icecream Cluster Monitoring

" + ret = """

Icecream Cluster Monitoring

+

Cluster's load: - Number of nodes: -

+ + + + + + + + + + + + +
NameArchLoadJobsSpeed
""" - ret += """""" - - ret += """

Cluster's load: - Number of nodes: -

- - - - - - - - - - - - -
NameArchLoadJobsSpeed
""" - - return ret - -Sidebar = web.Sidebar + """) diff --git a/www/pages/news.rss/__init__.py b/www/pages/news.rss/__init__.py index 0e0a0ba4..85a23e65 100644 --- a/www/pages/news.rss/__init__.py +++ b/www/pages/news.rss/__init__.py @@ -5,12 +5,13 @@ import time from urllib import quote import web +import web.news class Content(web.Content): - def __init__(self, name): - web.Content.__init__(self, name) + def __init__(self): + web.Content.__init__(self) - self.news = web.News(15) + self.news = web.news.News(15) def __call__(self, lang="en"): s = "" @@ -36,9 +37,5 @@ class Content(web.Content): \n""" % item return s -class Sidebar(web.Sidebar): - def __init__(self, name): - web.Sidebar.__init__(self, name) - - def content(self, lang): - pass +page = web.Page() +page.content = Content() diff --git a/www/pages/source/__init__.py b/www/pages/source/__init__.py index 236b4e05..bf597dc6 100644 --- a/www/pages/source/__init__.py +++ b/www/pages/source/__init__.py @@ -51,8 +51,8 @@ class SourceObject: class Content(web.Content): - def __init__(self, name): - web.Content.__init__(self, name) + def __init__(self): + web.Content.__init__(self) self.dirs = [] @@ -85,5 +85,6 @@ class Content(web.Content): ret += b() return ret -Sidebar = web.Sidebar - +page = web.Page() +page.content = Content() +page.sidebar = web.Sidebar() diff --git a/www/pages/static/__init__.py b/www/pages/static/__init__.py index 1ef0857e..36d7550e 100644 --- a/www/pages/static/__init__.py +++ b/www/pages/static/__init__.py @@ -5,8 +5,11 @@ import os from xml.dom.minidom import parseString import web +from web.banners import Banners +from web.elements import Box, Releases +from web.news import News -class Xml: +class Xml(object): def __init__(self, file): file = "%s/pages/static/%s.xml" % (os.getcwd(), file,) f = open(file) @@ -14,10 +17,10 @@ class Xml: f.close() self.xml = parseString(data).getElementsByTagName("Site")[0] - + def getAttribute(self, node, attr): return node.getAttribute(attr).strip() - + def getText(self, node): ret = "" for i in node.childNodes: @@ -34,7 +37,7 @@ class Content(Xml): for paragraphs in self.xml.getElementsByTagName("Paragraphs"): for paragraph in paragraphs.getElementsByTagName("Paragraph"): if self.getAttribute(paragraph, "news") == "1": - news = web.News(int(self.getAttribute(paragraph, "count"))) + news = News(int(self.getAttribute(paragraph, "count"))) ret += news(lang).encode("utf-8") continue @@ -45,7 +48,7 @@ class Content(Xml): heading = self.getText(heading) break - b = web.Box(heading) + b = Box(heading) # Content for content in paragraph.getElementsByTagName("Content"): @@ -70,10 +73,14 @@ class Sidebar(Xml): sidebar = self.xml.getElementsByTagName("Sidebar")[0] for paragraph in sidebar.getElementsByTagName("Paragraph"): if self.getAttribute(paragraph, "banner") == "1": - b = web.Banners() + b = Banners() ret += """

%(title)s

""" % b.random() continue + elif self.getAttribute(paragraph, "releases") == "1": + r = Releases() + ret += r(lang) + continue # Heading for heading in paragraph.getElementsByTagName("Heading"): @@ -95,3 +102,7 @@ class Sidebar(Xml): ret += s return ret + +page = web.Page() +page.content = Content(page.site) +page.sidebar = Sidebar(page.site) diff --git a/www/pages/static/download.xml b/www/pages/static/download.xml index 8d045cd2..1b30e4c1 100644 --- a/www/pages/static/download.xml +++ b/www/pages/static/download.xml @@ -190,6 +190,8 @@ + + Torrent clients]]> Torrent Clients]]> @@ -202,7 +204,7 @@ ]]> - + diff --git a/www/pages/static/index.xml b/www/pages/static/index.xml index 9cc399bb..f479d93e 100644 --- a/www/pages/static/index.xml +++ b/www/pages/static/index.xml @@ -72,21 +72,8 @@ - - information]]> + - Current release:
IPFire 2.5

-

Current update level:
Core 28

-

Current unstables:
IPFire 3.0 alpha 1

- ]]>
- Aktuelle Version:
IPFire 2.5

-

Aktuelles Update-Level:
Core 28

-

Testversionen:
IPFire 3.0 alpha 1

- ]]>
-
- Internet Relay Chat]]> + %(javascript)s