Commits

Anonymous committed 35d9bec

Load paragraphs dynamically into post form

  • Participants
  • Parent commits da572a9

Comments (0)

Files changed (4)

File sphinx/builders/webapp/templates/html/comments.html

                         </td>
                      </tr>
                      <tr>
-                        <!-- XXX: rawsources should be loaded automatically from jQuery script -->
                         <td>Paragraph:</td>
-                        <td><textarea name="paragraph" rows=10 cols=70></textarea></td>
-                        <textarea name="paragraph_unchanged" style="display: none"></textarea>
+                        <td><textarea name="paragraph_{{ paragraph_id }}" rows=10 cols=70></textarea>
+                           <textarea name="paragraph_orig_{{ paragraph_id }}" style="display: none"></textarea>
+                        </td>
                      </tr>
                      <tr>
                         <td colspan=2> &nbsp; </td>

File sphinx/themes/basic/static/comments.js

    var p_path = location.protocol + "//" + location.host
                 + "/get_paragraph?node=" + node + "&id=" + id;
    $.getJSON(p_path, function(data) {
-        alert(data);
-        // get the paragraph
+        $('textarea[name=paragraph_' + id + ']').replaceWith(
+           '<textarea name="paragraph_' + id + '" rows=10 cols=70>' + data + '</textarea>');
+        $('textarea[name=paragraph_orig_' + id + ']').replaceWith(
+           '<textarea name="paragraph_orig_' + id + '" style="display: none;">' + data + '</textarea>');
+
    });
    
 }

File sphinx/web/dbutils.py

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 """
-    sphinx.web.reposums
-    ~~~~~~~~~~~~~~~~~~~
+    sphinx.web.dbutils
+    ~~~~~~~~~~~~~~~~~~
 
     Handle MD5 sums database and checking.
   

File sphinx/web/middleware/appserver.py

             with the data from req.POST."""
             pid = reqdict['paragraph_id']
             post_elems = [ 'paragraph_id', 'name', 'email', 'www', 'priority',
-                           'paragraph', 'paragraph_unchanged', 'comment',
-                           'reply_to_%s' % (pid)]
+                           'comment', 'reply_to_%s' % (pid)]
             db_rec = {}
             for elem in post_elems:
                 if elem in reqdict:
         db_rec['width'] = 100
 
         if req.POST.get('submitFix'):
+            p_str = 'paragraph_%s' % (p_id)
+            p_orig_str = 'paragraph_orig_%s' % (p_id)
             db_rec['priority'] = req.POST.get('priority')
-            db_rec['paragraph'] = req.POST.get('paragraph')
+            db_rec['paragraph'] = req.POST.get(p_str)
 
-            p1 = req.POST.get('paragraph').splitlines(1)
-            p2 = req.POST.get('paragraph_unchanged').splitlines(1)
+            p1 = req.POST.get(p_str).splitlines(1)
+            p2 = req.POST.get(p_orig_str).splitlines(1)
 
             d = Differ()
             db_rec['paragraph'] = modify_diff(list(d.compare(p2, p1)))