jekyll-maps 2.0.4 → 2.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fd53874b13c6ba9f3170a3f1e0f33111859d9c2
4
- data.tar.gz: e8c452dced878ab7ee030ee6b1effe3ebefd935e
3
+ metadata.gz: ef80d68f5c5d8060d8f50b0510fae948d8522a36
4
+ data.tar.gz: 09d328775dfe11292d30e826bf5e6d8543612cc5
5
5
  SHA512:
6
- metadata.gz: 0df5d97537d323d0359547b23185307110e94169436acc3c201543b4a71893f3cae53e2649d9034a4adab6c9b2c7d53f5d9d79779f7df4489fcf4eecbe0f4c4d
7
- data.tar.gz: e487f20b8232ba92b4171723ce2433f90ab5b25b25330b75a99e2ab5e345fd1957ca84dae5e99fbf5fcf47721a8dbcc5b1098427978edc86a13dd5a11df4c257
6
+ metadata.gz: 23e6448c9dc8ae22e3718a932d63e2cf11bf59bb035387560c935c106024e1e88ac003f2166d630300ffe783aa6241b7085986a2743c56074986321c228575d0
7
+ data.tar.gz: 5a0da93c3f4ee6572db0b581c429134ddb5320c9f788163c993f7618d4e025371038e8cf689445315c36b97979b1ea073fab3903ac168a3a2bb3cdaadc66bcba
data/README.md CHANGED
@@ -15,119 +15,151 @@ GoogleMaps Marker Clusterer can be used if you have many points within close pro
15
15
 
16
16
  1. Add the following to your site's `Gemfile`:
17
17
 
18
- ```ruby
19
- gem 'jekyll-maps'
20
- ```
18
+
19
+ ```ruby
20
+ gem 'jekyll-maps'
21
+ ```
21
22
 
22
23
  2. Add the following to your site's `_config.yml`:
23
24
 
24
- ```yml
25
- gems:
26
- - jekyll-maps
27
- ```
25
+
26
+ ```yml
27
+ plugins:
28
+ - jekyll-maps
29
+ ```
28
30
 
29
31
  ## Usage
30
32
 
31
33
  ### Configure Google API Key
32
34
 
