tdiary-contrib 5.0.11 → 5.0.12
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.
- checksums.yaml +4 -4
- data/lib/tdiary/contrib/version.rb +1 -1
- data/plugin/google_map.rb +153 -141
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc1190e78433e0a69387575f2bcc40e2f07b433022b8571e63b2ec77a51ebc81
|
4
|
+
data.tar.gz: b8419819c2bd0b65217db448caf90805ccf47d8ed8c92052e5082fac25770f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3367e5faab5bc9b4c2af9dc4a4ad51f980b646a67d18363e8027926dc4956eac1ecce14ebb338d019f62180c9f2c6d52d9fe8c08a721af2549a4df6ea64f9ac6
|
7
|
+
data.tar.gz: 16d753593606e8522df46be581c85703c42856099a77052de3c7f4d1f63856455f62c4954c40dbeb1a71c5d1feb54fb33d58769385abc37747dc79cb3c65220c
|
data/plugin/google_map.rb
CHANGED
@@ -1,174 +1,186 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
# google_map.rb - embeded Google Map for tDiary, use Google Maps JavaScript API V3.
|
4
|
-
#
|
4
|
+
# https://developers.google.com/maps/documentation/javascript/tutorial
|
5
5
|
#
|
6
6
|
# Copyright (C) 2010, tamoot <tamoot+tdiary@gmail.com>
|
7
7
|
# You can redistribute it and/or modify it under GPL2.
|
8
8
|
#
|
9
9
|
|
10
10
|
def google_map(lat, lon, params = {})
|
11
|
-
|
12
|
-
|
11
|
+
params.merge!(:lat => lat, :lon => lon)
|
12
|
+
google_map_common(params)
|
13
13
|
end
|
14
14
|
|
15
15
|
def google_geomap(address, params = {})
|
16
|
-
|
17
|
-
|
16
|
+
params.merge!(:address => address)
|
17
|
+
google_map_common(params)
|
18
18
|
end
|
19
19
|
|
20
20
|
def google_map_common(params)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
21
|
+
params[:id] ||= ''
|
22
|
+
params[:lat] ||= 0.0
|
23
|
+
params[:lon] ||= 0.0
|
24
|
+
params[:address] ||= nil
|
25
|
+
params[:zoom] ||= 10
|
26
|
+
params[:html] ||= nil
|
27
|
+
params[:title] ||= nil
|
28
|
+
params[:width] ||= 320
|
29
|
+
params[:height] ||= 240
|
30
|
+
params[:type] ||= :ROADMAP
|
31
|
+
params[:overview]||= false
|
32
|
+
|
33
|
+
if feed?
|
34
|
+
require 'cgi'
|
35
|
+
|
36
|
+
url = nil
|
37
|
+
if params[:lat].nonzero? && params[:lon].nonzero?
|
38
|
+
query = "#{params[:lat]},#{params[:lon]}"
|
39
|
+
url = %Q|https://maps.google.com/maps?q=#{CGI::escape(query)}|
|
40
|
+
|
41
|
+
elsif params[:address] != nil
|
42
|
+
query = params[:address]
|
43
|
+
url = %Q|https://maps.google.com/maps?q=#{CGI::escape(query)}|
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
return %Q|<a href="#{url}">#{url}</a>| if url
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
dom_id = "#{@gmap_date.strftime("%Y%m%d")}_#{@gmap_count}"
|
52
|
+
params.merge!(:id => dom_id)
|
53
|
+
@gmap_data << params
|
54
|
+
@gmap_count += 1
|
55
|
+
|
56
|
+
%Q|<div class="gmap" id="#{dom_id}" style="width : #{params[:width]}px; height : #{params[:height]}px;"></div>|
|
57
57
|
end
|
58
58
|
|
59
59
|
add_header_proc do
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
|
61
|
+
%Q|<script type="text/javascript" src="//maps.google.com/maps/api/js?key=#{@conf['google_map.key']}"></script>\n|
|
62
|
+
end
|
63
63
|
end
|
64
64
|
|
65
65
|
add_body_enter_proc do |date|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
@gmap_data = []
|
67
|
+
@gmap_date = date
|
68
|
+
@gmap_count = 0
|
69
|
+
''
|
70
70
|
end
|
71
71
|
|
72
72
|
add_body_leave_proc do |date|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
73
|
+
gmap_scripts = ''
|
74
|
+
if !feed? && @gmap_data.any?
|
75
|
+
gmap_scripts = %Q|<script type="text/javascript">\n<!--\n|
|
76
|
+
@gmap_data.each do |data|
|
77
|
+
if data[:address]
|
78
|
+
gmap_scripts << google_geomap_script(data)
|
79
|
+
else
|
80
|
+
gmap_scripts << google_map_script(data)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
gmap_scripts << %Q|//-->\n</script>\n|
|
84
|
+
end
|
85
|
+
gmap_scripts
|
86
|
+
end
|
87
|
+
|
88
|
+
add_conf_proc('google_map', 'Google Maps', 'etc') do
|
89
|
+
if @mode == 'saveconf' then
|
90
|
+
@conf['google_map.key'], = @cgi.params['google_map.key']
|
91
|
+
end
|
92
|
+
|
93
|
+
<<-HTML
|
94
|
+
<h3 class="subtitle">Google Maps API Key</h3>
|
95
|
+
<p>API Key (see <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">developers.google.com/maps</a>)</p>
|
96
|
+
<p><input name="google_map.key" value="#{h @conf['google_map.key']}" size="50"></p>
|
97
|
+
HTML
|
86
98
|
end
|
87
99
|
|
88
100
|
def google_map_script(hash)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
101
|
+
str = ''
|
102
|
+
str << %Q|google.maps.event.addDomListener(window, 'load', function() {\n|
|
103
|
+
str << %Q| var mapdiv = document.getElementById("#{hash[:id]}");\n|
|
104
|
+
str << %Q| if(mapdiv){\n|
|
105
|
+
str << %Q| var myOptions = {\n|
|
106
|
+
str << %Q| zoom: #{hash[:zoom]},\n|
|
107
|
+
str << %Q| overviewMapControl: #{hash[:overview]},\n|
|
108
|
+
str << %Q| overviewMapControlOptions: {\n|
|
109
|
+
str << %Q| opened: #{hash[:overview]}\n|
|
110
|
+
str << %Q| },\n|
|
111
|
+
str << %Q| center: new google.maps.LatLng(#{hash[:lat]}, #{hash[:lon]}),\n|
|
112
|
+
str << %Q| mapTypeId: google.maps.MapTypeId.#{hash[:type]},\n|
|
113
|
+
str << %Q| scaleControl: true\n|
|
114
|
+
str << %Q| };\n|
|
115
|
+
str << %Q| var gMap = new google.maps.Map(mapdiv, myOptions);\n|
|
116
|
+
# set Marker
|
117
|
+
if hash[:title]
|
118
|
+
str << %Q| var marker = new google.maps.Marker({\n|
|
119
|
+
str << %Q| position: new google.maps.LatLng(#{hash[:lat]}, #{hash[:lon]}),\n|
|
120
|
+
str << %Q| map: gMap,\n|
|
121
|
+
str << %Q| title: '#{hash[:title]}'\n|
|
122
|
+
str << %Q| });\n|
|
123
|
+
# set InfoWindow
|
124
|
+
if hash[:html]
|
125
|
+
str << %Q| var infowindow = new google.maps.InfoWindow({\n|
|
126
|
+
str << %Q| content: '<span style="color: #000000;">#{hash[:html]}</span>',\n|
|
127
|
+
str << %Q| size: new google.maps.Size(350, 200)\n|
|
128
|
+
str << %Q| });\n|
|
129
|
+
str << %Q| infowindow.open(gMap, marker);\n|
|
130
|
+
end # :html
|
131
|
+
end # :title
|
132
|
+
str << %Q| };\n|
|
133
|
+
str << %Q|});\n|
|
134
|
+
|
135
|
+
str
|
124
136
|
end
|
125
137
|
|
126
138
|
def google_geomap_script(hash)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
139
|
+
str = ''
|
140
|
+
str << %Q|google.maps.event.addDomListener(window, 'load', function() {\n|
|
141
|
+
str << %Q| var mapdiv = document.getElementById("#{hash[:id]}");\n|
|
142
|
+
str << %Q| if(mapdiv){\n|
|
143
|
+
str << %Q| var geocoder = new google.maps.Geocoder();\n|
|
144
|
+
str << %Q| if(geocoder) {\n|
|
145
|
+
str << %Q| geocoder.geocode( { 'address': '#{hash[:address]}'}, function(results, status) {\n|
|
146
|
+
str << %Q| if (status == google.maps.GeocoderStatus.OK) {\n|
|
147
|
+
str << %Q| var geoLat = results[0].geometry.location;\n|
|
148
|
+
str << %Q| var myOptions = {\n|
|
149
|
+
str << %Q| zoom: #{hash[:zoom]},\n|
|
150
|
+
str << %Q| overviewMapControl: #{hash[:overview]},\n|
|
151
|
+
str << %Q| overviewMapControlOptions: {\n|
|
152
|
+
str << %Q| opened: #{hash[:overview]}\n|
|
153
|
+
str << %Q| },\n|
|
154
|
+
str << %Q| center: geoLat,\n|
|
155
|
+
str << %Q| mapTypeId: google.maps.MapTypeId.#{hash[:type]},\n|
|
156
|
+
str << %Q| scaleControl: true\n|
|
157
|
+
str << %Q| };\n|
|
158
|
+
str << %Q| var gMap = new google.maps.Map(mapdiv, myOptions);\n|
|
159
|
+
# set Marker
|
160
|
+
if hash[:title]
|
161
|
+
str << %Q| var marker = new google.maps.Marker({\n|
|
162
|
+
str << %Q| position: geoLat,\n|
|
163
|
+
str << %Q| map: gMap,\n|
|
164
|
+
str << %Q| title: '#{hash[:title]}'\n|
|
165
|
+
str << %Q| });\n|
|
166
|
+
# set InfoWindow
|
167
|
+
if hash[:html]
|
168
|
+
str << %Q| var infowindow = new google.maps.InfoWindow({\n|
|
169
|
+
str << %Q| content: '<span style="color: #000000;">#{hash[:html]}</span>',\n|
|
170
|
+
str << %Q| size: new google.maps.Size(350, 200)\n|
|
171
|
+
str << %Q| });\n|
|
172
|
+
str << %Q| infowindow.open(gMap, marker);\n|
|
173
|
+
end # :html
|
174
|
+
end # :title
|
175
|
+
str << %Q| }else{\n|
|
176
|
+
str << %Q| alert("Geocode was not successful for the following reason: " + status)\n|
|
177
|
+
str << %Q| }\n|
|
178
|
+
str << %Q| });\n|
|
179
|
+
str << %Q| }\n|
|
180
|
+
str << %Q| }\n|
|
181
|
+
str << %Q|});\n|
|
182
|
+
|
183
|
+
str
|
172
184
|
end
|
173
185
|
|
174
186
|
# Local Variables:
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdiary-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tDiary contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tdiary
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pushbullet_ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.3'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '3.0'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '1.3'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -507,7 +513,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
507
513
|
- !ruby/object:Gem::Version
|
508
514
|
version: '0'
|
509
515
|
requirements: []
|
510
|
-
rubygems_version: 3.0.
|
516
|
+
rubygems_version: 3.0.3
|
511
517
|
signing_key:
|
512
518
|
specification_version: 4
|
513
519
|
summary: tDiary contributions package
|