Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update with jinja2 template

  • Loading branch information...
commit 9685ef965d6b2d0f5311da1ab6d8a1ebe7fc8837 1 parent 50530a5
Whit Morriss authored
View
2  CHANGES.txt
@@ -1,4 +1,4 @@
0.0
---
-- Initial version
+- Initial version
View
4 README.txt
@@ -0,0 +1,4 @@
+CheesePrism README
+
+
+
View
23 cheeseprism/__init__.py
@@ -1,12 +1,23 @@
from pyramid.config import Configurator
-from cheeseprism.resources import Root
+from pyramid_jinja2 import renderer_factory
+from cheeseprism.models import get_root
def main(global_config, **settings):
- """ This function returns a Pyramid WSGI application.
+ """ This function returns a WSGI application.
+
+ It is usually called by the PasteDeploy framework during
+ ``paster serve``.
"""
- config = Configurator(root_factory=Root, settings=settings)
+ settings = dict(settings)
+ settings.setdefault('jinja2.i18n.domain', 'CheesePrism')
+
+ config = Configurator(root_factory=get_root, settings=settings)
+ config.add_translation_dirs('locale/')
+ config.include('pyramid_jinja2')
+
+ config.add_static_view('static', 'static')
config.add_view('cheeseprism.views.my_view',
- context='cheeseprism:resources.Root',
- renderer='cheeseprism:templates/mytemplate.pt')
- config.add_static_view('static', 'cheeseprism:static', cache_max_age=3600)
+ context='cheeseprism.models.MyModel',
+ renderer="mytemplate.jinja2")
+
return config.make_wsgi_app()
View
21 cheeseprism/locale/CheesePrism.pot
@@ -0,0 +1,21 @@
+# Translations template for PROJECT.
+# Copyright (C) 2011 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2011-05-12 09:14-0330\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+msgid "Hello!"
+msgstr ""
View
BIN  cheeseprism/locale/de/LC_MESSAGES/CheesePrism.mo
Binary file not shown
View
21 cheeseprism/locale/de/LC_MESSAGES/CheesePrism.po
@@ -0,0 +1,21 @@
+# Translations template for PROJECT.
+# Copyright (C) 2011 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2011-05-12 09:14-0330\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+msgid "Hello!"
+msgstr "Hallo!"
View
BIN  cheeseprism/locale/fr/LC_MESSAGES/CheesePrism.mo
Binary file not shown
View
21 cheeseprism/locale/fr/LC_MESSAGES/CheesePrism.po
@@ -0,0 +1,21 @@
+# Translations template for PROJECT.
+# Copyright (C) 2011 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2011-05-12 09:14-0330\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+msgid "Hello!"
+msgstr "Bonjour!"
View
8 cheeseprism/models.py
@@ -0,0 +1,8 @@
+class MyModel(object):
+ pass
+
+root = MyModel()
+
+
+def get_root(environ):
+ return root
View
BIN  cheeseprism/static/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
52 cheeseprism/static/pylons.css
@@ -4,26 +4,37 @@ body{line-height:1;}
ol,ul{list-style:none;}
blockquote,q{quotes:none;}
blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;}
+/* remember to define focus styles! */
:focus{outline:0;}
+/* remember to highlight inserts somehow! */
ins{text-decoration:none;}
del{text-decoration:line-through;}
+/* tables still need 'cellspacing="0"' in the markup */
table{border-collapse:collapse;border-spacing:0;}
+/* restyling */
sub{vertical-align:sub;font-size:smaller;line-height:normal;}
sup{vertical-align:super;font-size:smaller;line-height:normal;}
+/* lists */
ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;}
ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;}
li{display:list-item;}
+/* nested lists have no top/bottom margins */
ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;}
+/* 2 deep unordered lists use a circle */
ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;}
+/* 3 deep (or more) unordered lists use a square */
ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;}
.hidden{display:none;}
p{line-height:1.5em;}
-h1{font-size:1.75em;line-height:1.7em;font-family:helvetica,verdana;}
-h2{font-size:1.5em;line-height:1.7em;font-family:helvetica,verdana;}
-h3{font-size:1.25em;line-height:1.7em;font-family:helvetica,verdana;}
+h1{font-size:1.75em;/* 28px */
+line-height:1.7em;font-family:helvetica,verdana;}
+h2{font-size:1.5em;/* 24px */
+line-height:1.7em;font-family:helvetica,verdana;}
+h3{font-size:1.25em;/* 20px */
+line-height:1.7em;font-family:helvetica,verdana;}
h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;}
html,body{width:100%;height:100%;}
-body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "NobileRegular","Lucida Grande",Lucida,Verdana,sans-serif;}
+body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "Nobile","Lucida Grande",Lucida,Verdana,sans-serif;}
a{color:#1b61d6;text-decoration:none;}
a:hover{color:#e88f00;text-decoration:underline;}
body h1,
@@ -31,26 +42,23 @@ body h2,
body h3,
body h4,
body h5,
-body h6{font-family:"NeutonRegular","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#373839;font-style:normal;}
-#wrap{min-height:100%;}
-#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;vertical-align:middle;}
-#header{background:#000000;top:0;font-size:14px;}
-#footer{bottom:0;background:#000000 url(footerbg.png) repeat-x 0 top;position:relative;margin-top:-40px;clear:both;}
-.header,.footer{width:750px;margin-right:auto;margin-left:auto;}
+body h6{font-family:"Nobile","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#144fb2;font-style:normal;}
+#wrap {min-height: 100%;}
+#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;}
+#header{background-color:#e88f00;top:0;font-size:14px;}
+#footer{background-color:#000000;bottom:0;position: relative;margin-top:-40px;clear:both;}
+.header,.footer{width:700px;margin-right:auto;margin-left:auto;}
.wrapper{width:100%}
-#top,#top-small,#bottom{width:100%;}
-#top{color:#000000;height:230px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;}
-#top-small{color:#000000;height:60px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;}
-#bottom{color:#222;background-color:#ffffff;}
-.top,.top-small,.middle,.bottom{width:750px;margin-right:auto;margin-left:auto;}
-.top{padding-top:40px;}
-.top-small{padding-top:10px;}
-#middle{width:100%;height:100px;background:url(middlebg.png) repeat-x;border-top:2px solid #ffffff;border-bottom:2px solid #b2b2b2;}
+#top,#bottom{width:100%;}
+#top{color:#888;background-color:#eee;height:300px;border-bottom:2px solid #ddd;}
+#bottom{color:#222;background-color:#ffffff;overflow:auto;padding-bottom:80px;}
+.top,.bottom{width:700px;margin-right:auto;margin-left:auto;}
+.top{padding-top:100px;}
.app-welcome{margin-top:25px;}
.app-name{color:#000000;font-weight:bold;}
.bottom{padding-top:50px;}
-#left{width:350px;float:left;padding-right:25px;}
-#right{width:350px;float:right;padding-left:25px;}
+#left{width:325px;float:left;padding-right:25px;}
+#right{width:325px;float:right;padding-left:25px;}
.align-left{text-align:left;}
.align-right{text-align:right;}
.align-center{text-align:center;}
@@ -59,7 +67,7 @@ ul.links li{list-style-type:none;font-size:14px;}
form{border-style:none;}
fieldset{border-style:none;}
input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;}
-input[type=text],input[type=password]{width:205px;}
+input[type=text]{}
input[type=submit]{background-color:#ddd;font-weight:bold;}
/*Opera Fix*/
-body:before{content:"";height:100%;float:left;width:0;margin-top:-32767px;}
+body:before {content:"";height:100%;float:left;width:0;margin-top:-32767px;}
View
87 cheeseprism/templates/mytemplate.jinja2
@@ -0,0 +1,87 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal">
+<head>
+ <title>The Pyramid Web Application Development Framework</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
+ <meta name="keywords" content="python web application" />
+ <meta name="description" content="pyramid web application" />
+ <link rel="shortcut icon" href="{{request.application_url}}/static/favicon.ico" />
+ <link rel="stylesheet" href="{{request.application_url}}/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
+ <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Nobile:regular,italic,bold,bolditalic&amp;subset=latin" type="text/css" media="screen" charset="utf-8" />
+ <!--[if !IE 7]>
+ <style type="text/css">
+ #wrap {display:table;height:100%}
+ </style>
+ <![endif]-->
+ <style>
+ .locale { text-align: center; }
+ .locale-name { font-weight: bold; }
+ </style>
+</head>
+<body>
+ <div id="wrap">
+ <div id="header">
+ <div class="header">The Pyramid Web Application Development Framework</div>
+ </div>
+ <div id="top">
+ <div class="top align-center">
+ <img src="{{request.application_url}}/static/logo.png" width="300" height="80"/>
+ <p class="app-welcome">
+ Welcome to <span class="app-name">{{project}}</span>, an application generated by<br/>
+ the Pyramid web application development framework.
+ </p>
+ </div>
+ </div>
+ <div id="bottom">
+ <div class="locale">
+ <h2>{% trans %}Hello!{% endtrans %}</h2>
+ <p>Request performed with <span class="locale-name">{{ request.locale_name }}</span> locale.</p>
+ </div>
+ <div class="bottom">
+ <div id="left" class="align-right">
+ <h3>Search Pyramid documentation</h3>
+ <form method="get" action="http://docs.pylonshq.com/pyramid/dev/search.html">
+ <input type="text" id="q" name="q" value="" />
+ <input type="submit" id="x" value="Search" />
+ </form>
+ </div>
+ <div id="right" class="align-left">
+ <h3>Pyramid links</h3>
+ <ul class="links">
+ <li>
+ <a href="http://pylonshq.com">Pylons Website</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/">The Pylons Project Documentation</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/pyramid/dev/#narrative-documentation">Narrative Documentation</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/pyramid/dev/#api-documentation">API Documentation</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/pyramid/dev/#tutorials">Tutorials</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/pyramid/dev/#change-history">Change History</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/pyramid/dev/#sample-applications">Sample Applications</a>
+ </li>
+ <li>
+ <a href="http://docs.pylonshq.com/pyramid/dev/#support-and-development">Support and Development</a>
+ </li>
+ <li>
+ <a href="irc://irc.freenode.net#pyramid">IRC Channel</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div id="footer">
+ <div class="footer">© Copyright 2008-2010, Agendaless Consulting.</div>
+ </div>
+</body>
+</html>
View
15 cheeseprism/tests.py
@@ -1,16 +1,21 @@
import unittest
-
from pyramid import testing
+from pyramid.i18n import TranslationStringFactory
+
+_ = TranslationStringFactory('cheeseprism')
+
class ViewTests(unittest.TestCase):
- def setUp(self):
- self.config = testing.setUp()
+ def setUp(self):
+ testing.setUp()
+
def tearDown(self):
testing.tearDown()
def test_my_view(self):
from cheeseprism.views import my_view
request = testing.DummyRequest()
- info = my_view(request)
- self.assertEqual(info['project'], 'CheesePrism')
+ response = my_view(request)
+ self.assertEqual(response['project'], 'CheesePrism')
+
View
4 cheeseprism/views.py
@@ -1,2 +1,6 @@
+from pyramid.i18n import TranslationStringFactory
+
+_ = TranslationStringFactory('CheesePrism')
+
def my_view(request):
return {'project':'CheesePrism'}
View
22 development.ini
@@ -1,13 +1,17 @@
-[app:main]
+[app:CheesePrism]
use = egg:CheesePrism
-
-pyramid.reload_templates = true
-pyramid.debug_authorization = false
-pyramid.debug_notfound = false
-pyramid.debug_routematch = false
-pyramid.debug_templates = true
-pyramid.default_locale_name = en
-pyramid.includes = pyramid_debugtoolbar
+reload_templates = true
+debug_authorization = false
+debug_notfound = false
+debug_routematch = false
+debug_templates = true
+default_locale_name = en
+jinja2.directories = cheeseprism:templates
+
+[pipeline:main]
+pipeline =
+ egg:WebError#evalerror
+ CheesePrism
[server:main]
use = egg:Paste#http
View
3  message-extraction.ini
@@ -0,0 +1,3 @@
+[python: **.py]
+[jinja2: **.jinja2]
+encoding = utf-8
View
34 production.ini
@@ -1,12 +1,30 @@
-[app:main]
+[app:CheesePrism]
use = egg:CheesePrism
-
-pyramid.reload_templates = false
-pyramid.debug_authorization = false
-pyramid.debug_notfound = false
-pyramid.debug_routematch = false
-pyramid.debug_templates = false
-pyramid.default_locale_name = en
+reload_templates = false
+debug_authorization = false
+debug_notfound = false
+debug_routematch = false
+debug_templates = false
+default_locale_name = en
+
+[filter:weberror]
+use = egg:WebError#error_catcher
+debug = false
+;error_log =
+;show_exceptions_in_wsgi_errors = true
+;smtp_server = localhost
+;error_email = janitor@example.com
+;smtp_username = janitor
+;smtp_password = "janitor's password"
+;from_address = paste@localhost
+;error_subject_prefix = "Pyramid Error"
+;smtp_use_tls =
+;error_message =
+
+[pipeline:main]
+pipeline =
+ weberror
+ CheesePrism
[server:main]
use = egg:Paste#http
View
1  setup.cfg
@@ -14,6 +14,7 @@ statistics = true
add_comments = TRANSLATORS:
output_file = cheeseprism/locale/CheesePrism.pot
width = 80
+mapping_file = message-extraction.ini
[init_catalog]
domain = CheesePrism
View
3  setup.py
@@ -6,7 +6,7 @@
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
-requires = ['pyramid', 'pyramid_debugtoolbar']
+requires=['pyramid>=1.0a10', 'pyramid_jinja2', 'WebError']
setup(name='CheesePrism',
version='0.0',
@@ -34,4 +34,3 @@
""",
paster_plugins=['pyramid'],
)
-
Please sign in to comment.
Something went wrong with that request. Please try again.