Commits

rgrp  committed a96b122

[misc][m]: fixes for integration with js, refactor to use improved annotator middleware and switch to supporting markdown input text.

  • Participants
  • Parent commits d0ab95d

Comments (0)

Files changed (6)

File commentonit/config/routing.py

 
     map.connect('home', '/', controller='home', action='index')
     map.connect('annotate', '/annotate', controller='home', action='annotate')
+    # need both of these for e.g. the annotation store ...
+    # /annotation/ (used in GET) and /annotation used in PUT
+    map.connect('/{controller}')
     map.connect('/{controller}/')
     map.connect('/{controller}/{action}')
     map.connect('/{controller}/{action}/{id}')

File commentonit/controllers/home.py

         return render('index.html')
 
     def annotate(self):
+        c.prefix = server_api + 'annotation'
+        c.uri = 'make one up'
         # TODO: create text in the backend ...
         text = request.params.get('text', '')
-        c.content = '<pre>%s</pre>' % text
+        import webhelpers.markdown as md
+        if text:
+            c.content = md.markdown(text)
+        else:
+            c.content = ''
         out = render('annotate.html')
         # out is a webhelpers.html.builder.literal
         # we want to work with raw html ...

File commentonit/templates/annotate.html

   <py:def function="page_title">Annotate</py:def>
 
   <div py:match="content">
+    <div id="text-to-annotate">
     ${h.HTML(c.content)}
-
-    <script>
-        jQuery(function() {
-          $('pre').annotator();
-          $('pre').annotationStore();
-        });
-    </script>
+    </div>
 	</div>
 
   <xi:include href="layout.html" />

File commentonit/templates/index.html

       ${h.file(name='file', size=30)}
       -->
 
-      <label>Enter some text (plain):</label>
+      <label>Enter some text (you can use <a
+          href="http://daringfireball.net/projects/markdown/">markdown</a>)):</label>
       ${h.textarea(name='text', cols=80, rows=10)}
 
       <br />
       <br />
-      ${h.submit('Go', 'Go')}
+      ${h.submit('Go &raquo;', 'Go')}
     </form>
 	</div>
 

File commentonit/templates/layout.html

   <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 src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
+  <script type="text/javascript" src="http://m.okfn.org/kforge/scripts/kforge.js"></script>
+
   <py:if test="defined('page_specific_css')">
     ${page_specific_css()}
   </py:if>

File commentonit/tests/functional/test_home.py

     def test_annotate(self):
         res = self.app.get(url('annotate'))
         assert 'Annotate' in res
-        assert 'jsannotate.min.css' in res
+        assert 'annotator.min.css' in res
     
     sonnet = '''Shall I compare thee to a summer's day?
 Thou art more lovely and more temperate:
         res = form.submit()
         assert 'Annotate' in res 
         assert self.sonnet.split()[0] in res, res
-        assert '<pre' in res