svn commit: r1816105 - in /ofbiz/ofbiz-framework/trunk/themes/common: webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js webapp/images/OpenLayers-2.13.1.js widget/CommonScreens.xml widget/Theme.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1816105 - in /ofbiz/ofbiz-framework/trunk/themes/common: webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js webapp/images/OpenLayers-2.13.1.js widget/CommonScreens.xml widget/Theme.xml

jleroux@apache.org
Author: jleroux
Date: Thu Nov 23 07:16:25 2017
New Revision: 1816105

URL: http://svn.apache.org/viewvc?rev=1816105&view=rev
Log:
Fixed: OpenStreetMap geolocation no longer works
(OFBIZ-)

Easily checked at
//demo-trunk.ofbiz.apache.org/example/control/ExampleOsmGeoLocationPointSet1

It "works" but OpenStreetMap images are not showing. Locally there are no errors
in log. So hopefully it could be just an OpenStreetMap needed setting change.

Since Pierre said it worked, I searched the reason.

Turned it out it was a CSP exception in my main browser (FF) due to a setting
I'm not sure about. But anyway there are CSP errors reported in browsers tools
console.

I tried to use OpenLayers-4.5.0.js but it did not work as is.

I then tried in GeoLocation.ftl to follow the officially way to use the
Official OSM tileset as protocol-independent URLs

-        map.addLayer(new OpenLayers.Layer.OSM());
+        <#-- Official OSM tileset as protocol-independent URLs -->
+        <#noparse>
+        map.addLayer(new OpenLayers.Layer.OSM(['
//a.tile.openstreetmap.org/${z}/${x}/${y}.png',
'//b.tile.openstreetmap.org/${z}/${x}/${y}.png',
'//c.tile.openstreetmap.org/${z}/${x}/${y}.png']));
+        </#noparse>

But for a reason I did not get it did not work either.

Out of desperation this fixes it by using a modified
OpenLayers-2.13.1-modified-for-CSP-.js lib

Thanks: Pierre Smits for initially saying it was working in Safari

Added:
    ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js
      - copied, changed from r1816103, ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1.js
Removed:
    ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1.js
Modified:
    ofbiz/ofbiz-framework/trunk/themes/common/widget/CommonScreens.xml
    ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml

