Permalink
Browse files

Merge branch 'master' of github.com:openlayers/ol3 into vector

  • Loading branch information...
2 parents 022917e + f897c74 commit 44ca6c9ff669b1e80478c52ed31ab3e8df82e064 @ahocevar ahocevar committed Mar 3, 2013
View
@@ -8,6 +8,8 @@
/build/ol.css
/build/ol.js
/build/ol-all.js
+/build/ol-simple.js
+/build/ol-whitespace.js
/build/src
/build/phantomjs-*-windows
/build/phantomjs-*-windows.zip
View
@@ -98,7 +98,7 @@ def report_sizes(t):
virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'doc')
-virtual('build', 'build/ol.css', 'build/ol.js')
+virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js')
virtual('todo', 'fixme')
@@ -115,6 +115,18 @@ def build_ol_js(t):
report_sizes(t)
+@target('build/ol-simple.js', PLOVR_JAR, SRC, EXTERNAL_SRC, 'base.json', 'build/ol.json', 'build/ol-simple.json')
+def build_ol_js(t):
+ t.output('%(JAVA)s', '-jar', PLOVR_JAR, 'build', 'build/ol-simple.json')
+ report_sizes(t)
+
+
+@target('build/ol-whitespace.js', PLOVR_JAR, SRC, EXTERNAL_SRC, 'base.json', 'build/ol.json', 'build/ol-whitespace.json')
+def build_ol_js(t):
+ t.output('%(JAVA)s', '-jar', PLOVR_JAR, 'build', 'build/ol-whitespace.json')
+ report_sizes(t)
+
+
virtual('build-all', 'build/ol-all.js')
@@ -229,6 +241,28 @@ def build_lint_src_timestamp(t):
t.touch()
+def _strip_comments(lines):
+ # FIXME this is a horribe hack, we should use a proper JavaScript parser here
+ in_comment = False
+ for line in lines:
+ if in_comment:
+ index = line.find('*/')
+ if index != -1:
+ in_comment = False
+ yield line[index + 2:]
+ else:
+ index = line.find('/*')
+ if index != -1:
+ yield line[:index]
+ in_comment = True
+ else:
+ index = line.find('//')
+ if index != -1:
+ yield line[:index]
+ else:
+ yield line
+
+
@target('build/check-requires-timestamp', SRC, INTERNAL_SRC, EXTERNAL_SRC, EXAMPLES_SRC)
def build_check_requires_timestamp(t):
unused_count = 0
@@ -267,7 +301,7 @@ def build_check_requires_timestamp(t):
requires = set()
uses = set()
lineno = 0
- for line in open(filename):
+ for line in _strip_comments(open(filename)):
lineno += 1
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
if m:
@@ -336,8 +370,10 @@ def hostexamples(t):
t.makedirs('build/gh-pages/%(BRANCH)s/examples')
t.makedirs('build/gh-pages/%(BRANCH)s/build')
t.cp(EXAMPLES, (path.replace('.html', '.js') for path in EXAMPLES), 'examples/style.css', 'build/gh-pages/%(BRANCH)s/examples/')
+ t.rm_rf('build/gh-pages/%(BRANCH)s/examples/data')
+ t.cp_r('examples/data', 'build/gh-pages/%(BRANCH)s/examples/data')
t.cp('build/loader_hosted_examples.js', 'build/gh-pages/%(BRANCH)s/examples/loader.js')
- t.cp('build/ol.js', 'build/ol.css', 'build/gh-pages/%(BRANCH)s/build/')
+ t.cp('build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js', 'build/ol.css', 'build/gh-pages/%(BRANCH)s/build/')
t.cp('examples/example-list.html', 'build/gh-pages/%(BRANCH)s/examples/index.html')
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')
@@ -6,9 +6,9 @@
* This loader is used for the hosted examples. It is used in place of the
* development loader (examples/loader.js).
*
- * ol.css and ol.js are built with Plovr/Closure, based on build/ol.json.
- * (`build.py build` builds them). They are located in the ../build/
- * directory, relatively to this script.
+ * ol.css, ol.js, ol-simple.js, and ol-whitespace.js are built with
+ * Plovr/Closure. `build.py build` builds them. They are located in the
+ * ../build/ directory, relatively to this script.
*
* The script should be named loader.js. So it needs to be renamed to
* loader.js from loader_hosted_examples.js.
@@ -19,28 +19,57 @@
*/
(function() {
- var scripts = document.getElementsByTagName('script');
- var i, src, index, search, chunks, pair, params = {};
+ var i, pair;
+
+ var href = window.location.href, start, end, paramsString, pairs,
+ pageParams = {};
+ if (href.indexOf('?') > 0) {
+ start = href.indexOf('?') + 1;
+ end = href.indexOf('#') > 0 ? href.indexOf('#') : href.length;
+ paramsString = href.substring(start, end);
+ pairs = paramsString.split(/[&;]/);
+ for (i = 0; i < pairs.length; ++i) {
+ pair = pairs[i].split('=');
+ if (pair[0]) {
+ pageParams[decodeURIComponent(pair[0])] =
+ decodeURIComponent(pair[1]);
+ }
+ }
+ }
+
+ var scripts = document.getElementsByTagName('script');
+ var src, index, search, chunks, scriptParams = {};
for (i = scripts.length - 1; i >= 0; --i) {
src = scripts[i].getAttribute('src');
if (~(index = src.indexOf('loader.js?'))) {
search = src.substr(index + 10);
chunks = search ? search.split('&') : [];
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
- params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
+ if (pair[0]) {
+ scriptParams[decodeURIComponent(pair[0])] =
+ decodeURIComponent(pair[1]);
+ }
}
break;
}
}
+ var oljs = 'ol.js', mode;
+ if ('mode' in pageParams) {
+ mode = pageParams.mode.toLowerCase();
+ if (mode != 'advanced') {
+ oljs = 'ol-' + mode + '.js';
+ }
+ }
+
document.write('<link rel="stylesheet" href="../build/ol.css" '+
'type="text/css">');
document.write('<scr' + 'ipt type="text/javascript" ' +
- 'src="../build/ol.js">' +
+ 'src="../build/' + oljs + '">' +
'</scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" ' +
- 'src="' + encodeURIComponent(params.id) + '.js">' +
+ 'src="' + encodeURIComponent(scriptParams.id) + '.js">' +
'</scr' + 'ipt>');
}());
View
@@ -0,0 +1,24 @@
+{
+
+ "id": "ol-simple",
+
+ "externs": [
+ "externs/bingmaps.js",
+ "externs/proj4js.js",
+ "externs/tilejson.js"
+ ],
+
+ "inherits": "ol.json",
+
+ "inputs": [
+ "build/src/internal/src/requireall.js",
+ "build/src/internal/src/types.js"
+ ],
+
+ "mode": "SIMPLE",
+
+ // Note: we can't have a (function(){%output%})() output wrapper with
+ // WHITESPACE and SIMPLE modes. See this link for explanations:
+ // https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
+ "output-wrapper": "%output%"
+}
@@ -0,0 +1,24 @@
+{
+
+ "id": "ol-whitespace",
+
+ "externs": [
+ "externs/bingmaps.js",
+ "externs/proj4js.js",
+ "externs/tilejson.js"
+ ],
+
+ "inherits": "ol.json",
+
+ "inputs": [
+ "build/src/internal/src/requireall.js",
+ "build/src/internal/src/types.js"
+ ],
+
+ "mode": "WHITESPACE",
+
+ // Note: we can't have a (function(){%output%})() output wrapper with
+ // WHITESPACE and SIMPLE modes. See this link for explanations:
+ // https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
+ "output-wrapper": "%output%"
+}
@@ -1,6 +1,3 @@
-goog.require('goog.debug.Console');
-goog.require('goog.debug.Logger');
-goog.require('goog.debug.Logger.Level');
goog.require('ol.AnchoredElement');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
@@ -12,12 +9,6 @@ goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
-if (goog.DEBUG) {
- goog.debug.Console.autoInstall();
- goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
-}
-
-
var layer = new ol.layer.TileLayer({
source: new ol.source.MapQuestOpenAerial()
});
Oops, something went wrong.

0 comments on commit 44ca6c9

Please sign in to comment.