geoblacklight 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +19 -0
  3. data/.gitmodules +5 -0
  4. data/Gemfile +11 -0
  5. data/LICENSE.txt +13 -0
  6. data/README.md +103 -0
  7. data/Rakefile +44 -0
  8. data/app/assets/images/blacklight/logo.png +0 -0
  9. data/app/assets/images/geoblacklight/src_berkeley.png +0 -0
  10. data/app/assets/images/geoblacklight/src_cambridge.png +0 -0
  11. data/app/assets/images/geoblacklight/src_harvard.png +0 -0
  12. data/app/assets/images/geoblacklight/src_maryland.png +0 -0
  13. data/app/assets/images/geoblacklight/src_massgis.png +0 -0
  14. data/app/assets/images/geoblacklight/src_mit.png +0 -0
  15. data/app/assets/images/geoblacklight/src_princeton.png +0 -0
  16. data/app/assets/images/geoblacklight/src_stanford.png +0 -0
  17. data/app/assets/images/geoblacklight/src_tufts.png +0 -0
  18. data/app/assets/images/geoblacklight/src_un.png +0 -0
  19. data/app/assets/images/geoblacklight/type_arc.png +0 -0
  20. data/app/assets/images/geoblacklight/type_dot.png +0 -0
  21. data/app/assets/images/geoblacklight/type_library.png +0 -0
  22. data/app/assets/images/geoblacklight/type_map.png +0 -0
  23. data/app/assets/images/geoblacklight/type_polygon.png +0 -0
  24. data/app/assets/images/geoblacklight/type_raster.png +0 -0
  25. data/app/assets/javascripts/geoblacklight/application.js +2 -0
  26. data/app/assets/javascripts/geoblacklight/geoblacklight.js +4 -0
  27. data/app/assets/javascripts/geoblacklight/modules/map-home.js +25 -0
  28. data/app/assets/javascripts/geoblacklight/modules/map-results.js +72 -0
  29. data/app/assets/javascripts/geoblacklight/modules/map-view.js +211 -0
  30. data/app/controllers/download_controller.rb +107 -0
  31. data/app/controllers/wms_controller.rb +81 -0
  32. data/app/helpers/geoblacklight_helper.rb +91 -0
  33. data/app/views/catalog/_document_list.html.erb +12 -0
  34. data/app/views/catalog/_home_text.html.erb +40 -0
  35. data/app/views/catalog/_index_header_default.html.erb +59 -0
  36. data/app/views/catalog/_show_default.html.erb +68 -0
  37. data/app/views/catalog/_show_sidebar.html.erb +76 -0
  38. data/geoblacklight.gemspec +36 -0
  39. data/lib/generators/geoblacklight/install_generator.rb +46 -0
  40. data/lib/generators/geoblacklight/templates/catalog_controller.rb +217 -0
  41. data/lib/generators/geoblacklight/templates/geoblacklight.css.scss +79 -0
  42. data/lib/generators/geoblacklight/templates/geoblacklight.js +1 -0
  43. data/lib/geoblacklight.rb +5 -0
  44. data/lib/geoblacklight/config.rb +0 -0
  45. data/lib/geoblacklight/engine.rb +15 -0
  46. data/lib/geoblacklight/fixtures_indexer.rb +34 -0
  47. data/lib/geoblacklight/version.rb +3 -0
  48. data/lib/tasks/geoblacklight.rake +13 -0
  49. data/spec/fixtures/geoblacklight_schema/transformed.json +53 -0
  50. data/spec/spec_helper.rb +37 -0
  51. data/spec/test_app_templates/lib/generators/test_app_generator.rb +23 -0
  52. metadata +299 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDFmNTBjNGY5MjdhODA5MjU0ZWQyZTY2ZmMwNWQ4YWZjZGQ3M2YyMA==