Copied: ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js (from r1816103, ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1.js)
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js?p2=ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js&p1=ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1.js&r1=1816103&r2=1816105&rev=1816105&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1.js (original)
+++ ofbiz/ofbiz-framework/trunk/themes/common/webapp/images/OpenLayers-2.13.1-modified-for-CSP-.js Thu Nov 23 07:16:25 2017
@@ -606,7 +606,7 @@ b.id));a.appendChild(c);c=this.createEle
 h=d.getAttribute("owsURL")):""!=d.getAttribute("wfs")?(g="WFS",h=d.getAttribute("wfs")):""!=d.getAttribute("wcs")&&(g="WCS",h=d.getAttribute("wcs"));d=d.getElementsByTagName("Query");0<d.length&&((k=d[0].getAttribute("typeName"))||(k=d[0].getAttribute("typename")));d={layerName:e,owsType:g,owsURL:h,typeName:k};c.layerDescriptions.push(d);c.length=c.layerDescriptions.length;c[c.length-1]=d}else if("ServiceException"==e)return{error:(new OpenLayers.Format.OGCExceptionReport).read(a)};return c},CLASS_NAME:"OpenLayers.Format.WMSDescribeLayer.v1_1_1"});
 OpenLayers.Format.WMSDescribeLayer.v1_1_0=OpenLayers.Format.WMSDescribeLayer.v1_1_1;OpenLayers.Layer.XYZ=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:!0,sphericalMercator:!1,zoomOffset:0,serverResolutions:null,initialize:function(a,b,c){if(c&&c.sphericalMercator||this.sphericalMercator)c=OpenLayers.Util.extend({projection:"EPSG:900913",numZoomLevels:19},c);OpenLayers.Layer.Grid.prototype.initialize.apply(this,[a||this.name,b||this.url,{},c])},clone:function(a){null==a&&(a=new OpenLayers.Layer.XYZ(this.name,this.url,this.getOptions()));return a=OpenLayers.Layer.Grid.prototype.clone.apply(this,
 [a])},getURL:function(a){a=this.getXYZ(a);var b=this.url;OpenLayers.Util.isArray(b)&&(b=this.selectUrl(""+a.x+a.y+a.z,b));return OpenLayers.String.format(b,a)},getXYZ:function(a){var b=this.getServerResolution(),c=Math.round((a.left-this.maxExtent.left)/(b*this.tileSize.w));a=Math.round((this.maxExtent.top-a.top)/(b*this.tileSize.h));b=this.getServerZoom();if(this.wrapDateLine)var d=Math.pow(2,b),c=(c%d+d)%d;return{x:c,y:a,z:b}},setMap:function(a){OpenLayers.Layer.Grid.prototype.setMap.apply(this,
-arguments);this.tileOrigin||(this.tileOrigin=new OpenLayers.LonLat(this.maxExtent.left,this.maxExtent.bottom))},CLASS_NAME:"OpenLayers.Layer.XYZ"});OpenLayers.Layer.OSM=OpenLayers.Class(OpenLayers.Layer.XYZ,{name:"OpenStreetMap",url:["http://a.tile.openstreetmap.org/${z}/${x}/${y}.png","http://b.tile.openstreetmap.org/${z}/${x}/${y}.png","http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"],attribution:"&copy; <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors",sphericalMercator:!0,wrapDateLine:!0,tileOptions:null,initialize:function(a,b,c){OpenLayers.Layer.XYZ.prototype.initialize.apply(this,arguments);this.tileOptions=
+arguments);this.tileOrigin||(this.tileOrigin=new OpenLayers.LonLat(this.maxExtent.left,this.maxExtent.bottom))},CLASS_NAME:"OpenLayers.Layer.XYZ"});OpenLayers.Layer.OSM=OpenLayers.Class(OpenLayers.Layer.XYZ,{name:"OpenStreetMap",url:["//a.tile.openstreetmap.org/${z}/${x}/${y}.png","//b.tile.openstreetmap.org/${z}/${x}/${y}.png","//c.tile.openstreetmap.org/${z}/${x}/${y}.png"],attribution:"&copy; <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors",sphericalMercator:!0,wrapDateLine:!0,tileOptions:null,initialize:function(a,b,c){OpenLayers.Layer.XYZ.prototype.initialize.apply(this,arguments);this.tileOptions=
 OpenLayers.Util.extend({crossOriginKeyword:"anonymous"},this.options&&this.options.tileOptions)},clone:function(a){null==a&&(a=new OpenLayers.Layer.OSM(this.name,this.url,this.getOptions()));return a=OpenLayers.Layer.XYZ.prototype.clone.apply(this,[a])},CLASS_NAME:"OpenLayers.Layer.OSM"});OpenLayers.Renderer=OpenLayers.Class({container:null,root:null,extent:null,locked:!1,size:null,resolution:null,map:null,featureDx:0,initialize:function(a,b){this.container=OpenLayers.Util.getElement(a);OpenLayers.Util.extend(this,b)},destroy:function(){this.map=this.resolution=this.size=this.extent=this.container=null},supported:function(){return!1},setExtent:function(a,b){this.extent=a.clone();if(this.map.baseLayer&&this.map.baseLayer.wrapDateLine){var c=a.getWidth()/this.map.getExtent().getWidth();
 a=a.scale(1/c);this.extent=a.wrapDateLine(this.map.getMaxExtent()).scale(c)}b&&(this.resolution=null);return!0},setSize:function(a){this.size=a.clone();this.resolution=null},getResolution:function(){return this.resolution=this.resolution||this.map.getResolution()},drawFeature:function(a,b){null==b&&(b=a.style);if(a.geometry){var c=a.geometry.getBounds();if(c){var d;this.map.baseLayer&&this.map.baseLayer.wrapDateLine&&(d=this.map.getMaxExtent());c.intersectsBounds(this.extent,{worldBounds:d})?this.calculateFeatureDx(c,
 d):b={display:"none"};c=this.drawGeometry(a.geometry,b,a.id);if("none"!=b.display&&b.label&&!1!==c){d=a.geometry.getCentroid();if(b.labelXOffset||b.labelYOffset){var e=isNaN(b.labelXOffset)?0:b.labelXOffset,f=isNaN(b.labelYOffset)?0:b.labelYOffset,g=this.getResolution();d.move(e*g,f*g)}this.drawText(a.id,b,d)}else this.removeText(a.id);return c}}},calculateFeatureDx:function(a,b){this.featureDx=0;if(b){var c=b.getWidth();this.featureDx=Math.round(((a.left+a.right)/2-(this.extent.left+this.extent.right)/

Modified: ofbiz/ofbiz-framework/trunk/themes/common/widget/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common/widget/CommonScreens.xml?rev=1816105&r1=1816104&r2=1816105&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/themes/common/widget/CommonScreens.xml (original)
+++ ofbiz/ofbiz-framework/trunk/themes/common/widget/CommonScreens.xml Thu Nov 23 07:16:25 2017
@@ -442,7 +442,7 @@ under the License.
                     <!-- jQuery CSSs -->
                 <set field="layoutSettings.styleSheets[+0]" value="/common/js/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true"/>
 
-                <set field="layoutSettings.javaScripts[]" value="/images/OpenLayers-2.13.1.js" global="true" />
+                <set field="layoutSettings.javaScripts[]" value="/images/OpenLayers-2.13.1-modified-for-CSP-.js" global="true" />
                 <set field="layoutSettings.javaScripts[]" value="/common/js/util/OfbizUtil.js" global="true"/>
                 <set field="layoutSettings.javaScripts[]" value="/common/js/util/fieldlookup.js" global="true"/>
                 <!-- The default (global) shortcut icon -->

Modified: ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml?rev=1816105&r1=1816104&r2=1816105&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml (original)
+++ ofbiz/ofbiz-framework/trunk/themes/common/widget/Theme.xml Thu Nov 23 07:16:25 2017
@@ -67,7 +67,7 @@ under the License.
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/jquery.maskedinput-1.3.1.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/jeditable/jquery.jeditable.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/validate/jquery.validate.min.js"/>
-        <property name="VT_HDR_JAVASCRIPT['add']" value="/images/OpenLayers-2.13.1.js"/>
+        <property name="VT_HDR_JAVASCRIPT['add']" value="/images/OpenLayers-2.13.1-modified-for-CSP-.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/elrte-1.3/js/elrte.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/OfbizUtil.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/fieldlookup.js"/>