Hudarsono Hu avatar Hudarsono Hu committed 89db69e

basic templating works and hgignore

Comments (0)

Files changed (56)

Binary file added.

Add a comment to this file

appengine_django/__init__.pyc

Binary file modified.

Add a comment to this file

appengine_django/db/__init__.pyc

Binary file modified.

Add a comment to this file

appengine_django/db/base.pyc

Binary file modified.

Add a comment to this file

appengine_django/db/creation.pyc

Binary file modified.

Add a comment to this file

appengine_django/mail.pyc

Binary file modified.

Add a comment to this file

appengine_django/management/__init__.pyc

Binary file added.

Add a comment to this file

appengine_django/management/commands/__init__.pyc

Binary file added.

Add a comment to this file

appengine_django/management/commands/startapp.pyc

Binary file added.

Add a comment to this file

appengine_django/replacement_imp.pyc

Binary file modified.

Add a comment to this file

appengine_django/serializer/__init__.pyc

Binary file modified.

Add a comment to this file

appengine_django/serializer/json.pyc

Binary file modified.

Add a comment to this file

appengine_django/serializer/python.pyc

Binary file modified.

Add a comment to this file

appengine_django/serializer/pyyaml.pyc

Binary file modified.

Add a comment to this file

appengine_django/sessions/backends/__init__.pyc

Binary file modified.

Empty file added.

Binary file added.

+from appengine_django.models import BaseModel
+from google.appengine.ext import db
+
+# Create your models here.
+# Create your views here.
+from django.shortcuts import render_to_response
+
+
+def index(request):
+	return render_to_response('front-base.html')
+	
+
+def listPost(request):
+	return render_to_response('admin-postlist.html')

Binary file added.

 DEBUG = True
 TEMPLATE_DEBUG = DEBUG
 
+ROOT_PATH = os.path.dirname(__file__)
+
 ADMINS = (
     # ('Your Name', 'your_email@domain.com'),
 )
 
 # Absolute path to the directory that holds media.
 # Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = ''
+MEDIA_ROOT = os.path.join(ROOT_PATH, 'resources')
 
 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
 # trailing slash if there is a path component (optional in other cases).
 
 ROOT_URLCONF = 'urls'
 
