diff options
Diffstat (limited to 'israwhidebroken')
-rw-r--r-- | israwhidebroken/config/app.cfg | 35 | ||||
-rw-r--r-- | israwhidebroken/controllers.py | 7 | ||||
-rw-r--r-- | israwhidebroken/json.py | 22 | ||||
-rw-r--r-- | israwhidebroken/model.py | 107 | ||||
-rw-r--r-- | israwhidebroken/release.py | 10 | ||||
-rw-r--r-- | israwhidebroken/templates/footer.html | 17 | ||||
-rw-r--r-- | israwhidebroken/templates/header.html | 14 | ||||
-rw-r--r-- | israwhidebroken/templates/index.html | 17 | ||||
-rw-r--r-- | israwhidebroken/templates/login.html | 18 | ||||
-rw-r--r-- | israwhidebroken/templates/login.kid | 114 | ||||
-rw-r--r-- | israwhidebroken/templates/master.html | 32 | ||||
-rw-r--r-- | israwhidebroken/templates/master.kid | 50 | ||||
-rw-r--r-- | israwhidebroken/templates/welcome.kid | 47 |
13 files changed, 114 insertions, 376 deletions
diff --git a/israwhidebroken/config/app.cfg b/israwhidebroken/config/app.cfg index e980e09..97b8ddf 100644 --- a/israwhidebroken/config/app.cfg +++ b/israwhidebroken/config/app.cfg @@ -14,7 +14,7 @@ package = "israwhidebroken" # which view (template engine) to use if one is not specified in the # template name -# tg.defaultview = "kid" +tg.defaultview = "genshi" # The following Kid settings determine the settings used by the Kid serializer. @@ -91,11 +91,11 @@ visit.on=True # visit.cookie.path="/" # The name of the VisitManager plugin to use for visitor tracking. -visit.manager="sqlobject" +visit.manager="jsonfas2" -# Database class to use for visit tracking -visit.soprovider.model = "israwhidebroken.model.Visit" -identity.soprovider.model.visit = "israwhidebroken.model.VisitIdentity" +# Allow the cookies to be transported over regular http +# XXX FIXME CHANGE THIS FOR DEPLOYMENT +visit.cookie.secure = False # IDENTITY # -------- @@ -115,7 +115,7 @@ identity.failure_url="/login" # an https:// url in the failure_url, this will be respected. identity.force_external_redirect=False -# identity.provider='sqlobject' +identity.provider='jsonfas2' # The names of the fields on the login form containing the visitor's user ID # and password. In addition, the submit button is specified simply so its @@ -130,29 +130,6 @@ identity.force_external_redirect=False # Valid sources: form, visit, http_auth # identity.source="form,http_auth,visit" -# SqlObjectIdentityProvider -# ------------------------- -# Configuration options for the default IdentityProvider - -# The classes you wish to use for your Identity model. Remember to not use reserved -# SQL keywords for class names (at least unless you specify a different table -# name using sqlmeta). -identity.soprovider.model.user="israwhidebroken.model.User" -identity.soprovider.model.group="israwhidebroken.model.Group" -identity.soprovider.model.permission="israwhidebroken.model.Permission" - -# The password encryption algorithm used when comparing passwords against what's -# stored in the database. Valid values are 'md5' or 'sha1'. If you do not -# specify an encryption algorithm, passwords are expected to be clear text. -# The SqlObjectProvider *will* encrypt passwords supplied as part of your login -# form. If you set the password through the password property, like: -# my_user.password = 'secret' -# the password will be encrypted in the database, provided identity is up and -# running, or you have loaded the configuration specifying what encryption to -# use (in situations where identity may not yet be running, like tests). - -# identity.soprovider.encryption_algorithm=None - # compress the data sends to the web browser # [/] # gzip_filter.on = True diff --git a/israwhidebroken/controllers.py b/israwhidebroken/controllers.py index 1d93406..03e049e 100644 --- a/israwhidebroken/controllers.py +++ b/israwhidebroken/controllers.py @@ -8,12 +8,15 @@ from cherrypy import request, response # log = logging.getLogger("israwhidebroken.controllers") class Root(controllers.RootController): - @expose(template="israwhidebroken.templates.welcome") + @expose(template="israwhidebroken.templates.index") # @identity.require(identity.in_group("admin")) def index(self): import time # log.debug("Happy TurboGears Controller Responding For Duty") - flash("Your application is now running") + if identity.current.anonymous: + flash("Your application is now running") + else: + flash("Welcome, %s" % identity.current.user_name) return dict(now=time.ctime()) @expose(template="israwhidebroken.templates.login") diff --git a/israwhidebroken/json.py b/israwhidebroken/json.py index 2c27a07..9e47648 100644 --- a/israwhidebroken/json.py +++ b/israwhidebroken/json.py @@ -9,25 +9,3 @@ from turbojson.jsonify import jsonify from turbojson.jsonify import jsonify_sqlobject -from israwhidebroken.model import User, Group, Permission - -@jsonify.when('isinstance(obj, Group)') -def jsonify_group(obj): - result = jsonify_sqlobject( obj ) - result["users"] = [u.user_name for u in obj.users] - result["permissions"] = [p.permission_name for p in obj.permissions] - return result - -@jsonify.when('isinstance(obj, User)') -def jsonify_user(obj): - result = jsonify_sqlobject( obj ) - del result['password'] - result["groups"] = [g.group_name for g in obj.groups] - result["permissions"] = [p.permission_name for p in obj.permissions] - return result - -@jsonify.when('isinstance(obj, Permission)') -def jsonify_permission(obj): - result = jsonify_sqlobject( obj ) - result["groups"] = [g.group_name for g in obj.groups] - return result diff --git a/israwhidebroken/model.py b/israwhidebroken/model.py index 13f3209..6e8bcbd 100644 --- a/israwhidebroken/model.py +++ b/israwhidebroken/model.py @@ -44,110 +44,3 @@ class TestResult(SQLObject): bug_id = IntCol() # timestamp this result was entered timestamp = DateTimeCol(notNone=True) - -# the identity model - - -class Visit(SQLObject): - """ - A visit to your site - """ - class sqlmeta: - table = 'visit' - - visit_key = StringCol(length=40, alternateID=True, - alternateMethodName='by_visit_key') - created = DateTimeCol(default=datetime.now) - expiry = DateTimeCol() - - def lookup_visit(cls, visit_key): - try: - return cls.by_visit_key(visit_key) - except SQLObjectNotFound: - return None - lookup_visit = classmethod(lookup_visit) - - -class VisitIdentity(SQLObject): - """ - A Visit that is link to a User object - """ - visit_key = StringCol(length=40, alternateID=True, - alternateMethodName='by_visit_key') - user_id = IntCol() - - -class Group(SQLObject): - """ - An ultra-simple group definition. - """ - # names like "Group", "Order" and "User" are reserved words in SQL - # so we set the name to something safe for SQL - class sqlmeta: - table = 'tg_group' - - group_name = UnicodeCol(length=16, alternateID=True, - alternateMethodName='by_group_name') - display_name = UnicodeCol(length=255) - created = DateTimeCol(default=datetime.now) - - # collection of all users belonging to this group - users = RelatedJoin('User', intermediateTable='user_group', - joinColumn='group_id', otherColumn='user_id') - - # collection of all permissions for this group - permissions = RelatedJoin('Permission', joinColumn='group_id', - intermediateTable='group_permission', - otherColumn='permission_id') - - -class User(SQLObject): - """ - Reasonably basic User definition. - Probably would want additional attributes. - """ - # names like "Group", "Order" and "User" are reserved words in SQL - # so we set the name to something safe for SQL - class sqlmeta: - table = 'tg_user' - - user_name = UnicodeCol(length=16, alternateID=True, - alternateMethodName='by_user_name') - email_address = UnicodeCol(length=255, alternateID=True, - alternateMethodName='by_email_address') - display_name = UnicodeCol(length=255) - password = UnicodeCol(length=40) - created = DateTimeCol(default=datetime.now) - - # groups this user belongs to - groups = RelatedJoin('Group', intermediateTable='user_group', - joinColumn='user_id', otherColumn='group_id') - - def _get_permissions(self): - perms = set() - for g in self.groups: - perms |= set(g.permissions) - return perms - - def _set_password(self, cleartext_password): - """Runs cleartext_password through the hash algorithm before saving.""" - password_hash = identity.encrypt_password(cleartext_password) - self._SO_set_password(password_hash) - - def set_password_raw(self, password): - """Saves the password as-is to the database.""" - self._SO_set_password(password) - - -class Permission(SQLObject): - """ - A relationship that determines what each Group can do - """ - permission_name = UnicodeCol(length=16, alternateID=True, - alternateMethodName='by_permission_name') - description = UnicodeCol(length=255) - - groups = RelatedJoin('Group', - intermediateTable='group_permission', - joinColumn='permission_id', - otherColumn='group_id') diff --git a/israwhidebroken/release.py b/israwhidebroken/release.py index f2d2272..d9dc06a 100644 --- a/israwhidebroken/release.py +++ b/israwhidebroken/release.py @@ -1,14 +1,14 @@ # Release information about israwhidebroken -version = "1.0" +version = "0.1" # description = "Your plan to rule the world" # long_description = "More description about your plan" -# author = "Your Name Here" -# email = "YourEmail@YourDomain" -# copyright = "Vintage 2008 - a good year indeed" +author = "Will Woods" +email = "wwoods@redhat.com" +copyright = "Copyright (c) 2009 Red Hat, Inc." # if it's open source, you might want to specify these # url = "http://yourcool.site/" # download_url = "http://yourcool.site/download" -# license = "MIT" +license = "GPLv2+" # XXX AGPL? diff --git a/israwhidebroken/templates/footer.html b/israwhidebroken/templates/footer.html new file mode 100644 index 0000000..c703769 --- /dev/null +++ b/israwhidebroken/templates/footer.html @@ -0,0 +1,17 @@ +<html xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude" + py:strip=""> +<py:def function="footer"> +<div id="footer"> + <div class="flogo"> + <img src="${tg.url('/static/images/under_the_hood_blue.png')}" alt="TurboGears" /> + <p><a href="http://www.turbogears.org/2.0/">Powered by TurboGears 2</a></p> + </div> + <div class="foottext"> + <p>TurboGears is a open source front-to-back web development + framework written in Python. Copyright (c) 2005-2008 </p> + </div> + <div class="clearingdiv"></div> +</div> +</py:def> +</html> diff --git a/israwhidebroken/templates/header.html b/israwhidebroken/templates/header.html new file mode 100644 index 0000000..0276130 --- /dev/null +++ b/israwhidebroken/templates/header.html @@ -0,0 +1,14 @@ +<html xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude" + py:strip=""> +<py:def function="header"> + <div id="header"> + <h1> + Is Rawhide Broken? + <py:if test="defined('subtitle')"> + <span class="subtitle" py:replace="subtitle"></span> + </py:if> + </h1> + </div> +</py:def> +</html> diff --git a/israwhidebroken/templates/index.html b/israwhidebroken/templates/index.html new file mode 100644 index 0000000..eb3bc8f --- /dev/null +++ b/israwhidebroken/templates/index.html @@ -0,0 +1,17 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude"> + + <xi:include href="master.html" /> + +<head> + <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> + <title>Is Rawhide Broken?</title> +</head> + +<body> + <div>CONTENT!</div> +</body> +</html> diff --git a/israwhidebroken/templates/login.html b/israwhidebroken/templates/login.html new file mode 100644 index 0000000..c8c1d08 --- /dev/null +++ b/israwhidebroken/templates/login.html @@ -0,0 +1,18 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude"> + +<xi:include href="master.html" /> +<xi:include href="${tg.fedora_template('login.html')}" /> + +<head> +<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> +<title>Login Form</title> +</head> + +<body> +<loginform>${message}</loginform> +</body> +</html> diff --git a/israwhidebroken/templates/login.kid b/israwhidebroken/templates/login.kid deleted file mode 100644 index eb55735..0000000 --- a/israwhidebroken/templates/login.kid +++ /dev/null @@ -1,114 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:py="http://purl.org/kid/ns#"> - -<head> - <meta content="text/html; charset=UTF-8" - http-equiv="content-type" py:replace="''"/> - <title>Login</title> - <style type="text/css"> - #loginBox - { - width: 30%; - margin: auto; - margin-top: 10%; - padding-left: 10%; - padding-right: 10%; - padding-top: 5%; - padding-bottom: 5%; - font-family: verdana; - font-size: 10px; - background-color: #eee; - border: 2px solid #ccc; - } - - #loginBox h1 - { - font-size: 42px; - font-family: "Trebuchet MS"; - margin: 0; - color: #ddd; - } - - #loginBox p - { - position: relative; - top: -1.5em; - padding-left: 4em; - font-size: 12px; - margin: 0; - color: #666; - } - - #loginBox table - { - table-layout: fixed; - border-spacing: 0; - width: 100%; - } - - #loginBox td.label - { - width: 33%; - text-align: right; - } - - #loginBox td.field - { - width: 66%; - } - - #loginBox td.field input - { - width: 100%; - } - - #loginBox td.buttons - { - text-align: right; - } - - </style> -</head> - -<body> - <div id="loginBox"> - <h1>Login</h1> - <p>${message}</p> - <form action="${tg.url(previous_url)}" method="POST"> - <table> - <tr> - <td class="label"> - <label for="user_name">User Name:</label> - </td> - <td class="field"> - <input type="text" id="user_name" name="user_name"/> - </td> - </tr> - <tr> - <td class="label"> - <label for="password">Password:</label> - </td> - <td class="field"> - <input type="password" id="password" name="password"/> - </td> - </tr> - <tr> - <td colspan="2" class="buttons"> - <input type="submit" name="login" value="Login"/> - </td> - </tr> - </table> - - <input py:if="forward_url" type="hidden" name="forward_url" - value="${forward_url}"/> - - <div py:for="name,values in original_parameters.items()" py:strip="1"> - <input py:for="value in isinstance(values, list) and values or [values]" - type="hidden" name="${name}" value="${value}"/> - </div> - </form> - </div> -</body> -</html> diff --git a/israwhidebroken/templates/master.html b/israwhidebroken/templates/master.html new file mode 100644 index 0000000..da38a2d --- /dev/null +++ b/israwhidebroken/templates/master.html @@ -0,0 +1,32 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude" + py:strip=""> + <xi:include href="header.html" /> + <xi:include href="footer.html" /> + <xi:include href="${tg.fedora_template('jsglobals.html')}" /> + +<head py:match="head" py:attrs="select('@*')"> + <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> + <title py:replace="''">Your title goes here</title> + <meta py:replace="select('*')"/> + <link rel="stylesheet" type="text/css" media="screen" href="${tg.url('/static/css/style.css')}" /> +</head> + +<body py:match="body" py:attrs="select('@*')"> + <div id="pageLogin"> + <li py:if="tg.identity.anonymous" id="login" class="loginlogout"><a href="${tg.url(tg.identity.login_url)}">Login</a></li> + <li py:if="not tg.identity.anonymous" id="login" class="loginlogout"><a href="${tg.url('/logout')}">Logout</a></li> + </div> + ${header()} + <div id="main_content"> + <div id="status_block" class="flash" + py:if="value_of('tg_flash', None)" py:content="tg_flash"></div> + <div py:replace="select('*|text()')"/> + <!-- End of content --> + </div> + ${footer()} +</body> +</html> diff --git a/israwhidebroken/templates/master.kid b/israwhidebroken/templates/master.kid deleted file mode 100644 index ba39836..0000000 --- a/israwhidebroken/templates/master.kid +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<?python import sitetemplate ?>
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
- py:extends="sitetemplate">
-
-<head py:match="item.tag=='{http://www.w3.org/1999/xhtml}head'" py:attrs="item.items()">
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
- <title py:replace="''">Your title goes here</title>
- <meta py:replace="item[:]" name="description" content="master template"/>
- <style type="text/css" media="screen">
- #pageLogin
- {
- font-size: 10px;
- font-family: verdana;
- text-align: right;
- }
- </style>
- <link rel="stylesheet" type="text/css" media="screen" href="../static/css/style.css"
- py:attrs="href=tg.url('/static/css/style.css')"/>
-</head>
-
-<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'" py:attrs="item.items()">
- <div py:if="tg.config('identity.on') and not defined('logging_in')" id="pageLogin">
- <span py:if="tg.identity.anonymous">
- <a href="${tg.url(tg.identity.login_url)}">Login</a>
- </span>
- <span py:if="not tg.identity.anonymous">
- Welcome ${tg.identity.user.display_name or tg.identity.user.user_name}.
- <a href="${tg.url('/logout')}">Logout</a>
- </span>
- </div>
-
- <div id="header"> </div>
-
- <div id="main_content">
- <div id="status_block" class="flash"
- py:if="value_of('tg_flash', None)" py:content="tg_flash"></div>
- <div py:replace="[item.text]+item[:]">page content</div>
- </div>
-
- <div id="footer">
- <img src="${tg.url('/static/images/under_the_hood_blue.png')}"
- alt="TurboGears under the hood" />
- <p>TurboGears is a open source front-to-back web development framework
- written in Python</p>
- <p>Copyright © 2007 Kevin Dangoor</p>
- </div>
-</body>
-
-</html>
diff --git a/israwhidebroken/templates/welcome.kid b/israwhidebroken/templates/welcome.kid deleted file mode 100644 index 9095267..0000000 --- a/israwhidebroken/templates/welcome.kid +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
- py:extends="'master.kid'">
-<head>
-<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
-<title>Welcome to TurboGears</title>
-</head>
-<body>
-
- <div id="sidebar">
- <h2>Learn more</h2>
- Learn more about TurboGears and take part in its
- development
- <ul class="links">
- <li><a href="http://www.turbogears.org">Official website</a></li>
- <li><a href="http://docs.turbogears.org">Documentation</a></li>
- <li><a href="http://trac.turbogears.org/turbogears/">Trac
- (bugs/suggestions)</a></li>
- <li><a href="http://groups.google.com/group/turbogears"> Mailing list</a> </li>
- </ul>
- <span py:replace="now">now</span>
- </div>
- <div id="getting_started">
- <ol id="getting_started_steps">
- <li class="getting_started">
- <h3>Model</h3>
- <p> <a href="http://docs.turbogears.org/1.0/GettingStarted/DefineDatabase">Design models</a> in the <span class="code">model.py</span>.<br/>
- Edit <span class="code">dev.cfg</span> to <a href="http://docs.turbogears.org/1.0/GettingStarted/UseDatabase">use a different backend</a>, or start with a pre-configured SQLite database. <br/>
- Use script <span class="code">tg-admin sql create</span> to create the database tables.</p>
- </li>
- <li class="getting_started">
- <h3>View</h3>
- <p> Edit <a href="http://docs.turbogears.org/1.0/GettingStarted/Kid">html-like templates</a> in the <span class="code">/templates</span> folder;<br/>
- Put all <a href="http://docs.turbogears.org/1.0/StaticFiles">static contents</a> in the <span class="code">/static</span> folder. </p>
- </li>
- <li class="getting_started">
- <h3>Controller</h3>
- <p> Edit <span class="code"> controllers.py</span> and <a href="http://docs.turbogears.org/1.0/GettingStarted/CherryPy">build your
- website structure</a> with the simplicity of Python objects. <br/>
- TurboGears will automatically reload itself when you modify your project. </p>
- </li>
- </ol>
- <div class="notice"> If you create something cool, please <a href="http://groups.google.com/group/turbogears">let people know</a>, and consider contributing something back to the <a href="http://groups.google.com/group/turbogears">community</a>.</div>
- </div>
- <!-- End of getting_started -->
-</body>
-</html>
|