jekyll-maps 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff712952d8af10379eb6c0b661849966afda5d95
4
- data.tar.gz: 7c177d50a81d48be0231d9b3f408d0b893d5143b
3
+ metadata.gz: c2839acbbfb16951bd477def2dba07291bb91138
4
+ data.tar.gz: c2e49939d84003b196940a466fa10761ff735678
5
5
  SHA512:
6
- metadata.gz: b08891aa61f5a8206265a7eb89cb744f7e9762c71bc82442be66725104654dd0b883fe8b6498d223bcfe5d65eeca8ef4066c0ed8d2f1845f46cb89d642f62b30
7
- data.tar.gz: 4e2253c2dfa01023e861b5b75ccf8258e1b81904f35a43b085350a82af7bb251c06e51ba9cc204841a5aafd08e7cea27fbd584165593bcfb6e1f24ea961a5829
6
+ metadata.gz: 56ea3c0abad7154d3879424cc55984f32083c02abb2575b9fd59b481cf78b712a0062ad345255b0086b51ca1d4caf29810416909afd9e6a9df0075dafb0f804f
7
+ data.tar.gz: c411f5e64cd2cd995aec23fd1f0f2939a738f07d1bdcc2ae9b58e3281c2ebc1f040868d1fcb626e5738d6daaa141cf174e9eb563736f5f1537925f704e7d9210
data/.rubocop.yml CHANGED
@@ -12,6 +12,9 @@ Lint/UselessAccessModifier:
12
12
  Enabled: false
13
13
  Metrics/AbcSize:
14
14
  Max: 20
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - spec/**/*.rb
15
18
  Metrics/ClassLength:
16
19
  Max: 300
17
20
  Exclude:
@@ -19,6 +22,10 @@ Metrics/ClassLength:
19
22
  Metrics/CyclomaticComplexity:
20
23
  Max: 8
21
24
  Metrics/LineLength:
25
+ Exclude:
26
+ - Rakefile
27
+ - Gemfile
28
+ - jekyll-maps.gemspec
22
29
  Max: 90
23
30
  Severity: warning
24
31
  Metrics/MethodLength:
@@ -114,3 +121,7 @@ Style/StringLiteralsInInterpolation:
114
121
  EnforcedStyle: double_quotes
115
122
  Style/UnneededCapitalW:
116
123
  Enabled: false
124
+ Style/IndentHeredoc:
125
+ Enabled: false
126
+ Style/SymbolArray:
127
+ Enabled: false
data/.travis.yml CHANGED
@@ -5,5 +5,7 @@ rvm:
5
5
  - 2.1
6
6
  - 2.0
7
7
  script: script/cibuild
8
+ after_success:
9
+ - bundle exec codeclimate-test-reporter
8
10
  sudo: false
9
11
  cache: bundler
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "codeclimate-test-reporter", group: :test, require: nil
5
+ gem "codeclimate-test-reporter", :group => :test, :require => nil
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2.0.1 / 2017-04-11
2
+
3
+ * add option to hide markers (show_marker="false")
4
+ * do not show link in marker popup when no URL is set
5
+
1
6
  ## 2.0.0 / 2016-11-06
2
7
 
3
8
  * change default behaviour to load location from current page
data/README.md CHANGED
@@ -28,6 +28,18 @@ GoogleMaps Marker Clusterer can be used if you have many points within close pro
28
28
 
29
29
  ## Usage
30
30
 
