travlrmap 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +2 -1
  3. data/config/travlrmap.yaml.dist +2 -1
  4. data/lib/travlrmap/sinatra_app.rb +23 -0
  5. data/lib/travlrmap/version.rb +1 -1
  6. data/public/cluster/cluster-AQUA-1.png +0 -0
  7. data/public/cluster/cluster-AQUA-2.png +0 -0
  8. data/public/cluster/cluster-BLACK-1.png +0 -0
  9. data/public/cluster/cluster-BLACK-2.png +0 -0
  10. data/public/cluster/cluster-BLUE-1.png +0 -0
  11. data/public/cluster/cluster-BLUE-2.png +0 -0
  12. data/public/cluster/cluster-FUCHSIA-1.png +0 -0
  13. data/public/cluster/cluster-FUCHSIA-2.png +0 -0
  14. data/public/cluster/cluster-GRAY-1.png +0 -0
  15. data/public/cluster/cluster-GRAY-2.png +0 -0
  16. data/public/cluster/cluster-GREEN-1.png +0 -0
  17. data/public/cluster/cluster-GREEN-2.png +0 -0
  18. data/public/cluster/cluster-LIME-1.png +0 -0
  19. data/public/cluster/cluster-LIME-2.png +0 -0
  20. data/public/cluster/cluster-MAROON-1.png +0 -0
  21. data/public/cluster/cluster-MAROON-2.png +0 -0
  22. data/public/cluster/cluster-NAVY-1.png +0 -0
  23. data/public/cluster/cluster-NAVY-2.png +0 -0
  24. data/public/cluster/cluster-OLIVE-1.png +0 -0
  25. data/public/cluster/cluster-OLIVE-2.png +0 -0
  26. data/public/cluster/cluster-ORANGE-1.png +0 -0
  27. data/public/cluster/cluster-ORANGE-2.png +0 -0
  28. data/public/cluster/cluster-PURPLE-1.png +0 -0
  29. data/public/cluster/cluster-PURPLE-2.png +0 -0
  30. data/public/cluster/cluster-RED-1.png +0 -0
  31. data/public/cluster/cluster-RED-2.png +0 -0
  32. data/public/cluster/cluster-SILVER-1.png +0 -0
  33. data/public/cluster/cluster-SILVER-2.png +0 -0
  34. data/public/cluster/cluster-TEAL-1.png +0 -0
  35. data/public/cluster/cluster-TEAL-2.png +0 -0
  36. data/public/cluster/cluster-WHITE-1.png +0 -0
  37. data/public/cluster/cluster-WHITE-2.png +0 -0
  38. data/public/cluster/cluster-YELLOW-1.png +0 -0
  39. data/public/cluster/cluster-YELLOW-2.png +0 -0
  40. data/public/js-yaml.min.js +3 -0
  41. data/public/moment.js +3043 -0
  42. data/views/_map_js.erb +1 -1
  43. data/views/_point_comment.erb +7 -5
  44. data/views/geolocate.erb +203 -0
  45. data/views/layout.erb +8 -1
  46. metadata +23 -4
data/views/_map_js.erb CHANGED
@@ -33,7 +33,7 @@
33
33
  gridSize: <%= @map.fetch(:cluster_grid_size, 40) %>,
34
34
  minimumClusterSize: <%= @map.fetch(:cluster_minumum_size, 2) %>,
35
35
  zoomOnClick: <%= @map.fetch(:cluster_zoom_on_click, true) %>,
36
- imagePath: '<%= @map.fetch(:cluster_image_path, "/cluster/t") %>',
36
+ imagePath: '<%= @map.fetch(:cluster_image_path, "/cluster/m") %>',
37
37
  imageExtension: '<%= @map.fetch(:cluster_image_extension, "png") %>',
38
38
  <% if @map.include?(:cluster_image_sizes) %>
39
39
  imageSizes: [<%= @map[:cluster_image_sizes].join(",") %>],
