# HG changeset patch # User Sylvain Thénault # Date 1273048135 -7200 # Node ID 57372dbfd11457e3f48e0daf8e27290c786a33a4 # Parent b5af2ac0c43c910ddb6fc7a1c586ff5fcf1c5667 [https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser diff -r b5af2ac0c43c -r 57372dbfd114 devtools/fake.py --- a/devtools/fake.py Wed May 05 10:22:11 2010 +0200 +++ b/devtools/fake.py Wed May 05 10:28:55 2010 +0200 @@ -30,6 +30,7 @@ class FakeConfig(dict, BaseApptestConfiguration): translations = {} + uiprops = {} apphome = None def __init__(self, appid='data', apphome=None, cubes=()): self.appid = appid diff -r b5af2ac0c43c -r 57372dbfd114 etwist/server.py --- a/etwist/server.py Wed May 05 10:22:11 2010 +0200 +++ b/etwist/server.py Wed May 05 10:28:55 2010 +0200 @@ -178,6 +178,9 @@ pre_path = request.path.split('/')[1:] if pre_path[0] == 'https': pre_path.pop(0) + uiprops = self.config.https_uiprops + else: + uiprops = self.config.uiprops directory = pre_path[0] # Anything in data/, static/, fckeditor/ and the generated versioned # data directory is treated as static files @@ -187,7 +190,7 @@ if directory == 'static': return File(self.config.static_directory) if directory == 'fckeditor': - return File(self.config.ext_resources['FCKEDITOR_PATH']) + return File(uiprops['FCKEDITOR_PATH']) if directory != 'data': # versioned directory, use specific file with http cache # headers so their are cached for a very long time @@ -195,7 +198,7 @@ else: cls = File if path == 'fckeditor': - return cls(self.config.ext_resources['FCKEDITOR_PATH']) + return cls(uiprops['FCKEDITOR_PATH']) if path == directory: # recurse return self datadir = self.config.locate_resource(path) @@ -211,6 +214,8 @@ # reload modified files in debug mode if self.config.debugmode: self.config.uiprops.reload_if_needed() + if self.https_url: + self.config.https_uiprops.reload_if_needed() self.appli.vreg.reload_if_needed() if self.config['profile']: # default profiler don't trace threads return self.render_request(request) diff -r b5af2ac0c43c -r 57372dbfd114 goa/skel/loader.py --- a/goa/skel/loader.py Wed May 05 10:22:11 2010 +0200 +++ b/goa/skel/loader.py Wed May 05 10:28:55 2010 +0200 @@ -30,7 +30,7 @@ # apply monkey patches first goa.do_monkey_patch() # get instance's configuration (will be loaded from app.conf file) - GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js') + GAEConfiguration.uiprops['JAVASCRIPTS'].append('DATADIR/goa.js') config = GAEConfiguration('toto', APPLROOT) # create default groups create_groups() diff -r b5af2ac0c43c -r 57372dbfd114 goa/skel/main.py --- a/goa/skel/main.py Wed May 05 10:22:11 2010 +0200 +++ b/goa/skel/main.py Wed May 05 10:28:55 2010 +0200 @@ -31,7 +31,7 @@ # get instance's configuration (will be loaded from app.conf file) from cubicweb.goa.goaconfig import GAEConfiguration -GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js') +GAEConfiguration.uiprops['JAVASCRIPTS'].append('DATADIR/goa.js') config = GAEConfiguration('toto', APPLROOT) # dynamic objects registry diff -r b5af2ac0c43c -r 57372dbfd114 goa/tools/laxctl.py --- a/goa/tools/laxctl.py Wed May 05 10:22:11 2010 +0200 +++ b/goa/tools/laxctl.py Wed May 05 10:28:55 2010 +0200 @@ -43,7 +43,7 @@ do_monkey_patch() from cubicweb.goa.goavreg import GAEVregistry from cubicweb.goa.goaconfig import GAEConfiguration - #WebConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js') + #WebConfiguration.uiprops['JAVASCRIPTS'].append('DATADIR/goa.js') config = GAEConfiguration('toto', applroot) vreg = GAEVregistry(config) vreg.set_schema(config.load_schema()) diff -r b5af2ac0c43c -r 57372dbfd114 web/formwidgets.py --- a/web/formwidgets.py Wed May 05 10:22:11 2010 +0200 +++ b/web/formwidgets.py Wed May 05 10:28:55 2010 +0200 @@ -549,7 +549,7 @@ return (u""" """ % (helperid, inputid, year, month, - form._cw.vreg.config.uiprops['CALENDAR_ICON'], + form._cw.uiprops['CALENDAR_ICON'], form._cw._('calendar'), helperid) ) @@ -573,7 +573,7 @@ req.add_onload(u'jqNode("%s").datepicker(' '{buttonImage: "%s", dateFormat: "%s", firstDay: 1,' ' showOn: "button", buttonImageOnly: true})' % ( - domid, req.vreg.config.uiprops['CALENDAR_ICON'], fmt)) + domid, req.uiprops['CALENDAR_ICON'], fmt)) if self.datestr is None: value = self.values(form, field)[0] else: @@ -935,7 +935,7 @@ if self.settabindex and not 'tabindex' in attrs: attrs['tabindex'] = form._cw.next_tabindex() if self.icon: - img = tags.img(src=form._cw.vreg.config.uiprops[self.icon], alt=self.icon) + img = tags.img(src=form._cw.uiprops[self.icon], alt=self.icon) else: img = u'' return tags.button(img + xml_escape(label), escapecontent=False, @@ -966,7 +966,7 @@ def render(self, form, field=None, renderer=None): label = form._cw._(self.label) - imgsrc = form._cw.vreg.config.uiprops[self.imgressource] + imgsrc = form._cw.uiprops[self.imgressource] return ''\ '%(label)s%(label)s' % { 'label': label, 'imgsrc': imgsrc, diff -r b5af2ac0c43c -r 57372dbfd114 web/propertysheet.py --- a/web/propertysheet.py Wed May 05 10:22:11 2010 +0200 +++ b/web/propertysheet.py Wed May 05 10:28:55 2010 +0200 @@ -27,7 +27,7 @@ class PropertySheet(dict): def __init__(self, cache_directory, **context): self._cache_directory = cache_directory - self._context = context + self.context = context self.reset() context['sheet'] = self self._percent_rgx = re.compile('%(?!\()') @@ -40,7 +40,7 @@ self._cache = {} def load(self, fpath): - scriptglobals = self._context.copy() + scriptglobals = self.context.copy() scriptglobals['__file__'] = fpath execfile(fpath, scriptglobals, self) self._propfile_mtime[fpath] = os.stat(fpath)[-2] diff -r b5af2ac0c43c -r 57372dbfd114 web/request.py --- a/web/request.py Wed May 05 10:22:11 2010 +0200 +++ b/web/request.py Wed May 05 10:28:55 2010 +0200 @@ -83,6 +83,12 @@ super(CubicWebRequestBase, self).__init__(vreg) self.authmode = vreg.config['auth-mode'] self.https = https + if https: + self.uiprops = vreg.config.https_uiprops + self.datadir_url = vreg.config.https_datadir_url + else: + self.uiprops = vreg.config.uiprops + self.datadir_url = vreg.config.datadir_url # raw html headers that can be added from any view self.html_headers = HTMLHead() # form parameters @@ -99,7 +105,6 @@ self.next_tabindex = self.tabindexgen.next # page id, set by htmlheader template self.pageid = None - self.datadir_url = vreg.config.datadir_url self._set_pageid() # prepare output header self.headers_out = Headers() @@ -794,14 +799,14 @@ u'
') return u'
' - @deprecated('[3.9] use req.vreg.config.uiprops[rid]') + @deprecated('[3.9] use req.uiprops[rid]') def external_resource(self, rid, default=_MARKER): """return a path to an external resource, using its identifier raise `KeyError` if the resource is not defined """ try: - return self.vreg.config.uiprops[rid] + return self.uiprops[rid] except KeyError: if default is _MARKER: raise diff -r b5af2ac0c43c -r 57372dbfd114 web/views/basecomponents.py --- a/web/views/basecomponents.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/basecomponents.py Wed May 05 10:28:55 2010 +0200 @@ -79,7 +79,7 @@ def call(self): self.w(u'' - % (self._cw.base_url(), self._cw.vreg.config.uiprops['LOGO'])) + % (self._cw.base_url(), self._cw.uiprops['LOGO'])) class ApplHelp(component.Component): diff -r b5af2ac0c43c -r 57372dbfd114 web/views/basecontrollers.py --- a/web/views/basecontrollers.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/basecontrollers.py Wed May 05 10:28:55 2010 +0200 @@ -463,7 +463,7 @@ @jsonize def js_external_resource(self, resource): """returns the URL of the external resource named `resource`""" - return self._cw.vreg.config.uiprops[resource] + return self._cw.uiprops[resource] @check_pageid @jsonize diff -r b5af2ac0c43c -r 57372dbfd114 web/views/basetemplates.py --- a/web/views/basetemplates.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/basetemplates.py Wed May 05 10:28:55 2010 +0200 @@ -294,22 +294,22 @@ self.alternates() def favicon(self): - favicon = self._cw.vreg.config.uiprops.get('FAVICON', None) + favicon = self._cw.uiprops.get('FAVICON', None) if favicon: self.whead(u'\n' % favicon) def stylesheets(self): req = self._cw add_css = req.add_css - for css in req.vreg.config.uiprops['STYLESHEETS']: + for css in req.uiprops['STYLESHEETS']: add_css(css, localfile=False) - for css in req.vreg.config.uiprops['STYLESHEETS_PRINT']: + for css in req.uiprops['STYLESHEETS_PRINT']: add_css(css, u'print', localfile=False) - for css in req.vreg.config.uiprops['STYLESHEETS_IE']: + for css in req.uiprops['STYLESHEETS_IE']: add_css(css, localfile=False, ieonly=True) def javascripts(self): - for jscript in self._cw.vreg.config.uiprops['JAVASCRIPTS']: + for jscript in self._cw.uiprops['JAVASCRIPTS']: self._cw.add_js(jscript, localfile=False) def alternates(self): diff -r b5af2ac0c43c -r 57372dbfd114 web/views/idownloadable.py --- a/web/views/idownloadable.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/idownloadable.py Wed May 05 10:28:55 2010 +0200 @@ -48,7 +48,7 @@ w(u'
\n') diff -r b5af2ac0c43c -r 57372dbfd114 web/views/igeocodable.py --- a/web/views/igeocodable.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/igeocodable.py Wed May 05 10:28:55 2010 +0200 @@ -59,7 +59,7 @@ if hasattr(entity, 'marker_icon'): icon = entity.marker_icon() else: - icon = (self._cw.vreg.config.uiprops['GMARKER_ICON'], (20, 34), (4, 34), None) + icon = (self._cw.uiprops['GMARKER_ICON'], (20, 34), (4, 34), None) return {'latitude': entity.latitude, 'longitude': entity.longitude, 'title': entity.dc_long_title(), #icon defines : (icon._url, icon.size, icon.iconAncho', icon.shadow) diff -r b5af2ac0c43c -r 57372dbfd114 web/views/schema.py --- a/web/views/schema.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/schema.py Wed May 05 10:28:55 2010 +0200 @@ -248,7 +248,7 @@ eschema.type, self._cw.build_url('cwetype/%s' % eschema.type), eschema.type, _(eschema.type))) self.w(u'%s' % ( - url, self._cw.vreg.config.uiprops['UP_ICON'], _('up'))) + url, self._cw.uiprops['UP_ICON'], _('up'))) self.w(u'') self.w(u'
') self.permissions_table(eschema) @@ -277,7 +277,7 @@ rschema.type, self._cw.build_url('cwrtype/%s' % rschema.type), rschema.type, _(rschema.type))) self.w(u'%s' % ( - url, self._cw.vreg.config.uiprops['UP_ICON'], _('up'))) + url, self._cw.uiprops['UP_ICON'], _('up'))) self.w(u'') self.grouped_permissions_table(rschema) diff -r b5af2ac0c43c -r 57372dbfd114 web/views/tableview.py --- a/web/views/tableview.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/tableview.py Wed May 05 10:28:55 2010 +0200 @@ -204,7 +204,7 @@ def render_actions(self, divid, actions): box = MenuWidget('', 'tableActionsBox', _class='', islist=False) - label = tags.img(src=self._cw.vreg.config.uiprops['PUCE_DOWN'], + label = tags.img(src=self._cw.uiprops['PUCE_DOWN'], alt=xml_escape(self._cw._('action(s) on this selection'))) menu = PopupBoxMenu(label, isitem=False, link_class='actionsBox', ident='%sActions' % divid) diff -r b5af2ac0c43c -r 57372dbfd114 web/views/xmlrss.py --- a/web/views/xmlrss.py Wed May 05 10:22:11 2010 +0200 +++ b/web/views/xmlrss.py Wed May 05 10:28:55 2010 +0200 @@ -147,7 +147,7 @@ def call(self, **kwargs): try: - rss = self._cw.vreg.config.uiprops['RSS_LOGO'] + rss = self._cw.uiprops['RSS_LOGO'] except KeyError: self.error('missing RSS_LOGO external resource') return diff -r b5af2ac0c43c -r 57372dbfd114 web/webconfig.py --- a/web/webconfig.py Wed May 05 10:22:11 2010 +0200 +++ b/web/webconfig.py Wed May 05 10:28:55 2010 +0200 @@ -302,10 +302,15 @@ if not self.repairing: self.global_set_option('base-url', baseurl) httpsurl = self['https-url'] - if httpsurl and httpsurl[-1] != '/': - httpsurl += '/' - if not self.repairing: - self.global_set_option('https-url', httpsurl) + if httpsurl: + if httpsurl[-1] != '/': + httpsurl += '/' + if not self.repairing: + self.global_set_option('https-url', httpsurl) + if self.debugmode: + self.https_datadir_url = httpsurl + 'data/' + else: + self.https_datadir_url = httpsurl + 'data%s/' % self.instance_md5_version() if self.debugmode: self.datadir_url = baseurl + 'data/' else: @@ -318,31 +323,41 @@ join(self.appdatahome, 'uicache'), data=lambda x: self.datadir_url + x, datadir_url=self.datadir_url[:-1]) + self._init_uiprops(self.uiprops) + if self['https-url']: + self.https_uiprops = PropertySheet( + join(self.appdatahome, 'uicache'), + data=lambda x: self.https_datadir_url + x, + datadir_url=self.https_datadir_url[:-1]) + self._init_uiprops(self.https_uiprops) + + def _init_uiprops(self, uiprops): libuiprops = join(self.shared_dir(), 'data', 'uiprops.py') - self.uiprops.load(libuiprops) + uiprops.load(libuiprops) for path in reversed([self.apphome] + self.cubes_path()): - self._load_ui_properties(path) - self._load_ui_properties(self.apphome) + self._load_ui_properties_file(uiprops, path) + self._load_ui_properties_file(uiprops, self.apphome) - def _load_ui_properties(self, path): + def _load_ui_properties_file(self, uiprops, path): resourcesfile = join(path, 'data', 'external_resources') if exists(resourcesfile): warn('[3.9] %s file is deprecated, use an uiprops.py file' % resourcesfile, DeprecationWarning) + datadir_url = uiprops.context['datadir_url'] for rid, val in read_config(resourcesfile).iteritems(): if rid in ('STYLESHEETS', 'STYLESHEETS_PRINT', 'IE_STYLESHEETS', 'JAVASCRIPTS'): - val = [w.strip().replace('DATADIR/', self.datadir_url) + val = [w.strip().replace('DATADIR', datadir_url) for w in val.split(',') if w.strip()] if rid == 'IE_STYLESHEETS': rid = 'STYLESHEETS_IE' else: - val = val.strip().replace('DATADIR/', self.datadir_url) - self.uiprops[rid] = val + val = val.strip().replace('DATADIR', datadir_url) + uiprops[rid] = val uipropsfile = join(path, 'uiprops.py') if exists(uipropsfile): self.debug('loading %s', uipropsfile) - self.uiprops.load(uipropsfile) + uiprops.load(uipropsfile) # static files handling ###################################################