From f0012811f8af8b1334b46781861a6dd3777ee392 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Mon, 3 May 2010 18:21:53 +0200 Subject: First import from portato proj --- .gitignore | 2 + __init__.py | 1 + controller.py | 19 ++++ helper.py | 16 +++ index.py | 26 +++++ renderer.py | 40 +++++++ static/css/style.css | 275 +++++++++++++++++++++++++++++++++++++++++++++ templates/404.mako | 7 ++ templates/menu.mako | 5 + templates/page.mako | 46 ++++++++ templates/pages/index.mako | 49 ++++++++ templates/root.mako | 61 ++++++++++ 12 files changed, 547 insertions(+) create mode 100644 .gitignore create mode 100644 __init__.py create mode 100644 controller.py create mode 100644 helper.py create mode 100755 index.py create mode 100644 renderer.py create mode 100644 static/css/style.css create mode 100644 templates/404.mako create mode 100644 templates/menu.mako create mode 100644 templates/page.mako create mode 100644 templates/pages/index.mako create mode 100644 templates/root.mako diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..034ed13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +.*.sw? diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..c3189d1 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +from index import app diff --git a/controller.py b/controller.py new file mode 100644 index 0000000..e4c07f7 --- /dev/null +++ b/controller.py @@ -0,0 +1,19 @@ +from __future__ import with_statement + +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) + +def FourOhFour(page="?"): + """ + 404 error page. + """ + return web.notfound(render("404", level = "", page = page)) diff --git a/helper.py b/helper.py new file mode 100644 index 0000000..69d6ab2 --- /dev/null +++ b/helper.py @@ -0,0 +1,16 @@ +import web +import os +import cStringIO + +opj = os.path.join + +# some nice imports +import itertools as it + + +APPDIR = os.path.dirname(os.path.abspath(__file__)) +def appdir (*args): + return os.path.join(APPDIR, *args) + +def url (path): + return "\"%s\"" % web.url(path) diff --git a/index.py b/index.py new file mode 100755 index 0000000..b91418d --- /dev/null +++ b/index.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import web +import controller + +# +# URL Mappings +# +urls = ( + "/r/(.*)", controller.Redirect, + "/(.*)", controller.Page + ) + +# +# The App +# +app = web.application(urls, globals()) +app.notfound = controller.FourOhFour + +# debug for the moment +web.config.debug = True + +# +# And go! +if __name__ == "__main__": + app.run() diff --git a/renderer.py b/renderer.py new file mode 100644 index 0000000..b8ce716 --- /dev/null +++ b/renderer.py @@ -0,0 +1,40 @@ +import os +import web +import mako +from mako.lookup import TemplateLookup + +import helper + +class Renderer: + """ + Renderer loading the correct Mako Templates + """ + def __init__ (self): + self.lookup = TemplateLookup( + directories=[helper.appdir('templates')], + module_directory = "/tmp/webpy/kosten/", + input_encoding='utf-8', + output_encoding='utf-8', + format_exceptions = True) + + def render (self, tpl, level = "pages" , **kwargs): + try: + t = self.get_tpl(tpl, level) + 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) + + __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): + if not tpl.endswith(".mako"): + tpl = tpl+".mako" + + return os.path.join(level, tpl) + +# the one and only instance :) +render = Renderer() diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..26973a7 --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,275 @@ +/* +Design by Free CSS Templates +http://www.freecsstemplates.org +Released for free under a Creative Commons Attribution 2.5 License +*/ + +body { + margin: 0; + padding: 0; + background: #000000; + font-size: 13px; + font-family: "Trebuchet MS", Georgia, "Times New Roman", Times, serif; + text-align: justify; + color: #FFFFFF; +} + + +h1, h2, h3 { + margin: 0; + text-transform: lowercase; + font-weight: normal; + color: #FFFFFF; +} + +h1 { + letter-spacing: -1px; + font-size: 32px; +} + +h2 { + font-size: 23px; +} + +h3 { + font-size: 18px; +} + +p, ul, ol { + text-align: justify; + line-height: 20px; +} + +p + h2, p + h3 { + margin-top: 1.5em; +} + +a:link { + color: #8BD80E; +} + +a:hover, a:active { + text-decoration: none; + color: #8BD80E; +} + +a:visited { + color: #8BD80E; +} + +img { + border: none; +} + +img.left { + float: left; + margin-right: 15px; +} + +img.right { + float: right; + margin-left: 15px; +} + +/* Header */ + +#header { + width: 713px; + margin: 0 auto; + height: 42px; +} + +#wrapper { + margin: 0; + padding: 0; + background: #FFFFFF url(../images/img01.gif) repeat-x left top; +} + +/* Menu */ + +#menu { + float: left; + width: 713px; + height: 50px; + background: url(../images/img02.gif) no-repeat left top; +} + +#menu ul { + margin: 0; + padding: 0px 0 0 10px; + list-style: none; + line-height: normal; +} + +#menu li { + display: block; + float: left; +} + +#menu a { + display: block; + float: left; + background: url(../images/img04.gif) no-repeat right 55%; + margin-top: 5px; + margin-right: 3px; + padding: 8px 17px; + text-decoration: none; + font-size: 13px; + color: #000000; +} + +#menu a:hover { + color: #000000; +} + +#menu .current_page_item a { + color: #000000; +} + +/** LOGO */ + +#logo { + width: 713px; + height: 80px; + margin: 0 auto; +} + +#logo h1, #logo h2, #logo img { + float: left; + margin: 0; + padding: 30px 0 0 0px; + line-height: normal; +} + +#logo img { + float: left; + margin-right: 15px; + padding: 30px 0 0 0px; +} + +#logo h1 { + font-family: Georgia, "Times New Roman", Times, serif; + font-size:40px; +} + +#logo h1 a { + text-decoration: none; + color: #4C4C4C; +} + +#logo h1 a:hover { text-decoration: underline; } + +#logo h2 { + float: left; + padding: 45px 0 0 18px; + font: 18px Georgia, "Times New Roman", Times, serif; + color: #8BD80E; +} + +#logo p a { + text-decoration: none; + color: #8BD80E; +} + +#logo p a:hover { text-decoration: underline; } + +/* Page */ + +#page { + width: 663px; + margin: 0 auto; + background: #4C4C4C url(../images/img03.gif) no-repeat left bottom; + padding: 0 25px; +} + +/* Post */ + +.content { + float: left; + width: 620px; + padding: 15px 0px; + margin-bottom: 20px; +} + +.content .title { + margin-bottom: 20px; + padding-bottom: 5px; +} + +.content h2, .content h3 { + margin-bottom: 0.5em; +} + +.hstart { + font: 18px Georgia, "Times New Roman", Times, serif; + color: #8BD80E; +} + +/* Boxes */ + +.box { + background: #9e9e9e; + color: #000; + padding: 5px; + margin: 0.5em 0.5em 2em 0.5em; +} + +.box h2, .box h3 { + margin-bottom: 15px; + font-size: 16px; + color: #FFFFFF; +} + +.box ul { + margin: 0; + padding: 0; + list-style: none; +} + +.box a:link, .box a:hover, .box a:active, .box a:visited { + color: #EDEDED; +} + +.box > pre { + margin: 0; + padding: 0; + overflow: auto; +} + +/* Table of contents */ + +ul#toc { +} + +.tocLink { +} + +/* Footer */ +#footer-wrap { +} + +#footer { + margin: 0 auto; + padding: 20px 0 10px 0; + background: #000000; +} + +html>body #footer { + height: auto; +} + +#footer p { + font-size: 11px; +} + +#legal { + clear: both; + padding-top: 17px; + text-align: center; + color: #FFFFFF; +} + +#legal a { + font-weight: normal; + color: #FFFFFF; +} diff --git a/templates/404.mako b/templates/404.mako new file mode 100644 index 0000000..aeb95e3 --- /dev/null +++ b/templates/404.mako @@ -0,0 +1,7 @@ +<%! + title = "404 -- Page not found!" +%> +<%inherit file="/page.mako" /> +

