From: Tom Hughes Date: Fri, 2 Feb 2018 19:23:53 +0000 (+0000) Subject: Rewrite ooc site using leaflet and bring it under chef control X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/30d9ea905c709817bb4820380f230b5b1724b1f8?ds=sidebyside Rewrite ooc site using leaflet and bring it under chef control --- diff --git a/cookbooks/dev/files/default/ooc/index.html b/cookbooks/dev/files/default/ooc/index.html new file mode 100644 index 000000000..7510906e2 --- /dev/null +++ b/cookbooks/dev/files/default/ooc/index.html @@ -0,0 +1,15 @@ + + + + + GeoDNS - tile.openstreetmap.org + + + + + + + +
+ + diff --git a/cookbooks/dev/files/default/ooc/map.css b/cookbooks/dev/files/default/ooc/map.css new file mode 100644 index 000000000..0a22de636 --- /dev/null +++ b/cookbooks/dev/files/default/ooc/map.css @@ -0,0 +1,7 @@ +#map { + position: absolute; + top: 0px; + bottom: 0px; + left: 0px; + right: 0px; +} diff --git a/cookbooks/dev/files/default/ooc/map.js b/cookbooks/dev/files/default/ooc/map.js new file mode 100644 index 000000000..4811d2ef3 --- /dev/null +++ b/cookbooks/dev/files/default/ooc/map.js @@ -0,0 +1,48 @@ +$(document).ready(function () { + // Create a map + var map = L.map("map").fitBounds([[49.85,-10.5], [58.75, 1.9]]); + + // Create NPE layer + var npe = L.tileLayer("https://{s}.ooc.openstreetmap.org/npe/{z}/{x}/{y}.png", { + minZoom: 6, + maxZoom: 15 + }); + + // Create NPE Scotland layer + var npescotland = L.tileLayer("https://{s}.ooc.openstreetmap.org/npescotland/{z}/{x}/{y}.jpg", { + minZoom: 6, + maxZoom: 15 + }); + + // Create 7th edition layer + var os7 = L.tileLayer("https://{s}.ooc.openstreetmap.org/os7/{z}/{x}/{y}.jpg", { + minZoom: 3, + maxZoom: 14 + }); + + // Create 1st edition layer + var os1 = L.tileLayer("https://{s}.ooc.openstreetmap.org/os1/{z}/{x}/{y}.jpg", { + minZoom: 6, + maxZoom: 17 + }); + + // Add OpenStreetMap layer + var osm = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { + attribution: "© OpenStreetMap and contributors, under an open license", + maxZoom: 18 + }); + + // Create a layer switcher + var layers = L.control.layers({ + "OS NPE (Eng/Wales 1945-55) 1:50k": npe, + "OS NPE/7th (Scotland) 1:50k": npescotland, + "OS 7th Series (1947-60) 1:50k": os7, + "OS 1st Edition (1946-60) 1:25k": os1, + "OpenStreetMap": osm + } , null, { + collapsed: false + }).addTo(map); + + // Add the NPE layer to the map + npe.addTo(map); +}); diff --git a/cookbooks/dev/files/default/ooc/openlayers/OOC.js b/cookbooks/dev/files/default/ooc/openlayers/OOC.js new file mode 100644 index 000000000..e84251e49 --- /dev/null +++ b/cookbooks/dev/files/default/ooc/openlayers/OOC.js @@ -0,0 +1,145 @@ +/** + * Namespace: Util.OOC + */ +OpenLayers.Util.OOC = {}; + +/** + * @requires OpenLayers/Layer/XYZ.js + * + * Class: OpenLayers.Layer.NPE + * + * Inherits from: + * - + */ +OpenLayers.Layer.NPE = OpenLayers.Class(OpenLayers.Layer.XYZ, { + /** + * Constructor: OpenLayers.Layer.NPE + * + * Parameters: + * name - {String} + * url - {String} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + initialize: function(name, options) { + var url = [ + "http://a.ooc.openstreetmap.org/npe/${z}/${x}/${y}.png", + "http://b.ooc.openstreetmap.org/npe/${z}/${x}/${y}.png", + "http://c.ooc.openstreetmap.org/npe/${z}/${x}/${y}.png" + ]; + options = OpenLayers.Util.extend({ + numZoomLevels: 16, + transitionEffect: "resize", + sphericalMercator: true + }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); + }, + + CLASS_NAME: "OpenLayers.Layer.NPE" +}); + +/** + * @requires OpenLayers/Layer/XYZ.js + * + * Class: OpenLayers.Layer.OS7 + * + * Inherits from: + * - + */ +OpenLayers.Layer.OS7 = OpenLayers.Class(OpenLayers.Layer.XYZ, { + /** + * Constructor: OpenLayers.Layer.OS7 + * + * Parameters: + * name - {String} + * url - {String} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + initialize: function(name, options) { + var url = [ + "http://a.ooc.openstreetmap.org/os7/${z}/${x}/${y}.jpg", + "http://b.ooc.openstreetmap.org/os7/${z}/${x}/${y}.jpg", + "http://c.ooc.openstreetmap.org/os7/${z}/${x}/${y}.jpg" + ]; + options = OpenLayers.Util.extend({ + numZoomLevels: 15, + transitionEffect: "resize", + sphericalMercator: true + }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); + }, + + CLASS_NAME: "OpenLayers.Layer.OS7" +}); + +/** + * @requires OpenLayers/Layer/XYZ.js + * + * Class: OpenLayers.Layer.OS1 + * + * Inherits from: + * - + */ +OpenLayers.Layer.OS1 = OpenLayers.Class(OpenLayers.Layer.XYZ, { + /** + * Constructor: OpenLayers.Layer.OS1 + * + * Parameters: + * name - {String} + * url - {String} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + initialize: function(name, options) { + var url = [ + "http://a.ooc.openstreetmap.org/os1/${z}/${x}/${y}.jpg", + "http://b.ooc.openstreetmap.org/os1/${z}/${x}/${y}.jpg", + "http://c.ooc.openstreetmap.org/os1/${z}/${x}/${y}.jpg" + ]; + options = OpenLayers.Util.extend({ + numZoomLevels: 18, + transitionEffect: "resize", + sphericalMercator: true + }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); + }, + + CLASS_NAME: "OpenLayers.Layer.OS1" +}); + +/** + * @requires OpenLayers/Layer/XYZ.js + * + * Class: OpenLayers.Layer.NPEScotland + * + * Inherits from: + * - + */ +OpenLayers.Layer.NPEScotland = OpenLayers.Class(OpenLayers.Layer.XYZ, { + /** + * Constructor: OpenLayers.Layer.NPEScotland + * + * Parameters: + * name - {String} + * url - {String} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + initialize: function(name, options) { + var url = [ + "http://a.ooc.openstreetmap.org/npescotland/${z}/${x}/${y}.jpg", + "http://b.ooc.openstreetmap.org/npescotland/${z}/${x}/${y}.jpg", + "http://c.ooc.openstreetmap.org/npescotland/${z}/${x}/${y}.jpg" + ]; + options = OpenLayers.Util.extend({ + numZoomLevels: 16, + transitionEffect: "resize", + sphericalMercator: true + }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); + }, + + CLASS_NAME: "OpenLayers.Layer.NPEScotland" +}); + diff --git a/cookbooks/dev/files/default/ooc/robots.txt b/cookbooks/dev/files/default/ooc/robots.txt new file mode 100644 index 000000000..1f53798bb --- /dev/null +++ b/cookbooks/dev/files/default/ooc/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/cookbooks/dev/recipes/default.rb b/cookbooks/dev/recipes/default.rb index 4ac58484b..d6b27a06d 100644 --- a/cookbooks/dev/recipes/default.rb +++ b/cookbooks/dev/recipes/default.rb @@ -301,3 +301,31 @@ if node[:postgresql][:clusters][:"9.5/main"] end end end + +directory "/srv/ooc.openstreetmap.org" do + owner "root" + group "root" + mode 0o755 +end + +remote_directory "/srv/ooc.openstreetmap.org/html" do + source "ooc" + owner "root" + group "root" + mode 0o755 + files_owner "root" + files_group "root" + files_mode 0o644 +end + +ssl_certificate "ooc.openstreetmap.org" do + domains ["ooc.openstreetmap.org", + "a.ooc.openstreetmap.org", + "b.ooc.openstreetmap.org", + "c.ooc.openstreetmap.org"] + notifies :reload, "service[apache2]" +end + +apache_site "ooc.openstreetmap.org" do + template "apache.ooc.erb" +end diff --git a/cookbooks/dev/templates/default/apache.ooc.erb b/cookbooks/dev/templates/default/apache.ooc.erb new file mode 100644 index 000000000..6b921e830 --- /dev/null +++ b/cookbooks/dev/templates/default/apache.ooc.erb @@ -0,0 +1,57 @@ +# DO NOT EDIT - This file is being maintained by Chef + + + ServerName ooc.openstreetmap.org + ServerAlias a.ooc.openstreetmap.org + ServerAlias b.ooc.openstreetmap.org + ServerAlias c.ooc.openstreetmap.org + ServerAdmin webmaster@openstreetmap.org + + SSLEngine on + SSLCertificateFile /etc/ssl/certs/ooc.openstreetmap.org.pem + SSLCertificateKeyFile /etc/ssl/private/ooc.openstreetmap.org.key + + CustomLog /var/log/apache2/ooc.openstreetmap.org-access.log combined + ErrorLog /var/log/apache2/ooc.openstreetmap.org-error.log + + DocumentRoot /srv/ooc.openstreetmap.org/html + Alias /npe/ /home/ooc/npe/ + Alias /npescotland/ /home/ooc/npescotland/ + Alias /os7/ /home/ooc/os7/ + Alias /os1/ /home/ooc/os1/ + + + + ServerName ooc.openstreetmap.org + ServerAlias a.ooc.openstreetmap.org + ServerAlias b.ooc.openstreetmap.org + ServerAlias c.ooc.openstreetmap.org + ServerAdmin webmaster@openstreetmap.org + + CustomLog /var/log/apache2/ooc.openstreetmap.org-access.log combined + ErrorLog /var/log/apache2/ooc.openstreetmap.org-error.log + + RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/ + RedirectPermanent / https://ooc.openstreetmap.org/ + + + + ServerName npe.openstreetmap.org + ServerAdmin webmaster@openstreetmap.org + + CustomLog /var/log/apache2/npe.openstreetmap.org-access.log combined + ErrorLog /var/log/apache2/npe.openstreetmap.org-error.log + + RewriteEngine on + RewriteRule ^/robots.txt$ https://ooc.openstreetmap.org/robots.txt [R=permanent] + RewriteRule ^/openlayers/NPE.js$ https://ooc.openstreetmap.org/openlayers/OOC.js [R=permanent] + RewriteRule ^/(.*)$ https://ooc.openstreetmap.org/npe/$1 [R=permanent] + + + + Require all granted + + + + Require all granted +