[cvs-annodex] commit (/annodex): cmmlwiki/trunk/cgi-bin/edit.cgi cmmlwiki/trunk/cmmlwiki/browse.py

conrad nobody at lists.annodex.net
Mon Sep 26 00:45:46 EST 2005


Update of /annodex (new revision 1497)

Modified files:
   cmmlwiki/trunk/cgi-bin/edit.cgi
   cmmlwiki/trunk/cmmlwiki/browse.py

Log Message:
move edit form into browse.py subpackage


Modified: cmmlwiki/trunk/cgi-bin/edit.cgi
===================================================================
--- cmmlwiki/trunk/cgi-bin/edit.cgi	2005-09-25 14:28:56 UTC (rev 1496)
+++ cmmlwiki/trunk/cgi-bin/edit.cgi	2005-09-25 14:45:46 UTC (rev 1497)
@@ -56,93 +56,20 @@
 
     html_foot()
 
-def edit_form(dict):
+def edit(inspector, form):
+    try:
+      ixc = form['ixc'].value
+    except KeyError:
+      ixc = -1
     content_type ("text/html")
 
     html_head ("CMML Wiki")
 
-    print """
-<form method="post" action="">
-<input type="hidden" name="action" value="store"/>
-<input type="hidden" name="ixc" value="%(ixc)s"/>
+    name = ''
+    cmmlwiki.browse.clip_details (inspector, name, ixc)
 
-<div id="%(id)s" class="clip">
-<img src="%(img_src)s" align="left"/>
-<h3>%(id)s</h3>
-<table>
-<tr>
-  <th>Start:</th>
-  <td colspan="3"><input type="text" size="80" name="start_time" value="%(start_time)s"/><td>
-</tr>
-<tr>
-  <th>id:</th>
-  <td colspan="3"><input type="text" size="80" name="id" value="%(id)s"/><td>
-</tr>
-<tr>
-  <th>Image:</th>
-  <td colspan="3"><input type="text" size="80" name="img_src" value="%(img_src)s"/><td>
-</tr>
-<tr>
-  <th>Link:</th>
-  <td colspan="3"><input type="text" size="80" name="a_href" value="%(a_href)s"/><td>
-</tr>
-<tr>
-  <th>Link text:</th>
-  <td colspan="3"><input type="text" size="80" name="a_text" value="%(a_text)s"/><td>
-</tr>
-<tr>
-  <th>Desc:</th>
-  <td colspan="3"><textarea rows="8" cols="80" name="desc">%(desc)s</textarea></td>
-</tr>
-</table>
-</div>
-<div class="buttons">
-  <input type="reset" value="Reset"/>&nbsp;
-  <input type="submit" name="store" value="Save"/>&nbsp;
-  <input type="submit" name="store" value="Preview TOC"/>&nbsp;
-  <input type="submit" name="store" value="Preview Video"/>&nbsp;
-  <input type="submit" name="store" value="Cancel"/>&nbsp;
-</div>
-</form>
-""" % dict
-
     html_foot()
 
-def edit(form):
-    try:
-      ixc = form['ixc'].value
-    except KeyError:
-      ixc = -1
-
-    if (ixc == -1):
-        dict = {}
-        dict['ixc'] = -1
-        dict['start_time'] = 0
-        dict['id'] = ""
-        dict['img_src'] = ""
-        dict['a_href'] = ""
-        dict['a_text'] = ""
-        dict['desc'] = ""
-        edit_form(dict)
-    else:
-        con = sqlite.connect(db)
-        cur = con.cursor()
-        sql = 'SELECT * FROM clips WHERE ixc="%s"' % ixc
-        cur.execute(sql)
-        try:
-            row = cur.next()
-            dict = {}
-            dict['ixc'] = row['ixc']
-            dict['start_time'] = time2npt(row['start_time'])
-            dict['id'] = xmlescape (row['id'])
-            dict['img_src'] = row['img_src']
-            dict['a_href'] = row['a_href']
-            dict['a_text'] = row['a_text']
-            dict['desc'] = xmlescape (row['desc'])
-            edit_form(dict)
-        except StopIteration:
-            error ("No such id %s" % ixc)
-
 #def attr_str (attr, dict, key):
 #    if (dict.has_key(key)):
 #      return '%s="%s"' % (attr, dict[key])
