[OpenLayers-Commits] r11464 - in sandbox/cmoullet/openlayers: .
build lib/OpenLayers lib/OpenLayers/Control
lib/OpenLayers/Handler tests/Control tools
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Fri Feb 25 04:01:14 EST 2011
Author: cmoullet
Date: 2011-02-25 01:01:13 -0800 (Fri, 25 Feb 2011)
New Revision: 11464
Added:
sandbox/cmoullet/openlayers/build/mobile.cfg
sandbox/cmoullet/openlayers/tools/closure.py
sandbox/cmoullet/openlayers/tools/closure_ws.py
Modified:
sandbox/cmoullet/openlayers/
sandbox/cmoullet/openlayers/build/README.txt
sandbox/cmoullet/openlayers/build/build.py
sandbox/cmoullet/openlayers/lib/OpenLayers/Control/Geolocate.js
sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseDefaults.js
sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseToolbar.js
sandbox/cmoullet/openlayers/lib/OpenLayers/Control/OverviewMap.js
sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Box.js
sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js
sandbox/cmoullet/openlayers/tests/Control/Geolocate.html
sandbox/cmoullet/openlayers/tools/update_dev_dir.sh
Log:
Merge with trunk
Property changes on: sandbox/cmoullet/openlayers
___________________________________________________________________
Modified: svn:mergeinfo
- /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11161-11410
+ /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11161-11463
Modified: sandbox/cmoullet/openlayers/build/README.txt
===================================================================
--- sandbox/cmoullet/openlayers/build/README.txt 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/build/README.txt 2011-02-25 09:01:13 UTC (rev 11464)
@@ -1,14 +1,43 @@
+The OpenLayers build tool supports several different
+forms of compressing your javascript code, and a method
+of describing build profiles to create customized
+OpenLayers builds with only the components you need.
-## HowTo: Build & deploy "Shrunk" Single File Library version of OpenLayers ##
+When building a file, you can choose to build with several
+different compression options to the Python-based build.py
+script. The following is an example script:
- * Build:
+python build.py -c closure full OpenLayers-closure.js
- cd build
- ./build.py
- cd ..
+This script selects the 'closure' compression mechanism,
+uses a config file called 'full.cfg', and writes the output
+to OpenLayers-closure.js.
- * Upload the result to the server: e.g.
+The options available for compression are:
- scp build/OpenLayers.js openlayers at openlayers.org:openlayers.org/htdocs/code/
+ * closure
+ This requires you to have a closure-compiler.jar in your
+ tools directory. You can do this by fetching the compiler
+ from:
+ http://closure-compiler.googlecode.com/files/compiler-latest.zip
+ Then unzipping that file, and placing compiler.jar into tools
+ and renaming it closure-compiler.jar.
+
+ * closure_ws
+ This uses the closure compiler webservice. This will only work
+ for files source Javascript files which are under 1MB. (Note that
+ the default OpenLayers full build is not under 1MB.)
+
+ * jsmin
+ jsmin is the default compiler, and uses the Python-based
+ jsmin script to compress the Javascript.
+
+ * minimize
+ This is a simple whitespace removing Python script, designed
+ to fill in when other tools are unavailable.
+
+ * none
+ None will leave the Javascript uncompressed.
+
Modified: sandbox/cmoullet/openlayers/build/build.py
===================================================================
--- sandbox/cmoullet/openlayers/build/build.py 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/build/build.py 2011-02-25 09:01:13 UTC (rev 11464)
@@ -12,6 +12,16 @@
have_compressor.append("jsmin")
except ImportError:
print "No jsmin"
+ try:
+ import closure
+ have_compressor.append("closure")
+ except ImportError, E:
+ print "No closure (%s) % E"
+ try:
+ import closure_ws
+ have_compressor.append("closure_ws")
+ except ImportError:
+ print "No closure_ws"
try:
import minimize
@@ -39,14 +49,16 @@
print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
+ print "Compressing using %s" % use_compressor
if use_compressor == "jsmin":
- print "Compressing using jsmin."
minimized = jsmin.jsmin(merged)
elif use_compressor == "minimize":
- print "Compressing using minimize."
minimized = minimize.minimize(merged)
+ elif use_compressor == "closure_ws":
+ minimized = closure_ws.minimize(merged)
+ elif use_compressor == "closure":
+ minimized = closure.minimize(merged)
else: # fallback
- print "Not compressing."
minimized = merged
print "Adding license file."
minimized = file("license.txt").read() + minimized
@@ -60,4 +72,11 @@
opt = optparse.OptionParser(usage="%s [options] [config_file] [output_file]\n Default config_file is 'full.cfg', Default output_file is 'OpenLayers.js'")
opt.add_option("-c", "--compressor", dest="compressor", help="compression method: one of 'jsmin', 'minimize', or 'none'", default="jsmin")
(options, args) = opt.parse_args()
- build(*args, options=options)
+ if not len(args):
+ build(options=options)
+ elif len(args) == 1:
+ build(args[0], options=options)
+ elif len(args) == 2:
+ build(args[0], args[1], options=options)
+ else:
+ print "Wrong number of arguments"
Copied: sandbox/cmoullet/openlayers/build/mobile.cfg (from rev 11463, trunk/openlayers/build/mobile.cfg)
===================================================================
--- sandbox/cmoullet/openlayers/build/mobile.cfg (rev 0)
+++ sandbox/cmoullet/openlayers/build/mobile.cfg 2011-02-25 09:01:13 UTC (rev 11464)
@@ -0,0 +1,18 @@
+[first]
+
+[last]
+
+[include]
+OpenLayers/Map.js
+OpenLayers/Kinetic.js
+OpenLayers/Projection.js
+OpenLayers/Layer/SphericalMercator.js
+OpenLayers/Layer/XYZ.js
+OpenLayers/Layer/Bing.js
+OpenLayers/Control/TouchNavigation.js
+OpenLayers/Control/Geolocate.js
+OpenLayers/Control/ZoomPanel.js
+
+[exclude]
+
+
Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Control/Geolocate.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Control/Geolocate.js 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Control/Geolocate.js 2011-02-25 09:01:13 UTC (rev 11464)
@@ -74,6 +74,14 @@
},
/**
+ * Method: destroy
+ */
+ destroy: function() {
+ this.deactivate();
+ OpenLayers.Control.prototype.destroy.apply(this, arguments);
+ },
+
+ /**
* Method: activate
* Activates the control.
*
Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseDefaults.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseDefaults.js 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseDefaults.js 2011-02-25 09:01:13 UTC (rev 11464)
@@ -165,7 +165,7 @@
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
+ this.map.eventsDiv.appendChild(this.zoomBox);
}
document.onselectstart = OpenLayers.Function.False;
OpenLayers.Event.stop(evt);
@@ -302,7 +302,7 @@
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeZoomBox: function() {
- this.map.viewPortDiv.removeChild(this.zoomBox);
+ this.map.eventsDiv.removeChild(this.zoomBox);
this.zoomBox = null;
},
Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseToolbar.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseToolbar.js 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Control/MouseToolbar.js 2011-02-25 09:01:13 UTC (rev 11464)
@@ -207,7 +207,7 @@
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
+ this.map.eventsDiv.appendChild(this.zoomBox);
this.performedDrag = true;
break;
case "measure":
Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Control/OverviewMap.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Control/OverviewMap.js 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Control/OverviewMap.js 2011-02-25 09:01:13 UTC (rev 11464)
@@ -157,7 +157,7 @@
this.handlers.drag.destroy();
}
- this.ovmap && this.ovmap.viewPortDiv.removeChild(this.extentRectangle);
+ this.ovmap && this.ovmap.eventsDiv.removeChild(this.extentRectangle);
this.extentRectangle = null;
if (this.rectEvents) {
@@ -489,7 +489,7 @@
{controls: [], maxResolution: 'auto',
fallThrough: false}, this.mapOptions);
this.ovmap = new OpenLayers.Map(this.mapDiv, options);
- this.ovmap.viewPortDiv.appendChild(this.extentRectangle);
+ this.ovmap.eventsDiv.appendChild(this.extentRectangle);
// prevent ovmap from being destroyed when the page unloads, because
// the OverviewMap control has to do this (and does it).
Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Box.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Box.js 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Handler/Box.js 2011-02-25 09:01:13 UTC (rev 11464)
@@ -96,10 +96,10 @@
new OpenLayers.Pixel(-9999, -9999));
this.zoomBox.className = this.boxDivClassName;
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
+ this.map.eventsDiv.appendChild(this.zoomBox);
OpenLayers.Element.addClass(
- this.map.viewPortDiv, "olDrawBox"
+ this.map.eventsDiv, "olDrawBox"
);
},
@@ -157,11 +157,11 @@
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeBox: function() {
- this.map.viewPortDiv.removeChild(this.zoomBox);
+ this.map.eventsDiv.removeChild(this.zoomBox);
this.zoomBox = null;
this.boxCharacteristics = null;
OpenLayers.Element.removeClass(
- this.map.viewPortDiv, "olDrawBox"
+ this.map.eventsDiv, "olDrawBox"
);
},
Modified: sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js
===================================================================
--- sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/lib/OpenLayers/Map.js 2011-02-25 09:01:13 UTC (rev 11464)
@@ -643,7 +643,15 @@
/**
* APIMethod: destroy
- * Destroy this map
+ * Destroy this map.
+ * Note that if you are using an application which removes a container
+ * of the map from the DOM, you need to ensure that you destroy the
+ * map *before* this happens; otherwise, the page unload handler
+ * will fail because the DOM elements that map.destroy() wants
+ * to clean up will be gone. (See
+ * http://trac.osgeo.org/openlayers/ticket/2277 for more information).
+ * This will apply to GeoExt and also to other applications which
+ * modify the DOM of the container of the OpenLayers Map.
*/
destroy:function() {
// if unloadDestroy is null, we've already been destroyed
Modified: sandbox/cmoullet/openlayers/tests/Control/Geolocate.html
===================================================================
--- sandbox/cmoullet/openlayers/tests/Control/Geolocate.html 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/tests/Control/Geolocate.html 2011-02-25 09:01:13 UTC (rev 11464)
@@ -113,6 +113,17 @@
map.addControl(control);
control.activate();
}
+ function test_destroy(t) {
+ t.plan(1);
+ var control = new OpenLayers.Control.Geolocate({
+ geolocation: geolocation,
+ watch: true
+ });
+ control.activate();
+ control.destroy();
+ t.ok(control.active === false, "control deactivated before being destroyed");
+ }
+
function loader() {
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("Test Layer",
Copied: sandbox/cmoullet/openlayers/tools/closure.py (from rev 11463, trunk/openlayers/tools/closure.py)
===================================================================
--- sandbox/cmoullet/openlayers/tools/closure.py (rev 0)
+++ sandbox/cmoullet/openlayers/tools/closure.py 2011-02-25 09:01:13 UTC (rev 11464)
@@ -0,0 +1,21 @@
+import sys
+import os
+import tempfile
+
+path = os.path.abspath(os.path.join(os.path.dirname(__file__), "closure-compiler.jar"))
+if not os.path.exists(path):
+ raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
+
+def minimize(code):
+ ntf = tempfile.NamedTemporaryFile()
+ ntf.write(code)
+ ntf.flush()
+
+ ntf2 = tempfile.NamedTemporaryFile()
+
+ os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
+ ntf2.seek(0)
+ data = ntf2.read()
+ ntf.close()
+ ntf2.close()
+ return data
Copied: sandbox/cmoullet/openlayers/tools/closure_ws.py (from rev 11463, trunk/openlayers/tools/closure_ws.py)
===================================================================
--- sandbox/cmoullet/openlayers/tools/closure_ws.py (rev 0)
+++ sandbox/cmoullet/openlayers/tools/closure_ws.py 2011-02-25 09:01:13 UTC (rev 11464)
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+import httplib, urllib, sys
+import time
+# Define the parameters for the POST request and encode them in
+# a URL-safe format.
+
+def minimize(code):
+
+ params = urllib.urlencode([
+ ('js_code', code),
+ ('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
+ ('output_format', 'text'),
+ ('output_info', 'compiled_code'),
+ ])
+
+ t = time.time()
+ # Always use the following value for the Content-type header.
+ headers = { "Content-type": "application/x-www-form-urlencoded" }
+ conn = httplib.HTTPConnection('closure-compiler.appspot.com')
+ conn.request('POST', '/compile', params, headers)
+ response = conn.getresponse()
+ data = response.read()
+ conn.close()
+ if data.startswith("Error"):
+ raise Exception(data)
+ print "%.3f seconds to compile" % (time.time() - t)
+ return data
Modified: sandbox/cmoullet/openlayers/tools/update_dev_dir.sh
===================================================================
--- sandbox/cmoullet/openlayers/tools/update_dev_dir.sh 2011-02-25 08:59:04 UTC (rev 11463)
+++ sandbox/cmoullet/openlayers/tools/update_dev_dir.sh 2011-02-25 09:01:13 UTC (rev 11464)
@@ -18,7 +18,7 @@
cd /osgeo/openlayers/docs/dev/tools/
python exampleparser.py
cd /osgeo/openlayers/docs/dev/build
- ./build.py tests.cfg
+ ./build.py -c closure tests.cfg
cp OpenLayers.js ..
cd ..
More information about the Commits
mailing list