33
- To be able to use Google Maps you need to obtain [API Key](https://developers.google.com/maps/documentation/javascript/get-api-key).
35
+ To be able to use Google Maps you need to obtain
36
+ [API Key](https://developers.google.com/maps/documentation/javascript/get-api-key).
34
37
 
35
38
  Once you have your API Key you need to add it to Jekyll's `_config.yml`:
36
39
 
37
- ```yml
38
- maps:
39
- google:
40
- api_key: <YOUR_KEY>
41
- ```
40
+ ```yml
41
+ maps:
42
+ google:
43
+ api_key: <YOUR_KEY>
44
+ ```
42
45
 
43
46
  ### Data Source
44
47
 
45
48
  First, add location information to your posts YAML front-matter:
46
49
 
47
- ```yml
48
- location:
50
+ ```yml
51
+ location:
52
+ latitude: 51.5285582
53
+ longitude: -0.2416807
54
+ ```
55
+
56
+ You can specify multiple locations per post:
57
+
58
+ ```yml
59
+ location:
60
+ - latitude: 51.5285582
61
+ longitude: -0.2416807
62
+ - latitude: 52.5285582
63
+ longitude: -2.2416807
64
+ - title: custom marker title
65
+ image: custom marker image
66
+ url: custom marker url
49
67
  latitude: 51.5285582
50
68
  longitude: -0.2416807
51
- ```
52
-
53
- Alternatively, you can add location info to your custom collection's documents or even in data files:
54
-
55
- ```yml
56
- - title: Paris
57
- url: http://google.fr
58
- location:
59
- latitude: 48.8587741
60
- longitude: 2.2074741
61
-
62
- - title: Madrid
63
- url: http://google.es
64
- location:
65
- latitude: 40.4378698
66
- longitude: -3.8196204
67
- ```
68
-
69
+ ```
70
+
71
+ Alternatively, you can add location info to your custom collection's documents or even in data
72
+ files:
73
+
74
+ ```yml
75
+ - title: Paris
76
+ url: http://google.fr
77
+ location:
78
+ latitude: 48.8587741
79
+ longitude: 2.2074741
80
+
81
+ - title: Madrid
82
+ url: http://google.es
83
+ location:
84
+ latitude: 40.4378698
85
+ longitude: -3.8196204
86
+ ```
87
+
69
88
  By default this plugin will display location from the page it's placed on:
70
89
 
71
- ```
72
- {% google_map %}
73
- ```
74
-
75
- But you can use src attribute to load locations from other places, like posts, collections or data files!
90
+ ```
91
+ {% google_map %}
92
+ ```
93
+
94
+ But you can use src attribute to load locations from other places, like posts, collections or data
95
+ files!
76
96
 
77
97
  For example, this map will show locations from all posts from 2016:
78
-
79
- ```
80
- {% google_map src="_posts/2016" %}
81
- ```
82
-
98
+
99
+ ```
100
+ {% google_map src="_posts/2016" %}
101
+ ```
102
+
83
103
  This map will show locations from a collection called 'my_collection':
84
104
 
85
- ```
86
- {% google_map src="_collections/my_collection" %}
87
- ```
88
-
105
+ ```
106
+ {% google_map src="_collections/my_collection" %}
107
+ ```
108
+
89
109
  This map will show locations from all data files located in 'my_points' sub-folder:
90
110
 
91
- ```
92
- {% google_map src="_data/my_points" %}
93
- ```
111
+ ```
112
+ {% google_map src="_data/my_points" %}
113
+ ```
94
114
 
95
115
  You can configure map's dimensions and assign custom CSS class to the element:
96
116
 
97
- ```
98
- {% google_map width="100%" height="400" class="my-map" %}
99
- ```
100
-
117
+ ```
118
+ {% google_map width="100%" height="400" class="my-map" %}
119
+ ```
120
+
121
+ You can also just set marker coordinates directly in tag attributes:
122
+
123
+ ```
124
+ {% google_map latitude="48.8587741" longitude="2.2074741" marker_title="My Location" marker_img="/img.jpg" marker_url="/my-location.html" %}
125
+ ```
126
+
127
+ This will create a map with single marker in given location. `marker_title`, `marker_img` and
128
+ `marker_url` attributes are optional and current page's data will be used by default.
129
+
101
130
  ### Filters
102
131
 
103
- You can also filter which locations to display on the map!<br/>
104
- For instance, following tag will only display locations from documents which have `lang: en` in their front-matter data.
132
+ You can also filter which locations to display on the map!<br/> For instance, following tag will
133
+ only display locations from documents which have `lang: en` in their front-matter data.
105
134
 
106
- ```
107
- {% google_map src="_posts" lang="en" %}
108
- ```
135
+ ```
136
+ {% google_map src="_posts" lang="en" %}
137
+ ```
109
138
 
110
139
  ### Marker Cluster
111
140
 
112
- By default [Marker Clusterer](https://github.com/googlemaps/js-marker-clusterer) is enabled.
113
- If you have many markers on the map, it will group them and show icon with the count of markers in each cluster - [see example](https://googlemaps.github.io/js-marker-clusterer/examples/advanced_example.html).
141
+ By default [Marker Clusterer](https://github.com/googlemaps/js-marker-clusterer) is enabled. If you
142
+ have many markers on the map, it will group them and show icon with the count of markers in each
143
+ cluster -
144
+ [see example](https://googlemaps.github.io/js-marker-clusterer/examples/advanced_example.html).
114
145
 
115
146
  If you don't want to use marker cluster, you can disable it globally in `_config.yml`:
116
147
 
117
- ```yml
118
- maps:
119
- google:
120
- marker_cluster:
121
- enabled: false
122
- ```
148
+ ```yml
149
+ maps:
150
+ google:
151
+ marker_cluster:
152
+ enabled: false
153
+ ```
123
154
 
124
155
  Or you can disable it per single map tag:
125
156
 
126
- ```
127
- {% google_map no_cluster %}
128
- ```
157
+ ```
158
+ {% google_map no_cluster %}
159
+ ```
129
160
 
130
- If you have any questions or proposals - open up an [issue](https://github.com/ayastreb/jekyll-maps/issues/new)!
161
+ If you have any questions or proposals - open up an
162
+ [issue](https://github.com/ayastreb/jekyll-maps/issues/new)!
131
163
 
132
164
  ## Examples
133
165
 
@@ -143,4 +175,5 @@ Want to see it in action? Check out [Demo Page](https://ayastreb.me/jekyll-maps/
143
175
 
144
176
  ## License
145
177
 
146
- [MIT](https://github.com/ayastreb/jekyll-maps/blob/master/LICENSE). Feel free to use, copy or distribute it.
178
+ [MIT](https://github.com/ayastreb/jekyll-maps/blob/master/LICENSE). Feel free to use, copy or
179
+ distribute it.
data/jekyll-maps.gemspec CHANGED
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  lib = File.expand_path("../lib", __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require "jekyll-maps/version"
@@ -12,7 +10,7 @@ Gem::Specification.new do |spec|
12
10
  spec.authors = ["Anatoliy Yastreb"]
13
11
  spec.email = ["anatoliy.yastreb@gmail.com"]
14
12
 
15
- spec.homepage = "https://github.com/ayastreb/jekyll-maps"
13
+ spec.homepage = "https://ayastreb.me/jekyll-maps/"
16
14
  spec.licenses = ["MIT"]
17
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
18
16
  spec.require_paths = ["lib"]
@@ -21,5 +19,5 @@ Gem::Specification.new do |spec|
21
19
 
22
20
  spec.add_development_dependency "rake", "~> 11.0"
23
21
  spec.add_development_dependency "rspec", "~> 3.5"
24
- spec.add_development_dependency "rubocop", "~> 0.41"
22
+ spec.add_development_dependency "rubocop", "0.49.1"
25
23
  end
@@ -1,7 +1,7 @@
1
1
  /* global google */
2
2
  /* global MarkerClusterer */
3
3
  // eslint-disable-next-line no-unused-vars
4
- var jekyllMaps = (function () {
4
+ var jekyllMaps = (function() {
5
5
  'use strict'
6
6
  var clusterSettings = {}
7
7
  var clusterReady = false
@@ -19,7 +19,7 @@ var jekyllMaps = (function () {
19
19
  /**
20
20
  * Setup Google Maps options and call renderer.
21
21
  */
22
- function initializeMap () {
22
+ function initializeMap() {
23
23
  options = {
24
24
  mapTypeId: google.maps.MapTypeId.ROADMAP,
25
25
  center: new google.maps.LatLng(0, 0)
@@ -35,7 +35,7 @@ var jekyllMaps = (function () {
35
35
  * @param Array locations
36
36
  * @param Object settings
37
37
  */
38
- function register (id, locations, options) {
38
+ function register(id, locations, options) {
39
39
  data.push({ id: id, locations: locations, options: options })
40
40
  render()
41
41
  }
@@ -43,14 +43,17 @@ var jekyllMaps = (function () {
43
43
  /**
44
44
  * Render maps data if Google Maps API is loaded.
45
45
  */
46
- function render () {
46
+ function render() {
47
47
  if (!mapReady) return
48
48
 
49
49
  while (data.length > 0) {
50
50
  var item = data.pop()
51
51
  var bounds = new google.maps.LatLngBounds()
52
52
  var mapOptions = Object.assign({}, options, item.options)
53
- var map = new google.maps.Map(document.getElementById(item.id), mapOptions)
53
+ var map = new google.maps.Map(
54
+ document.getElementById(item.id),
55
+ mapOptions
56
+ )
54
57
  var infoWindow = new google.maps.InfoWindow()
55
58
  var markers = item.locations.map(createMarker)
56
59
 
@@ -64,8 +67,11 @@ var jekyllMaps = (function () {
64
67
  }
65
68
  }
66
69
 
67
- function createMarker (location) {
68
- var position = new google.maps.LatLng(location.latitude, location.longitude)
70
+ function createMarker(location) {
71
+ var position = new google.maps.LatLng(
72
+ location.latitude,
73
+ location.longitude
74
+ )
69
75
  bounds.extend(position)
70
76
  if (!mapOptions.showMarker) return false
71
77
 
@@ -73,7 +79,7 @@ var jekyllMaps = (function () {
73
79
  position: position,
74
80
  title: location.title,
75
81
  image: location.image,
76
- url: location.url,
82
+ url: location.url.length > 0 ? mapOptions.baseUrl + location.url : '',
77
83
  map: map
78
84
  })
79
85
  if (mapOptions.showMarkerPopup) marker.addListener('click', markerPopup)
@@ -81,8 +87,9 @@ var jekyllMaps = (function () {
81
87
  return marker
82
88
  }
83
89
 
84
- function markerPopup () {
85
- var contentHtml = '<div class="map-info-window"><h5>' + this.title + '</h5>'
90
+ function markerPopup() {
91
+ var contentHtml =
92
+ '<div class="map-info-window"><h5>' + this.title + '</h5>'
86
93
  var imageHtml = '<img src="' + this.image + '" alt="' + this.title + '"/>'
87
94
  if (this.url.length > 0) {
88
95
  var linkText = this.image.length > 0 ? imageHtml : 'View'
@@ -95,13 +102,13 @@ var jekyllMaps = (function () {
95
102
  }
96
103
  }
97
104
 
98
- function initializeCluster (settings) {
105
+ function initializeCluster(settings) {
99
106
  clusterReady = true
100
107
  clusterSettings = settings || {}
101
108
  processCluster()
102
109
  }
103
110
 
104
- function processCluster () {
111
+ function processCluster() {
105
112
  if (!clusterReady) return
106
113
 
107
114
  while (maps.length > 0) {
@@ -109,14 +116,15 @@ var jekyllMaps = (function () {
109
116
  // eslint-disable-next-line no-new
110
117
  new MarkerClusterer(obj.map, obj.markers, {
111
118
  gridSize: clusterSettings.grid_size || 25,
112
- imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
119
+ imagePath:
120
+ 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
113
121
  })
114
122
  }
115
123
  }
116
- }())
124
+ })()
117
125
  /* Object.assign polyfill */
118
126
  if (typeof Object.assign !== 'function') {
119
- Object.assign = function (target) {
127
+ Object.assign = function(target) {
120
128
  'use strict'
121
129
  if (target == null) {
122
130
  throw new TypeError('Cannot convert undefined or null to object')
@@ -124,11 +132,11 @@ if (typeof Object.assign !== 'function') {
124
132
 
125
133
  target = Object(target)
126
134
  for (var index = 1; index < arguments.length; index++) {
127
- var source = arguments[ index ]
135
+ var source = arguments[index]
128
136
  if (source != null) {
129
137
  for (var key in source) {
130
138
  if (Object.prototype.hasOwnProperty.call(source, key)) {
131
- target[ key ] = source[ key ]
139
+ target[key] = source[key]
132
140
  }
133
141
  }
134
142
  }
@@ -21,7 +21,7 @@ module Jekyll
21
21
  #{JS_LIB_NAME}.register(
22
22
  '#{@args[:attributes][:id]}',
23
23
  #{locations.to_json},
24
- #{map_options.to_json}
24
+ #{map_options(context.registers[:site]).to_json}
25
25
  );
26
26
  </script>
27
27
  HTML
@@ -53,8 +53,9 @@ HTML
53
53
  end
54
54
 
55
55
  private
56
- def map_options
56
+ def map_options(site)
57
57
  opts = {
58
+ :baseUrl => site.baseurl || "/",
58
59
  :useCluster => !@args[:flags][:no_cluster],
59
60
  :showMarker => @args[:attributes][:show_marker] != "false",
60
61
  :showMarkerPopup => @args[:attributes][:show_popup] != "false"
@@ -12,8 +12,8 @@ module Jekyll
12
12
  elsif @options[:filters].empty?
13
13
  @documents << page if with_location?(page)
14
14
  else
15
- site.collections.each { |_, collection| filter(collection.docs) }
16
- site_data(site).each { |_, items| traverse(items) }
15
+ site.collections.each_value { |collection| filter(collection.docs) }
16
+ site_data(site).each_value { |items| traverse(items) }
17
17
  end
18
18
 
19
19
  documents_to_locations
@@ -55,7 +55,7 @@ module Jekyll
55
55
  def traverse(items)
56
56
  return filter(items) if items.is_a?(Array)
57
57
 
58
- items.each { |_, children| traverse(children) } if items.is_a?(Hash)
58
+ items.each_value { |children| traverse(children) } if items.is_a?(Hash)
59
59
  end
60
60
 
61
61
  private
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Maps
3
- VERSION = "2.0.4".freeze
3
+ VERSION = "2.1.0".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.4
4
+ version: 2.1.0
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-06-19 00:00:00.000000000 Z
11
+ date: 2018-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0.41'
61
+ version: 0.49.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0.41'
68
+ version: 0.49.1
69
69
  description: Google Maps support in Jekyll blog to easily embed maps with posts' locations
70
70
  email:
71
71
  - anatoliy.yastreb@gmail.com
@@ -92,7 +92,7 @@ files:
92
92
  - lib/jekyll-maps/version.rb
93
93
  - script/bootstrap
94
94
  - script/cibuild
95
- homepage: https://github.com/ayastreb/jekyll-maps
95
+ homepage: https://ayastreb.me/jekyll-maps/
96
96
  licenses:
97
97
  - MIT
98
98
  metadata: {}