Changeset 3217

Show
Ignore:
Timestamp:
2007-09-02 22:16:15 (1 year ago)
Author:
dcrowdy
Message:

Added keyboard shortcuts (and the ability to disable them); when adding a clip made playback start form that clip, and added a help page.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • arkaiv/trunk/arkaiv/controllers/page.py

    r3215 r3217  
    219219    def addclip(self): 
    220220        clip = {} 
    221         clip['starttime'] = int(request.params['starttime']) 
     221        clip['starttime'] = float(request.params['starttime']) 
    222222        clip['itemid'] = request.params['itemid'] 
    223223        clip['a_text'] = request.params['a_text'] 
    224         clip['id'] = request.params['id'] 
     224        clip['id'] = clip['starttime'] # A kludge so users don't have to worry about providing ids 
    225225        clip['a_href'] = request.params['a_href'] 
    226226        clip['desc'] = request.params['desc'] 
     
    233233        if has_video == "Yes": 
    234234            clip['img_src'] = self.__createimageforclip(cmmlfile, clip) 
    235 #            basename = os.path.splitext(cmmlfile)[0] 
    236 #            imagedirname = basename + "_clipimages" 
    237 #            clipimagename = str(clip['starttime']) + ".png" 
    238 #            oggsource = model.getsourcepath(clip['itemid']) 
    239 #            cwd = os.getcwd() 
    240 #            os.chdir(imagedirname)  # ugly... 
    241 #            frameimage = Frame(oggsource, clip['starttime'], clipimagename)     
    242 #            os.chdir(cwd)   # very ugly... # 
    243 # 
    244 #            # add that info to the dictionary - only needs to be a relative 
    245 #            # location 
    246 # 
    247 #            relpath = os.path.split(imagedirname)[1] 
    248 #            clip['img_src'] = relpath + "/" + clipimagename  
    249235 
    250236        else: 
     
    258244        parser = cmmlParser() 
    259245        parser.addclipstocmmlfile(cmmlfile, cliplist) 
    260         redirect_to(action='displayitem', id=clip['itemid'], edit="yes") 
     246        redirect_to(action='displayitem', id=clip['itemid'],  
     247                    playclip=clip['id'], edit="yes") 
    261248 
    262249    def deleteclip(self): 
     
    532519#        print cwd 
    533520        os.chdir(imagedirname)  # ugly... 
    534         frameimage = Frame(oggsource, int(clipinfo['starttime']), clipimagename)     
     521        frameimage = Frame(oggsource, float(clipinfo['starttime']), clipimagename)     
    535522        print "after frameimage" 
    536523        os.chdir(cwd)   # very ugly... # 
     
    543530        return imagefile 
    544531 
     532    def displayhelp(self): 
     533        return render('/help.mak') 
     534 
     535 
  • arkaiv/trunk/arkaiv/model/__init__.py

    r3214 r3217  
    512512    new_clip = Clip() 
    513513    new_clip.start_time = info['starttime'] 
    514     new_clip.id = info['id'] 
     514    new_clip.id = info['starttime'] 
    515515    new_clip.a_href = info['a_href'] 
    516516    new_clip.a_text = info['a_text'] 
  • arkaiv/trunk/arkaiv/model/cmmlparser.py

    r3213 r3217  
    139139        for clip in cliplist: 
    140140            newclip = Etree.SubElement(root, 'clip') 
    141             newclip.set('id', clip['id']) 
     141#            newclip.set('id', clip['id']) 
    142142            newclip.set('start', str(clip['start_time'])) 
    143             newclip.set('id', clip['id']
     143            newclip.set('id', str(clip['id'])
    144144            img = Etree.SubElement(newclip, 'img') 
    145145            img.set('src', str(clip['img_src'])) 
  • arkaiv/trunk/arkaiv/templates/autohandler

    r3215 r3217  
    66 
    77    </head> 
    8     <body
     8    <body onkeypress='keyPressed(event)'
    99<p class="header"> 
    1010<h1>Arkaiv</h1> 
     
    1313  <li>${ h.link_to("All Items", h.url(action="mainpage")) }</li> 
    1414  <li>${ h.link_to("Collections", h.url(action="collections")) }</li> 
    15   <li>${ h.link_to("Add annodex media", h.url(action="addannodexform")) }</li> 
     15  <li>${ h.link_to("Add media", h.url(action="addannodexform")) }</li> 
     16  <li>${ h.link_to("Help", h.url(action="displayhelp")) }</li> 
    1617  <li><span class="searchpadding"> 
    1718${ h.form(h.url(action='search'), multipart=True) } 
  • arkaiv/trunk/arkaiv/templates/displayitem.mak

    r3215 r3217  
    11<%inherit file="/autohandler"/>  
    22<div id="video"> 
     3 
    34<p id="edititemname">${c.itemname}</p> 
    45<script type="text/javascript"> 
     
    2829<td><input type="text" name="gotofield" size="5"/></td> 
    2930<td>(secs)</td> 
     31<td>Disable key shortcuts:</td> 
     32<td><input type="checkbox" name="shortcuts" value="toggle" onchange="toggleShortcuts()"></td> 
    3033</tr> 
    3134</table> 
     
    167170 
    168171Add new clip: 
    169 ${ h.form(h.url(action='addclip'), multipart=True) } 
    170 <table style="font-size:small"> 
    171 <tr> 
    172     <td>Start time</td> 
     172<!--${ h.form(h.url(action='addclip'), multipart=True) }--> 
     173<form name="addaclip" action="addclip" > 
     174<table style="font-size:small"> 
     175<tr> 
     176    <td>Start</td> 
    173177  <td>${ h.text_field('starttime', size=5) }</td> 
     178    <td>Desc</td> 
     179  <td> 
     180  <input type="text" name="desc" size="20" onfocus="disableShortcuts()" onblur="enableShortcuts()" id="desc" /> 
     181  <!--${ h.text_field('desc') }--></td> 
     182</tr> 
     183<tr> 
    174184    <td>a_text</td> 
    175185  <td>${ h.text_field('a_text') }</td> 
    176 </tr> 
    177 <tr> 
    178     <td>Id</td> 
    179   <td>${ h.text_field('id', size=5) }</td> 
    180186    <td>a_href</td> 
    181187  <td>${ h.text_field('a_href') }</td> 
    182188</tr> 
    183 <tr> 
    184     <td>img_src</td> 
    185   <td>${ h.text_field('img_src', size=5) }</td> 
    186     <td>desc</td> 
    187   <td>${ h.text_field('desc') }</td> 
    188 </tr> 
    189189</table> 
    190190${ h.hidden_field('headindex', value = c.headdict['ixh']) } 
    191191${ h.hidden_field('itemid', value=c.itemid) } 
    192192${ h.hidden_field('hasvideo', value=c.sourcedict['has_video']) } 
    193  
    194193${ h.submit('Add') }  
    195194${ h.end_form() }  
    196 </div> 
     195 
    197196<script> 
    198197var plugin = document.embeds[0]; 
    199198var input  = document.api.ifield; 
     199var clipstart = document.addaclip.starttime; 
    200200var goto  = document.api.gotofield; 
    201201var output = document.api.ofield; 
     202var focusid = "enable"; 
     203var shortcuts = document.api.shortcuts; 
    202204 
    203205function Play() { 
    204206  plugin.play(); 
    205   addOutput("Play!"); 
     207  addOutput("Play"); 
    206208} 
    207209 
    208210function Pause() { 
    209211  plugin.pause(); 
    210   addOutput("Pause!"); 
     212  addOutput("Pause"); 
    211213} 
    212214 
     
    220222function GetPlayPosition() { 
    221223  addOutput("Play position: " + plugin.getPlayPosition() + " ms"); 
     224} 
     225 
     226function PauseOrPlay(){ 
     227        addOutput("current state: " + plugin.getCurrentState()); 
     228        if (plugin.getCurrentState()==0) {Play();} 
     229        else { 
     230        if (plugin.getCurrentState()==1) Pause();} 
    222231} 
    223232 
     
    265274    outLines--; 
    266275  } 
    267 
     276 
     277
     278 
     279function addClipStarttime() { 
     280  clipstart.value = plugin.getPlayPosition()/1000; 
     281
     282 
     283function keyPressed(e) { 
     284  if (focusid=="disable") {return;} 
     285  else { 
     286  switch (String.fromCharCode(e.which)) { 
     287        case "t": GetPlayPosition(); break; 
     288        case "s": addClipStarttime(); break; 
     289        case "p": PauseOrPlay(); break; 
     290  } 
     291  focusid="enable"; 
     292  } 
     293
     294function disableShortcuts() { 
     295  focusid="disable"; 
     296  addOutput("Shortcuts: " + focusid); 
     297  } 
     298 
     299function enableShortcuts() { 
     300  focusid="enable"; 
     301  addOutput("Shortcuts: " + focusid); 
     302  } 
     303 
     304function toggleShortcuts() { 
     305  if (focusid=="enable") {focusid="disable";} 
     306  else { 
     307  if (focusid=="disable") {focusid="enable";} 
     308  } 
     309 
     310
     311 
    268312</script> 
    269313 
     314