Permalink
Browse files

- forgot to push this minor change :p

  • Loading branch information...
2 parents 22453d8 + 7683002 commit 6e26212293fd190060d899b2f0b0238753d806e5 @elpargo elpargo committed Oct 7, 2009
View
@@ -0,0 +1 @@
+1b217de099a87ce91e881fe410209259146c4f7c 2.1a1
View
@@ -0,0 +1,2 @@
+recursive-include devtools/commands/quickstart_mako *
+recursive-include devtools/templates *
@@ -48,6 +48,7 @@
from paste.script import command
from paste.script import create_distro
import os
+import shutil
import stat
import sys
@@ -92,6 +93,9 @@ class QuickstartCommand(command.Command):
parser.add_option("-a", "--auth",
help='add authentication and authorization support',
action="store_true", dest="auth")
+ parser.add_option("-m", "--mako",
+ help="default templates mako",
+ action="store_true", dest="mako", default=None)
parser.add_option("-g", "--geo",
help="add GIS support",
action="store_true", dest="geo")
@@ -138,6 +142,10 @@ def command(self):
self.package = raw_input(
"Enter package name [%s]: " % package).strip() or package
+ if self.mako == None:
+ mako = raw_input("Would you prefer mako templates? (yes/[no]): ")
+ self.mako = dict(y=True, n=False).get(mako.lstrip()[:1].lower(), False)
+
if not self.no_input:
while self.auth is None:
self.auth = raw_input(
@@ -200,6 +208,7 @@ def command(self):
cmd_args.append("geo=%s" % self.geo)
cmd_args.append("package=%s" % self.package)
cmd_args.append("tgversion=%s" % self.version)
+ cmd_args.append("mako=%s"%self.mako)
# set the exact ORM-version for the proper requirements
# it's extracted from our own requirements, so looking
# them up must be in sync (there must be the extras_require named
@@ -244,3 +253,15 @@ def command(self):
for file in files:
if file == "empty":
os.remove(os.path.join(base, file))
+
+ if self.mako:
+ print 'Writing mako template files to ./'+os.path.join(self.name, 'templates')
+
+ #remove existing template files
+ package_template_dir = os.path.abspath(os.path.join(self.name, 'templates'))
+ shutil.rmtree(package_template_dir, ignore_errors=True)
+# os.mkdir(package_template_dir)
+
+ #replace template files with mako ones
+ mako_template_dir = os.path.abspath(os.path.dirname(__file__))+'/quickstart_mako'
+ shutil.copytree(mako_template_dir, package_template_dir)
@@ -0,0 +1,109 @@
+<%inherit file="local:templates.master"/>
+
+<%def name="title()">
+Learning TurboGears 2.0: Quick guide to the Quickstart pages.
+</%def>
+
+${parent.sidebar_top()}
+${parent.sidebar_bottom()}
+ <div id="getting_started">
+ <h2>Architectural basics of a quickstart TG2 site.</h2>
+ <p>The TG2 quickstart command produces this basic TG site. Here's how it works.</p>
+ <ol id="getting_started_steps">
+ <li class="getting_started">
+ <h3>Code my data model</h3>
+ <p> When you want a model for storing favorite links or wiki content,
+ the <strong>/model</strong> folder in your site is ready to go.</p>
+ <p> You can build a dynamic site without any data model at all. There
+ still be a default data-model template for you if you didn't enable
+ authentication and authorization in quickstart. If you have enabled
+ authorization, the auth data-model is ready-made.</p>
+ </li>
+ <li class="getting_started">
+ <h3>Design my URL structure</h3>
+ <p> The "<span class="code">root.py</span>" file under the
+ <strong>/controllers</strong> folder has your URLs. When you
+ called the url or this page (<span class="code"><a href="${tg.url('/about')}">/about</a></span>),
+ the command went through the RootController class to the
+ <span class="code">about</span><span class="code">()</span> method.</p>
+ <p> Those Python methods are responsible to create the dictionary of
+ variables that will be used in your web views (template).</p>
+ </li>
+ <li class="getting_started">
+ <h3>Reuse the web page elements</h3>
+ <p> A web page viewed by user could be constructed by single or
+ several reusable templates under <strong>/templates</strong>.
+ Take 'about' page for example, each reusable template generating
+ a part of the page.</p>
+
+ <p> <strong><span class="code">about.mak</span></strong> - This is the
+ template that created this page. If you take a look at this template
+ you will see that there are a lot of wacky symbols, if you are not familiar
+ with <a href="http://www.makotemplates.org">Mako</a> you should probably
+ check out the docs on their site. </p>
+
+ <p>Let's take a look at what this template does in order of execution.
+ The first thing this template does
+ is inherit from <strong><span class="code">master.mak</span></strong>. We'll
+ go into the details of this later, but for now just know that this
+ template is allowed to both call on master.mak, and also override it's
+ capabilites. This inheritance is what gives mako it's power to
+ provide reusable templates.
+ </p>
+ <p>But um, whats that 'local:' stuff about? </p>
+ <p>
+ Well, TG wants to provide re-usable components like tgext.admin, and also
+ provide a way for you to use your default site layouts. This is done
+ easily by providing a shortcut to the namespace of your project, so the
+ component template finder can find <strong>your</strong> master.html and format
+ itself the way you want it to.
+ </p>
+ <p> The next thing about.mak does is to create a function called title()
+ which provides the title for the document. This overrides the title
+ method provided by master.mak, and therefore, when the template
+ is rendered, it will use the title provided by this funciton.
+
+ <p>
+ Next, there are a couple of calls to the master template to set up the
+ boxes you see in the page over on the right, We'll examine what
+ these are in the master template in a second. Finally, we get to the meat
+ of the document, and that's pretty much all about.mak does
+ </p>
+
+ <p> <strong><span class="code">master.mak</span></strong> -
+ This template provides the overall layout for your project, and
+ allows you to override different elements of the overall structure
+ of your default look-and-feel. Let's take a look at this template
+ from top to bottom again.</p>
+ <p>The first 15 lines provide an overall layout for the document,
+ with definitions for the header, title and body. Each one of these
+ sections has been turned into a method that you can change within your
+ child templates, but you do not have to provide any single one of them
+ TurboGears extensions may however expect these methods to be provided
+ to display their content properly. Keep this in mind if you decide
+ to alter your master.mak. You are of course always free to modify
+ your master template, but doing so can render your extensions useless,
+ so tread carefully.</p>
+
+ <p> The next section describes the overall layout for the body of the
+ document, with flash messages appearing at the top, and self.body()
+ appearing at the bottom. self.body will take whatever is not defined
+ as a method in your child template and render it in this space. This
+ is really useful because it allows you to be freestyle with your
+ body definition. If you don't want to override any of the master
+ template defines, all you have to do is inherit the master, and then
+ provide the code you want to appear surrounded by your header and footer.
+ </p>
+
+ <p>
+ Next are the title, header, footer and sidebar defines. These are all of
+ course overriddable.
+ </p>
+
+ <p>The final define sets up the menubar. This provides some links,
+ as well as a way of highlighing the page you are currently on.
+ </p>
+ </li>
+ </ol>
+ <p>Good luck with TurboGears 2!</p>
+</div
@@ -0,0 +1,54 @@
+<%inherit file="local:templates.master"/>
+<%def name="title()">Learning TurboGears 2.0: Quick guide to authentication.</%def>
+
+${parent.sidebar_top()}
+${parent.sidebar_bottom()}
+ <div id="getting_started">
+ <h2>Authentication &amp; Authorization in a TG2 site.</h2>
+ <p>If you have access to this page, this means you have enabled authentication and authorization
+ in the quickstart to create your project.</p>
+ <p>
+ The paster command will have created a few specific controllers for you. But before you
+ go to play with those controllers you'll need to make sure your application has been
+ properly bootstapped.
+ This is dead easy, here is how to do this:
+ </p>
+
+ <span class="code">
+ paster setup-app development.ini
+ </span>
+
+ <p>
+ inside your application's folder and you'll get a database setup (using the preferences you have
+ set in your development.ini file). This database will also have been prepopulated with some
+ default logins/passwords so that you can test the secured controllers and methods.
+ </p>
+ <p>
+ To change the comportement of this setup-app command you just need to edit the <span class="code">websetup.py</span> file.
+ </p>
+ <p>
+ Now try to visiting the <a href="${tg.url('/manage_permission_only')}">manage_permission_only</a> URL. You will be challenged with a login/password form.
+ </p>
+ <p>
+ Only managers are authorized to visit this method. You will need to log-in using:
+ <p>
+ <span class="code">
+ login: manager
+ </span>
+ </p>
+ <p>
+ <span class="code">
+ password: managepass
+ </span>
+ </p>
+ </p>
+ <p>
+ Another protected resource is <a href="${tg.url('/editor_user_only')}">editor_user_only</a>. This one is protected by a different set of permissions.
+ You will need to be <span class="code">editor</span> with a password of <span class="code">editpass</span> to be able to access it.
+ </p>
+ <p>
+ The last kind of protected resource in this quickstarted app is a full so called <a href="${tg.url('/secc')}">secure controller</a>. This controller is protected globally.
+ Instead of having a @require decorator on each method, we have set an allow_only attribute at the class level. All the methods in this controller will
+ require the same level of access. You need to be manager to access <a href="${tg.url('/secc')}">secc</a> or <a href="${tg.url('/secc/some_where')}">secc/some_where</a>.
+ </p>
+ </div>
@@ -0,0 +1,31 @@
+<%inherit file="local:templates.master"/>
+
+<%def name="title()">
+ Welcome to TurboGears 2.0, standing on the shoulders of giants, since 2007
+</%def>
+
+${parent.sidebar_top()}
+
+<h2>Content Type Dispatch</h2>
+<p>
+This page shows how you can provide multiple pages
+directly from the same controller method. This page is generated
+from the expose decorator with the template defintion provided.
+You can provide a url with parameters and this page will display
+the parameters as html, and the json version will express
+the entries as JSON. Here, try it out: <a href="/data.html?a=1&b=2">/data.html?a=1&b=2</a>
+</p>
+
+<p>Click here for the <a href="${tg.url('/data.json', params=params)}">JSON Version of this page.</a></p>
+<p>The data provided in the template call is:
+ <table>
+ %for key, value in params.iteritems():
+ <tr>
+ <td>${key}</td>
+ <td>${value}</td>
+ </tr>
+ %endfor
+ </table>
+
+
+<%def name="sidebar_bottom()"></%def>
@@ -0,0 +1,26 @@
+<%inherit file="local:templates.master"/>
+
+<%def name="title()">
+ Learning TurboGears 2.0: Information about TG and WSGI
+</%def>
+
+${parent.sidebar_top()}
+<h2>The WSGI nature of the framework</h2>
+ <p>In this page you can see all the WSGI variables your request object has,
+ the ones in capital letters are required by the spec, then a sorted by
+ component list of variables provided by the Components, and at last
+ the "wsgi." namespace with very useful information about your WSGI Server</p>
+ <p>The keys in the environment are:
+ <table>
+ %for key in sorted(environment):
+ <tr>
+ <td>${key}</td>
+ <td>${environment[key]}</td>
+ </tr>
+ %endfor
+ </table>
+
+ </p>
+
+
+<%def name="sidebar_bottom()"></%def>
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+ <title>A ${code} Error has Occurred </title>
+</head>
+
+<body>
+<h1>Error ${code}</h1>
+
+<div>${message | n}</div>
+</body>
+</html>
@@ -0,0 +1,8 @@
+<%def name="header()">
+ <div id="header">
+ <h1>
+ Welcome to TurboGears 2
+ <span class="subtitle">The Python web metaframework</span>
+ </h1>
+ </div>
+</%def>
@@ -0,0 +1,32 @@
+<%inherit file="local:templates.master"/>
+
+<%def name="title()">
+ Welcome to TurboGears 2.0, standing on the shoulders of giants, since 2007
+</%def>
+
+${parent.sidebar_top()}
+
+<div id="getting_started">
+ <h2>Presentation</h2>
+ <p>TurboGears 2 is rapid web application development toolkit designed to make your life easier.</p>
+ <ol id="getting_started_steps">
+ <li class="getting_started">
+ <h3>Code your data model</h3>
+ <p> Design your data model, Create the database, and Add some bootstrap data.</p>
+ </li>
+ <li class="getting_started">
+ <h3>Design your URL architecture</h3>
+ <p> Decide your URLs, Program your controller methods, Design your
+ templates, and place some static files (CSS and/or JavaScript). </p>
+ </li>
+ <li class="getting_started">
+ <h3>Distribute your app</h3>
+ <p> Test your source, Generate project documents, Build a distribution.</p>
+ </li>
+ </ol>
+</div>
+<div class="clearingdiv" />
+<div class="notice"> Thank you for choosing TurboGears.
+</div>
+
+<%def name="sidebar_bottom()"></%def>
@@ -0,0 +1,10 @@
+<%inherit file="local:templates.master"/>
+<%def name="title()">Login Form</%def>
+<div id="loginform">
+<form action="${tg.url('/login_handler', came_from = came_from.encode('utf-8'), __logins = login_counter.encode('utf-8'))}" method="POST" class="loginfields">
+ <h2><span>Login</span></h2>
+ <label for="login">Username:</label><input type="text" id="login" name="login" class="text"></input><br/>
+ <label for="password">Password:</label><input type="password" id="password" name="password" class="text"></input>
+ <input type="submit" id="submit" value="Login" />
+</form>
+</div>
Oops, something went wrong.

0 comments on commit 6e26212

Please sign in to comment.