+Sorry - the requested page ${page} cannot be found. +

diff --git a/templates/menu.mako b/templates/menu.mako new file mode 100644 index 0000000..64701b2 --- /dev/null +++ b/templates/menu.mako @@ -0,0 +1,5 @@ +<%! + menu = [ + ("/index", "Kosten"), + ] +%> diff --git a/templates/page.mako b/templates/page.mako new file mode 100644 index 0000000..aa2aa51 --- /dev/null +++ b/templates/page.mako @@ -0,0 +1,46 @@ +<%! + title = "" + uses_toc = False +%> +<% + page_text = capture(next.body) +%> + +<%inherit file="/root.mako" /> + +## content + +

${self.attr.title}

+% 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}>» ${caller.body()} + + +<%def name="toc()"> + + + +<%def name="preface()"> diff --git a/templates/pages/index.mako b/templates/pages/index.mako new file mode 100644 index 0000000..8ce483e --- /dev/null +++ b/templates/pages/index.mako @@ -0,0 +1,49 @@ +<%! + title = "Portato" +%> +<%inherit file="/page.mako" /> + +

+ Portato is a GUI for the package manager of Gentoo and Sabayon - Portage. It is mostly written in Python for the GTK+-frontend, which is used in most Linux desktop environments (except KDE). +

+ +

+ 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 development version. +

+ +<%self:h2>Installation +

+ Portato is delivered with the standard portage tree and can be installed using emerge portato. + If you want to use the development version, you need to do the following (given you have installed and configured layman ... if not: see this guide): +

+ +<%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:h2>Translations +

+ Portato does know about the so called Native Language Support. It currently supports the following languages: Catalan, English, Italian, German, Polish, Portugese, and Turkish. +

+

+ If you want to add support for another language, please see the translation howto. +

+ +<%self:h2>Forums +

+ This project itself does not have any forums. But there are a couple of threads in other forums:
+ If you are using Gentoo look into this forum thread (engl) or into the German one. If you are using Sabayon, use this one. +

+ +<%self:h2>Similar projects +

+ Of course there are other projects too, which do the same or at least a similar job. These are for example: +

+ diff --git a/templates/root.mako b/templates/root.mako new file mode 100644 index 0000000..bfadb2a --- /dev/null +++ b/templates/root.mako @@ -0,0 +1,61 @@ + + + + + + ${self.title()} + ${self.style()} + + + +
+ + + +
+ +
+
+ ${next.body()} +
+
 
+
+ + + + +## functions + +<%def name="title()"> + Kostenverwaltung + + +<%def name="style()"> + + + +<%def name="footer()"> + powered by mako & web.py | + © 2010. All Rights Reserved. René Neumann | + with the help of Free CSS Templates. + + +<%def name="menu()"> + <%namespace file="menu.mako" name="m" /> + + -- cgit v1.2.3-70-g09d2