5
+ data.tar.gz: !binary |-
6
+ ODk4NTkyNGI2YTFmOGM4OTEwZTUyZjFiMTJjZTZlMGQ3MzUzZTEzNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDhlNjgyYmU1NTg5OTI2MDIxZWI4ODJhM2ZjNTYwZTYwYWVlNjhjZjhhZWIx
10
+ NmE1Zjc5MDg1YTUzOGZiZjIyMDgzYWJlM2E2MDkwZWQ2OGY5NGY5ODVjMDNh
11
+ OWU0YmVkZTM5YTg0ZmVkZmI3MDMxNDNiNDZjNTZlNjZmODA1NGE=
12
+ data.tar.gz: !binary |-
13
+ YzY5NmJiY2U5MjJlODg5ZjEyMjY2YTZiYTFiY2FiNjEyMGQ5ZWM3MmUyMWY0
14
+ ODJmYWI4ZTFlMjA4ZjJmZTQ3ZTMwMDFkZmMwNjQ5NmRjZjg0YTJmNGJjMDk1
15
+ ODdiNTZhOTAwYzg0NzFmY2MwZWNhYzgzMTAyOGMzNGE3Njg1YmI=
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ spec/internal
19
+ jetty
data/.gitmodules ADDED
@@ -0,0 +1,5 @@
1
+ [submodule "geoblacklight-schema"]
2
+ path = schema
3
+ url = https://github.com/sul-dlss/geoblacklight-schema.git
4
+ branch = master
5
+
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in geoblacklight.gemspec
4
+ gemspec
5
+
6
+ # load local rails test instance Gemfile
7
+ file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("../spec/internal", __FILE__))
8
+ if File.exists?(file)
9
+ puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
10
+ instance_eval File.read(file)
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2014 The Board of Trustees of the Leland Stanford Junior University.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # Geoblacklight
2
+
3
+ GeoBlacklight started at Stanford and its goal is to provide a
4
+ world-class discovery platform for geospatial (GIS) holdings. It
5
+ is an open collaborative project aiming to build off of the successes
6
+ of the Blacklight Solr-powered discovery interface and the
7
+ multi-institutional OpenGeoportal federated metadata sharing
8
+ communities. We are currently in a collaborative design phase and
9
+ we're actively looking for community input and development partners.
10
+ More coming soon!
11
+
12
+ ## Features
13
+
14
+ * Text search with scoring formula
15
+ * Facet by institution, year, publisher, data type, access, format
16
+ * Facet by place, subject
17
+ * Sort by relevance, year, publisher, title
18
+ * Results list view icons and snippets
19
+ * Detail map view for WMS features
20
+ * Detail map view feature inspection
21
+ * Slugs
22
+ * MODS display
23
+ * Results list map view of bounding boxes
24
+ * WMS/WFS/WCS links
25
+ * Download Shapefile
26
+ * Download KML
27
+ * Download Metadata (for Stanford)
28
+
29
+ ## Features to port from alpha
30
+
31
+ * Blacklight bookmarks and history
32
+ * Facet pagination (more>> link)
33
+ * Login for persistent bookmarks and history
34
+
35
+ ## TODO
36
+
37
+ * Refactoring to `lib/`
38
+ * Test suites
39
+ * Spatial search
40
+ * Spatial relevancy
41
+ * Download GeoTIFF
42
+ * Clip to map view for download(?)
43
+ * Download Metadata (for non-Stanford)
44
+ * Facet by language, projection, collection (dummy data)
45
+ * Citation and share buttons
46
+ * Featured datasets and articles
47
+ * geoblacklight-schema
48
+ * FGDC-based conversion of external OGP records
49
+ * MODS-based conversion for Stanford records
50
+
51
+ ## Development
52
+
53
+ To install a development instance of Geoblacklight follow these instructions.
54
+
55
+ Clone the repository (using `--recurse`)
56
+
57
+ git clone --recurse git@github.com:sul-dlss/geoblacklight.git
58
+
59
+ Download and configure `jetty`
60
+
61
+ rake jetty:download jetty:unzip
62
+ rake geoblacklight:configure_jetty
63
+
64
+ Create a test app (created at `/spec/internal`)
65
+
66
+ rake engine_cart:generate
67
+
68
+ Boot `jetty`
69
+
70
+ rake jetty:start
71
+
72
+ Boot GeoBlacklight test app
73
+
74
+ cd spec/internal
75
+ rake geoblacklight:solr:seed # to load sample documents into jetty Solr instance
76
+ rails server
77
+
78
+ ## Installation
79
+
80
+ Add this line to your application's `Gemfile`:
81
+
82
+ gem 'geoblacklight'
83
+
84
+ And then execute:
85
+
86
+ $ bundle
87
+
88
+ Or install it yourself as:
89
+
90
+ $ gem install geoblacklight
91
+
92
+ ## Usage
93
+
94
+ 1. Populate Solr index with geoblacklight-schema documents
95
+ 2. ...
96
+
97
+ ## Contributing
98
+
99
+ 1. Fork it ( http://github.com/`my-github-username`/geoblacklight/fork )
100
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
101
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
102
+ 4. Push to the branch (`git push origin my-new-feature`)
103
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ BLACKLIGHT_JETTY_VERSION = '4.7.2'
4
+ ZIP_URL = "https://github.com/drh-stanford/blacklight-jetty/archive/v#{BLACKLIGHT_JETTY_VERSION}.zip"
5
+ APP_ROOT = File.dirname(__FILE__)
6
+
7
+ require 'rspec/core/rake_task'
8
+ require 'engine_cart/rake_task'
9
+
10
+ require 'jettywrapper'
11
+
12
+ task default: :ci
13
+
14
+ RSpec::Core::RakeTask.new(:spec)
15
+
16
+ desc "Load fixtures"
17
+ task :fixtures => ['engine_cart:generate'] do
18
+ EngineCart.within_test_app do
19
+ system "rake geoblacklight:solr:seed RAILS_ENV=test"
20
+ end
21
+ end
22
+
23
+ desc "Execute Continuous Integration build"
24
+ task :ci => ['engine_cart:generate', 'jetty:clean', 'geoblacklight:configure_jetty'] do
25
+
26
+ require 'jettywrapper'
27
+ jetty_params = Jettywrapper.load_config('test')
28
+
29
+ error = Jettywrapper.wrap(jetty_params) do
30
+ Rake::Task['fixtures'].invoke
31
+ Rake::Task['spec'].invoke
32
+ end
33
+ raise "test failures: #{error}" if error
34
+ end
35
+
36
+
37
+ namespace :geoblacklight do
38
+ desc "Copies the default SOLR config for the bundled Testing Server"
39
+ task :configure_jetty do
40
+ FileList['schema/conf/*'].each do |f|
41
+ cp("#{f}", 'jetty/solr/blacklight-core/conf/', :verbose => true)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,2 @@
1
+ //= require leaflet
2
+ //= require_tree .
@@ -0,0 +1,4 @@
1
+ console.log('DEBUG: Inside geoblacklight/geoblacklight.js')
2
+
3
+ "use strict";
4
+
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ console.log('DEBUG: Inside geoblacklight/modules/map-home.js');
4
+
5
+ Blacklight.onLoad(function () {
6
+ $('#geoblacklight-map-home').geoBlacklight_setupMapHome();
7
+ });
8
+
9
+ /* Requires leaflet */
10
+ (function( $ ) {
11
+
12
+ $.fn.geoBlacklight_setupMapHome = function () {
13
+ console.log(this)
14
+ return this.each(function () {
15
+ var map = L.map('map');
16
+ var basemap = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
17
+ attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">',
18
+ maxZoom: 18
19
+ }).addTo(map);
20
+ map.setZoom(1);
21
+ map.setView([0,0]);
22
+ })
23
+ };
24
+
25
+ })( jQuery );
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+ console.log('DEBUG: Inside geoblacklight/modules/map-results.js');
3
+
4
+ Blacklight.onLoad(function () {
5
+ $('#geoblacklight-map-results').geoBlacklight_setupMapResults();
6
+ });
7
+
8
+ /* Requires leaflet */
9
+ (function( $ ) {
10
+ var map;
11
+ $.fn.geoBlacklight_setupMapResults = function () {
12
+ // console.log(this)
13
+ return this.each(function () {
14
+ map = L.map('map');
15
+ var basemap = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
16
+ attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">',
17
+ maxZoom: 18
18
+ }).addTo(map);
19
+ map.setView([0,0],1);
20
+ // console.log(mapBbox);
21
+ map.fitBounds(mapBbox);
22
+ })
23
+ };
24
+
25
+ $.fn.geoBlacklight_addBbox = function (i) {
26
+ i.addTo(map);
27
+ };
28
+
29
+ $.fn.geoBlacklight_removeBbox = function (j) {
30
+ for(var i in map._layers) {
31
+ if(map._layers[i]._path !== undefined && i !== 0) {
32
+ try {
33
+ map.removeLayer(map._layers[i]);
34
+ }
35
+ catch(e) {
36
+ console.log("problem with " + e + map._layers[i]);
37
+ }
38
+ }
39
+ }
40
+ };
41
+
42
+ $.fn.geoBlacklight_computeBbox = function (i) {
43
+ var doc = solrDocs[i];
44
+ //Calculates map bounding box and creates layer bbox
45
+ if (doc.solr_bbox){
46
+ bBoxs[i] = L.polygon([
47
+ [doc.solr_sw_pt_0_d, doc.solr_sw_pt_1_d],
48
+ [doc.solr_ne_pt_0_d, doc.solr_sw_pt_1_d],
49
+ [doc.solr_ne_pt_0_d, doc.solr_ne_pt_1_d],
50
+ [doc.solr_sw_pt_0_d, doc.solr_ne_pt_1_d]]);
51
+
52
+ if (mapBbox.length == 0) {
53
+ mapBbox = [[doc.solr_sw_pt_0_d, doc.solr_sw_pt_1_d],
54
+ [doc.solr_ne_pt_0_d, doc.solr_ne_pt_1_d]];
55
+ } else{
56
+ if (doc.solr_sw_pt_0_d < mapBbox[0][0]){
57
+ mapBbox[0][0] = doc.solr_sw_pt_0_d;
58
+ }
59
+ if (doc.solr_sw_pt_1_d < mapBbox[0][1]){
60
+ mapBbox[0][1] = doc.solr_sw_pt_1_d;
61
+ }
62
+ if (doc.solr_ne_pt_0_d > mapBbox[1][0]){
63
+ mapBbox[1][0] = doc.solr_ne_pt_0_d;
64
+ }
65
+ if (doc.solr_ne_pt_1_d > mapBbox[1][1]){
66
+ mapBbox[1][1] = doc.solr_ne_pt_1_d;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ })( jQuery );
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+
3
+ console.log('DEBUG: Inside geoblacklight/modules/map-view.js');
4
+ Blacklight.onLoad(function () {
5
+ $('#geoblacklight-map-view').geoBlacklight_setupMapView();
6
+ $('#geoblacklight-tools').geoBlacklight_setupTools();
7
+ });
8
+
9
+ /* Requires leaflet */
10
+ (function( $, document ) {
11
+ var map, wmsLayer, spinner, mapBbox, alertMsg, layerBbox;
12
+
13
+ function WktBboxToJson(solrDoc){
14
+ return [[solrDoc.solr_sw_pt_0_d, solrDoc.solr_sw_pt_1_d],
15
+ [solrDoc.solr_ne_pt_0_d, solrDoc.solr_sw_pt_1_d],
16
+ [solrDoc.solr_ne_pt_0_d, solrDoc.solr_ne_pt_1_d],
17
+ [solrDoc.solr_sw_pt_0_d, solrDoc.solr_ne_pt_1_d]];
18
+ }
19
+
20
+ $.fn.geoBlacklight_setupMapView = function (options){
21
+ return this.each(function () {
22
+ console.log(this)
23
+ map = L.map('map');
24
+ console.log(solrDoc)
25
+ // var layerBbox;
26
+ // var location = JSON.parse(doc.Location);
27
+ if (solrDoc.solr_bbox){
28
+ layerBbox = WktBboxToJson(solrDoc);
29
+ map.fitBounds([[solrDoc.solr_sw_pt_0_d, solrDoc.solr_sw_pt_1_d],
30
+ [solrDoc.solr_ne_pt_0_d, solrDoc.solr_ne_pt_1_d]]);
31
+ }
32
+
33
+ /* XXX: externalize configuration for Mapbox application key */
34
+ var basemap = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
35
+ attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">',
36
+ maxZoom: 18
37
+ }).addTo(map);
38
+
39
+ map.on('click', function(e){
40
+ spinner = "<span id='attribute-table' class=''><i class='fa fa-spinner fa-spin fa-3x fa-align-center'></i></span>"
41
+ $("#attribute-table").replaceWith(spinner);
42
+ // console.log(e)
43
+ mapBbox = map.getBounds()
44
+ var wmsoptions = {
45
+ "URL": solrDoc.solr_wms_url,
46
+ "SERVICE": "WMS",
47
+ "VERSION": "1.1.1",
48
+ "REQUEST": "GetFeatureInfo",
49
+ "LAYERS": solrDoc.layer_id_s,
50
+ "STYLES": "",
51
+ "SRS": "EPSG:4326", /* XXX: is this the correct projection? */
52
+ "BBOX": mapBbox._southWest.lng + "," + mapBbox._southWest.lat + "," + mapBbox._northEast.lng + "," + mapBbox._northEast.lat,
53
+ "WIDTH": $("#map").width(),
54
+ "HEIGHT": $("#map").height(),
55
+ "QUERY_LAYERS": solrDoc.layer_id_s,
56
+ "X": Math.round(e.containerPoint.x),
57
+ "Y": Math.round(e.containerPoint.y),
58
+ "EXCEPTIONS": "application/json",
59
+ "info_format": "application/json"
60
+ }
61
+ console.log(e);
62
+
63
+ $.ajax({
64
+ type: 'POST',
65
+ url: '/wms/handle',
66
+ data: wmsoptions,
67
+ success: function(data){
68
+ console.log(data)
69
+ if ('gis_service' in data){
70
+ console.log(data);
71
+ return;
72
+ }
73
+ var t = $("<table id='attribute-table' class='table table-hover table-condensed table-responsive table-striped table-bordered'><thead><tr class=''><th>Attribute</th><th>Value</th></tr></thead><tbody>")
74
+ $.each(data.values, function(i,val){
75
+ t.append("<tr><td>" + val[0] + "</td><td>" + val[1] + "</tr>")
76
+ });
77
+ $('#attribute-table').replaceWith(t);
78
+ },
79
+ fail: function(error){
80
+ console.log(error);
81
+ }
82
+ });
83
+ });
84
+
85
+ if (solrDoc.solr_wms_url && solrDoc.layer_id_s &&
86
+ (solrDoc.dc_rights_s == 'Public' || solrDoc.dct_provenance_s == 'Stanford')){
87
+ wmsLayer = L.tileLayer.wms(solrDoc.solr_wms_url, {
88
+ layers: solrDoc.layer_id_s,
89
+ format: 'image/png',
90
+ transparent: true, //so this seems to work for Stanford and Harvard
91
+ tiled: true,
92
+ CRS: "EPSG:900913",
93
+ opacity: 0.75
94
+ }).addTo(map);
95
+ }else{
96
+ L.polygon(layerBbox).addTo(map);
97
+ $("#control").hide();
98
+ }
99
+ initHandle(wmsLayer);
100
+
101
+ })
102
+
103
+ }
104
+
105
+
106
+ function initHandle(wmsLayer) {
107
+ //MapBox Opacity Control
108
+ var handle = document.getElementById('handle'),
109
+ start = false,
110
+ startTop;
111
+
112
+ document.onmousemove = function(e) {
113
+ if (!start) return;
114
+ // Adjust control
115
+ handle.style.top = Math.max(-5, Math.min(195, startTop + parseInt(e.clientY, 10) - start)) + 'px';
116
+ // Adjust opacity
117
+ wmsLayer.setOpacity(1 - (handle.offsetTop / 200));
118
+ };
119
+
120
+ if (handle) {
121
+ handle.onmousedown = function(e) {
122
+ // Record initial positions
123
+ start = parseInt(e.clientY, 10);
124
+ startTop = handle.offsetTop - 5;
125
+ return false;
126
+ };
127
+
128
+ }
129
+
130
+ document.onmouseup = function(e) {
131
+ start = null;
132
+ };
133
+
134
+ }
135
+
136
+ })( jQuery, document );
137
+
138
+ (function ( $, document ) {
139
+ $.fn.geoBlacklight_setupTools = function() {
140
+ return this.each(function () {
141
+ $(document).ready(function(){
142
+ //See full abstract
143
+ $('#more-abstract').on('click', function(){
144
+ $('#abstract-trunc').toggle();
145
+ $('#abstract-full').removeClass('hidden');
146
+ });
147
+
148
+ //Fire download shapefile REQUEST
149
+ $('#download-shapefile').on('click', function(){
150
+ $('#download-shapefile').addClass('disabled');
151
+ $('#icon-shapefile').removeClass('fa-download');
152
+ $('#icon-shapefile').addClass('fa-spinner fa-spin');
153
+ $.ajax({
154
+ type: 'POST',
155
+ url: '/download/shapefile',
156
+ data: solrDoc,
157
+ }).done(function(data){
158
+ var alertMsg;
159
+ $('#download-shapefile').removeClass('disabled');
160
+ $('#icon-shapefile').removeClass('fa-spinner fa-spin');
161
+ $('#icon-shapefile').addClass('fa-download');
162
+ console.log(data);
163
+ if ('error' in data){
164
+ console.log('something bad');
165
+ alertMsg = "<div class='alert alert-danger fade in'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>Holy guacamole!</strong> Something went wrong with the download :(</div>";
166
+ }else{
167
+ alertMsg = "<div class='alert alert-success fade in'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>Good to go!</strong> Your file is <a href='/download/file?q=" + data.data + "'>ready to download.</a></div>";
168
+ }
169
+ $("#main-flashes").append(alertMsg);
170
+ }).fail(function(data){
171
+ var alertMsg = "<div class='alert alert-danger fade in'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>Holy guacamole!</strong> Something went wrong with the download :(</div>";
172
+ $("#main-flashes").append(alertMsg);
173
+ $('#icon-shapefile').removeClass('fa-spinner fa-spin');
174
+ $('#icon-shapefile').addClass('fa-download');
175
+
176
+ });
177
+ });
178
+
179
+ $('#download-kml').on('click', function(){
180
+ $('#download-kml').addClass('disabled');
181
+ $('#icon-kml').removeClass('fa-download');
182
+ $('#icon-kml').addClass('fa-spinner fa-spin');
183
+ $.ajax({
184
+ type: 'POST',
185
+ url: '/download/kml',
186
+ data: solrDoc,
187
+ }).done(function(data){
188
+ var alertMsg;
189
+ $('#download-kml').removeClass('disabled');
190
+ $('#icon-kml').removeClass('fa-spinner fa-spin');
191
+ $('#icon-kml').addClass('fa-download');
192
+ console.log(data);
193
+ if ('error' in data){
194
+ console.log('something bad');
195
+ alertMsg = "<div class='alert alert-danger fade in'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>Holy guacamole!</strong> Something went wrong with the download :(</div>";
196
+ }else{
197
+ alertMsg = "<div class='alert alert-success fade in'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>Good to go!</strong> Your file is <a href='/download/file?q=" + data.data + "'>ready to download.</a></div>";
198
+ }
199
+ $("#main-flashes").append(alertMsg);
200
+ }).fail(function(data){
201
+ var alertMsg = "<div class='alert alert-danger fade in'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>Holy guacamole!</strong> Something went wrong with the download :(</div>";
202
+ $("#main-flashes").append(alertMsg);
203
+ $('#icon-kml').removeClass('fa-spinner fa-spin');
204
+ $('#icon-kml').addClass('fa-download');
205
+ });
206
+ });
207
+ });
208
+
209
+ })
210
+ }
211
+ })( jQuery, document );