diff --git a/Makefile b/Makefile index f56d48150c..bcccf0b198 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,14 @@ build/jsdoc-$(BRANCH)-timestamp: $(SRC) $(shell find doc/template -type f) $(JSDOC) -t doc/template -r src -d build/gh-pages/$(BRANCH)/apidoc touch $@ +.PHONY: hostexamples +hostexamples: build examples + mkdir -p build/gh-pages/$(BRANCH)/examples + mkdir -p build/gh-pages/$(BRANCH)/build + cp $(EXAMPLES) $(subst .html,.js,$(EXAMPLES)) examples/style.css build/gh-pages/$(BRANCH)/examples/ + cp build/loader_hosted_examples.js build/gh-pages/$(BRANCH)/examples/loader.js + cp build/ol.js build/ol.css build/gh-pages/$(BRANCH)/build/ + .PHONY: test test: $(INTERNAL_SRC) $(PHANTOMJS) test/phantom-jasmine/run_jasmine_test.coffee test/ol.html diff --git a/build/loader_hosted_examples.js b/build/loader_hosted_examples.js new file mode 100644 index 0000000000..3ec22aa5e2 --- /dev/null +++ b/build/loader_hosted_examples.js @@ -0,0 +1,46 @@ +/** + * + * Loader to add ol.css, ol.js and the example-specific js file to the + * documents. + * + * 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 build/ol.json. + * (`make build` should build 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. + * + * Usage: + * + * + */ + +(function() { + var scripts = document.getElementsByTagName('script'); + + var i, src, index, search, chunks, pair, params = {}; + 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]); + } + break; + } + } + + document.write(''); + document.write('' + + ''); + document.write('' + + ''); +}()); diff --git a/examples/full-screen.html b/examples/full-screen.html index f61977613c..a8ab852868 100644 --- a/examples/full-screen.html +++ b/examples/full-screen.html @@ -12,7 +12,6 @@ height: 100%; } - ol3 full-screen demo diff --git a/examples/loader.js b/examples/loader.js index 3ea91f7536..7c56ba7ff6 100644 --- a/examples/loader.js +++ b/examples/loader.js @@ -1,10 +1,12 @@ /** - * Loader to add the plovr generated script to the document. The following - * default values may be overridden with query string parameters: + * Loader to add the plovr generated script and ol.css to the document. * - * * hostname - the current hostname + * The following default values may be overridden with query string + * parameters: + * + * * hostname - the current hostname (window.location.hostname) * * port - 9810 * * mode - ADVANCED * * id - id param in loader.js query string; defaults to 'ol' if not set @@ -54,6 +56,8 @@ pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key])); } + document.write(''); var url = 'http://' + host + '/compile?' + pairs.join('&'); document.write(''); }()); diff --git a/examples/overlay-and-popup.html b/examples/overlay-and-popup.html index 67bba0aa9b..fd0d44eaee 100644 --- a/examples/overlay-and-popup.html +++ b/examples/overlay-and-popup.html @@ -66,7 +66,6 @@ margin-left: -13px; } - ol3 overlay-and-popup demo diff --git a/examples/side-by-side.html b/examples/side-by-side.html index c1c16f3220..da4a0472e3 100644 --- a/examples/side-by-side.html +++ b/examples/side-by-side.html @@ -2,7 +2,6 @@ -