[xiph-commits] r3217 - in arkaiv/trunk/arkaiv: controllers model templates

dcrowdy at svn.annodex.net dcrowdy at svn.annodex.net
Sun Sep 2 22:16:15 PDT 2007


Author: dcrowdy
Date: 2007-09-02 22:16:15 -0700 (Sun, 02 Sep 2007)
New Revision: 3217

Added:
   arkaiv/trunk/arkaiv/templates/help.mak
Modified:
   arkaiv/trunk/arkaiv/controllers/page.py
   arkaiv/trunk/arkaiv/controllers/page.pyc
   arkaiv/trunk/arkaiv/model/__init__.py
   arkaiv/trunk/arkaiv/model/__init__.pyc
   arkaiv/trunk/arkaiv/model/cmmlparser.py
   arkaiv/trunk/arkaiv/model/cmmlparser.pyc
   arkaiv/trunk/arkaiv/templates/autohandler
   arkaiv/trunk/arkaiv/templates/displayitem.mak
Log:
Added keyboard shortcuts (and the ability to disable them); when adding a clip made playback start form that clip, and added a help page.


Modified: arkaiv/trunk/arkaiv/controllers/page.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/page.py	2007-09-03 04:57:14 UTC (rev 3216)
+++ arkaiv/trunk/arkaiv/controllers/page.py	2007-09-03 05:16:15 UTC (rev 3217)
@@ -218,10 +218,10 @@
 
     def addclip(self):
         clip = {}
-        clip['starttime'] = int(request.params['starttime'])
+        clip['starttime'] = float(request.params['starttime'])
         clip['itemid'] = request.params['itemid']
         clip['a_text'] = request.params['a_text']
-        clip['id'] = request.params['id']
+        clip['id'] = clip['starttime'] # A kludge so users don't have to worry about providing ids
         clip['a_href'] = request.params['a_href']
         clip['desc'] = request.params['desc']
         has_video = request.params['hasvideo']
@@ -232,20 +232,6 @@
         # create an image to display for the clip
         if has_video == "Yes":
             clip['img_src'] = self.__createimageforclip(cmmlfile, clip)
-#            basename = os.path.splitext(cmmlfile)[0]
-#            imagedirname = basename + "_clipimages"
-#            clipimagename = str(clip['starttime']) + ".png"
-#            oggsource = model.getsourcepath(clip['itemid'])
-#            cwd = os.getcwd()
-#            os.chdir(imagedirname)  # ugly...
-#            frameimage = Frame(oggsource, clip['starttime'], clipimagename)    
-#            os.chdir(cwd)   # very ugly... #
-#
-#            # add that info to the dictionary - only needs to be a relative
-#            # location
-#
-#            relpath = os.path.split(imagedirname)[1]
-#            clip['img_src'] = relpath + "/" + clipimagename 
 
         else:
             clip['img_src'] = ""
@@ -257,7 +243,8 @@
         cliplist = model.getclipinfoforitem(clip['itemid'])
         parser = cmmlParser()
         parser.addclipstocmmlfile(cmmlfile, cliplist)
-        redirect_to(action='displayitem', id=clip['itemid'], edit="yes")
+        redirect_to(action='displayitem', id=clip['itemid'], 
+                    playclip=clip['id'], edit="yes")
 
     def deleteclip(self):
         clipid = request.params['clipid']
@@ -531,7 +518,7 @@
         cwd = os.getcwd()
 #        print cwd
         os.chdir(imagedirname)  # ugly...
-        frameimage = Frame(oggsource, int(clipinfo['starttime']), clipimagename)    
+        frameimage = Frame(oggsource, float(clipinfo['starttime']), clipimagename)    
         print "after frameimage"
         os.chdir(cwd)   # very ugly... #
 
@@ -542,3 +529,7 @@
 #        print imagefile
         return imagefile
 
+    def displayhelp(self):
+        return render('/help.mak')
+
+