31
+ ### Configure Google API Key
32
+
33
+ To be able to use Google Maps you need to obtain [API Key](https://developers.google.com/maps/documentation/javascript/get-api-key).
34
+
35
+ Once you have your API Key you need to add it to Jekyll's `_config.yml`:
36
+
37
+ ```yml
38
+ maps:
39
+ google:
40
+ api_key: <YOUR_KEY>
41
+ ```
42
+
31
43
  ### Data Source
32
44
 
33
45
  First, add location information to your posts YAML front-matter:
@@ -54,16 +66,36 @@ Alternatively, you can add location info to your custom collection's documents o
54
66
  longitude: -3.8196204
55
67
  ```
56
68
 
57
- When you have your data ready, just add following tag to the page where you want to see the map:
69
+ By default this plugin will display location from the page it's placed on:
58
70
 
59
71
  ```
60
72
  {% google_map %}
61
73
  ```
62
74
 
75
+ But you can use src attribute to load locations from other places, like posts, collections or data files!
76
+
77
+ For example, this map will show locations from all posts from 2016:
78
+
79
+ ```
80
+ {% google_map src="_posts/2016" %}
81
+ ```
82
+
83
+ This map will show locations from a collection called 'my_collection':
84
+
85
+ ```
86
+ {% google_map src="_collections/my_collection" %}
87
+ ```
88
+
89
+ This map will show locations from all data files located in 'my_points' sub-folder:
90
+
91
+ ```
92
+ {% google_map src="_data/my_points" %}
93
+ ```
94
+
63
95
  You can configure map's dimensions and assign custom CSS class to the element:
64
96
 
65
97
  ```
66
- {% google_map width:100% height:400 class:my-map %}
98
+ {% google_map width="100%" height="400" class="my-map" %}
67
99
  ```
68
100
 
69
101
  ### Filters
@@ -72,7 +104,7 @@ You can also filter which locations to display on the map!<br/>
72
104
  For instance, following tag will only display locations from documents which have `lang: en` in their front-matter data.
73
105
 
74
106
  ```
75
- {% google_map lang:en %}
107
+ {% google_map src="_posts" lang="en" %}
76
108
  ```
77
109
 
78
110
  ### Marker Cluster
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task default: :spec
6
+ task :default => :spec
data/jekyll-maps.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require "jekyll-maps/version"
@@ -66,6 +66,9 @@ var jekyllMaps = (function () {
66
66
 
67
67
  function createMarker (location) {
68
68
  var position = new google.maps.LatLng(location.latitude, location.longitude)
69
+ bounds.extend(position)
70
+ if (!mapOptions.showMarker) return false
71
+
69
72
  var marker = new google.maps.Marker({
70
73
  position: position,
71
74
  title: location.title,
@@ -73,21 +76,21 @@ var jekyllMaps = (function () {
73
76
  url: location.url,
74
77
  map: map
75
78
  })
76
-
77
- bounds.extend(position)
78
79
  if (mapOptions.showMarkerPopup) marker.addListener('click', markerPopup)
79
80
 
80
81
  return marker
81
82
  }
82
83
 
83
84
  function markerPopup () {
84
- var contentString = '<div class="map-info-window"><h5>' + this.title + '</h5>'
85
- var link = 'View'
86
- if (this.image.length > 0) {
87
- link = '<img src="' + this.image + '" alt="' + this.title + '"/>'
85
+ var contentHtml = '<div class="map-info-window"><h5>' + this.title + '</h5>'
86
+ var imageHtml = '<img src="' + this.image + '" alt="' + this.title + '"/>'
87
+ if (this.url.length > 0) {
88
+ var linkText = this.image.length > 0 ? imageHtml : 'View'
89
+ contentHtml += '<a href="' + this.url + '">' + linkText + '</a></div>'
90
+ } else if (this.image.length > 0) {
91
+ contentHtml += imageHtml
88
92
  }
89
- contentString += '<a href="' + this.url + '">' + link + '</a></div>'
90
- infoWindow.setContent(contentString)
93
+ infoWindow.setContent(contentHtml)
91
94
  infoWindow.open(map, this)
92
95
  }
93
96
  }
@@ -56,6 +56,7 @@ HTML
56
56
  def map_options
57
57
  opts = {
58
58
  :useCluster => !@args[:flags][:no_cluster],
59
+ :showMarker => @args[:attributes][:show_marker] != "false",
59
60
  :showMarkerPopup => @args[:attributes][:show_popup] != "false"
60
61
  }
61
62
  if @args[:attributes][:zoom]
@@ -72,11 +72,18 @@ module Jekyll
72
72
  :latitude => document["location"]["latitude"],
73
73
  :longitude => document["location"]["longitude"],
74
74
  :title => document["title"],
75
- :url => document["url"] || document.url,
75
+ :url => fetch_url(document),
76
76
  :image => document["image"] || ""
77
77
  }
78
78
  end
79
79
  end
80
+
81
+ private
82
+ def fetch_url(document)
83
+ return document["url"] if document.is_a?(Hash) && document.key?("url")
84
+ return document.url if document.respond_to? :url
85
+ return ""
86
+ end
80
87
  end
81
88
  end
82
89
  end
@@ -10,6 +10,7 @@ module Jekyll
10
10
  width
11
11
  height
12
12
  class
13
+ show_marker
13
14
  show_popup
14
15
  zoom
15
16
  ).freeze
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Maps
3
- VERSION = "2.0.0".freeze
3
+ VERSION = "2.0.1".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.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoliy Yastreb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-06 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll