travlrmap 1.2.0 → 1.3.0
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.
- data/lib/travlrmap/sinatra_app.rb +5 -0
- data/lib/travlrmap/version.rb +1 -1
- data/views/_point_comment.erb +11 -9
- data/views/geolocate.erb +30 -10
- metadata +4 -4
@@ -26,6 +26,11 @@ module Travlrmap
|
|
26
26
|
|
27
27
|
alias_method :h, :escape_html
|
28
28
|
|
29
|
+
def domain_from_url(url)
|
30
|
+
host = URI.parse(url).host.downcase
|
31
|
+
host.start_with?('www.') ? host[4..-1] : host
|
32
|
+
end
|
33
|
+
|
29
34
|
def protected!
|
30
35
|
return if authorized?
|
31
36
|
headers['WWW-Authenticate'] = 'Basic realm="Restricted Area"'
|
data/lib/travlrmap/version.rb
CHANGED
data/views/_point_comment.erb
CHANGED
@@ -7,16 +7,18 @@
|
|
7
7
|
|
8
8
|
<% if point[:href] %>
|
9
9
|
<a href='<%= point[:href] %>' target='_blank'>
|
10
|
-
<%
|
11
|
-
<%
|
12
|
-
|
13
|
-
|
14
|
-
<%
|
15
|
-
|
16
|
-
|
17
|
-
<% else %>
|
18
|
-
Link
|
10
|
+
<% end %>
|
11
|
+
<% if point[:linkimg] || point[:linktext] %>
|
12
|
+
<% if point[:linkimg] %>
|
13
|
+
<img src='<%= point[:linkimg] %>'><br />
|
14
|
+
<% end %>
|
15
|
+
<% if point[:linktext] %>
|
16
|
+
<%= h point[:linktext] %>
|
19
17
|
<% end %>
|
18
|
+
<% elsif point[:href] %>
|
19
|
+
<%= domain_from_url(point[:href]) %>
|
20
|
+
<% end %>
|
21
|
+
<% if point[:href] %>
|
20
22
|
</a>
|
21
23
|
<% end %>
|
22
24
|
</p>
|
data/views/geolocate.erb
CHANGED
@@ -3,12 +3,16 @@
|
|
3
3
|
<div class="col-md-9">
|
4
4
|
<input type="text" class="form-control" id="location" autofocus>
|
5
5
|
</div>
|
6
|
-
<div class="col-md-
|
6
|
+
<div class="col-md-3">
|
7
7
|
<button type="submit" class="btn btn-primary">Search</button>
|
8
|
+
<button type="button" id="my_location" class="btn btn-primary">My Location</button>
|
8
9
|
</div>
|
9
10
|
</form>
|
10
11
|
</div>
|
11
12
|
<div class="row"><div class="col-md-12"> </div></div>
|
13
|
+
<div class="row">
|
14
|
+
<div class="col-md-9"><center>Perform a search to place a marker or right click to place one anywhere.</center></div>
|
15
|
+
</div>
|
12
16
|
<div class="row" style="height: 80%">
|
13
17
|
<div class="col-md-9" style="height: 100%">
|
14
18
|
<div class="map" id="main_map"> </div>
|
@@ -49,9 +53,6 @@
|
|
49
53
|
</form>
|
50
54
|
</div>
|
51
55
|
</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
|
|
56
57
|
<script src="/moment.js"></script>
|
57
58
|
<script src="/datepicker/bootstrap-datepicker.js"></script>
|
@@ -64,11 +65,7 @@
|
|
64
65
|
var addrComponents = results[0].address_components;
|
65
66
|
|
66
67
|
for (var i = 0; i < addrComponents.length; i++) {
|
67
|
-
if (addrComponents[i].types[0]
|
68
|
-
return addrComponents[i].long_name;
|
69
|
-
}
|
70
|
-
|
71
|
-
if (addrComponents[i].types[0] == "postal_town") {
|
68
|
+
if ($.inArray(addrComponents[i].types[0], ["establishment", "point_of_interest", "postal_town", "locality"])) {
|
72
69
|
return addrComponents[i].long_name;
|
73
70
|
}
|
74
71
|
}
|
@@ -108,7 +105,6 @@
|
|
108
105
|
|
109
106
|
document.getElementById('point_title').value = getLocationName(results);
|
110
107
|
document.getElementById('point_country').value = getCountry(results);
|
111
|
-
document.getElementById('point_date').value = moment().format("YYYY-MM-DD");
|
112
108
|
} else {
|
113
109
|
alert("Geocode was not successful for the following reason: " + status);
|
114
110
|
}
|
@@ -155,6 +151,22 @@
|
|
155
151
|
});
|
156
152
|
}
|
157
153
|
|
154
|
+
function updateWithCurrentPosition(pos) {
|
155
|
+
map.removeMarkers();
|
156
|
+
|
157
|
+
GMaps.geocode({
|
158
|
+
lat: pos.coords.latitude,
|
159
|
+
lng: pos.coords.longitude,
|
160
|
+
callback: function(results, status) {
|
161
|
+
updateForm(results, status, true)
|
162
|
+
}
|
163
|
+
});
|
164
|
+
}
|
165
|
+
|
166
|
+
function errorGettingCurrentPos(error) {
|
167
|
+
alert("Could not get current position: " + err.message);
|
168
|
+
}
|
169
|
+
|
158
170
|
$(document).ready(function() {
|
159
171
|
$('#point_date').datepicker({
|
160
172
|
format: 'yyyy-mm-dd',
|
@@ -196,6 +208,14 @@
|
|
196
208
|
selectText('preview_yaml');
|
197
209
|
};
|
198
210
|
|
211
|
+
document.getElementById('my_location').onclick = function() {
|
212
|
+
if (navigator.geolocation) {
|
213
|
+
navigator.geolocation.getCurrentPosition(updateWithCurrentPosition, errorGettingCurrentPos);
|
214
|
+
} else {
|
215
|
+
alert("Optaining your position is not supported with this browser");
|
216
|
+
}
|
217
|
+
};
|
218
|
+
|
199
219
|
$('#point_info').submit(function(e) {
|
200
220
|
e.preventDefault();
|
201
221
|
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.3.0
|
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-
|
18
|
+
date: 2015-01-16 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|