Modified: arkaiv/trunk/arkaiv/controllers/page.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/arkaiv/model/__init__.py
===================================================================
--- arkaiv/trunk/arkaiv/model/__init__.py	2007-09-03 04:57:14 UTC (rev 3216)
+++ arkaiv/trunk/arkaiv/model/__init__.py	2007-09-03 05:16:15 UTC (rev 3217)
@@ -511,7 +511,7 @@
     i = item_q.get_by(ixi=info['itemid'])
     new_clip = Clip()
     new_clip.start_time = info['starttime']
-    new_clip.id = info['id']
+    new_clip.id = info['starttime']
     new_clip.a_href = info['a_href']
     new_clip.a_text = info['a_text']
     new_clip.img_src = info['img_src']

Modified: arkaiv/trunk/arkaiv/model/__init__.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/arkaiv/model/cmmlparser.py
===================================================================
--- arkaiv/trunk/arkaiv/model/cmmlparser.py	2007-09-03 04:57:14 UTC (rev 3216)
+++ arkaiv/trunk/arkaiv/model/cmmlparser.py	2007-09-03 05:16:15 UTC (rev 3217)
@@ -138,9 +138,9 @@
        # Now we write the new clips back
         for clip in cliplist:
             newclip = Etree.SubElement(root, 'clip')
-            newclip.set('id', clip['id'])
+#            newclip.set('id', clip['id'])
             newclip.set('start', str(clip['start_time']))
-            newclip.set('id', clip['id'])
+            newclip.set('id', str(clip['id']))
             img = Etree.SubElement(newclip, 'img')
             img.set('src', str(clip['img_src']))
             desc = Etree.SubElement(newclip, 'desc')

Modified: arkaiv/trunk/arkaiv/model/cmmlparser.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/arkaiv/templates/autohandler
===================================================================
--- arkaiv/trunk/arkaiv/templates/autohandler	2007-09-03 04:57:14 UTC (rev 3216)
+++ arkaiv/trunk/arkaiv/templates/autohandler	2007-09-03 05:16:15 UTC (rev 3217)
@@ -5,14 +5,15 @@
 ${ h.javascript_include_tag('/javascripts/effects.js', builtins=True) } 
 
     </head>
-    <body>
+    <body onkeypress='keyPressed(event)'>
 <p class="header">
 <h1>Arkaiv</h1>
 <div id="navcontainer">
 <ul id="navlist">
   <li>${ h.link_to("All Items", h.url(action="mainpage")) }</li>
   <li>${ h.link_to("Collections", h.url(action="collections")) }</li>
-  <li>${ h.link_to("Add annodex media", h.url(action="addannodexform")) }</li>
+  <li>${ h.link_to("Add media", h.url(action="addannodexform")) }</li>
+  <li>${ h.link_to("Help", h.url(action="displayhelp")) }</li>
   <li><span class="searchpadding">
 ${ h.form(h.url(action='search'), multipart=True) }
 ${ h.text_field('searchterms', value="Search") } 

Modified: arkaiv/trunk/arkaiv/templates/displayitem.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/displayitem.mak	2007-09-03 04:57:14 UTC (rev 3216)
+++ arkaiv/trunk/arkaiv/templates/displayitem.mak	2007-09-03 05:16:15 UTC (rev 3217)
@@ -1,5 +1,6 @@
 <%inherit file="/autohandler"/> 
 <div id="video">
+
 <p id="edititemname">${c.itemname}</p>
 <script type="text/javascript">
  new Ajax.InPlaceEditor('edititemname', '/page/edititemname', { callback: function(form, value) { return 'itemid=${c.itemid}&myparam=' + escape(value) }});
@@ -27,6 +28,8 @@
 <td><input type="button" value="Go to pos" onclick='GotoPosition()'/></td>
 <td><input type="text" name="gotofield" size="5"/></td>
 <td>(secs)</td>
+<td>Disable key shortcuts:</td>
+<td><input type="checkbox" name="shortcuts" value="toggle" onchange="toggleShortcuts()"></td>
 </tr>
 </table>
 <table style="font-size:small">
@@ -166,48 +169,47 @@
 </table>
 
 Add new clip:
-${ h.form(h.url(action='addclip'), multipart=True) }
+<!--${ h.form(h.url(action='addclip'), multipart=True) }-->
+<form name="addaclip" action="addclip" >
 <table style="font-size:small">
 <tr>
