summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark McClain <mark.mcclain@shootq.com>2011-09-23 13:13:59 -0400
committerMark McClain <mark.mcclain@shootq.com>2011-09-23 13:13:59 -0400
commit8882c17986ebb646cbc206f549f45f08f0a1e636 (patch)
treee12527aa3d2bb6daeca88b9f6692557d67a8698f
parent4092b305ecb71399c39c6a4f180a24e918712a6a (diff)
parent0c28bea0390d7eb79e0a5e7b8110dc33245b9041 (diff)
downloadpecan-8882c17986ebb646cbc206f549f45f08f0a1e636.tar.gz
Merge branch 'master' of github.com:pecan/pecan
-rw-r--r--pecan/templates/project/+package+/controllers/root.py24
-rw-r--r--pecan/templates/project/+package+/templates/index.html65
-rw-r--r--pecan/templates/project/+package+/templates/success.html3
-rw-r--r--pecan/templates/project/public/css/style.css14
-rw-r--r--pecan/templates/project/public/images/logo.pngbin0 -> 35094 bytes
5 files changed, 56 insertions, 50 deletions
diff --git a/pecan/templates/project/+package+/controllers/root.py b/pecan/templates/project/+package+/controllers/root.py
index 2990f59..f5f61d3 100644
--- a/pecan/templates/project/+package+/controllers/root.py
+++ b/pecan/templates/project/+package+/controllers/root.py
@@ -1,4 +1,4 @@
-from pecan import expose, request
+from pecan import expose
from formencode import Schema, validators as v
from webob.exc import status_map
@@ -9,13 +9,23 @@ class SampleForm(Schema):
class RootController(object):
- @expose('index.html')
- def index(self, name='', age=''):
- return dict(errors=request.pecan['validation_errors'], name=name, age=age)
+
+ @expose(
+ generic = True,
+ template = 'index.html'
+ )
+ def index(self):
+ return dict()
- @expose('success.html', schema=SampleForm(), error_handler='/index')
- def handle_form(self, name, age):
- return dict(name=name, age=age)
+ @index.when(
+ method = 'POST',
+ template = 'success.html',
+ schema = SampleForm(),
+ error_handler = '/index',
+ htmlfill = dict(auto_insert_errors = True, prefix_error = False)
+ )
+ def index_post(self, name, age):
+ return dict(name=name)
@expose('error.html')
def error(self, status):
diff --git a/pecan/templates/project/+package+/templates/index.html b/pecan/templates/project/+package+/templates/index.html
index 1b7a845..5385e88 100644
--- a/pecan/templates/project/+package+/templates/index.html
+++ b/pecan/templates/project/+package+/templates/index.html
@@ -7,41 +7,36 @@
## now define the body of the template
<header>
- <h1>Welcome to Pecan</h1>
+ <h1><img src="/images/logo.png" /></h1>
</header>
- <p>This is the default Pecan project, which includes:</p>
-
- <ul>
- <li>The ability to serve static files.</li>
- <li>Templating using the <a href="http://www.makotemplates.org">Mako template engine</a>.</li>
- <li>Built-in error management using <a href="http://pypi.python.org/pypi/WebError">WebError</a>.</li>
- </ul>
-
- <p>
- Note that most functionality is enabled/disabled in your <code>app.py</code>,
- which can be edited to suit your needs, and to add additional WSGI middleware.
- </p>
-
- <p>
- To get an idea of how to develop applications with Pecan,
- here is a simple form:
- </p>
-
- <form method="POST" action="/handle_form" class="${'invalid' if errors else ''}">
- <table>
- <tr>
- <td><label for="name">What is your name</label></td>
- <td><input name="name" value="${name}" class="${'invalid' if error_for('name') else ''}" /></td>
- <td>${error_for('name')}</td>
- </tr>
- <tr>
- <td><label for="age">How old are you?</label></td>
- <td><input name="age" value="${age}" class="${'invalid' if error_for('age') else ''}" /></td>
- <td>${error_for('age')}</td>
- </tr>
- </table>
-
- <input type="submit" value="Submit" />
- </form>
+ <div id="content">
+
+ <p>This is a sample Pecan project.</p>
+
+ <p>
+ Instructions for getting started can be found online at <a
+ href="http://pecanpy.org" target="window">pecanpy.org</a>
+ </p>
+
+ <p>
+ To get an idea of how to develop applications with Pecan,
+ here is a simple form:
+ </p>
+
+ <form method="POST" action="/">
+ <table>
+ <tr>
+ <td><label for="name">Your Name:</label></td>
+ <td><input name="name" /></td>
+ </tr>
+ <tr>
+ <td><label for="age">Your Age:</label></td>
+ <td><input name="age" /></td>
+ </tr>
+ </table>
+
+ <input type="submit" value="Submit" />
+ </form>
+ </div>
diff --git a/pecan/templates/project/+package+/templates/success.html b/pecan/templates/project/+package+/templates/success.html
index c51430d..938f006 100644
--- a/pecan/templates/project/+package+/templates/success.html
+++ b/pecan/templates/project/+package+/templates/success.html
@@ -7,6 +7,7 @@
## now define the body
<header>
- <h1>Success!</h1>
+ <h1><img src="/images/logo.png" /></h1>
</header>
<p>Your form submission was successful! Thanks, ${name}!</p>
+ <p><a href="/">Go Back</a></p>
diff --git a/pecan/templates/project/public/css/style.css b/pecan/templates/project/public/css/style.css
index b68a653..8acc9f7 100644
--- a/pecan/templates/project/public/css/style.css
+++ b/pecan/templates/project/public/css/style.css
@@ -2,7 +2,6 @@ body {
background: #311F00;
color: white;
font-family: 'Helvetica Neue', 'Helvetica', 'Verdana', sans-serif;
- font-size: 1.25em;
padding: 1em 2em;
}
@@ -15,17 +14,18 @@ a:hover {
text-decoration: underline;
}
+div#content {
+ width: 800px;
+ margin: 0 auto;
+}
+
form {
margin: 0 1em;
padding: 1em;
border: 5px transparent;
}
-form.invalid {
- border: 5px solid FAFF78;
-}
-
-input.invalid {
+input.error {
background: #FAFF78;
}
@@ -36,4 +36,4 @@ header {
h1, h2, h3, h4, h5, h6 {
font-family: 'Futura-CondensedExtraBold', 'Futura', 'Helvetica', sans-serif;
text-transform: uppercase;
-} \ No newline at end of file
+}
diff --git a/pecan/templates/project/public/images/logo.png b/pecan/templates/project/public/images/logo.png
new file mode 100644
index 0000000..5994d22
--- /dev/null
+++ b/pecan/templates/project/public/images/logo.png
Binary files differ