Commits

Anonymous committed 0ca3d18

[wui][m]: set up simple home controller for base index page and wire it in.

  • Participants
  • Parent commits e550400

Comments (0)

Files changed (7)

commentonit/config/routing.py

 
     # CUSTOM ROUTES HERE
 
+    map.connect('home', '/', controller='home', action='index')
     map.connect('/{controller}/{action}')
     map.connect('/{controller}/{action}/{id}')
 

commentonit/controllers/home.py

+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from commentonit.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class HomeController(BaseController):
+
+    def index(self):
+        return render('index.html')
+

commentonit/lib/helpers.py

 Consists of functions to typically be used within templates, but also
 available to Controllers. This module is available to templates as 'h'.
 """
-# Import helpers as desired, or define your own, ie:
-#from webhelpers.html.tags import checkbox, password
+from webhelpers.html.tags import *
+from routes import url_for
+

commentonit/templates/index.html

+<html
+  xmlns:py="http://genshi.edgewall.org/"
+  xmlns:xi="http://www.w3.org/2001/XInclude"
+  py:strip="">
+  
+  <py:def function="page_title">Home</py:def>
+
+  <div py:match="content">
+    <form action="annotate" method="POST">
+      <label>Enter a Url:</label>
+      ${h.text(name='url', size=30)}
+    </form>
+	</div>
+
+  <xi:include href="layout.html" />
+</html>

commentonit/templates/layout.html

+<!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"
+  xmlns:py="http://genshi.edgewall.org/" 
+  xmlns:xi="http://www.w3.org/2001/XInclude"
+  >
+
+<head>
+  <title>Comment on It - ${page_title()}</title>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <link rel="stylesheet" href="http://m.okfn.org/kforge/css/master.css" type="text/css" media="screen, print" title="Master stylesheet" charset="utf-8" />
+  <link rel="stylesheet" href="/css/extra.css" type="text/css" media="screen, print" title="Master stylesheet" charset="utf-8" />
+  <link rel="shortcut icon" href="http://m.okfn.org/gfx/logo/favicon.ico" type="image/x-icon" />
+  <script type="text/javascript" src="http://m.okfn.org/kforge/scripts/prototype.js"></script>
+  <script type="text/javascript" src="http://m.okfn.org/kforge/scripts/behaviour.js"></script>
+  <script type="text/javascript" src="http://m.okfn.org/kforge/scripts/master.js"></script>
+
+  <py:if test="defined('page_specific_css')">
+    ${page_specific_css()}
+  </py:if>
+  <style type="text/css">
+    #top-bar {
+      display: none;
+    }
+
+    #subnav {
+      background: transparent;
+      height: 0px;
+      padding: 0;
+      margin-bottom: -10px;
+    }
+
+  </style>
+</head>
+
+<body>
+<div id="airlock">
+  <!--[if IE]>
+    <hr class="holder" />
+  <![endif]-->
+  <div id="top">
+    <div id="top-inner">
+      <div id="top-bar">
+        <py:choose>
+        <py:when test="c.user">
+        <p>
+          Logged in as <strong>${c.user}</strong> 
+          | <a href="/account/logout/">Logout</a>
+        </p>
+        </py:when>
+        <py:otherwise>
+          <p>
+          <a href="/account/">Register</a> or
+          <a href="/account/login/">Login</a>
+          </p>
+        </py:otherwise>
+        </py:choose>
+      </div><!-- /top-bar -->
+      
+      <h1>
+        <a href="${h.url_for('home')}" title="Home">Comment on It</a>
+      </h1>
+    
+    </div><!-- /top-inner -->
+     
+    <h3 class="hidden">Sections:</h3>
+    <ul id="navigation">
+			<li><a href="${h.url_for('home')}">Home</a></li>
+    </ul>
+    <h3 class="hidden">In this section:</h3>
+    <ul id="subnav">
+      <minornavigation>
+      </minornavigation>
+    </ul>
+       
+    <!--[if IE]>
+    <hr class="holder" />
+    <![endif]-->
+    
+  </div><!-- /top -->
+  
+  <p class="hidden"><a href="#main" title="Skip to page content">[ Skip to main content ]</a></p> 
+  
+  <div id="primary" class="sidebar">
+    <div class="box">
+      <h2>Using This Service</h2>
+      <p></p>
+    </div>
+    <primarysidebar>
+    <!-- Primary Side Bar Goes Here -->
+    </primarysidebar>
+    
+    <!--[if IE]>
+    <hr class="primary" />
+    <![endif]-->
+    
+  </div><!-- /primary -->
+
+  <div id="main">
+    <content>
+      <p>Master content template placeholder &hellip; please replace me.</p>
+    </content>
+    
+    <div id="footer">
+      <p>
+        <a href="http://validator.w3.org/check/referer" title="Valid XHTML 1.1">XHTML</a>
+        | <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>
+        | <a href="http://www.okfn.org/ckan/">Project Home Page</a>
+        | <a href="mailto:info@okfn.org">Contact Us</a>
+      </p>
+      <p>
+        <img style="margin-bottom: -5px;" src="http://m.okfn.org/images/logo/okf_logo_white_and_green_tiny.png" /> An <a href="http://www.okfn.org/">Open Knowledge Foundation</a> Project
+      </p>
+      <p>
+        (c) Open Knowledge Foundation
+        | All material available under <a href="http://www.opendefinition.org/">open licenses</a> (CC by-sa or MIT)
+        | <a href="http://www.opendefinition.org/1.0/"><img
+            style="border: none; margin-bottom: -4px;"
+            src="http://m.okfn.org/images/ok_buttons/ok_90x15_blue.png"
+            alt="This Content and Data is Open" /></a>
+      </p>
+    </div><!-- /footer -->
+    
+    <!--[if IE]>
+    <hr class="main" />
+    <![endif]-->
+    
+  </div><!-- /main -->
+
+</div><!-- /airlock -->
+
+<!-- Google Analytics -->
+<script type="text/javascript">
+  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-8271754-7");
+pageTracker._setDomainName(".isitopen.ckan.net");
+pageTracker._trackPageview();
+} catch(err) {}
+</script>
+<!-- Google Analytics -->
+
+</body>
+</html>

commentonit/tests/__init__.py

 This module initializes the application via ``websetup`` (`paster
 setup-app`) and provides the base testing objects.
 """
-from unittest import TestCase
-
 from paste.deploy import loadapp
 from paste.script.appinstall import SetupCommand
 from pylons import config, url
 
 environ = {}
 
-class TestController(TestCase):
+class TestController(object):
 
     def __init__(self, *args, **kwargs):
         if pylons.test.pylonsapp:
             wsgiapp = loadapp('config:%s' % config['__file__'])
         self.app = TestApp(wsgiapp)
         url._push_object(URLGenerator(config['routes.map'], environ))
-        TestCase.__init__(self, *args, **kwargs)
+

commentonit/tests/functional/test_home.py

+from commentonit.tests import *
+
+class TestHomeController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url('home'))
+        assert 'Comment on It' in response
+