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

« back to all changes in this revision

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

Add support in XHTMLView for plugin styles and scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import genshi.template
24
24
 
 
25
from ivle.webapp.media import media_url
25
26
from ivle.webapp.base.views import BaseView
26
27
import ivle.conf
27
28
import ivle.util
32
33
    It is expected that apps which use this view will be written using Genshi
33
34
    templates.
34
35
    """
 
36
 
 
37
    template = 'template.html'
 
38
    plugin_scripts = {}
 
39
    plugin_styles = {}
 
40
 
35
41
    def __init__(self, req, **kwargs):
36
42
        for key in kwargs:
37
43
            setattr(self, key, kwargs[key])
52
58
        tmpl = loader.load(app_template)
53
59
        app = tmpl.generate(viewctx)
54
60
 
 
61
        for plugin in self.plugin_scripts:
 
62
            for path in self.plugin_scripts[plugin]:
 
63
                req.scripts.append(media_url(req, plugin, path))
 
64
 
 
65
        for plugin in self.plugin_styles:
 
66
            for path in self.plugin_styles[plugin]:
 
67
                req.styles.append(media_url(req, plugin, path))
 
68
 
55
69
        # Global template
56
70
        ctx = genshi.template.Context()
57
71
        ctx['app_styles'] = req.styles