@@ -1,17 +1,17 @@
1
1
  <p>
2
2
  <font size="+2"><%= point[:title] %></font>
3
3
  <hr>
4
- <% if point[:comment] %>
4
+ <% if !point.fetch(:comment, "").empty? %>
5
5
  <%= h point[:comment] %><br /><br />
6
6
  <% end %>
7
7
 
8
- <% if point[:href] %>
8
+ <% if !point.fetch(:href, "").empty? %>
9
9
  <a href='<%= point[:href] %>' target='_blank'>
10
- <% if point[:linkimg] || point[:linktext] %>
11
- <% if point[:linkimg] %>
10
+ <% if !point.fetch(:linkimg, "").empty? || !point.fetch(:linktext, "").empty? %>
11
+ <% if !point.fetch(:linkimg, "").empty? %>
12
12
  <img src='<%= point[:linkimg] %>'><br />
13
13
  <% end %>
14
- <% if point[:linktext] %>
14
+ <% if !point.fetch(:linktext, "").empty? %>
15
15
  <%= h point[:linktext] %>
16
16
  <% end %>
17
17
  <% else %>
@@ -20,3 +20,5 @@
20
20
  </a>
21
21
  <% end %>
22
22
  </p>
23
+ <p>
24
+ <font weight"-2"><%= h @types[ point[:type] ][:description] %><% if point[:date] %> on <%= h point[:date] %><% end %>
@@ -0,0 +1,203 @@
1
+ <div class="row">
2
+ <form id="search_box">
3
+ <div class="col-md-9">
4
+ <input type="text" class="form-control" id="location">
5
+ </div>
6
+ <div class="col-md-1">
7
+ <button type="submit" class="btn btn-primary">Search</button>
8
+ </div>
9
+ </form>
10
+ </div>
11
+ <div class="row"><div class="col-md-12">&nbsp;</div></div>
12
+ <div class="row" style="height: 80%">
13
+ <div class="col-md-9" style="height: 100%">
14
+ <div class="map" id="main_map"> </div>
15
+ </div>
16
+ <div class="col-md-3">
17
+ <form id="point_info">
18
+ <div class="form-group">
19
+ <input type="text" class="form-control" id="point_title" placeholder="Title">
20
+ </div>
21
+ <div class="form-group">
22
+ <input type="text" class="form-control" id="point_comment" placeholder="Comment">
23
+ </div>
24
+ <div class="form-group">
25
+ <select id="point_type" class="form-control">
26
+ <% @types.each do |name, type| %>
27
+ <option value="<%= name %>"><%= type[:description] %></option>
28
+ <% end %>
29
+ </select>
30
+ </div>
31
+ <div class="form-group">
32
+ <input type="text" class="form-control" id="point_date" placeholder="yyyy-mm-dd">
33
+ </div>
34
+ <div class="form-group">
35
+ <input type="text" class="form-control" id="point_href" placeholder="Link URL">
36
+ </div>
37
+ <div class="form-group">
38
+ <input type="text" class="form-control" id="point_linktext" placeholder="Link Text">
39
+ </div>
40
+ <div class="form-group">
41
+ <input type="text" class="form-control" id="point_linkimg" placeholder="Link Image URL">
42
+ </div>
43
+ <div class="form-group">
44
+ <input type="text" class="form-control" id="point_country" placeholder="Country">
45
+ </div>
46
+ <div class="form-group">
47
+ <button type="submit" class="btn btn-primary">Preview</button>
48
+ </div>
49
+ </form>
50
+ </div>
51
+ </div>
52
+ <div class="row">
53
+ <div class="col-md-9"><center>Perform a search to place a marker or right click to place one anywhere.</center></div>
54
+ </div>
55
+
56
+ <script type="text/javascript">
57
+ var map;
58
+ var marker;
59
+
60
+ function getLocationName(results) {
61
+ var addrComponents = results[0].address_components;
62
+
63
+ for (var i = 0; i < addrComponents.length; i++) {
64
+ if (addrComponents[i].types[0] == "point_of_interest") {
65
+ return addrComponents[i].long_name;
66
+ }
67
+
68
+ if (addrComponents[i].types[0] == "postal_town") {
69
+ return addrComponents[i].long_name;
70
+ }
71
+ }
72
+
73
+ return results[0].formatted_address;
74
+ }
75
+
76
+ function getCountry(results) {
77
+ var addrComponents = results[0].address_components;
78
+
79
+ for (var i = 0; i < addrComponents.length; i++) {
80
+ if (addrComponents[i].types[0] == "country") {
81
+ return addrComponents[i].long_name;
82
+ }
83
+
84
+ if (addrComponents[i].types.length == 2) {
85
+ if (addrComponents[i].types[0] == "political") {
86
+ return addrComponents[i].long_name;
87
+ }
88
+ }
89
+ }
90
+ return "n/a";
91
+ }
92
+
93
+ function updateForm(results, status, createMarker) {
94
+ if (status == google.maps.GeocoderStatus.OK) {
95
+ var latlng = results[0].geometry.location;
96
+
97
+ if (createMarker) {
98
+ map.setZoom(15);
99
+ map.setCenter(latlng.lat(), latlng.lng());
100
+ marker = map.addMarker({
101
+ lat: latlng.lat(),
102
+ lng: latlng.lng(),
103
+ });
104
+ }
105
+
106
+ document.getElementById('point_title').value = getLocationName(results);
107
+ document.getElementById('point_country').value = getCountry(results);
108
+ document.getElementById('point_date').value = moment().format("YYYY-MM-DD");
109
+ } else {
110
+ alert("Geocode was not successful for the following reason: " + status);
111
+ }
112
+ }
113
+
114
+ $(document).ready(function() {
115
+ map = new GMaps({
116
+ div: '#main_map',
117
+ zoom: 3,
118
+ lat: 20,
119
+ lng: 0,
120
+ });
121
+
122
+ GMaps.on('rightclick', map.map, function(event) {
123
+ var lat = event.latLng.lat();
124
+ var lng = event.latLng.lng();
125
+
126
+ map.removeMarkers();
127
+ map.setCenter(lat, lng);
128
+
129
+ marker = map.addMarker({
130
+ lat: lat,
131
+ lng: lng,
132
+ });
133
+
134
+ GMaps.geocode({
135
+ lat: lat,
136
+ lng: lng,
137
+ callback: function(results, status) {
138
+ updateForm(results, status, false)
139
+ }
140
+ });
141
+ });
142
+
143
+ $('#point_info').submit(function(e) {
144
+ e.preventDefault();
145
+
146
+ var point = {};
147
+ point.type = document.getElementById('point_type').value
148
+ point.title = document.getElementById('point_title').value
149
+ point.comment = document.getElementById('point_comment').value
150
+ point.country = document.getElementById('point_country').value
151
+ point.date = document.getElementById('point_date').value
152
+ point.href = document.getElementById('point_href').value
153
+ point.linktext = document.getElementById('point_linktext').value
154
+ point.linkimg = document.getElementById('point_linkimg').value
155
+ point.lon = marker.position.lng();
156
+ point.lat = marker.position.lat();
157
+
158
+ document.getElementById('preview_html').innerHTML = "Validating point and fetching preview...";
159
+ document.getElementById('preview_yaml').innerHTML = "";
160
+
161
+ $('#myModal').modal({});
162
+
163
+ $.post("/points/validate", JSON.stringify(point), function(data) {
164
+ alert("Response: " + JSON.stringify(data));
165
+ document.getElementById('preview_html').innerHTML = data.html;
166
+ document.getElementById('preview_yaml').innerHTML = "<pre>" + data.yaml + "</pre>";
167
+ });
168
+ });
169
+
170
+ $('#search_box').submit(function(e) {
171
+ e.preventDefault();
172
+ map.removeMarkers();
173
+
174
+ GMaps.geocode({
175
+ address: $('#location').val().trim(),
176
+ callback: function(results, status) {
177
+ updateForm(results, status, true)
178
+ }
179
+ });
180
+ });
181
+ });
182
+ </script>
183
+
184
+ <!-- modal popup for point preview -->
185
+ <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
186
+ <div class="modal-dialog">
187
+ <div class="modal-content">
188
+ <div class="modal-header">
189
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
190
+ <h4 class="modal-title" id="myModalLabel">Point Preview</h4>
191
+ </div>
192
+ <div class="modal-body">
193
+ <div id="preview_html" align="center">
194
+ </div>
195
+ <div id="preview_yaml">
196
+ </div>
197
+ </div>
198
+ <div class="modal-footer">
199
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
200
+ </div>
201
+ </div>
202
+ </div>
203
+ </div>
data/views/layout.erb CHANGED
@@ -17,6 +17,8 @@
17
17
  <link rel="stylesheet" href="/travlrmap.css">
18
18
  <script src="/gmaps.js"></script>
19
19
  <script src="/markerclusterer_compiled.js"></script>
20
+ <script src="/moment.js"></script>
21
+ <script src="/js-yaml.min.js"></script>
20
22
 
21
23
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
22
24
  <!--[if lt IE 9]>
@@ -39,7 +41,7 @@
39
41
  <a class="navbar-brand" href="/"><%= @map[:title] %></a>
40
42
  </div>
41
43
  <div id="navbar" class="collapse navbar-collapse">
42
- <ul class="nav navbar-nav">
44
+ <ul class="nav navbar-nav navbar-left">
43
45
  <li class="dropdown">
44
46
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Views <span class="caret"></span></a>
45
47
  <ul class="dropdown-menu" role="menu">
@@ -49,6 +51,11 @@
49
51
  </ul>
50
52
  </li>
51
53
  </ul>
54
+ <% if @map[:show_geocode_link] %>
55
+ <ul class="nav navbar-nav navbar-right">
56
+ <li><a href="/geocode">Geocode</a></li>
57
+ </ul>
58
+ <% end %>
52
59
  </div>
53
60
  </div>
54
61
  </nav>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travlrmap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 14
10
- version: 0.0.14
9
+ - 15
10
+ version: 0.0.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2015-01-04 00:00:00 +00:00
18
+ date: 2015-01-07 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -120,6 +120,22 @@ dependencies:
120
120
  version: 1.5.2