@@ -309,7 +236,7 @@
     elif (action == "toc"):
         toc(inspector, ixi)
     elif (action == "edit"):
-        edit(form)
+        edit(inspector, form)
     elif (action == "store"):
         store(inspector, ixi, form)
     elif (action == "delete"):

Modified: cmmlwiki/trunk/cmmlwiki/browse.py
===================================================================
--- cmmlwiki/trunk/cmmlwiki/browse.py	2005-09-25 14:28:56 UTC (rev 1496)
+++ cmmlwiki/trunk/cmmlwiki/browse.py	2005-09-25 14:45:46 UTC (rev 1497)
@@ -129,3 +129,77 @@
 """ % (divid)
   #new Draggable ('%s', {constraint:false,handle:'dhandle'});
 
+def clip_details (inspector, name, ixc):
+
+    def print_clip_details(dict):
+        print """
+<form method="post" action="">
+<input type="hidden" name="action" value="store"/>
+<input type="hidden" name="ixc" value="%(ixc)s"/>
+
+<div id="%(id)s" class="clip">
+<img src="%(img_src)s" align="left"/>
+<h3>%(id)s</h3>
+<table>
+<tr>
+  <th>Start:</th>
+  <td colspan="3"><input type="text" size="80" name="start_time" value="%(start_time)s"/><td>
+</tr>
+<tr>
+  <th>id:</th>
+  <td colspan="3"><input type="text" size="80" name="id" value="%(id)s"/><td>
+</tr>
+<tr>
+  <th>Image:</th>
+  <td colspan="3"><input type="text" size="80" name="img_src" value="%(img_src)s"/><td>
+</tr>
+<tr>
+  <th>Link:</th>
+  <td colspan="3"><input type="text" size="80" name="a_href" value="%(a_href)s"/><td>
+</tr>
+<tr>
+  <th>Link text:</th>
+  <td colspan="3"><input type="text" size="80" name="a_text" value="%(a_text)s"/><td>
+</tr>
+<tr>
+  <th>Desc:</th>
+  <td colspan="3"><textarea rows="8" cols="80" name="desc">%(desc)s</textarea></td>
+</tr>
+</table>
+</div>
+<div class="buttons">
+  <input type="reset" value="Reset"/>&nbsp;
+  <input type="submit" name="store" value="Save"/>&nbsp;
+  <input type="submit" name="store" value="Preview TOC"/>&nbsp;
+  <input type="submit" name="store" value="Preview Video"/>&nbsp;
+  <input type="submit" name="store" value="Cancel"/>&nbsp;
+</div>
+</form>
+""" % dict
+
+    if (ixc == -1):
+        dict = {}
+        dict['ixc'] = -1
+        dict['start_time'] = 0
+        dict['id'] = ""
+        dict['img_src'] = ""
+        dict['a_href'] = ""
+        dict['a_text'] = ""
+        dict['desc'] = ""
+        print_clip_details (dict)
+    else:
+        sql = 'SELECT * FROM clips WHERE ixc="%s"' % ixc
+        inspector.cur.execute(sql)
+        try:
+            row = inspector.cur.next()
+            dict = {}
+            dict['ixc'] = row['ixc']
+            dict['start_time'] = time2npt(row['start_time'])
+            dict['id'] = xmlescape (row['id'])
+            dict['img_src'] = row['img_src']
+            dict['a_href'] = row['a_href']
+            dict['a_text'] = row['a_text']
+            dict['desc'] = xmlescape (row['desc'])
+            print_clip_details (dict)
+        except StopIteration:
+            error ("No such id %s" % ixc)


-- 
conrad



More information about the cvs-annodex mailing list