-ROOT_PATH = os.path.dirname(__file__)
+
 TEMPLATE_DIRS = (
     os.path.join(ROOT_PATH, 'templates')
 )
 
 INSTALLED_APPS = (
      'appengine_django',
+	 'uni_form'
+	 'posts',
 #    'django.contrib.auth',
 #    'django.contrib.contenttypes',
 #    'django.contrib.sessions',

Binary file added.

templates/admin-base.html

+<html>
+<head>
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/reset.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/text.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/960.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/admin.css" />
+</head>
+
+<body>
+<div class="container_12">
+	<div class="grid_6">
+		<div id="admin-menu">
+			<ul id="menu-posts">
+				<li class="top"><a href="#">Posts</a></li>
+				<li class="item"><a href="#">New Post</a></li>
+			</ul>
+			<ul id="menu-cat">
+				<li class="top"><a href="#">Categories</a></li>
+				<li class="item"><a href="#">New Category</a></li>
+			</ul>
+		</div>
+	</div>
+
+	<div class="grid_6">
+		&nbsp;
+	</div>
+	
+	<div class="clear" style="height:100"></div>
+	
+	{% block content %}{% endblock %}
+	
+</div>
+</body>
+</html>
Add a comment to this file

templates/admin-newpost.html

Empty file added.

templates/admin-postlist.html

+{% extends 'admin-base.html' %}
+
+{% block content %}
+<div class="grid_12">
+	<table>
+		<thead>
+			<tr>
+				<th class="first">Action</th>
+				<th>Title</th>
+				<th class="last">Created</th>
+			</tr>
+		</thead>
+		<tbody>
+			<tr>
+				<td><a href="#">Edit</a>
+				<td>Quick Jump Into Django Programming</td>
+				<td>12 Semptember 2010</td>
+			</tr>
+			<tr>
+				<td><a href="#">Edit</a>
+				<td>Quick Jump Into Django Programming</td>
+				<td>12 Semptember 2010</td>
+			</tr>
+			<tr>
+				<td><a href="#">Edit</a>
+				<td>Quick Jump Into Django Programming</td>
+				<td>12 Semptember 2010</td>
+			</tr>
+			<tr>
+				<td><a href="#">Edit</a>
+				<td>Quick Jump Into Django Programming</td>
+				<td>12 Semptember 2010</td>
+			</tr>
+			<tr>
+				<td><a href="#">Edit</a>
+				<td>Quick Jump Into Django Programming</td>
+				<td>12 Semptember 2010</td>
+			</tr>
+		</tbody>
+	</table>
+</div>
+{% endblock %}

templates/front-base.html

+<html>
+<head>
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/reset.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/text.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/960.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/resources/css/theme.css" />
+</head>
+
+<body>
+<div class="container_12">
+	{% include 'header.html' %}
+	
+	<div id="main-content" class="grid_9">
+		
+		<div class="content">
+			{% block main_content %}
+		</div>
+	</div>
+	
+	<div id="side-menu" class="grid_3">
+		{% block side_menu %}
+	</div>
+</div>
+</body>
+</html>

templates/header.html

+<div class="grid_6">
+	&nbsp;
+</div>
+
+<div class="grid_6">
+	<div id="nav">
+		<ul>
+			<li><a href="#">Home</a></li>
+			<li><a href="#">Portfolios</a></li>
+			<li><a href="#">About</a></li>
+			<li><a href="#">Contact</a></li>
+		</ul>
+	</div>
+</div>
+
+<div class="clear" style="height:30"></div>

templates/stream.html

+{% extends 'front-base.html' %}
+
+{% block main_content %}
+<h3 class="title">Title of Post</h3>
+<span class="date">Writen at 12 September 2010</span>
+<p>
+So why doesn't C do it this way? Probably the hardware didn't do this at the time C was designed. And the hardware probably didn't do it this way because in the oldest hardware, negative numbers were represented as "sign + magnitude" rather than the two's complement representation used these days (at least for integers). My first computer was a Control Data mainframe and it used one's complement for integers as well as floats. A pattern of 60 ones meant negative zero!
+
+Tim Peters, who knows where all Python's floating point skeletons are buried, has expressed some worry about my desire to extend these rules to floating point modulo. He's probably right; the truncate-towards-negative-infinity rule can cause precision loss for x%1.0 when x is a very small negative number. But that's not enough for me to break integer modulo, and // is tightly coupled to that.
+
+PS. Note that I am using // instead of / -- this is Python 3 syntax, and also allowed in Python 2 to emphasize that you know you are invoking integer division. The / operator in Python 2 is ambiguous, since it returns a different result for two integer operands than for an int and a float or two floats. But that's a totally separate 
+</p>
+{% endblock %}
+
+
+{% block side_menu %}
+<span class="side-title">Categories</span>
+<div id="nav-cat">
+	<ul>
+		<li>&#187; <a href="#">Python</a></li>
+		<li>&#187; <a href="#">Java</a></li>
+		<li>&#187; <a href="#">Django</a></li>
+		<li>&#187; <a href="#">Google Appengine</a></li>
+	</ul>	
+<div>
+{% endblock %}
+Copyright (c) 2009 Daniel Greenfeld and contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

uni_form/__init__.py

+__author__ = "Daniel Greenfeld"
+__version__="0.7.0"

Binary file added.

uni_form/helpers.py

+"""
+    Utilities for helping developers use python for adding various attributes,
+    elements, and UI elements to forms generated via the uni_form template tag.
+
+"""
+from django.core.urlresolvers import reverse, NoReverseMatch
+from django.forms.forms import BoundField
+from django.template.loader import render_to_string
+from django.utils.safestring import mark_safe
+
+
+from uni_form.util import BaseInput, Toggle
+
+
+class FormHelpersException(Exception):
+    """ This is raised when building a form via helpers throws an error.
+        We want to catch form helper errors as soon as possible because
+        debugging templatetags is never fun.
+    """
+    pass
+
+
+class Submit(BaseInput):
+    """
+        Used to create a Submit button descriptor for the uni_form template tag.
+    """
+    
+    input_type = 'submit'
+    field_classes = 'submit submitButton'
+
+
+class Button(BaseInput):
+    """
+        Used to create a Submit input descriptor for the uni_form template tag.
+    """
+    
+    input_type = 'button'
+    field_classes = 'button'
+
+class Hidden(BaseInput):
+    """
+        Used to create a Hidden input descriptor for the uni_form template tag.
+    """
+    
+    input_type = 'hidden'
+    field_classes = 'hidden'
+
+class Reset(BaseInput):
+    """
+        Used to create a Hidden input descriptor for the uni_form template tag.
+    """
+    
+    input_type = 'reset'
+    field_classes = 'reset resetButton'    
+
+def render_field(field, form):
+    if isinstance(field, str):
+        return render_form_field(form, field)
+    else:
+        return field.render(form)
+
+def render_form_field(form, field):
+    try:
+        field_instance = form.fields[field]
+    except KeyError:
+        raise Exception("Could not resolve form field '%s'." % field)
+    bound_field = BoundField(form, field_instance, field)
+    html = render_to_string("uni_form/field.html", {'field': bound_field})
+    if not hasattr(form, 'rendered_fields'):
+        form.rendered_fields = []
+    if not field in form.rendered_fields:
+        form.rendered_fields.append(field)
+    else:
+        raise Exception("A field should only be rendered once: %s" % field)
+    return html
+
+class Layout(object):
+    '''
+    Form Layout, add fieldsets, rows, fields and html
+    
+    example:
+    
+    layout = Layout(Fieldset('', 'is_company'),
+                    Fieldset(_('Contact details'),
+                              'email',
+                              Row('password1','password2'),
+                              'first_name',
+                              'last_name',
+                              HTML('<img src="/media/somepicture.jpg"/>'),
+                              'company',)
+    helper.add_layout(layout)
+    '''
+    def __init__(self, *fields):
+        self.fields = fields
+    
+    def render(self, form):
+        html = ""
+        for field in self.fields:
+            html += render_field(field, form)
+        for field in form.fields.keys():
+            if not field in form.rendered_fields:
+                html += render_field(field, form)
+        return html
+
+class Fieldset(object):
+    
+    ''' Fieldset container. Renders to a <fieldset>. '''
+    
+    def __init__(self, legend, *fields, **args):
+        if 'css_class' in args.keys():
+            self.css = args['css_class']
+        else:
+            self.css = None
+        self.legend_html = legend and ('<legend>%s</legend>' % unicode(legend)) or ''
+        self.fields = fields
+    
+    
+    def render(self, form):
+        if self.css:
+            html = u'<fieldset class="%s">' % self.css
+        else:
+            html = u'<fieldset>'
+        html += self.legend_html
+        for field in self.fields:
+            html += render_field(field, form)
+        html += u'</fieldset>'
+        return html
+
+
+
+class Row(object):
+    ''' row container. Renders to a set of <div>'''
+    def __init__(self, *fields, **kwargs):
+        self.fields = fields
+        if 'css_class' in kwargs.keys():
+            self.css = kwargs['css_class']
+        else:
+            self.css = "formRow"
+    
+    def render(self, form):
+        output = u'<div class="%s">' % self.css
+        for field in self.fields:
+            output += render_field(field, form)
+        output += u'</div>'
+        return u''.join(output)
+
+class Column(object):
+    ''' column container. Renders to a set of <div>'''
+    def __init__(self, *fields, **kwargs):
+        self.fields = fields
+        if 'css_class' in kwargs.keys():
+            self.css = kwargs['css_class']
+        else:
+            self.css = "formColumn"
+    
+    def render(self, form):
+        output = u'<div class="%s">' % self.css
+        for field in self.fields:
+            output += render_field(field, form)
+        output += u'</div>'
+        return u''.join(output)
+
+class HTML(object):
+    
+    ''' HTML container '''
+    
+    def __init__(self, html):
+        self.html = unicode(html)
+    
+    def render(self, form):
+        return self.html
+
+
+
+
+class FormHelper(object):
+    """
+        By setting attributes to me you can easily create the text that goes
+        into the uni_form template tag. One use case is to add to your form
+        class.
+        
+        First we create a MyForm class and instantiate it
+        
+        >>> from django import forms
+        >>> from uni_form.helpers import FormHelper, Submit, Reset
+        >>> from django.utils.translation import ugettext_lazy as _
+        >>> class MyForm(forms.Form):
+        ...     title = forms.CharField(label=_("Title"), max_length=30, widget=forms.TextInput())
+        ...     # this displays how to attach a formHelper to your forms class.
+        ...     helper = FormHelper()
+        ...     helper.form_id = 'this-form-rocks'
+        ...     helper.form_class = 'search'
+        ...     submit = Submit('search','search this site')
+        ...     helper.add_input(submit)
+        ...     reset = Reset('reset','reset button')
+        ...     helper.add_input(reset)
+        
+        After this in the template:
+            
+            {% load uni_form_tags %}
+            {% uni_form form form.helper %}
+        
+    
+    """
+    
+    def __init__(self):
+        self._form_method = 'POST'
+        self._form_action = ''
+        self.form_id = ''
+        self.form_class = ''
+        self.inputs = []
+        self.toggle = Toggle()
+        self.layout = None
+    
+    def get_form_method(self):
+        return self._form_method
+    
+    def set_form_method(self, method):
+        if method.lower() not in ('get','post'):
+            raise FormHelpersException('Only GET and POST are valid in the \
+                    form_method helper attribute')
+        
+        self._form_method = method.upper()
+    
+    # we set properties the old way because we want to support pre-2.6 python
+    form_method = property(get_form_method, set_form_method)
+    
+    def get_form_action(self):
+        return self._form_action
+    
+    def set_form_action(self, action):
+        try:
+            self._form_action = reverse(action)
+        except NoReverseMatch:
+            self._form_action = action
+            #msg = 'Your form action needs to be a named url defined in a urlconf file\n'
+            #msg += 'Your broken action is: %s\n' % action
+            #msg += 'NoReverseMatch: %s' % e
+            #raise FormHelpersException(msg)
+    
+    # we set properties the old way because we want to support pre-2.6 python
+    form_action = property(get_form_action, set_form_action)
+    
+    def add_input(self, input_object):
+        self.inputs.append(input_object)
+    
+    def add_layout(self, layout):
+        self.layout = layout
+    
+    def render_layout(self, form):
+        return mark_safe(self.layout.render(form))
+    
+    def get_attr(self):
+        items = {}
+        items['form_method'] = self.form_method.strip()
+        
+        if self.form_action:
+            items['form_action'] = self.form_action.strip()
+        if self.form_id:
+            items['id'] = self.form_id.strip()
+        if self.form_class:
+            items['class'] = self.form_class.strip()
+        if self.inputs:
+            items['inputs'] = self.inputs
+        if self.toggle.fields:
+            items['toggle_fields'] = self.toggle.fields
+        return items
+        

Binary file added.

uni_form/locale/da/LC_MESSAGES/django.po

+# django-uni-form in Danish.
+# django-uni-form på Dansk.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# Michael Lind Mortensen <illio@cs.au.dk>, 2009.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-09-13 23:51+0200\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"
+
+#: templates/uni_form/whole_uni_form.html:6
+msgid "Required fields"
+msgstr "Obligatoriske felter"

uni_form/media/uni_form/uni-form-generic.css

+/* Uni-Form by Dragan Babic [Superawesome Industries]  - http: //sprawsm.com/uni-form/ */ 
+/* Some rights reserved - http: //creativecommons.org/licenses/by-sa/2.5/ */
+/* Do not edit this file directly, make your changes to uni-form.css in the same folder */
+
+/* ------------------------------------------------------------------------------ */
+
+.uniForm{ margin: 0; padding: 0; position: relative; z-index: 1; } /* reset stuff */
+
+  /* Some generals and more resets */
+  .uniForm fieldset{ border: none; margin: 0; padding: 0; position: relative; }
+    .uniForm fieldset legend{ margin: 0; padding: 0; }
+
+    /* This is the main unit that contains our form elements */
+    .uniForm .ctrlHolder,
+    .uniForm .buttonHolder{ margin: 0; padding: 0; clear: both; }
+
+    /* Clear all floats */ 
+    .uniForm:after,
+      .uniForm .buttonHolder:after, 
+      .uniForm .ctrlHolder:after, 
+        .uniForm .ctrlHolder .multiField:after,
+          .uniForm .inlineLabel:after{ content: "."; display: block; height: 0; line-height: 0; font-size: 0; clear: both; min-height: 0; visibility: hidden; }
+
+    /* A class to be used on a label that contains a checkbox or a radio button */
+    .uniForm .inlineLabel,
+    .uniForm .inlineLabels .inlineLabel,
+    .uniForm .blockLabels .inlineLabel{ width: auto; float: none; margin: 0; display: block; }
+      /* IE shows borders & padding on checkboxes and radio buttons if they are declared on an input element, remove them */
+      /* Legacy/Inheritance fix */
+      .uniForm .inlineLabel input,
+      .uniForm .inlineLabels .inlineLabel input,
+      .uniForm .blockLabels .inlineLabel input{ border: none; padding: 0; margin: 0; }
+
+/* ------------------------------------------------------------------------------ */
+
+    /* Styles for form controls where labels are above the input elements */
+    /* Set the class of the parent (preferably to a fieldset) to .blockLabels */
+
+      .uniForm label,
+      .uniForm .label,
+      .uniForm .blockLabels label,
+      .uniForm .blockLabels .label{ display: block; float: none; padding: 0; line-height: 100%; width: auto; }
+
+      /* Float the input elements */
+      .uniForm .textInput,
+      .uniForm .blockLabels .textInput,
+      .uniForm .blockLabels .fileUpload,
+      .uniForm .selectInput,
+      .uniForm .blockLabels .selectInput,
+      .uniForm .blockLabels select,
+      .uniForm textarea,
+      .uniForm .blockLabels textarea{ float: left; }
+      
+      /* Postition the hints */
+      .uniForm .formHint,
+      .uniForm .blockLabels .formHint{ float: right; margin: 0; clear: none; }
+      
+      /* Position the elements inside combo boxes (multiple selects/checkboxes/radio buttons per unit) */
+      .uniForm .multiField,
+      .uniForm .blockLabels .multiField{ width: auto; float: left; }
+        .uniForm .multiField .inlineLabel,
+        .uniForm .blockLabels .multiField .inlineLabel{ display: block; margin: 0 0 .5em 0; }
+        .uniForm .multiField .blockLabel,
+        .uniForm .blockLabels .multiField .blockLabel{ float: left; width: auto; margin: 0; }
+        .uniForm .multiField .blockLabel .textInput,
+        .uniForm .multiField .blockLabel .selectInput,
+        .uniForm .multiField .blockLabel select,
+        .uniForm .blockLabels .multiField .blockLabel .textInput,
+        .uniForm .blockLabels .multiField .blockLabel .selectInput,
+        .uniForm .blockLabels .multiField .blockLabel select{ width: 100%; margin: 0; }
+
+/* ------------------------------------------------------------------------------ */
+
+    /* Styles for form controls where labels are in line with the input elements */
+    /* Set the class of the parent (preferably to a fieldset) to .inlineLabels */
+        .uniForm .inlineLabels label,
+        .uniForm .inlineLabels .label{ float: left; margin: 0; padding: 0; line-height: 100%; position: relative; }
+        
+        /* Float the input elements */
+        .uniForm .inlineLabels .textInput,
+        .uniForm .inlineLabels .fileUpload,        
+        .uniForm .inlineLabels .selectInput,
+        .uniForm .inlineLabels select,
+        .uniForm .inlineLabels textarea{ float: left; }
+
+      /* Postition the hints */
+      .uniForm .inlineLabels .formHint{ clear: both; float: none; }
+      .uniForm .inlineLabels .multiField{ float: left; }
+      .uniForm .inlineLabels .multiField .inlineLabel{}
+      .uniForm .inlineLabels .multiField .blockLabel{}
+        .uniForm .inlineLabels .multiField .blockLabel .textInput,
+        .uniForm .inlineLabels .multiField .blockLabel .selectInput,
+        .uniForm .inlineLabels .multiField .blockLabel select{ display: block; width: 100%; float: none; }
+        .uniForm .inlineLabels .multiField select{ float: left; }
+      
+/* ------------------------------------------------------------------------------ */
+
+    /* Required fields asterisk styling for .blockLabels */
+    .uniForm label em,
+    .uniForm .label em,
+    .uniForm .blockLabels label em,
+    .uniForm .blockLabels .label em{ position: absolute; left: -7px; }
+    
+    /* Required fields asterisk styling for .inlineLabels */
+    .uniForm .inlineLabels label em,
+    .uniForm .inlineLabels .label em{ display: block; position: absolute; left: auto; right: 0; font-style: normal; font-weight: bold; }
+    .uniForm .inlineLabel em{ position: absolute; left: 7px; }
+
+/* ------------------------------------------------------------------------------ */
+
+    /* Messages */
+    .uniForm #errorMsg,
+    .uniForm .error{
+    }
+      .uniForm #errorMsg dt,
+      .uniForm #errorMsg h3{
+      }
+      .uniForm #errorMsg dd{
+      }
+        .uniForm #errorMsg ol{
+        }
+          .uniForm #errorMsg ol li{
+          }
+      .uniForm .errorField{
+      }
+    
+    .uniForm #OKMsg{
+    }
+
+/* ------------------------------------------------------------------------------ */
+
+    /* Columns */
+    
+    .uniForm .col{ float: left; }
+    .uniForm .col.first{}
+    .uniForm .col.last{}

