Commits

rgrp  committed 8d7cb88

[wui][m]: basic annotate action (though with no annotation atm).

  • Participants
  • Parent commits 0ca3d18

Comments (0)

Files changed (7)

File commentonit/config/routing.py

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

File commentonit/controllers/home.py

     def index(self):
         return render('index.html')
 
+    def annotate(self):
+        # TODO: create text in the backend ...
+        text = request.params.get('text', '')
+        c.content = '<pre>%s</pre>' % text
+        return render('annotate.html')
+

File commentonit/lib/helpers.py

 """
 from webhelpers.html.tags import *
 from routes import url_for
+from genshi import HTML
 

File commentonit/templates/annotate.html

+<html
+  xmlns:py="http://genshi.edgewall.org/"
+  xmlns:xi="http://www.w3.org/2001/XInclude"
+  py:strip="">
+  
+  <py:def function="page_title">Annotate</py:def>
+
+  <div py:match="content">
+    ${h.HTML(c.content)}
+	</div>
+
+  <xi:include href="layout.html" />
+</html>

File commentonit/templates/index.html

 
   <div py:match="content">
     <form action="annotate" method="POST">
-      <label>Enter a Url:</label>
-      ${h.text(name='url', size=30)}
+      <!--
+      <label>Upload a file:</label>
+      ${h.file(name='file', size=30)}
+      -->
+
+      <label>Enter some text (plain):</label>
+      ${h.textarea(name='text', cols=80, rows=10)}
+
+      <br />
+      <br />
+      ${h.submit('Go', 'Go')}
     </form>
 	</div>
 

File commentonit/templates/layout.html

     <div id="top-inner">
       <div id="top-bar">
         <py:choose>
-        <py:when test="c.user">
+        <py:when test="False">
         <p>
-          Logged in as <strong>${c.user}</strong> 
+          Logged in as <strong>${}</strong> 
           | <a href="/account/logout/">Logout</a>
         </p>
         </py:when>

File commentonit/tests/functional/test_home.py

         response = self.app.get(url('home'))
         assert 'Comment on It' in response
 
+    def test_annotate(self):
+        res = self.app.get(url('annotate'))
+        assert 'Annotate' in res
+    
+    sonnet = '''Shall I compare thee to a summer's day?
+Thou art more lovely and more temperate:
+Rough winds do shake the darling buds of May,
+And summer's lease hath all too short a date:
+Sometime too hot the eye of heaven shines,
+And often is his gold complexion dimm'd,
+And every fair from fair sometime declines,
+By chance, or nature's changing course untrimm'd: 
+But thy eternal summer shall not fade,
+Nor lose possession of that fair thou ow'st,
+Nor shall death brag thou wander'st in his shade,
+When in eternal lines to time thou grow'st,
+  So long as men can breathe, or eyes can see,
+  So long lives this, and this gives life to thee.
+'''
+
+    def test_app(self):
+        res = self.app.get(url('home'))
+        form = res.forms[0]
+        form['text'] = self.sonnet
+        res = form.submit()
+        assert 'Annotate' in res 
+        assert self.sonnet.split()[0] in res, res
+