-    <td>Start time</td>
+    <td>Start</td>
   <td>${ h.text_field('starttime', size=5) }</td>
+    <td>Desc</td>
+  <td>
+  <input type="text" name="desc" size="20" onfocus="disableShortcuts()" onblur="enableShortcuts()" id="desc" />
+  <!--${ h.text_field('desc') }--></td>
+</tr>
+<tr>
     <td>a_text</td>
   <td>${ h.text_field('a_text') }</td>
-</tr>
-<tr>
-    <td>Id</td>
-  <td>${ h.text_field('id', size=5) }</td>
     <td>a_href</td>
   <td>${ h.text_field('a_href') }</td>
 </tr>
-<tr>
-    <td>img_src</td>
-  <td>${ h.text_field('img_src', size=5) }</td>
-    <td>desc</td>
-  <td>${ h.text_field('desc') }</td>
-</tr>
 </table>
 ${ h.hidden_field('headindex', value = c.headdict['ixh']) }
 ${ h.hidden_field('itemid', value=c.itemid) }
 ${ h.hidden_field('hasvideo', value=c.sourcedict['has_video']) }
-
 ${ h.submit('Add') } 
 ${ h.end_form() } 
-</div>
+
 <script>
 var plugin = document.embeds[0];
 var input  = document.api.ifield;
+var clipstart = document.addaclip.starttime;
 var goto  = document.api.gotofield;
 var output = document.api.ofield;
+var focusid = "enable";
+var shortcuts = document.api.shortcuts;
 
 function Play() {
   plugin.play();
-  addOutput("Play!");
+  addOutput("Play");
 }
 
 function Pause() {
   plugin.pause();
-  addOutput("Pause!");
+  addOutput("Pause");
 }
 
 function SetLocation(location) {
@@ -221,6 +223,13 @@
   addOutput("Play position: " + plugin.getPlayPosition() + " ms");
 }
 
+function PauseOrPlay(){
+	addOutput("current state: " + plugin.getCurrentState());
+	if (plugin.getCurrentState()==0) {Play();}
+	else {
+	if (plugin.getCurrentState()==1) Pause();}
+}
+
 function skip(dir) {
 //    addOutput("we get here")
     i = getInput();
@@ -264,6 +273,42 @@
     output.value = output.value.substr(0, i);
     outLines--;
   }
+
 }
+
+function addClipStarttime() {
+  clipstart.value = plugin.getPlayPosition()/1000;
+}
+
+function keyPressed(e) {
+  if (focusid=="disable") {return;}
+  else {
+  switch (String.fromCharCode(e.which)) {
+  	case "t": GetPlayPosition(); break;
+  	case "s": addClipStarttime(); break;
+  	case "p": PauseOrPlay(); break;
+  }
+  focusid="enable";
+  }
+}
+function disableShortcuts() {
+  focusid="disable";
+  addOutput("Shortcuts: " + focusid);
+  }
+
+function enableShortcuts() {
+  focusid="enable";
+  addOutput("Shortcuts: " + focusid);
+  }
+
+function toggleShortcuts() {
+  if (focusid=="enable") {focusid="disable";}
+  else {
+  if (focusid=="disable") {focusid="enable";}
+  }
+
+}
+
 </script>
 
+

Added: arkaiv/trunk/arkaiv/templates/help.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/help.mak	                        (rev 0)
+++ arkaiv/trunk/arkaiv/templates/help.mak	2007-09-03 05:16:15 UTC (rev 3217)
@@ -0,0 +1,24 @@
+<%inherit file="/autohandler"/> 
+<h2>Help</h2>
+
+<h3>Shortcut keys</h3>
+
+When an item is displayed and played, the following shortcuts work:
+
+<table style="font-size:small">
+<tr>
+<td>Key</td>
+<td>Description</td>
+</tr>
+<tr>
+<td>p</td><td>Toggle play/pause</td>
+</tr>
+<tr>
+<td>t</td> <td>Display the time for the current point in playback</td>
+</tr>
+<tr>
+<td>s</td><td> Add the current playback point time position to the start textbox for adding clips</td>
+</tr>
+</table>
+
+



More information about the commits mailing list