From 3aa5d6909b128c4ef0d1f9ff3924531dbf77e7fd Mon Sep 17 00:00:00 2001 From: Baldur Gudbjornsson Date: Wed, 4 May 2016 13:53:36 -0400 Subject: [PATCH] adds circle deploy structure and artifact directory (#87) * adds circle deploy structure and artifact directory * testing deploy * ignore tests for now * lets be lazy * adds dot for good messure * moving index files to render map * handling public for now * just building master --- circle.yml | 19 +- dist/.gitkeep | 0 dist/bundle.js | 664 --------------------------------------------- dist/bundle.min.js | 1 - index.html | 2 +- 5 files changed, 19 insertions(+), 667 deletions(-) create mode 100644 dist/.gitkeep delete mode 100644 dist/bundle.js delete mode 100644 dist/bundle.min.js diff --git a/circle.yml b/circle.yml index 0a53938a..98ab3165 100644 --- a/circle.yml +++ b/circle.yml @@ -1,3 +1,20 @@ machine: node: - version: 4.2.2 \ No newline at end of file + version: 4.2.2 +general: + artifacts: + - "dist" + +test: + override: + - echo "Testing enabled later" + +deployment: + production: + branch: master + commands: + - npm install + - npm run build + - cp index.html dist/ + - cp -R public dist/ + - aws s3 sync dist "s3://erasermap.com/maps" diff --git a/dist/.gitkeep b/dist/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dist/bundle.js b/dist/bundle.js deleted file mode 100644 index 6b8cae1c..00000000 --- a/dist/bundle.js +++ /dev/null @@ -1,664 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.WebMap = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o", loc.hash); - var url = loc.hash.substr(1); - if (url != current) { - var previous = data; - data = parse.call(hash, url); - if (!data && valid.call(format, url)) { - // console.warn("valid:", url); - } else if (!data && def) { - data = def.call(hash, previous); - hash.write(true); - url = loc.hash.substr(1); - } - var diff = hashable.diff(previous, data); - onchange.call(hash, { - url: url, - data: data, - previous: previous, - diff: diff - }); - current = url; - } - } - - return hash; - }; - - hashable.validFragment = function(fragment) { - return !!document.getElementById(fragment); - }; - - hashable.format = function(fmt) { - var query = false; - if (!fmt) fmt = ""; - else if (fmt.charAt(fmt.length - 1) === "?") { - query = true; - fmt = fmt.substr(0, fmt.length - 1); - } - - var keys = [], - word = "([-\\w\\.]+)", - wordPattern = new RegExp("{" + word + "}", "g"), - pattern = new RegExp("^" + fmt.replace(wordPattern, function(_, key) { - keys.push(key); - return word; - }) + "$"); - - // console.log("pattern:", pattern, "keys:", keys); - - var format = function(data) { - if (!data) data = {}; - - var used = [], - str = fmt.replace(wordPattern, function(_, key) { - return data[key]; - }); - - if (!query) return str; - - var qkeys = Object.keys(data) - .filter(function(key) { - return keys.indexOf(key) === -1; - }); - return qkeys.length - ? [str, hashable.qs.format(hashable.copy(data, qkeys))].join("?") - : str; - }; - - format.match = function(str) { - if (query) { - str = str.split("?", 2)[0]; - } - return str.match(pattern); - }; - - format.parse = function(str) { - var qdata; - if (query) { - var bits = str.split("?", 2); - str = bits[0]; - qdata = hashable.qs.parse(bits[1]); - if (qdata) { - if (Array.isArray(query)) { - qdata = hashable.copy(qdata, query); - } else { - // copy only the keys that aren't in the format - var qkeys = Object.keys(qdata) - .filter(function(key) { - return keys.indexOf(key) === -1; - }); - qdata = hashable.copy(qdata, qkeys); - } - } - } - var match = format.match(str); - if (match) { - var data = {}; - keys.forEach(function(key, i) { - data[key] = match[i + 1]; - }); - if (qdata) hashable.extend(data, qdata); - return data; - } - return null; - }; - - format.query = function(q) { - if (!arguments.length) return query; - query = q; - return format; - }; - - format.toString = function() { - return fmt; - }; - - return format; - }; - - /* - * path + query string formatter, creates data in the form: - * - * {path: "bit/after/hash", } - * - * e.g.: - * - * "#foo/bar?qux=1" -> {path: "foo/bar", qux: 1} - */ - hashable.format.path = function() { - - var format = function(data) { - data = hashable.extend({}, data); - var path = data.path || ""; - delete data.path; - var query = hashable.qs.format(data); - return query - ? [path, query].join("?") - : path; - }; - - format.match = function(str) { - return true; - }; - - format.parse = function(str) { - var bits = str.split("?", 2), - data = {path: bits[0]}; - if (bits.length > 1) { - var query = hashable.qs.parse(bits[1]); - if (query) { - return hashable.extend(data, query); - } - } - return data; - }; - - return format; - }; - - hashable.format.map = function(f) { - var fmt = hashable.format(f || "{z}/{y}/{x}") - .query(true), - precision = function(z) { - return Math.max(0, Math.ceil(Math.log(z) / Math.LN2)); - }; - - var format = function(data) { - if (data && !hashable.empty(data.z)) { - var p = precision(+data.z); - data.x = (+data.x).toFixed(p); - data.y = (+data.y).toFixed(p); - } - return fmt(data); - }; - - format.match = function(str) { - return fmt.match(str); - }; - - format.parse = function(str) { - var parsed = fmt.parse(str); - if (parsed) { - parsed.z = +parsed.z; - parsed.x = +parsed.x; - parsed.y = +parsed.y; - if (isNaN(parsed.z) || isNaN(parsed.x) || isNaN(parsed.y)) { - return null; - } - } - return parsed; - }; - - format.query = function(q) { - if (!arguments.length) return fmt.query(); - fmt.query(q); - return fmt; - }; - - format.precision = function(p) { - if (!arguments.length) return precision; - precision = hashable.functor(p); - return format; - }; - - return format; - }; - - /* - * query string parse & format - */ - hashable.qs = (function() { - var qs = { - separator: "&", - }; - - var replacements = qs.replacements = { - "%20": "+", - "%2C": "," - }; - - qs.parse = function(str) { - if (!str || str === "?") return null; - if (str.charAt(0) === "?") str = str.substr(1); - var data = {}; - str.split(qs.separator) - .forEach(function(bit) { - var parts = bit.split("="), - key = decode(parts[0]), - val = bit.substr(key.length + 1); - if (parts.length === 1 || val === "true") { - data[key] = true; - } else if (val === "false") { - data[key] = false; - } else { - data[key] = decode(val); - } - }); - return data; - }; - - qs.format = function(data, sortKeys) { - if (typeof data === "string") return data; - else if (data === null || typeof data === "undefined") return ""; - - var keys = Object.keys(data) - .filter(function(key) { - return !hashable.empty(data[key]); - }); - if (sortKeys) { - keys = keys.sort(function(a, b) { - return a > b ? 1 : a < b ? -1 : 0; - }); - } - var bits = keys.map(function(key) { - return (data[key] === true) - ? key - : [key, encode(data[key])].join("="); - }); - return bits.length - ? bits.join(qs.separator) - : ""; - }; - - function encode(d) { - return encodeURIComponent(d) - .replace(/(\%[A-F0-9]{2})/g, function(_, hex) { - return hex in replacements - ? replacements[hex] - : hex; - }); - } - - function decode(str) { - return decodeURIComponent(str.replace(/\+/g, " ")); - } - - return qs; - })(); - - /* - * extend an object with one or more other objects' keys - */ - hashable.extend = function(a, b, etc) { - [].slice.call(arguments, 1).forEach(function(o) { - if (!o) return; - for (var key in o) { - a[key] = o[key]; - } - }); - return a; - }; - - /* - * find the difference (non-recursive) between two objects, - * returned as an array of objects like: - * - * {op: "remove", value: } - * a key was set in the first object, but not set in the second. - * - * {op: "change", value: [, ]} - * a key was changed between the first and second object. value[0] is the - * original, and value[1] is the changed value. - * - * {op: "add", value: } - * a key was set in the second object but not the first. - */ - hashable.diff = function(a, b) { - var ak = Object.keys(a || {}), - bk = Object.keys(b || {}), - diff = {}, - key, i; - while (ak.length) { - key = ak.shift(); - i = bk.indexOf(key); - if (i === -1) { - diff[key] = {op: "remove", value: a[key]}; - } else if (b[key] != a[key]) { - diff[key] = {op: "change", value: [a[key], b[key]]}; - bk.splice(i, 1); - } else { - bk.splice(i, 1); - } - } - while (bk.length) { - key = bk.shift(); - diff[key] = {op: "add", value: b[key]}; - } - return (Object.keys(diff).length > 0) - ? diff - : null; - }; - - hashable.copy = function(obj, keys) { - var copy = {}; - keys.forEach(function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - - hashable.empty = function(d) { - return (d === null) - || (typeof d === "undefined") - || d.length === 0; - }; - - hashable.functor = function(d) { - return (typeof d === "function") - ? d - : function() { return d; }; - }; - - - /** - * Leaflet plugin support - */ - if (typeof L === "object") { - L.Hash = L.hash = function() { - var hash = hashable.hash() - .format(hashable.format.map()) - .enable(); - - var moveend, zoomend, viewreset, - changed = false; - - hash.onAdd = function(map) { - hash.change(function(e) { - var view = e.data; - if (view) { - // console.log("view:", view); - map.setView([view.y, view.x], view.z, - changed ? null : {animate: false}); - changed = true; - map.fireEvent("hashchange", e); - } - }) - .default(function() { - return { - z: map.getZoom(), - x: map.getCenter().lng, - y: map.getCenter().lat - }; - }) - .enable(); - - map - .on("moveend", moveend = function() { - var c = map.getCenter(); - hash.update({x: c.lng, y: c.lat}) - .write(); - }) - .on("zoomend", zoomend = function() { - var z = map.getZoom(); - hash.update({z: z}) - .write(); - }) - .on("viewreset", viewreset = function() { - var c = map.getCenter(), - z = map.getZoom(); - hash.update({x: c.lng, y: c.lat, z: z}) - .write(); - }); - }; - - hash.onRemove = function(map) { - hash.change(null).disable(); - map - .off("moveend", moveend) - .off("zoomend", zoomend) - .off("viewreset", viewreset); - }; - - hash.addTo = function(map) { - map.addLayer(hash); - return hash; - }; - - return hash; - }; - - } // end Leaflet support - -})(typeof module === "object" ? module.exports : this.hashable = {}); - -},{}],2:[function(require,module,exports){ -'use strict'; - -module.exports = (function WebMap () { - var map; - var hashable = require('hashable'); - - var webMapObj = { - init: function (domEl, centerLatLon, zoom) { - map = L.map(domEl).setView(centerLatLon, zoom); - - // overriding double click behaviour to zoom up where it is clicked - map.doubleClickZoom.disable(); - map.on('dblclick', function (e) { - map.setView(e.latlng, map.getZoom() + 1); - }); - - // do not activate scroll wheel zoom when map is iframed - map.scrollWheelZoom = this._isThisIframed(); - this._setupHash(); - - return this; - }, - - _setupHash: function () { - // setting Location Hash with hashable - var hash = hashable.hash() - .change(function (e) { - var data = e.data; - map.setView([data.lat, data.lng], data.z); - }) - .default(function () { - var fmt = hashable.format.path(); - var path = fmt.parse(window.location.hash); - return { - z: path.z || map.getZoom(), - lng: path.lng || map.getCenter().lng, - lat: path.lat || map.getCenter().lat - }; - }) - .enable() - .check(); - - map.on('moveend', function () { - var center = map.getCenter(); - var fmt = hashable.format.path(); - var p = precision(hash.data().z); - hash.update({lng: center.lng.toFixed(p), lat: center.lat.toFixed(p)}); - var formattedData = fmt(hash.data()); - window.history.replaceState({}, null, '#' + formattedData); - }) - .on('zoomend', function () { - hash.update({z: map.getZoom()}); - var fmt = hashable.format.path(); - var formattedData = fmt(hash.data()); - window.history.replaceState({}, null, '#' + formattedData); - }); - - var precision = function (z) { - return Math.max(0, Math.ceil(Math.log(z) / Math.LN2)); - }; - }, - - setupScene: function (scene) { - if (this._hasWebGL()) { - // adding tangram layer - var layer = Tangram.leafletLayer({ - scene: scene, - attribution: 'Tangram | © OSM contributors | Mapzen' - }).addTo(map); - } else { - // adding osm default tile layer for - console.log('WebGL is not available, falling back to OSM default tile.'); - L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors' - }).addTo(map); - } - }, - - getLeafletMap: function () { - return map; - }, - - _hasWebGL: function () { - try { - var canvas = document.createElement('canvas'); - return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))); - } catch (x) { - return false; - } - }, - _isThisIframed: function () { - if (window.self !== window.top) return true; - else return false; - } - }; - - return webMapObj; -})(); - -},{"hashable":1}]},{},[2])(2) -}); \ No newline at end of file diff --git a/dist/bundle.min.js b/dist/bundle.min.js deleted file mode 100644 index 6ffabf13..00000000 --- a/dist/bundle.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.WebMap=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o1){var query=hashable.qs.parse(bits[1]);if(query)return hashable.extend(data,query)}return data},format},hashable.format.map=function(f){var fmt=hashable.format(f||"{z}/{y}/{x}").query(!0),precision=function(z){return Math.max(0,Math.ceil(Math.log(z)/Math.LN2))},format=function(data){if(data&&!hashable.empty(data.z)){var p=precision(+data.z);data.x=(+data.x).toFixed(p),data.y=(+data.y).toFixed(p)}return fmt(data)};return format.match=function(str){return fmt.match(str)},format.parse=function(str){var parsed=fmt.parse(str);return parsed&&(parsed.z=+parsed.z,parsed.x=+parsed.x,parsed.y=+parsed.y,isNaN(parsed.z)||isNaN(parsed.x)||isNaN(parsed.y))?null:parsed},format.query=function(q){return arguments.length?(fmt.query(q),fmt):fmt.query()},format.precision=function(p){return arguments.length?(precision=hashable.functor(p),format):precision},format},hashable.qs=function(){function encode(d){return encodeURIComponent(d).replace(/(\%[A-F0-9]{2})/g,function(_,hex){return hex in replacements?replacements[hex]:hex})}function decode(str){return decodeURIComponent(str.replace(/\+/g," "))}var qs={separator:"&"},replacements=qs.replacements={"%20":"+","%2C":","};return qs.parse=function(str){if(!str||"?"===str)return null;"?"===str.charAt(0)&&(str=str.substr(1));var data={};return str.split(qs.separator).forEach(function(bit){var parts=bit.split("="),key=decode(parts[0]),val=bit.substr(key.length+1);data[key]=1===parts.length||"true"===val?!0:"false"===val?!1:decode(val)}),data},qs.format=function(data,sortKeys){if("string"==typeof data)return data;if(null===data||"undefined"==typeof data)return"";var keys=Object.keys(data).filter(function(key){return!hashable.empty(data[key])});sortKeys&&(keys=keys.sort(function(a,b){return a>b?1:b>a?-1:0}));var bits=keys.map(function(key){return data[key]===!0?key:[key,encode(data[key])].join("=")});return bits.length?bits.join(qs.separator):""},qs}(),hashable.extend=function(a){return[].slice.call(arguments,1).forEach(function(o){if(o)for(var key in o)a[key]=o[key]}),a},hashable.diff=function(a,b){for(var key,i,ak=Object.keys(a||{}),bk=Object.keys(b||{}),diff={};ak.length;)key=ak.shift(),i=bk.indexOf(key),-1===i?diff[key]={op:"remove",value:a[key]}:b[key]!=a[key]?(diff[key]={op:"change",value:[a[key],b[key]]},bk.splice(i,1)):bk.splice(i,1);for(;bk.length;)key=bk.shift(),diff[key]={op:"add",value:b[key]};return Object.keys(diff).length>0?diff:null},hashable.copy=function(obj,keys){var copy={};return keys.forEach(function(key){key in obj&&(copy[key]=obj[key])}),copy},hashable.empty=function(d){return null===d||"undefined"==typeof d||0===d.length},hashable.functor=function(d){return"function"==typeof d?d:function(){return d}},"object"==typeof L&&(L.Hash=L.hash=function(){var moveend,zoomend,viewreset,hash=hashable.hash().format(hashable.format.map()).enable(),changed=!1;return hash.onAdd=function(map){hash.change(function(e){var view=e.data;view&&(map.setView([view.y,view.x],view.z,changed?null:{animate:!1}),changed=!0,map.fireEvent("hashchange",e))})["default"](function(){return{z:map.getZoom(),x:map.getCenter().lng,y:map.getCenter().lat}}).enable(),map.on("moveend",moveend=function(){var c=map.getCenter();hash.update({x:c.lng,y:c.lat}).write()}).on("zoomend",zoomend=function(){var z=map.getZoom();hash.update({z:z}).write()}).on("viewreset",viewreset=function(){var c=map.getCenter(),z=map.getZoom();hash.update({x:c.lng,y:c.lat,z:z}).write()})},hash.onRemove=function(map){hash.change(null).disable(),map.off("moveend",moveend).off("zoomend",zoomend).off("viewreset",viewreset)},hash.addTo=function(map){return map.addLayer(hash),hash},hash})}("object"==typeof module?module.exports:this.hashable={})},{}],2:[function(require,module){"use strict";module.exports=function(){var t,e=require("hashable"),a={init:function(e,a,n){return t=L.map(e).setView(a,n),t.doubleClickZoom.disable(),t.on("dblclick",function(e){t.setView(e.latlng,t.getZoom()+1)}),t.scrollWheelZoom=this._isThisIframed(),this._setupHash(),this},_setupHash:function(){var a=e.hash().change(function(e){var a=e.data;t.setView([a.lat,a.lng],a.z)})["default"](function(){var a=e.format.path(),n=a.parse(window.location.hash);return{z:n.z||t.getZoom(),lng:n.lng||t.getCenter().lng,lat:n.lat||t.getCenter().lat}}).enable().check();t.on("moveend",function(){var o=t.getCenter(),r=e.format.path(),i=n(a.data().z);a.update({lng:o.lng.toFixed(i),lat:o.lat.toFixed(i)});var l=r(a.data());window.history.replaceState({},null,"#"+l)}).on("zoomend",function(){a.update({z:t.getZoom()});var n=e.format.path(),o=n(a.data());window.history.replaceState({},null,"#"+o)});var n=function(t){return Math.max(0,Math.ceil(Math.log(t)/Math.LN2))}},setupScene:function(e){this._hasWebGL()?Tangram.leafletLayer({scene:e,attribution:'Tangram | © OSM contributors | Mapzen'}).addTo(t):(console.log("WebGL is not available, falling back to OSM default tile."),L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png",{attribution:'© OpenStreetMap contributors'}).addTo(t))},getLeafletMap:function(){return t},_hasWebGL:function(){try{var t=document.createElement("canvas");return!(!window.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(e){return!1}},_isThisIframed:function(){return window.self!==window.top}};return a}()},{hashable:1}]},{},[2])(2)}); \ No newline at end of file diff --git a/index.html b/index.html index 1d7fdba9..aa404c33 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@
- +