~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to services/serveservice

  • Committer: David Coles
  • Date: 2010-07-28 10:52:48 UTC
  • mfrom: (1791.2.10 mediahandlers)
  • Revision ID: coles.david@gmail.com-20100728105248-zvbn9g72v1nsskvd
A series of HTML5 based media handlers using the <audio> and <video> tags.  
This replaces the previous page that just showed a download link (which is 
already available on the menu).

Also solves issue where media files were downloaded by the client twice (once 
in an AJAX request intended only for text).

Known issues:
    * Bug #588285: External BHO will not be able to play media due to not
      having IVLE cookie.
    * Bug #610745: Does not correctly preview revisions
    * Bug #610780: Ogg media does not work in Chromium

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
def determine_file_type(filename):
38
38
    filetype = mimetypes.guess_type(filename)[0]
39
39
    if filetype is None:
40
 
         filetype = ivle.mimetypes.DEFAULT_MIMETYPE
 
40
        filetype = ivle.mimetypes.DEFAULT_MIMETYPE
41
41
    return filetype
42
42
 
43
43
def throw_error(message, extra={}):
142
142
    zipmod.make_zip(zipbasepath, paths, zipfile)
143
143
 
144
144
    print json.dumps({'type': zip_mimetype,
145
 
                      'name': zipfilename.decode('utf-8')})
 
145
                      'name': zipfilename.decode('utf-8'),
 
146
                      'size': len(zipfile.getvalue()),
 
147
                      })
146
148
 
147
149
    stream = zipfile
148
150
    stream.seek(0)
149
151
else:
150
152
 
151
153
    print json.dumps({'type': determine_file_type(filename),
152
 
                      'name': os.path.basename(filename).decode('utf-8')})
 
154
                      'name': os.path.basename(filename).decode('utf-8'),
 
155
                      'size': os.path.getsize(filename),
 
156
                      })
153
157
    stream = open(filename)
154
158
 
155
159
next = stream.read(1024)