jekyll-maps 2.0.3 → 2.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9017b81a9491708709221e31c9e6131bb2eec5a
4
- data.tar.gz: 07c63633b3c8873380da1e806a8bea997c3193f7
3
+ metadata.gz: 4fd53874b13c6ba9f3170a3f1e0f33111859d9c2
4
+ data.tar.gz: e8c452dced878ab7ee030ee6b1effe3ebefd935e
5
5
  SHA512:
6
- metadata.gz: 6535079eb86812d6f9656a6f63c7fbc9c5ae8c11a9ff5336700b9dca3ac618c9ca38ece6467ad8ebd8814b7859d5bbc02523b3eb86ab60afac31e9361c48f35a
7
- data.tar.gz: 9cd8a8528036d954f6904f4160d65c636c566bb5ac3cb88c995ed3fbf2733178c1b99ff3d09bf235272da0b7411c63573b94d86a9424793ffd6e029e7b0a909d
6
+ metadata.gz: 0df5d97537d323d0359547b23185307110e94169436acc3c201543b4a71893f3cae53e2649d9034a4adab6c9b2c7d53f5d9d79779f7df4489fcf4eecbe0f4c4d
7
+ data.tar.gz: e487f20b8232ba92b4171723ce2433f90ab5b25b25330b75a99e2ab5e345fd1957ca84dae5e99fbf5fcf47721a8dbcc5b1098427978edc86a13dd5a11df4c257
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.4.1
3
4
  - 2.3.0
4
5
  - 2.2
5
6
  - 2.1
6
- - 2.0
7
7
  script: script/cibuild
8
8
  after_success:
9
9
  - bundle exec codeclimate-test-reporter
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2.0.4 / 2017-07-19
2
+
3
+ * allow multiple locations per document (fix #6)
4
+ * allow inline locations with map attributes, e.g. `{% google_map laititude='42.23323' longitude='3.213232' %}` (fix #23)
5
+
1
6
  ## 2.0.3 / 2017-05-17
2
7
 
3
8
  * load locations from specific data file (fix #26)
@@ -7,14 +7,27 @@ module Jekyll
7
7
  end
8
8
 
9
9
  def find(site, page)
10
- if @options[:filters].empty?
11
- @documents << page if location?(page)
10
+ if @options[:attributes][:latitude] && @options[:attributes][:longitude]
11
+ return [location_from_options(page)]
12
+ elsif @options[:filters].empty?
13
+ @documents << page if with_location?(page)
12
14
  else
13
15
  site.collections.each { |_, collection| filter(collection.docs) }
14
16
  site_data(site).each { |_, items| traverse(items) }
15
17
  end
16
18
 
17
- convert
19
+ documents_to_locations
20
+ end
21
+
22
+ private
23
+ def location_from_options(page)
24
+ {
25
+ :latitude => @options[:attributes][:latitude],
26
+ :longitude => @options[:attributes][:longitude],
27
+ :title => @options[:attributes][:marker_title] || page["title"],
28
+ :url => @options[:attributes][:marker_url] || fetch_url(page),
29
+ :image => @options[:attributes][:marker_img] || page["image"] || ""
30
+ }
18
31
  end
19
32
 
20
33
  private
@@ -48,12 +61,12 @@ module Jekyll
48
61
  private
49
62
  def filter(docs)
50
63
  docs.each do |doc|
51
- @documents << doc if location?(doc) && match_filters?(doc)
64
+ @documents << doc if with_location?(doc) && match_filters?(doc)
52
65
  end
53
66
  end
54
67
 
55
68
  private
56
- def location?(doc)
69
+ def with_location?(doc)
57
70
  !doc["location"].nil? && !doc["location"].empty?
58
71
  end
59
72
 
@@ -70,23 +83,36 @@ module Jekyll
70
83
  end
71
84
 
72
85
  private
73
- def convert
74
- @documents.map do |document|
75
- {
76
- :latitude => document["location"]["latitude"],
77
- :longitude => document["location"]["longitude"],
78
- :title => document["title"],
79
- :url => fetch_url(document),
80
- :image => document["image"] || ""
81
- }
86
+ def documents_to_locations
87
+ locations = []
88
+ @documents.each do |document|
89
+ if document["location"].is_a?(Array)
90
+ document["location"].each do |location|
91
+ locations.push(convert(document, location))
92
+ end
93
+ else
94
+ locations.push(convert(document, document["location"]))
95
+ end
82
96
  end
97
+ locations
98
+ end
99
+
100
+ private
101
+ def convert(document, location)
102
+ {
103
+ :latitude => location["latitude"],
104
+ :longitude => location["longitude"],
105
+ :title => location["title"] || document["title"],
106
+ :url => location["url"] || fetch_url(document),
107
+ :image => location["image"] || document["image"] || ""
108
+ }
83
109
  end
84
110
 
85
111
  private
86
112
  def fetch_url(document)
87
113
  return document["url"] if document.is_a?(Hash) && document.key?("url")
88
114
  return document.url if document.respond_to? :url
89
- return ""
115
+ ""
90
116
  end
91
117
  end
92
118
  end
@@ -13,6 +13,11 @@ module Jekyll
13
13
  show_marker
14
14
  show_popup
15
15
  zoom
16
+ latitude
17
+ longitude
18
+ marker_title
19
+ marker_img
20
+ marker_url
16
21
  ).freeze
17
22
 
18
23
  class << self
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Maps
3
- VERSION = "2.0.3".freeze
3
+ VERSION = "2.0.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-maps
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoliy Yastreb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll