jekyll-maps 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +2 -0
- data/History.md +8 -0
- data/README.md +7 -1
- data/lib/jekyll-maps.rb +2 -0
- data/lib/jekyll-maps/google_map.html +6 -11
- data/lib/jekyll-maps/google_map_tag.rb +7 -36
- data/lib/jekyll-maps/location_finder.rb +43 -0
- data/lib/jekyll-maps/options_parser.rb +18 -0
- data/lib/jekyll-maps/version.rb +1 -1
- data/script/cibuild +4 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d991367839c14b8f67ff64821219fc0ebcf9290
|
4
|
+
data.tar.gz: ab2ab30d54e9f1ed120f377f0350cc53d5f52d12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ee237acea3325e5c7fa62defb1f41b829586bafa05135c917cd54e8ab085fe98fdf177cd1f1299b8467843777c24662ad841331cabe119e94371310538ec62
|
7
|
+
data.tar.gz: e31ce264d925ae834ae80e0ae9fb2e0b8b1cee5ab15cf94bd1a38c0e4d0b074521aa2f3095c1f1cb619304c470d52b206df9317ae8377ad831fa8a5ecf1a4bfb
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/History.md
ADDED
data/README.md
CHANGED
@@ -1,2 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Jekyll Maps
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-maps.svg)](https://badge.fury.io/rb/jekyll-maps)
|
4
|
+
[![Build Status](https://travis-ci.org/ayastreb/jekyll-maps.svg?branch=master)](https://travis-ci.org/ayastreb/jekyll-maps)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/ayastreb/jekyll-maps/badges/gpa.svg)](https://codeclimate.com/github/ayastreb/jekyll-maps)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/ayastreb/jekyll-maps/badges/coverage.svg)](https://codeclimate.com/github/ayastreb/jekyll-maps/coverage)
|
7
|
+
|
2
8
|
Google Maps support in Jekyll blog to easily embed maps with posts' locations
|
data/lib/jekyll-maps.rb
CHANGED
@@ -27,15 +27,13 @@
|
|
27
27
|
var position = new google.maps.LatLng(location.latitude, location.longitude);
|
28
28
|
var marker = new google.maps.Marker({
|
29
29
|
position: position,
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
title: location.title,
|
31
|
+
url: location.url,
|
32
|
+
map: map
|
33
33
|
});
|
34
34
|
|
35
35
|
marker.addListener('click', function () {
|
36
|
-
|
37
|
-
window.location.href = this.url;
|
38
|
-
}
|
36
|
+
window.location.href = this.url
|
39
37
|
});
|
40
38
|
bounds.extend(position);
|
41
39
|
|
@@ -50,9 +48,6 @@
|
|
50
48
|
},
|
51
49
|
};
|
52
50
|
}());
|
53
|
-
|
54
|
-
window.onload = function () {
|
55
|
-
jekyllMaps.loadScript('https://googlemaps.github.io/js-marker-clusterer/src/markerclusterer.js');
|
56
|
-
jekyllMaps.loadScript('http://maps.googleapis.com/maps/api/js?callback=jekyllMaps.initialize');
|
57
|
-
};
|
58
51
|
</script>
|
52
|
+
<script src='https://googlemaps.github.io/js-marker-clusterer/src/markerclusterer.js'></script>
|
53
|
+
<script src='https://maps.googleapis.com/maps/api/js?callback=jekyllMaps.initialize'></script>
|
@@ -1,50 +1,21 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module Maps
|
3
3
|
class GoogleMapTag < Liquid::Tag
|
4
|
-
attr_accessor :context
|
5
|
-
|
6
4
|
def initialize(_, args, _)
|
7
|
-
|
8
|
-
|
9
|
-
@filter_value = args.split(":").last.strip
|
10
|
-
end
|
11
|
-
|
5
|
+
options = OptionsParser.parse(args)
|
6
|
+
@finder = LocationFinder.new(options)
|
12
7
|
super
|
13
8
|
end
|
14
9
|
|
15
10
|
def render(context)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
private
|
21
|
-
def locations
|
22
|
-
filter_posts.map do |post|
|
23
|
-
{
|
24
|
-
:latitude => post["location"]["latitude"],
|
25
|
-
:longitude => post["location"]["longitude"],
|
26
|
-
:title => post["title"],
|
27
|
-
:url => post.url
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def filter_posts
|
33
|
-
posts = context.registers[:site].posts.docs.reject do |post|
|
34
|
-
post["location"].nil? || post["location"].empty?
|
35
|
-
end
|
36
|
-
if @filter_key
|
37
|
-
posts.reject do |post|
|
38
|
-
post[@filter_key].nil? || post[@filter_key] != @filter_value
|
39
|
-
end
|
40
|
-
else
|
41
|
-
posts
|
42
|
-
end
|
11
|
+
template.render!({
|
12
|
+
"locations" => @finder.find(context.registers[:site]).to_json
|
13
|
+
})
|
43
14
|
end
|
44
15
|
|
45
16
|
private
|
46
17
|
def template
|
47
|
-
@template ||= Liquid::Template.parse
|
18
|
+
@template ||= Liquid::Template.parse(template_contents)
|
48
19
|
end
|
49
20
|
|
50
21
|
private
|
@@ -57,7 +28,7 @@ module Jekyll
|
|
57
28
|
private
|
58
29
|
def template_path
|
59
30
|
@template_path ||= begin
|
60
|
-
File.expand_path
|
31
|
+
File.expand_path("./google_map.html", File.dirname(__FILE__))
|
61
32
|
end
|
62
33
|
end
|
63
34
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Maps
|
3
|
+
class LocationFinder
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def find(site)
|
9
|
+
matching_documents(site).map do |document|
|
10
|
+
{
|
11
|
+
:latitude => document["location"]["latitude"],
|
12
|
+
:longitude => document["location"]["longitude"],
|
13
|
+
:title => document["title"],
|
14
|
+
:url => document.url
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def matching_documents(site)
|
21
|
+
documents = []
|
22
|
+
site.collections.each do |_, collection|
|
23
|
+
collection.docs.each do |doc|
|
24
|
+
documents << doc if location?(doc) && match_filters?(doc)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
documents
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def location?(doc)
|
32
|
+
!doc["location"].nil? && !doc["location"].empty?
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def match_filters?(doc)
|
37
|
+
@options[:filters].each do |key, value|
|
38
|
+
return false if doc[key].nil? || doc[key] != value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Maps
|
3
|
+
class OptionsParser
|
4
|
+
class << self
|
5
|
+
def parse(raw_options)
|
6
|
+
options = { :filters => {} }
|
7
|
+
raw_options.strip.split(" ").each do |pair|
|
8
|
+
key = pair.split(":").first.strip
|
9
|
+
value = pair.split(":").last.strip
|
10
|
+
value = value.split(",") if value.include?(",")
|
11
|
+
options[:filters][key] = value
|
12
|
+
end
|
13
|
+
options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/jekyll-maps/version.rb
CHANGED
data/script/cibuild
ADDED
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: 1.0.
|
4
|
+
version: 1.0.2
|
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-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -75,7 +75,9 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rubocop.yml"
|
78
|
+
- ".travis.yml"
|
78
79
|
- Gemfile
|
80
|
+
- History.md
|
79
81
|
- LICENSE
|
80
82
|
- README.md
|
81
83
|
- Rakefile
|
@@ -83,8 +85,11 @@ files:
|
|
83
85
|
- lib/jekyll-maps.rb
|
84
86
|
- lib/jekyll-maps/google_map.html
|
85
87
|
- lib/jekyll-maps/google_map_tag.rb
|
88
|
+
- lib/jekyll-maps/location_finder.rb
|
89
|
+
- lib/jekyll-maps/options_parser.rb
|
86
90
|
- lib/jekyll-maps/version.rb
|
87
91
|
- script/bootstrap
|
92
|
+
- script/cibuild
|
88
93
|
homepage: https://github.com/ayastreb/jekyll-google-maps
|
89
94
|
licenses:
|
90
95
|
- MIT
|