uni_form/media/uni_form/uni-form.css

+@import "uni-form-generic.css";
+/* Keep in mind that wherever you see 'Required property' it means that the property must exist */
+
+/* ------------------------------------------------------------------------------ */
+
+  /* Generals */
+  .uniForm fieldset{}
+    .uniForm fieldset legend{ color: #333; font-weight: bold; font-size: 100%; margin: 0; padding: 1.5em 0; }
+    
+    /* This is the main unit that contains our form elements */
+    .uniForm .ctrlHolder{ padding: 7px; border-bottom: 1px solid #dfdfdf; }
+    
+    .uniForm .buttonHolder{ text-align: right; }
+      .uniForm .resetButton{ float: left; }
+      .uniForm .primaryAction{ font-weight: bold; }
+    
+    /* This class gets added to div.ctrlHolder to highlight the row */
+    .uniForm .focused{ background: #fffcdf; }
+      
+      /* .inlineLabel is used for inputs within labels - checkboxes and radio buttons */
+      .uniForm .inlineLabel input,
+      .uniForm .inlineLabels .inlineLabel input,
+      .uniForm .blockLabels .inlineLabel input{ float: left; margin: 0 .4em 0 0; }
+        .uniForm .inlineLabel span{ float: left; width: 90%; }
+        
+/* ------------------------------------------------------------------------------ */
+
+    /* .blockLabels (default style, will be applied even if you don't class the parent element) */
+    .uniForm .blockLabels .ctrlHolder{}
+      
+      .uniForm label,
+      .uniForm .blockLabels label,
+      .uniForm .blockLabels .label{ margin: 0 0 .5em 0; }
+      
+      .uniForm .textInput,
+      .uniForm .blockLabels .textInput,
+      .uniForm .blockLabels .fileUpload{ width: 53%; /* <- Required property */ }
+    
+      .uniForm .selectInput,
+      .uniForm select,
+      .uniForm .blockLabels .selectInput,
+      .uniForm .blockLabels select{ width: 53.5%; /* <- Required property */ }
+      .uniForm textarea,
+      .uniForm .blockLabels textarea{ width: 53%; /* <- Required property */ height: 12em; }
+
+      .uniForm .formHint,
+      .uniForm .blockLabels .formHint{ width: 45%; /* <- Required property */ font-size: .9em; color: #777; position: relative; top: -.5em; }
+      
+      .uniForm .multiField,
+      .uniForm .blockLabels .multiField{ width: 53%; }
+        .uniForm .multiField .inlineLabel,
+        .uniForm .blockLabels .multiField .inlineLabel{ display: block; margin: 0 0 .5em 0; }
+        .uniForm .multiField .blockLabel,
+        .uniForm .blockLabels .multiField .blockLabel{ width: 30%; margin: 0 10px 0 0; }
+        .uniForm .multiField .blockLabel .textInput,
+        .uniForm .multiField .blockLabel .selectInput,
+        .uniForm .multiField .blockLabel select,
+        .uniForm .blockLabels .multiField .blockLabel .textInput,
+        .uniForm .blockLabels .multiField .blockLabel .selectInput,
+        .uniForm .blockLabels .multiField .blockLabel select{ width: 100%; margin: .3em 0 0 0; }
+
+/* ------------------------------------------------------------------------------ */
+
+    /* .inlineLabels */
+    .uniForm .inlineLabels .ctrlHolder{}
+    
+    .uniForm .inlineLabels label,
+    .uniForm .inlineLabels .label{ width: 45%; /* <- Required property */ margin: .3em 2% 0 0; /* <- Required property */ }
+    
+    .uniForm .inlineLabels .textInput,
+    .uniForm .inlineLabels .fileUpload{ width: 45%; /* <- Required property */ }
+    
+    .uniForm .inlineLabels .selectInput,
+    .uniForm .inlineLabels select{ width: 45%; /* <- Required property */ }
+    
+    .uniForm .inlineLabels textarea{  width: 45%; /* <- Required property */ height: 12em; }
+
+    .uniForm .inlineLabels .formHint{ margin-top: 0; margin-left: 47%; font-size: .9em; color: #777; position: static; }
+    
+    .uniForm .inlineLabels .multiField{ width: 45%; /* <- Required property */ margin: 0 0 .3em 0; }
+      .uniForm .inlineLabels .multiField .inlineLabel{ display: block; margin: 0 0 .5em 0; }
+      .uniForm .inlineLabels .multiField .blockLabel{ float: left; width: 26%; margin: 0 3% 0 0; }
+      .uniForm .inlineLabels .multiField .blockLabel .textInput,
+      .uniForm .inlineLabels .multiField .blockLabel .selectInput,
+      .uniForm .inlineLabels .multiField .blockLabel select{ width: 100%; margin: .3em 0 0 0; }
+
+/* Focus pseudoclasses */
+.uniForm .ctrlHolder .textInput:focus{ outline: none; /* Get rid of the 'glow' effect in WebKit, optional */ }
+.uniForm .ctrlHolder textarea:focus{ outline: none; /* Get rid of the 'glow' effect in WebKit, optional */ }
+.uniForm div.focused .formHint{ color: #333; }
+
+/* Columns (they are floated left by default) */
+.uniForm .col{ width: 47.9%; /* <- Required property */ margin: 0 2% 20px 0; }
+/* Use .first and .last classes to control the layout/spacing of your columns */
+.uniForm .col.first{ width: 49%; /* <- Required property */ float: left; clear: none; }
+.uniForm .col.last{ width: 49%; /* <- Required property */ float: right; clear: none; margin-right: 0; }
+
+/* Messages */
+.uniForm #errorMsg{ background: #ffdfdf; border: 1px solid #df7d7d; border-width: 1px 0; margin: 0 0 1.5em 0; padding: 7px; }
+.uniForm .error{ background: #ffdfdf; border: 1px solid #df7d7d; border-width: 1px 0; }
+
+  .uniForm #errorMsg dt, .uniForm #errorMsg h3{ margin: 0 0 .5em 0; font-size: 100%; line-height: 100%; font-weight: bold; }
+  .uniForm #errorMsg dd{ margin: 0; padding: 0; }
+    .uniForm #errorMsg ol{ margin: 0; padding: 0; }
+      .uniForm #errorMsg ol li{ margin: 0; padding: 2px; list-style-position: inside; border-bottom: 1px dotted #df7d7d; position: relative; }
+    .uniForm .errorField{ color: #af4c4c; margin: 0 0 6px 0; padding: 4px; background: #ffbfbf; }
+
+.uniForm #OKMsg{ background: #C8FFBF; border: 1px solid #A2EF95; border-width: 1px 0; margin: 0 0 1.5em 0; padding: 7px; }
+  .uniForm #OKMsg p{ margin: 0; }
+
+/*
+IT IS STRONGLY ADVISED TO MAKE YOUR CHANGES AFTER THIS COMMENT BY REPEATING (COPYING) THE SELECTOR FROM ABOVE, 
+AND MODIFYING IT WITH YOUR OWN PROPERTIES/VALUES. THIS IS RECOMMENDED BECAUSE IF YOU HAPPEN TO RUN INTO TROUBLE, 
+YOU CAN VERY EASILY REVERT TO A GENERIC STYLE OF UNI-FORM. BEST OF LUCK... 
+*/
+
+/* ------------------------------------------------------------------------------ */
+

uni_form/media/uni_form/uni-form.jquery.js

+jQuery.fn.uniform = function(settings) {
+  settings = jQuery.extend({
+    valid_class    : 'valid',
+    invalid_class  : 'invalid',
+    focused_class  : 'focused',
+    holder_class   : 'ctrlHolder',
+    field_selector : 'input, select, textarea'
+  }, settings);
+  
+  return this.each(function() {
+    var form = jQuery(this);
+ 
+    // Select form fields and attach them higlighter functionality
+    form.find(settings.field_selector).focus(function() {
+      form.find('.' + settings.focused_class).removeClass(settings.focused_class);
+      jQuery(this).parents("." + settings.holder_class).addClass(settings.focused_class)
+    }).blur(function() {
+      form.find('.' + settings.focused_class).removeClass(settings.focused_class);
+    });
+  });
+};
+
+// Auto set on page load...
+$(document).ready(function() {
+  q = jQuery('form.uniForm');
+  if(q.length) {
+    q.uniform();
+  }
+  $(document.activeElement).focus() //safari doesn't support this and has no alternative
+});

Empty file added.

uni_form/templates/uni_form/errors.html

+{% if form.non_field_errors %}
+<div id="errorMsg">
+      <ul>
+        {{ form.non_field_errors|unordered_list }}
+     </ul>
+</div>
+{% endif %}

uni_form/templates/uni_form/field.html

+{% load uni_form_field %}
+
+{% if field.is_hidden %}
+    {{ field }}
+{% else %}
+    <div id="div_{{ field.auto_id }}" class="ctrlHolder{% if field.errors %} error{% endif %}{% if field|is_checkbox %} checkbox{% endif %} {% if field.field.widget.attrs.class %} {{ field.field.widget.attrs.class }}{% endif %}">
+        {% for error in field.errors %}
+            <p id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="errorField">
+                {{ error }}
+            </p>
+        {% endfor %}
+
+        {% if field|is_checkbox %}
+            {{ field|with_class }}
+        {% endif %}
+
+        {% if field.label %}
+            <label for="{{ field.auto_id }}">
+                {{ field.label }}{% if field.field.required %}<span>*</span>{% endif %}
+            </label>
+        {% endif %}
+
+        {% if not field|is_checkbox %}
+            {{ field|with_class }}
+        {% endif %}
+
+        {% if field.help_text %}
+            <p id="hint_{{ field.auto_id }}" class="formHint">{{ field.help_text|safe }}</p>
+        {% endif %}
+    </div>
+{% endif %}

uni_form/templates/uni_form/field.strict.html

+{% load uni_form_field %}
+
+{% if field.is_hidden %}
+    {{ field }}
+{% else %}
+    <div id="div_{{ field.auto_id }}" class="ctrlHolder{% if field.errors %} error{% endif %}{% if field|is_checkbox %} checkbox{% endif %} {% if field.field.widget.attrs.class %} {{ field.field.widget.attrs.class }}{% endif %}">
+        {% for error in field.errors %}
+            <p id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="errorField">
+                {{ error }}
+            </p>
+        {% endfor %}
+
+        {% if field|is_checkbox %}
+            {{ field|with_class }}
+        {% endif %}
+
+        {% if field.label %}
+            <label for="{{ field.auto_id }}" class="inlineLabel">
+                {{ field.label }}{% if field.field.required %}<em>*</em>{% endif %}
+            </label>
+        {% endif %}
+
+        {% if not field|is_checkbox %}
+            {{ field|with_class }}
+        {% endif %}
+
+        {% if field.help_text %}
+            <p id="hint_{{ field.auto_id }}" class="formHint">{{ field.help_text|safe }}</p>
+        {% endif %}
+    </div>
+{% endif %}

uni_form/templates/uni_form/includes.html

+{% comment %}
+This is used by the uni_form_setup template tag to identify where to grab media files.
+{% endcomment %}
+ 
+<link rel="stylesheet" href="{{ MEDIA_URL }}uni_form/uni-form-generic.css" type="text/css" />
+<link rel="stylesheet" href="{{ MEDIA_URL }}uni_form/uni-form.css" type="text/css" />
+<script src="{{ MEDIA_URL }}uni_form/uni-form.jquery.js" type="text/javascript"></script> 

uni_form/templates/uni_form/uni_form.html

+{% include "uni_form/errors.html" %}
+{% for field in form %}
+    {% include "uni_form/field.html" %}
+{% endfor %}
+

uni_form/templates/uni_form/uni_form_jquery.html

+<style>
+    .hideme {
+        display: none;
+    }
+</style>
+
+<script type="text/javascript">
+
+    
+$(document).ready(function() {
+
+{% if toggle_fields %}    
+
+    {% for field in toggle_fields %}
+        $('#{{ field.auto_id }}').addClass('hideme');
+
+        var str_{{ field.auto_id }} = $('#div_{{ field.auto_id }} label').text();
+        $('#div_{{ field.auto_id }} label').text(str_{{ field.auto_id }} + ' (click to edit)');
+
+        $("#div_{{ field.auto_id }}").click(function() {
+          $('#div_{{ field.auto_id }} label').text(str_{{ field.auto_id }});
+          $("#{{ field.auto_id }}").removeClass('hideme');
+          $("#{{ field.auto_id }}").focus();    
+        });        
+    {% endfor %}
+{% endif %}
+});
+</script>
+
+          

uni_form/templates/uni_form/whole_uni_form.html

+{% load uni_form_tags i18n %}
+
+<form action="{{ form_action }}" class="uniForm {{ form_class }}" method="{{ form_method }}" id="{{ form_id|slugify }}" {% if form.is_multipart %}enctype="multipart/form-data"{% endif %}>
+	{% if form_html %}{{ form_html }}{% else %}
+    <fieldset class="inlineLabels">  
+    <legend>* {% trans "Required fields" %}</legend> 
+    	{{ form|as_uni_form }}
+    </fieldset>
+	{% endif %}
+    {% if inputs %}
+        <div class="buttonHolder">
+            {% for input in inputs %}
+                <input type="{{ input.input_type }}"
+                        name="{{ input.name|slugify }}"
+                        value="{{ input.value }}"
+                        {% ifnotequal input.input_type "hidden" %}
+                            class="{{ input.field_classes }}"
+                            id="{{ input.input_type }}-id-{{ input.name|slugify }}"
+                        {% endifnotequal %}
+                        />
+            {% endfor %}
+        </div>    
+    {% endif %}
+
+</form>
Add a comment to this file

uni_form/templatetags/__init__.py

Empty file added.

Add a comment to this file

uni_form/templatetags/__init__.pyc

Binary file added.

uni_form/templatetags/uni_form_field.py

+from django import template
+
+register = template.Library()
+
+class_converter = {
+    "textinput":"textinput textInput",
+    "fileinput":"fileinput fileUpload"
+}
+
+@register.filter
+def is_checkbox(field):
+    return field.field.widget.__class__.__name__.lower() == "checkboxinput"
+
+@register.filter
+def with_class(field):
+    class_name = field.field.widget.__class__.__name__.lower()
+    class_name = class_converter.get(class_name, class_name)
+    if "class" in field.field.widget.attrs:
+        field.field.widget.attrs['class'] += " %s" % class_name
+    else:
+        field.field.widget.attrs['class'] = class_name
+    return unicode(field)
+
+
Add a comment to this file

uni_form/templatetags/uni_form_field.pyc

Binary file added.

uni_form/templatetags/uni_form_tags.py

+from django.conf import settings
+from django.template import Context, Template
+from django.template.loader import get_template
+from django import template
+
+from django.template.defaultfilters import slugify
+
+register = template.Library()
+
+
+###################################################
+# Core as_uni_form filter.
+# You will likely use this simple filter
+# most of the time.
+# This is easy to get working and very simple in
+# concept and execution.
+###################################################
+@register.filter
+def as_uni_form(form):
+    template = get_template('uni_form/uni_form.html')
+    c = Context({'form':form})
+    return template.render(c)
+
+@register.filter
+def as_uni_errors(form):
+    template = get_template('uni_form/errors.html')
+    c = Context({'form':form})
+    return template.render(c)
+
+@register.filter
+def as_uni_field(field):
+    template = get_template('uni_form/field.html')
+    c = Context({'field':field})
+    return template.render(c)
+    
+@register.inclusion_tag("uni_form/includes.html", takes_context=True)
+def uni_form_setup(context):
+    """
+Creates the <style> and <script> tags needed to initialize the uni-form.
+ 
+Create a local uni-form/includes.html template if you want to customize how
+these files are loaded. 
+"""
+    if 'MEDIA_URL' not in context:
+        context['MEDIA_URL'] = settings.MEDIA_URL        
+    return (context)
+
+############################################################################
+#
+# Everything from now on gets more fancy
+# It can be argued that having django-uni-form construct your forms is overkill
+# and that I am playing architecture astronaut games with form building.
+#
+# However, all the bits that follow are designed to be section 508 compliant,
+# so all the fancy JS bits are garanteed to degrade gracefully.
+#
+############################################################################
+
+def namify(text):
+    """ Some of our values need to be rendered safe as python variable names.
+        So we just replaces hyphens with underscores.
+    """
+    return slugify(text).replace('-','_')
+    
+
+class BasicNode(template.Node):
+    """ Basic Node object that we can rely on for Node objects in normal
+        template tags. I created this because most of the tags we'll be using
+        will need both the form object and the helper string. This handles
+        both the form object and parses out the helper string into attributes
+        that templates can easily handle. """
+    
+    def __init__(self, form, helper):
+        self.form = template.Variable(form)
+        self.helper = template.Variable(helper)
+    
+    def get_render(self, context):
+        actual_form = self.form.resolve(context)
+        helper = self.helper.resolve(context)
+        attrs = None
+        if helper:
+            attrs = helper.get_attr()
+        form_class = ''
+        form_id = ''
+        inputs = []
+        toggle_fields = set(())
+        if attrs:
+            form_method = attrs.get("form_method", 'POST')
+            form_action = attrs.get("form_action", '')
+            form_class = attrs.get("class", '')
+            form_id = attrs.get("id", "")
+            inputs = attrs.get('inputs', [])
+            toggle_fields = attrs.get('toggle_fields', set(()))
+        final_toggle_fields = []
+        if toggle_fields:
+            final_toggle_fields = []
+            for field in actual_form:
+                if field.auto_id in toggle_fields:
+                    final_toggle_fields.append(field)
+        
+        if helper and helper.layout:
+            form_html = helper.render_layout(actual_form)
+        else:
+            form_html = ""
+        response_dict = {
+                        'form':actual_form,
+                        'form_html':form_html,
+                        'form_action':form_action,
+                        'form_method':form_method,
+                        'attrs':attrs,
+                        'form_class' : form_class,
+                        'form_id' : form_id,
+                        'inputs' : inputs,
+                        'toggle_fields': final_toggle_fields
+                        }
+        c = Context(response_dict)
+        return c
+        
+
+##################################################################
+#
+# Actual tags start here
+#
+##################################################################
+
+
+@register.tag(name="uni_form")
+def do_uni_form(parser, token):
+    
+    """
+    You need to pass in at least the form object, and can also pass in the
+    optional attrs string. Writing the attrs string is rather challenging so
+    use of the objects found in uni_form.helpers is encouraged.
+    
+    form: The forms object to be rendered by the tag
+    
+    attrs (optional): A string of semi-colon seperated attributes that can be
+    applied to theform in string format. They are used as follows.
+    
+    form_action: applied to the form action attribute. Can be a named url in 
+    your urlconf that can be executed via the *url* default template tag or can
+    simply point to another URL. 
+    Defaults to empty::
+        
+        form_action=<my-form-action>
+    
+    form_method: applied to the form action attribute. Defaults to POST and the only available thing you can enter is GET.::
+        
+        form_method=<my-form-method>
+    
+    id: applied to the form as a whole. Defaults to empty::
+        
+        id=<my-form-id>
+    
+    class: add space seperated classes to the class list. Always starts with uniform::
+        
+        class=<my-first-custom-form-class> <my-custom-form-class>
+    
+    button: for adding of generic buttons. The name also becomes the slugified id::
+        
+        button=<my-custom-button-name>|<my-custom-button-value>
+    
+    submit: For adding of submt buttons. The name also becomes the slugified id::
+        
+        submit=<my-custom-submit-name>|<my-custom-submit-value>
+    
+    hidden: For adding of hidden buttons::
+        
+        hidden=<my-custom-hidden-name>|<my-custom-hidden-value>
+    
+    reset: For adding of reset buttons::
+        
+        reset=<my-custom-reset-name>|<my-custom-reset-value>
+
+    
+    Example::
+        
+        {% uni_form my-form my_helper %}
+    
+    """
+    
+    token = token.split_contents()
+    
+    form = token.pop(1)
+    try:
+        helper = token.pop(1)
+    except IndexError:
+        helper = None
+
+    
+    return UniFormNode(form, helper)
+    
+
+class UniFormNode(BasicNode):
+    
+    def render(self, context):
+        
+        c = self.get_render(context)
+        
+        template = get_template('uni_form/whole_uni_form.html')
+        return template.render(c)
+        
+
+#################################
+# uni_form scripts
+#################################
+
+@register.tag(name="uni_form_jquery")
+def uni_form_jquery(parser, token):
+    """
+    toggle_field: For making fields designed to be toggled for editing add them
+    by spaces. You must specify by field id (field.auto_id)::
+        
+        toggle_fields=<first_field>,<second_field>
+    
+    """
+    
+    token = token.split_contents()
+    
+    form = token.pop(1)
+    try:
+        attrs = token.pop(1)
+    except IndexError:
+        attrs = None
+
+    
+    return UniFormJqueryNode(form,attrs)
+
+class UniFormJqueryNode(BasicNode):
+    
+    def render(self,context):
+        
+        c = self.get_render(context)
+        
+        template = get_template('uni_form/uni_form_jquery.html')
+        return template.render(c)   
Add a comment to this file

uni_form/templatetags/uni_form_tags.pyc

Binary file added.

uni_form/tests/__init__.py

+from tests import *

uni_form/tests/tests.py

+from django import forms
+from django.template import Context, Template
+from django.template.loader import get_template_from_string
+from django.test import TestCase
+
+from uni_form.helpers import FormHelper, Submit, Reset, Hidden, Button
+
+class TestForm(forms.Form):
+    
+    is_company = forms.CharField(label="company", required=False, widget=forms.CheckboxInput())
+    email = forms.CharField(label="email", max_length=30, required=True, widget=forms.TextInput())
+    password1 = forms.CharField(label="password", max_length=30, required=True, widget=forms.PasswordInput())
+    password2 = forms.CharField(label="re-enter password", max_length=30, required=True, widget=forms.PasswordInput())
+    first_name = forms.CharField(label="first name", max_length=30, required=True, widget=forms.TextInput())
+    last_name = forms.CharField(label="last name", max_length=30, required=True, widget=forms.TextInput())
+
+
+class TestBasicFunctionalityTags(TestCase):
+    
+    def setUp(self):
+        pass
+    
+    def tearDown(self):
+        pass
+    
+    def test_as_uni_form(self):
+        
+        # build the context
+        c = Context({'form':TestForm()})
+        
+        # Simple form templare
+        template = get_template_from_string("""
+{% load uni_form_tags %}
+{{ form|as_uni_form }}
+        """)
+        
+        # render the form template
+        html = template.render(c)
+        
+        self.assertTrue("<td>" not in html)
+        self.assertTrue("id_is_company" in html)
+    
+    def test_uni_form_setup(self):
+        
+        c = Context()
+        template = get_template_from_string("""
+{% load uni_form_tags %}
+{% uni_form_setup %}
+        """)
+        html = template.render(c)
+        
+        # Just look for file names because locations and names can change.
+        self.assertTrue('uni-form-generic.css' in html)
+        self.assertTrue('uni-form.css' in html)
+        self.assertTrue('uni-form.jquery.js' in html)
+        
+class TestFormHelpers(TestCase):
+    
+    def setUp(self):
+        pass
+    
+    def tearDown(self):
+        pass    
+    
+    def test_uni_form_helper_inputs(self):
+        
+        form_helper = FormHelper()
+        submit  = Submit('my-submit', 'Submit')
+        reset   = Reset('my-reset', 'Reset')
+        hidden  = Hidden('my-hidden', 'Hidden')
+        button  = Button('my-button', 'Button')
+        form_helper.add_input(submit)
+        form_helper.add_input(reset)
+        form_helper.add_input(hidden)
+        form_helper.add_input(button)
+        
+        c = Context({'form':TestForm(),'form_helper':form_helper})        
+        
+        template = get_template_from_string("""
+{% load uni_form_tags %}
+{% uni_form form form_helper %}
+        """)
+        html = template.render(c)
+        
+        self.assertTrue('class="submit submitButton"' in html)
+        self.assertTrue('id="submit-id-my-submit"' in html)        
+
+        self.assertTrue('class="reset resetButton"' in html)
+        self.assertTrue('id="reset-id-my-reset"' in html)        
+
+        self.assertTrue('name="my-hidden"' in html)        
+
+        self.assertTrue('class="button"' in html)
+        self.assertTrue('id="button-id-my-button"' in html)        
+
+    def test_uni_form_helper_generic_attributes(self):
+        
+        form_helper = FormHelper()    
+        form_helper.form_id = 'this-form-rocks'
+        form_helper.form_class = 'forms-that-rock'
+        form_helper.form_method = 'GET'
+    
+        c = Context({'form':TestForm(),'form_helper':form_helper})            
+        template = get_template_from_string("""
+{% load uni_form_tags %}
+{% uni_form form form_helper %}
+        """)
+        html = template.render(c)        
+
+        good_response = """<form action="" class="uniForm forms-that-rock" method="POST" id="this-form-rocks" >"""
+        
+        self.assertTrue('<form action="" class="uniForm forms-that-rock" method="GET" id="this-form-rocks" >' in html)
+class BaseInput(object):
+    """
+        An base Input class to reduce the amount of code in the Input classes.
+    """
+    
+    def __init__(self,name,value):
+        self.name = name
+        self.value = value
+        
+
+class Toggle(object):
+    """
+        A container for holder toggled items such as fields and buttons.
+    """
+    
+    fields = []
+    
+    

Binary file added.

 # limitations under the License.
 
 from django.conf.urls.defaults import *
+from django.conf import settings
 
 urlpatterns = patterns('',
     # Example:
 
     # Uncomment this for admin:
 #     (r'^admin/', include('django.contrib.admin.urls')),
+
+	# serve static resources
+	(r'^resources/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT }),
+	
+	(r'^', 'posts.views.index'),
+	(r'^posts/', 'posts.views.listPost'),
 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.