From 9f1e0f001afcadbf0dfc22236d3aa00dbdf9bc62 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 6 Apr 2015 05:25:38 -0600 Subject: [PATCH] Proper lists for example resources --- config/examples/example.html | 2 +- examples_src/d3.html | 4 +++- examples_src/overlay.html | 3 ++- examples_src/overviewmap-custom.html | 3 ++- examples_src/polygon-styles.html | 3 ++- examples_src/popup.html | 3 ++- examples_src/readme.md | 2 +- examples_src/sphere-mollweide.html | 3 ++- tasks/build-examples.js | 13 ++++++------- 9 files changed, 21 insertions(+), 15 deletions(-) diff --git a/config/examples/example.html b/config/examples/example.html index a6ddf6a5a2..8c0fb7dee4 100644 --- a/config/examples/example.html +++ b/config/examples/example.html @@ -8,7 +8,7 @@ - {{{ resources }}} + {{{ extra_head }}} {{{ css.tag }}} diff --git a/examples_src/d3.html b/examples_src/d3.html index 41499bf376..6b345e27eb 100644 --- a/examples_src/d3.html +++ b/examples_src/d3.html @@ -5,7 +5,9 @@ shortdesc: "Example of using ol3 and d3 together." docs: >

The example loads TopoJSON geometries and uses d3 (d3.geo.path) to render these geometries to a canvas element that is then used as the image of an ol3 image layer.

tags: "d3" -resources: "http://d3js.org/d3.v3.min.js,http://d3js.org/topojson.v1.min.js" +resources: + - http://d3js.org/d3.v3.min.js + - http://d3js.org/topojson.v1.min.js ---
diff --git a/examples_src/overlay.html b/examples_src/overlay.html index 4dfda85731..c7f60cbdfd 100644 --- a/examples_src/overlay.html +++ b/examples_src/overlay.html @@ -5,7 +5,8 @@ shortdesc: "Demonstrates overlays." docs: >

The popups are created using Popovers from Bootstrap.

tags: "overlay, popup, bootstrap, popover, mapquest, openaerial" -resources: overlay.css +resources: + - overlay.css ---
diff --git a/examples_src/overviewmap-custom.html b/examples_src/overviewmap-custom.html index 684697018f..d42948f866 100644 --- a/examples_src/overviewmap-custom.html +++ b/examples_src/overviewmap-custom.html @@ -5,7 +5,8 @@ shortdesc: "Example of OverviewMap control with advanced customization." docs: >

This example demonstrates how you can customize the overviewmap control using its supported options as well as defining custom CSS. You can also rotate the map using the shift key to see how the overview map reacts.

tags: "overview, overviewmap" -resources: overviewmap-custom.css +resources: + - overviewmap-custom.css ---
diff --git a/examples_src/polygon-styles.html b/examples_src/polygon-styles.html index d425638295..c5651ed5ef 100644 --- a/examples_src/polygon-styles.html +++ b/examples_src/polygon-styles.html @@ -7,7 +7,8 @@ docs: > * The first style is for the polygons themselves. * The second style is to draw the vertices of the polygons. tags: "polygon, vector, style, GeometryFunction" -resources: polygon-styles.css +resources: + - polygon-styles.css ---
diff --git a/examples_src/popup.html b/examples_src/popup.html index 31074d70d9..b2750935cc 100644 --- a/examples_src/popup.html +++ b/examples_src/popup.html @@ -7,7 +7,8 @@ docs: > Click on the map to get a popup. The popup is composed of a few basic elements: a container, a close button, and a place for the content. To anchor the popup to the map, an ol.Overlay is created with the popup container. A listener is registered for the map's click event to display the popup, and another listener is set as the click handler for the close button to hide the popup.

tags: "overlay, popup, mapquest, openaerial" -resources: popup.css +resources: + - popup.css ---
diff --git a/examples_src/readme.md b/examples_src/readme.md index dc3ab3f354..e5cff8f570 100644 --- a/examples_src/readme.md +++ b/examples_src/readme.md @@ -7,4 +7,4 @@ The `.html` files in this folder are built by applying the templates in the `con * shortdesc: A short description for the example index * docs: Documentation of the example. Can be markdown. * tags: Tags for the example index -* resources: Additional js or css resources required by the example. This is a comma separated list of URLs. +* resources: Additional js or css resources required by the example. This is a YAML list of URLs. diff --git a/examples_src/sphere-mollweide.html b/examples_src/sphere-mollweide.html index e10e22637a..ad7ed8c5df 100644 --- a/examples_src/sphere-mollweide.html +++ b/examples_src/sphere-mollweide.html @@ -5,7 +5,8 @@ shortdesc: "Example of a Sphere Mollweide map with a Graticule component." docs: > Example of a Sphere Mollweide map with a Graticule component. tags: "graticule, Mollweide, projection, proj4js" -resources: http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js +resources: + - http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js ---
diff --git a/tasks/build-examples.js b/tasks/build-examples.js index b80b094f04..796809da09 100644 --- a/tasks/build-examples.js +++ b/tasks/build-examples.js @@ -70,22 +70,21 @@ function augmentExamples(files, metalsmith, done) { // add additional resources if (file.resources) { - var resources = file.resources.split(','); - var resource; - for (var i = resources.length - 1; i >= 0; --i) { - resource = resources[i]; + var resources = []; + for (var i = file.resources.length - 1; i >= 0; --i) { + var resource = file.resources[i]; if (isJsRegEx.test(resource)) { resources[i] = ''; } else if (isCssRegEx.test(resource)) { resources[i] = ''; } else { - done(new Error('Invalid value for "resource": ' + - resource + 'is not .js or .css: ' + filename)); + done(new Error('Invalid value for resource: ' + + resource + ' is not .js or .css: ' + filename)); return; } - file.resources = resources.join('\n'); } + file.extra_head = resources.join('\n'); } } }