121
121
  type: :runtime
122
122
  version_requirements: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ name: rack
125
+ prerelease: false
126
+ requirement: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - "="
130
+ - !ruby/object:Gem::Version
131
+ hash: 7
132
+ segments:
133
+ - 1
134
+ - 5
135
+ - 2
136
+ version: 1.5.2
137
+ type: :runtime
138
+ version_requirements: *id008
123
139
  description: "description: Sinatra based map builder"
124
140
  email: rip@devco.net
125
141
  executables: []
@@ -136,8 +152,10 @@ files:
136
152
  - views/index.erb
137
153
  - views/_point_comment.erb
138
154
  - views/_map_js.erb
155
+ - views/geolocate.erb
139
156
  - public/travlrmap.css
140
157
  - public/favicon.ico
158
+ - public/js-yaml.min.js
141
159
  - public/markerclusterer_compiled.js
142
160
  - public/gmaps.js
143
161
  - public/markers/marker-NAVY-MINI.png
@@ -281,6 +299,7 @@ files:
281
299
  - public/cluster/m2.png
282
300
  - public/cluster/cluster-PURPLE-5.png
283
301
  - public/cluster/cluster-MAROON-4.png
302
+ - public/moment.js
284
303
  - config/travlrmap.yaml.dist
285
304
  - config.ru
286
305
  - Gemfile