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

« back to all changes in this revision

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

Move trampoline UID configuration out of config.

conf.h is now generated during the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    template = 'template.html'
42
42
    plugin_scripts = {}
43
43
    plugin_styles = {}
44
 
    allow_overlays = True
45
44
    overlay_blacklist = []
46
45
 
47
46
    def __init__(self, req, **kwargs):
48
47
        for key in kwargs:
49
48
            setattr(self, key, kwargs[key])
50
49
 
51
 
    def filter(self, stream, ctx):
52
 
        return stream
53
 
 
54
50
    def render(self, req):
55
51
        req.content_type = 'text/html' # TODO: Detect application/xhtml+xml
56
52
 
62
58
        # view.
63
59
        app_template = os.path.join(os.path.dirname(
64
60
                        inspect.getmodule(self).__file__), self.template) 
 
61
        req.write_html_head_foot = False
65
62
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
66
63
        tmpl = loader.load(app_template)
67
 
        app = self.filter(tmpl.generate(viewctx), viewctx)
 
64
        app = tmpl.generate(viewctx)
68
65
 
69
66
        for plugin in self.plugin_scripts:
70
67
            for path in self.plugin_scripts[plugin]:
77
74
        # Global template
78
75
        ctx = genshi.template.Context()
79
76
        # XXX: Leave this here!! (Before req.styles is read)
80
 
        ctx['overlays'] = self.render_overlays(req) if req.user else []
 
77
        ctx['overlays'] = self.render_overlays(req)
81
78
 
82
79
        ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
83
80
        ctx['styles'] += req.styles
84
81
 
85
82
        ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
86
83
                           ('util.js', 'json2.js', 'md5.js')]
87
 
        ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
88
84
        ctx['scripts'] += req.scripts
89
85
 
90
86
        ctx['scripts_init'] = req.scripts_init
91
87
        ctx['app_template'] = app
92
 
        ctx['title_img'] = media_url(req, CorePlugin,
93
 
                                     "images/chrome/title.png")
94
88
        self.populate_headings(req, ctx)
95
89
        tmpl = loader.load(os.path.join(os.path.dirname(__file__), 
96
90
                                                        'ivle-headings.html'))
103
97
        ctx['favicon'] = None
104
98
        ctx['root_dir'] = ivle.conf.root_dir
105
99
        ctx['public_host'] = ivle.conf.public_host
106
 
        ctx['svn_base'] = ivle.conf.svn_addr
107
100
        ctx['write_javascript_settings'] = req.write_javascript_settings
108
101
        if req.user:
109
102
            ctx['login'] = req.user.login
117
110
            ctx['help_path'] = self.help
118
111
 
119
112
        ctx['apps_in_tabs'] = []
120
 
        for plugin in req.config.plugin_index[ViewPlugin]:
 
113
        for plugin in req.plugin_index[ViewPlugin]:
121
114
            if not hasattr(plugin, 'tabs'):
122
115
                continue
123
116
 
124
117
            for tab in plugin.tabs:
125
118
                # tab is a tuple: name, title, desc, icon, path
126
119
                new_app = {}
127
 
                new_app['this_app'] = hasattr(self, 'tab') \
128
 
                                      and tab[0] == self.tab
 
120
                new_app['this_app'] = hasattr(self, 'appname') \
 
121
                                      and tab[0] == self.appname
129
122
 
130
123
                # Icon name
131
124
                if tab[3] is not None:
151
144
        scripts_init.
152
145
        """
153
146
        overlays = []
154
 
        if not self.allow_overlays:
155
 
            return overlays
156
 
 
157
 
        for plugin in req.config.plugin_index[OverlayPlugin]:
 
147
        for plugin in req.plugin_index[OverlayPlugin]:
158
148
            for overclass in plugin.overlays:
159
149
                if overclass in self.overlay_blacklist:
160
150
                    continue
198
188
 
199
189
        if req.user is None:
200
190
            # Not logged in. Redirect to login page.
201
 
            if req.uri == '/':
202
 
                query_string = ''
203
 
            else:
204
 
                query_string = '?url=' + urllib.quote(req.uri, safe="/~")
205
 
            req.throw_redirect('/+login' + query_string)
 
191
            req.throw_redirect('/+login?' + 
 
192
                               urllib.urlencode([('url', req.uri)]))
206
193
 
207
194
        req.status = 403