summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controller.py49
-rwxr-xr-xindex.py14
-rw-r--r--renderer.py17
-rw-r--r--templates/menu.mako2
-rw-r--r--templates/page.mako39
-rw-r--r--templates/pages/index.mako49
-rw-r--r--templates/root.mako4
7 files changed, 62 insertions, 112 deletions
diff --git a/controller.py b/controller.py
index e4c07f7..69eaf76 100644
--- a/controller.py
+++ b/controller.py
@@ -4,16 +4,47 @@ import web
from helper import appdir
from renderer import render
-class Page:
- """
- All the general and simple pages.
- """
- def GET(self, name = '/'):
- if not name or name == '/': name = 'index'
- return render(name)
+class Show:
+ def GET(self, year = '', month = ''):
+ if year: return "Show %s/%s" % (year, month)
+ else: return "Show current"
+
+class Add:
+ def GET(self):
+ return "Add new"
+
+class Edit:
+ def GET(self, id):
+ return "Edit " + id
+
+class Const:
+ def GET(self):
+ return "Const"
+
+class ConstAdd:
+ def GET(self):
+ return "Add new const"
-def FourOhFour(page="?"):
+class ConstEdit:
+ def GET(self, id):
+ return "Const Edit " + id
+
+class Cat:
+ def GET(self, id = '/'):
+ if id:
+ id = id[1:]
+
+ if not id: return "Add new cat"
+ else: return "Edit cat " + id
+
+class FourOhFour:
"""
404 error page.
"""
- return web.notfound(render("404", level = "", page = page))
+
+ def GET (self, p):
+ raise self.catch(p)
+
+ @staticmethod
+ def catch (page = "?"):
+ return web.notfound(render("404", page = page))
diff --git a/index.py b/index.py
index d9e2e7d..aaf0f75 100755
--- a/index.py
+++ b/index.py
@@ -8,10 +8,16 @@ import model
# URL Mappings
#
urls = (
- "/r/(.*)", controller.Redirect,
- "/(.*)", controller.Page
+ "/add/?", controller.Add,
+ "/edit/(\d+)", controller.Edit,
+ "/const/?", controller.Const,
+ "/const/add/?", controller.ConstAdd,
+ "/const/edit/(\d+)", controller.ConstEdit,
+ "/cat/?(/\d+)?", controller.Cat,
+ "/(\d\d\d\d)/(\d\d)", controller.Show,
+ "/", controller.Show,
+ "/(.*)", controller.FourOhFour
)
-
#
# ORM
#
@@ -33,7 +39,7 @@ def handle_sql(handler):
# The App
#
app = web.application(urls, globals())
-app.notfound = controller.FourOhFour
+app.notfound = controller.FourOhFour.catch
# add orm processor
app.add_processor(handle_sql)
diff --git a/renderer.py b/renderer.py
index b8ce716..6f983a4 100644
--- a/renderer.py
+++ b/renderer.py
@@ -17,24 +17,21 @@ class Renderer:
output_encoding='utf-8',
format_exceptions = True)
- def render (self, tpl, level = "pages" , **kwargs):
+ def render (self, tpl, **kwargs):
try:
- t = self.get_tpl(tpl, level)
+ t = self.get_tpl(tpl)
except mako.exceptions.TopLevelLookupException, e:
raise web.ctx.app_stack[-1].notfound(tpl)
- return t.render(h = helper, url = helper.url, w = web, _hl = highlighting, **kwargs)
+ return t.render(h = helper, url = helper.url, w = web, **kwargs)
__call__ = render
- def get_tpl (self, tpl, level):
- return self.lookup.get_template(self.get_tpl_name(tpl, level))
-
- def get_tpl_name (self, tpl, level):
+ def get_tpl (self, tpl):
if not tpl.endswith(".mako"):
tpl = tpl+".mako"
-
- return os.path.join(level, tpl)
-
+
+ return self.lookup.get_template(tpl)
+
# the one and only instance :)
render = Renderer()
diff --git a/templates/menu.mako b/templates/menu.mako
index 64701b2..fc2e740 100644
--- a/templates/menu.mako
+++ b/templates/menu.mako
@@ -1,5 +1,7 @@
<%!
menu = [
("/index", "Kosten"),
+ ("/const", "Konstante Kosten"),
+ ("/categories", "Kategorien")
]
%>
diff --git a/templates/page.mako b/templates/page.mako
index aa2aa51..cc9911f 100644
--- a/templates/page.mako
+++ b/templates/page.mako
@@ -1,46 +1,9 @@
<%!
title = ""
- uses_toc = False
%>
-<%
- page_text = capture(next.body)
-%>
-
<%inherit file="/root.mako" />
## content
<h1 class="title">${self.attr.title}</h1>
-% if self.attr.uses_toc:
- ${self.preface()}
- ${self.toc()}
-% endif
-
-${page_text}
-
-## functions
-
-<%def name="h2(tag='h2')">
- <%
- if self.attr.uses_toc:
- c = capture(caller.body)
- name = c.replace(" ", "_").replace("/", "_").lower()
- tlist = getattr(self.attr, "tlist", [])
- tlist.append((str(name), str(c)))
-
- self.attr.tlist = tlist
- else:
- name = "#"
- %>
- <${tag}><a name="${name}"><span class="hstart">» </span></a>${caller.body()}</${tag}>
-</%def>
-
-<%def name="toc()">
- <ul id="toc">
- % for url, name in self.attr.tlist:
- <li><a class="tocLink" href="#${url}">${name}</a></li>
- % endfor
- </ul>
-</%def>
-
-<%def name="preface()"></%def>
+${next.body()}
diff --git a/templates/pages/index.mako b/templates/pages/index.mako
deleted file mode 100644
index 8ce483e..0000000
--- a/templates/pages/index.mako
+++ /dev/null
@@ -1,49 +0,0 @@
-<%!
- title = "Portato"
-%>
-<%inherit file="/page.mako" />
-
-<p>
- Portato is a GUI for the package manager of <a href="http://www.gentoo.org">Gentoo</a> and <a href="http://www.sabayonlinux.org">Sabayon</a> - Portage. It is mostly written in <a href="http://www.python.org">Python</a> for the GTK+-frontend, which is used in most Linux desktop environments (except KDE).
-</p>
-
-<p>
- As the current portage development is quite fast-paced, Portato is not able to keep step. Thus it might be that the released version(s) do not behave as expected. In these cases also try the <a href=${"development" | url}>development version</a>.
-</p>
-
-<%self:h2>Installation</%self:h2>
-<p>
- Portato is delivered with the standard portage tree and can be installed using <code>emerge portato</code>.
- If you want to use the development version, you need to do the following (given you have installed and configured layman ... if not: see <a href="http://www.gentoo.org/proj/en/overlays/userguide.xml">this guide</a>):
-</p>
-
-<%self:hl lang="bash">
-layman -a portato
-echo "=app-portage/portato-9999" >> /etc/portage/package.unmask
-echo "=app-portage/portato-9999" >> /etc/portage/package.keywords
-emerge -av portato
-</%self:hl>
-
-<%self:h2>Translations</%self:h2>
-<p>
- Portato does know about the so called <strong>Native Language Support</strong>. It currently supports the following languages: Catalan, English, Italian, German, Polish, Portugese, and Turkish.
-</p>
-<p>
- If you want to add support for another language, please see the <a href=${"translating" | url}>translation howto</a>.
-</p>
-
-<%self:h2>Forums</%self:h2>
-<p>
- This project itself does not have any forums. But there are a couple of threads in other forums:<br>
- If you are using Gentoo look into <a href="http://forums.gentoo.org/viewtopic-t-502350.html">this forum thread (engl)</a> or into <a href="http://forums.gentoo.org/viewtopic-t-495971.html">the German one</a>. If you are using Sabayon, use <a href="http://sabayonlinux.org/forum/viewtopic.php?f=54&t=10158">this one</a>.
-</p>
-
-<%self:h2>Similar projects</%self:h2>
-<p>
- Of course there are other projects too, which do the same or at least a similar job. These are for example:
-</p>
-<ul>
- <li><a href="http://www.haskell.org/himerge">Himerge</a> - a frontend written in Haskell (yeah ;P)</li>
- <li><a href="http://porthole.sourceforge.net/">Porthole</a> - also written in Python and using GTK+. This frontend inspired me to do my own ;). I also suggest this one as the alternative if Portato does not work as expected.</li>
- <li><a href="http://www.kuroo.org/">Kuroo</a> - a frontend especially aimed for the KDE environment. <em>(Development seems to have stopped)</em>
-</ul>
diff --git a/templates/root.mako b/templates/root.mako
index bfadb2a..627d14a 100644
--- a/templates/root.mako
+++ b/templates/root.mako
@@ -10,7 +10,7 @@
<body>
<div id="wrapper">
<div id="logo">
- <h1><a href=${"" | url}>Kosten</a></h1>
+ <h1><a href=${"/" | url}>Kosten</a></h1>
<h2>»   vom Nec</h2>
</div>
@@ -42,7 +42,7 @@
</%def>
<%def name="style()">
- <link href=${"static/css/style.css" | url} rel="stylesheet" type="text/css" />
+ <link href=${"/static/css/style.css" | url} rel="stylesheet" type="text/css" />
</%def>
<%def name="footer()">