Commits

Andriy Kornatskyy committed a06d98d

Completed with preprocessor templates in demo.

Comments (0)

Files changed (19)

demos/template/Makefile

 		content/templates-jinja2/shared/**/*.html \
 		content/templates-mako/shared/**/*.html \
 		content/templates-tenjin/shared/**/*.html \
-		content/templates-wheezy/preprocessor/shared/**/*.html \
+		content/templates-preprocessor/shared/**/*.html \
 		content/templates-wheezy/shared/**/*.html
 	xgettext --join-existing --sort-by-file --omit-header \
 		--language=Python \
 		content/templates-jinja2/public/*.html \
 		content/templates-mako/public/*.html \
 		content/templates-tenjin/public/*.html \
+		content/templates-preprocessor/public/*.html \
 		content/templates-wheezy/public/*.html
 	xgettext --join-existing --sort-by-file --omit-header \
 		--language=Python \
 		content/templates-jinja2/membership/*.html \
 		content/templates-mako/membership/*.html \
 		content/templates-tenjin/membership/*.html \
-		content/templates-wheezy/preprocessor/membership/*.html \
+		content/templates-preprocessor/membership/*.html \
 		content/templates-wheezy/membership/*.html
 	cp i18n/*.po i18n/en/LC_MESSAGES
 	for l in `ls -d i18n/*/ | cut -d / -f 2`; do \

demos/template/content/templates-preprocessor/membership/signin.html

+#extends("shared/master.html")
+
+#def title():
+Sign In
+#end
+
+#def content():
+#require(path_for)
+@require(credential, model, errors, xsrf)
+<div id="signin">
+    <h2>
+        Sign In</h2>
+    <p>
+    Please enter your username and password. <a href="#path_for('signup')">
+    Sign up</a> if you don't have an account.
+    </p>
+    @model.error()
+    <form action="#path_for('signin')" method="post">
+        @xsrf()
+        <div>
+            <fieldset>
+                <legend>Account Credentials</legend>
+                <p>
+                @credential.username.label('Username:')
+                @credential.username.textbox(autocomplete='off')!h
+                @credential.username.error()
+                </p>
+                <p>
+                @credential.password.label('Password:')
+                @credential.password.password(autocomplete='off', maxlength='12')!h
+                @credential.password.error()
+                </p>
+                <p>
+                @model.remember_me.checkbox()
+                @model.remember_me.label('Remember me?', class_='inline')
+                @model.remember_me.error()
+                </p>
+                <p>
+                <input type="submit" value="Sign In" />
+                </p>
+            </fieldset>
+            <i><b>demo</b> user password is P@@ssw0rd. You can press 'Ctrl'
+                + '1' to auto complete information.</i>
+        </div>
+    </form>
+</div>
+#end
+
+#def script():
+<script type="text/javascript">
+</script>
+#end

demos/template/content/templates-preprocessor/membership/signup.html

+#extends("shared/master.html")
+
+#def title():
+Sign Up
+#end
+
+#def content():
+@require(credential, account, registration, account_types, questions)
+@require(model, errors, resubmission)
+#require(_, path_for)
+<div id="signup">
+    <h2>
+        Create a New Account</h2>
+    <p>
+    Use the form below to create a new account.
+    </p>
+    <p>
+    Passwords are required to be a minimum of 8 characters
+    in length.
+    </p>
+    @model.error()
+    <form action="#path_for('signup')" method="post">
+        @resubmission()
+        <div>
+            <fieldset>
+                <legend>Account Information</legend>
+                <p>
+                @credential.username.label('Username:')
+                @credential.username.textbox(autocomplete='off')!h
+                @credential.username.error()
+                </p>
+                <p>
+                @account.display_name.label('Display name:')
+                @account.display_name.textbox(autocomplete='off')!h
+                @account.display_name.error()
+                </p>
+                <p>
+                @account.email.label('Email:')
+                @account.email.textbox(autocomplete='off')!h
+                @account.email.error()
+                </p>
+                <p>
+                @account.account_type.label('Account Type:')
+                @account.account_type.radio(choices=account_types)
+                @account.account_type.error()
+                </p>
+                <p>
+                @registration.date_of_birth.label('#_('Date of birth (YYYY/MM/DD):')')
+                @registration.date_of_birth.format('#_('YYYY/MM/DD')').textbox(autocomplete='off')!h
+                @registration.date_of_birth.error()
+                </p>
+                <p>
+                @credential.password.label('Password:')
+                @credential.password.password(autocomplete='off', maxlength='12')!h
+                @credential.password.error()
+                </p>
+                <p>
+                @model.confirm_password.label('Confirm password:')
+                @model.confirm_password.password(autocomplete='off', maxlength='12')!h
+                @model.confirm_password.error()
+                </p>
+                <p>
+                @model.questionid.label('Security question:')
+                @model.questionid.dropdown(choices=questions)
+                @model.questionid.error()
+                </p>
+                <p>
+                @registration.answer.label('Answer:')
+                @registration.answer.textbox(autocomplete='off', maxlength='30')!h
+                @registration.answer.error()
+                </p>
+                <p>
+                <input type="submit" value="Register" />
+                </p>
+            </fieldset>
+        </div>
+    </form>
+</div>
+#end
+
+#def script():
+<script type="text/javascript">
+</script>
+#end

demos/template/content/templates-preprocessor/public/about.html

+#extends("shared/master.html")
+#require(_, path_for)
+
+#def title():
+#_('About')
+#end
+
+#def content():
+<div id="about">
+    <h2>#_('About')</h2>
+    <p>Proin at lorem vel dolor pharetra aliquam. Phasellus auctor,
+    nunc vitae lobortis pretium, mauris ligula sagittis quam, nec
+    volutpat est arcu a diam. Nunc nisi augue, sollicitudin eu
+    adipiscing ac, commodo at urna. Nullam sit amet odio sit amet
+    elit dictum ultrices.</p>
+    <p>Try out the following responses:
+    </p>
+    <ul>
+        <li><a href="#path_for('http400')">Bad Request</a></li>
+        <li><a href="#path_for('http403')">Forbidden</a></li>
+        <li><a href="#path_for('http404')">Not Found</a></li>
+        <li><a href="#path_for('http500')">Internal Error</a></li>
+    </ul>
+</div>
+#end

demos/template/content/templates-preprocessor/public/home.html

+#extends("shared/master.html")
+#require(_)
+
+#def title():
+#_('Home')
+#end
+
+#def content():
+<div id="welcome">
+    <h2>#_('Welcome!')</h2>
+    <p>
+    Lorem ipsum dolor sit amet, consectetur adipiscing elit. \
+    Donec quis tempus tellus. Curabitur faucibus fermentum enim, \
+    quis aliquet.
+    </p>
+</div>
+#end

demos/template/content/templates-preprocessor/public/http400.html

+#extends("shared/master.html")
+
+#def title():
+Bad Request
+#end
+
+#def content():
+<div id="error">
+    <h2>Oops! Code 400. Sorry, we can't process your request.</h2>
+    <p>
+    The 400 Bad Request error is an HTTP status code that
+    means that the request you sent to the website server (i.e.
+    a request to load a web page) was somehow malformed therefore
+    the server was unable to understand or process the request.
+    </p>
+</div>
+#end

demos/template/content/templates-preprocessor/public/http403.html

+#extends("shared/master.html")
+
+#def title():
+Access Denied
+#end
+
+#def content():
+<div id="error">
+    <h2>Oops! Code 403. Access is denied.</h2>
+    <p>
+    You do not have permission to view this directory or page
+    using the credentials that you supplied.
+    </p>
+</div>
+#end

demos/template/content/templates-preprocessor/public/http404.html

+#extends("shared/master.html")
+
+#def title():
+We are sorry, the page you requested cannot be found.
+#end
+
+#def content():
+<div id="error">
+    <h2>Oops! Code 404. Sorry, we can't find that page.</h2>
+    <p>
+    Unfortunately the page you are looking for may have been
+    removed, had its name changed, under construction or is
+    temporarily unavailable. Try checking the web address for
+    typos, please. We apologize for the inconvenience.
+    </p>
+</div>
+#end

demos/template/content/templates-preprocessor/public/http500.html

+#extends("shared/master.html")
+
+#def title():
+We are sorry, we can not process your request.
+#end
+
+#def content():
+<div id="error">
+    <h2>Oops! Code 500. Sorry, we can not process your request.</h2>
+    <p>
+    The web server encountered an unexpected condition that
+    prevented it from fulfilling the request by the client for
+    access to the requested URL.
+    </p>
+</div>
+#end

demos/template/content/templates-preprocessor/shared/master.html

+#require(_, path_for)
+<!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">
+    <head>
+        <title>#_('My Site') - \
+        #def title():
+        #end
+        #title()</title>
+        <link href="#path_for('static', path='css/site.css')" \
+            type="text/css" rel="stylesheet" />
+    </head>
+    <body>
+        <div class="page">
+            <div id="header">
+                <div id="title">
+                    <h1><a href="#path_for('default')">#_('My Site')</a></h1>
+                </div>
+                <div id="logindisplay">
+                    #include("shared/snippet/menu-signin.html")
+                    #include("shared/snippet/menu-locale.html")
+                </div>
+                <div id="menucontainer">
+                    #include("shared/snippet/menu-header.html")
+                </div>
+            </div>
+            <div id="main">
+                <div id="placeholder">
+                    #def content():
+                    #end
+                    #content()\
+                </div>
+                <div id="footer">#_('Version') #__version__</div>
+            </div>
+        </div>
+        #include("shared/snippet/script.html")
+        #def script():
+        #end
+        #script()\
+    </body>
+</html>

demos/template/content/templates-preprocessor/shared/snippet/menu-header.html

+#require(_, path_for)
+@require(route_args)
+
+#def link(href, title):
+    <a href="#path_for(href)">#title</a></li>\
+#end
+
+#def active_item(route_name):
+    @# ignore
+    @if '#route_name' == route_args.route_name:
+        <li class="active"> \
+    @else:
+        <li> \
+    @end
+#end
+
+<ul id="menu">
+    #active_item('home')#link('home', _('s:Home'))
+    #active_item('about')#link('about', _('s:About'))
+</ul>

demos/template/content/templates-preprocessor/shared/snippet/menu-locale.html

+#require(_)
+@require(path_for, route_args)
+<i>
+    <a href="@path_for(route_args.route_name, locale='en')">#_('English')</a> | \
+    <a href="@path_for(route_args.route_name, locale='ru')">#_('Russian')</a>
+</i>

demos/template/content/templates-preprocessor/shared/snippet/menu-signin.html

+#require(_, path_for)
+@require(principal)
+@if principal:
+#_('Welcome') <b>@principal.alias!h</b>! [
+<a href="#path_for('signout')">#_('Sign out')</a>]
+@else:
+[<a href="#path_for('signin')">#_('Sign in')</a>]
+@end

demos/template/content/templates-preprocessor/shared/snippet/script.html

+#require(path_for)
+<script src="#path_for('static', path='js/jquery-1.7.1.min.js')"
+ type="text/javascript"></script>
+<script src="#path_for('static', path='js/core.js')"
+ type="text/javascript"></script>
+<script src="#path_for('static', path='js/autocomplete.js')"
+ type="text/javascript"></script>

demos/template/content/templates-wheezy/preprocessor/membership/signup.html

-@extends("shared/master.html")
-
-@def title():
-Sign Up
-@end
-
-@def content():
-@require(credential, account, registration, account_types, questions)
-@require(model, errors, resubmission)
-#require(_, path_for)
-<div id="signup">
-    <h2>
-        Create a New Account</h2>
-    <p>
-    Use the form below to create a new account.
-    </p>
-    <p>
-    Passwords are required to be a minimum of 8 characters
-    in length.
-    </p>
-    @model.error()
-    <form action="#path_for('signup')" method="post">
-        @resubmission()
-        <div>
-            <fieldset>
-                <legend>Account Information</legend>
-                <p>
-                @credential.username.label('Username:')
-                @credential.username.textbox(autocomplete='off')!h
-                @credential.username.error()
-                </p>
-                <p>
-                @account.display_name.label('Display name:')
-                @account.display_name.textbox(autocomplete='off')!h
-                @account.display_name.error()
-                </p>
-                <p>
-                @account.email.label('Email:')
-                @account.email.textbox(autocomplete='off')!h
-                @account.email.error()
-                </p>
-                <p>
-                @account.account_type.label('Account Type:')
-                @account.account_type.radio(choices=account_types)
-                @account.account_type.error()
-                </p>
-                <p>
-                @registration.date_of_birth.label('#_('Date of birth (YYYY/MM/DD):')')
-                @registration.date_of_birth.format('#_('YYYY/MM/DD')').textbox(autocomplete='off')!h
-                @registration.date_of_birth.error()
-                </p>
-                <p>
-                @credential.password.label('Password:')
-                @credential.password.password(autocomplete='off', maxlength='12')!h
-                @credential.password.error()
-                </p>
-                <p>
-                @model.confirm_password.label('Confirm password:')
-                @model.confirm_password.password(autocomplete='off', maxlength='12')!h
-                @model.confirm_password.error()
-                </p>
-                <p>
-                @model.questionid.label('Security question:')
-                @model.questionid.dropdown(choices=questions)
-                @model.questionid.error()
-                </p>
-                <p>
-                @registration.answer.label('Answer:')
-                @registration.answer.textbox(autocomplete='off', maxlength='30')!h
-                @registration.answer.error()
-                </p>
-                <p>
-                <input type="submit" value="Register" />
-                </p>
-            </fieldset>
-        </div>
-    </form>
-</div>
-@end
-
-@def script():
-<script type="text/javascript">
-</script>
-@end

demos/template/content/templates-wheezy/preprocessor/shared/master.html

-#require(_, path_for)
-<!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">
-    <head>
-        <title>#_('My Site') - \
-        @def title():
-        @end
-        @title()</title>
-        <link href="#path_for('static', path='css/site.css')" \
-            type="text/css" rel="stylesheet" />
-    </head>
-    <body>
-        <div class="page">
-            <div id="header">
-                <div id="title">
-                    <h1><a href="#path_for('default')">#_('My Site')</a></h1>
-                </div>
-                <div id="logindisplay">
-                    #include("shared/snippet/menu-signin.html")
-                    #include("shared/snippet/menu-locale.html")
-                </div>
-                <div id="menucontainer">
-                    #include("shared/snippet/menu-header.html")
-                </div>
-            </div>
-            <div id="main">
-                <div id="placeholder">
-                    @def content():
-                    @end
-                    @content()\
-                </div>
-                <div id="footer">#_('Version') #__version__</div>
-            </div>
-        </div>
-        #include("shared/snippet/script.html")
-        @def script():
-        @end
-        @script()\
-    </body>
-</html>

demos/template/content/templates-wheezy/preprocessor/shared/snippet/menu-header.html

-#require(_, path_for)
-@require(route_args)
-
-#def link(href, title):
-    <a href="#path_for(href)">#title</a></li>\
-#end
-
-@def active_item(route_name):
-    @# ignore
-    @if route_name == route_args.route_name:
-        <li class="active"> \
-    @else:
-        <li> \
-    @end
-@end
-
-<ul id="menu">
-    @active_item('home')#link('home', _('s:Home'))
-    @active_item('about')#link('about', _('s:About'))
-</ul>

demos/template/content/templates-wheezy/preprocessor/shared/snippet/script.html

-#require(path_for)
-<script src="#path_for('static', path='js/jquery-1.7.1.min.js')"
- type="text/javascript"></script>
-<script src="#path_for('static', path='js/core.js')"
- type="text/javascript"></script>
-<script src="#path_for('static', path='js/autocomplete.js')"
- type="text/javascript"></script>

demos/template/src/config.py

     from wheezy.html.utils import html_escape
     from wheezy.template.engine import Engine
     from wheezy.template.ext.core import CoreExtension
-    from wheezy.template.ext.determined import DeterminedExtension
     from wheezy.template.loader import autoreload
     from wheezy.template.loader import FileLoader
     from wheezy.template.preprocessor import Preprocessor
         })
         return engine
 
-    searchpath = [
-        'content/templates-wheezy/preprocessor',
-        'content/templates-wheezy']
+    searchpath = ['content/templates-preprocessor']
     engine = Engine(
         loader=FileLoader(searchpath),
         extensions=[
-            CoreExtension('#', line_join=None),
-            DeterminedExtension(['path_for', '_']),
+            CoreExtension('#', line_join=None)
         ])
     engine.global_vars.update({
         '__version__': __version__