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

« back to all changes in this revision

Viewing changes to ivle/webapp/base/overlays.py

  • 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:
22
22
 
23
23
import genshi
24
24
 
 
25
from ivle.webapp.base.xhtml import GenshiLoaderMixin
 
26
 
 
27
 
25
28
class BaseOverlay(object):
26
29
    """Abstract base class for all overlays."""
27
30
    plugin_scripts = {}
32
35
 
33
36
    def render(self, req):
34
37
        raise NotImplementedError()
35
 
        
36
 
class XHTMLOverlay(BaseOverlay):
 
38
 
 
39
 
 
40
class XHTMLOverlay(GenshiLoaderMixin, BaseOverlay):
37
41
    """Abstract base class for XHTML overlays.
38
 
    
 
42
 
39
43
    An overlay which provides a base class for overlays which need to return 
40
44
    XHTML. It is expected that apps which use this overlay will be written using
41
45
    Genshi templates.
42
46
    """
43
 
    
 
47
 
44
48
    template = 'template.html'
45
 
    
 
49
 
46
50
    def render(self, req):
47
51
        """Renders an XML stream from the template for this overlay."""
48
52
        ctx = genshi.template.Context()
49
53
        # This is where the sub-class is actually called
50
54
        self.populate(req, ctx)
51
 
        
 
55
 
52
56
        # Renders out the template.
53
57
        template_path = os.path.join(os.path.dirname(
54
58
                        inspect.getmodule(self).__file__), self.template)
55
 
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
56
 
        tmpl = loader.load(template_path)
 
59
        tmpl = self._loader.load(template_path)
57
60
        return tmpl.generate(ctx)
58
 
        
 
61
 
59
62
    def populate(self, req, ctx):
60
63
        raise NotImplementedError()