Skip to content

Commit

Permalink
Merge pull request #4411 from geoadmin/fix_PB-764_fix_polyfill
Browse files Browse the repository at this point in the history
PB-764 made polyfill url configurable via env
  • Loading branch information
boecklic authored Jul 5, 2024
2 parents 17b0ceb + 9ad6501 commit f2cab88
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ PIPENV_NOSPIN=True
LOGS_DIR=./logs
SQLALCHEMY_ISOLATION_LEVEL=AUTOCOMMIT
SQLALCHEMY_POOL_PRE_PING=True
DISABLE_POLYFILL=false
POLYFILL_URL="//cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=fetch,requestAnimationFrame,Element.prototype.classList,URL"
2 changes: 2 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ WMTS_PUBLIC_HOST=sys-wmts.dev.bgdi.ch
WSGI_PROCESSES=1
WSGI_THREADS=2
LOGS_DIR=./logs
DISABLE_POLYFILL=false
POLYFILL_URL="//cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=fetch,requestAnimationFrame,Element.prototype.classList,URL"
2 changes: 2 additions & 0 deletions chsdi/config/base.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ max_featureids_request = 20
default_cache_control = ${CACHE_CONTROL}
static_max_age = ${STATIC_MAX_AGE}
robots_file = ${ROBOTS_FILE}
disable_polyfill = ${DISABLE_POLYFILL}
polyfill_url = ${POLYFILL_URL}

# Use the BOD directly, no .po./mo files
dynamic_translation = ${DYNAMIC_TRANSLATION}
4 changes: 3 additions & 1 deletion chsdi/templates/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ window.GeoAdmin.serviceUrl = "${api_url}";
${layersconfig|n}

document.write('<link rel="stylesheet" type="text/css" href="${ga_css}" />');
% if disable_polyfill=='false':
if ('${ignore_polyfill}' != 'true') {
document.write('<scr' + 'ipt type="text/javascript" src="//cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" src="${polyfill_url}"></scr' + 'ipt>');
}
% endif
document.write('<scr' + 'ipt type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js"></scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" src="${epsg_21781_js}"></scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" src="${epsg_2056_js}"></scr' + 'ipt>');
Expand Down
7 changes: 6 additions & 1 deletion chsdi/views/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def get_resource_url(filename, extension, mode_str=''):
epsg_21781_js = get_resource_url('EPSG21781', 'js')
epsg_2056_js = get_resource_url('EPSG2056', 'js')

disable_polyfill = request.registry.settings.get('disable_polyfill')
polyfill_url = request.registry.settings.get('polyfill_url')

response = render_to_response(
'chsdi:templates/loader.js',
{
Expand All @@ -57,7 +60,9 @@ def get_resource_url(filename, extension, mode_str=''):
'epsg_2056_js': epsg_2056_js,
'api_url': request.path_url.replace('/loader.js', ''),
'ignore_polyfill': ignore_polyfill,
'data': json.dumps(data, separators=(',', ':'))
'data': json.dumps(data, separators=(',', ':')),
'disable_polyfill': disable_polyfill,
'polyfill_url': polyfill_url
},
request=request
)
Expand Down

0 comments on commit f2cab88

Please sign in to comment.