algoliasearch-jekyll 0.6.1 → 0.7.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 +4 -4
- data/CONTRIBUTING.md +6 -4
- data/Gemfile +0 -1
- data/{Guardfile → Guardfile_jekyllv2} +1 -1
- data/Guardfile_jekyllv3 +7 -0
- data/README.md +5 -0
- data/algoliasearch-jekyll.gemspec +6 -7
- data/gemfiles/jekyll_v2.gemfile +1 -1
- data/gemfiles/jekyll_v3.gemfile +1 -1
- data/lib/error_handler.rb +1 -1
- data/lib/record_extractor.rb +4 -4
- data/lib/version.rb +1 -1
- data/scripts/git_hooks/pre-commit +1 -1
- data/scripts/lint +2 -0
- data/scripts/release +6 -0
- data/scripts/watch +1 -1
- data/scripts/watch_v2 +1 -1
- data/scripts/watch_v3 +1 -1
- data/spec/push_spec.rb +1 -1
- data/spec/record_extractor_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +5 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c1ea0f7d0eecf20f9cb33f30116df426637a9f4
|
4
|
+
data.tar.gz: 8ec5644ebbd8c08fcead43c3c6cf64c0bbe82db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd5939456e660845ec71719c47ea296088284907b8d58b3d7ac08e5b070ac6dc688edcd18030e0bb87efe2b62a655c71ffb393f81e674936235cf16a9a46ccb
|
7
|
+
data.tar.gz: d19157c6ba465da2dea75f62e4744d3b55fb170043c7aedd0098f7b37bba2d53bb00b4fc2ade9458a1c716340e103768a16381a44052245400089787a3781853
|
data/CONTRIBUTING.md
CHANGED
@@ -25,8 +25,11 @@ You can then launch:
|
|
25
25
|
- `./scripts/test_v3` to launch tests on Jekyll v3
|
26
26
|
- `./scripts/test` to launch tests on both
|
27
27
|
- `./scripts/watch` to start a test watcher (for TDD) for Jekyll v2
|
28
|
-
- `./scripts/watch_v3` to start a test watcher (for TDD) for Jekyll v3
|
29
|
-
|
28
|
+
- `./scripts/watch_v3` to start a test watcher (for TDD) for Jekyll v3
|
29
|
+
|
30
|
+
The watched test will both launch Guard (with `guard-rspec`), but each will use
|
31
|
+
its own `Guardfile` version, launching the correct `appraisal` before the
|
32
|
+
`rspec` command.
|
30
33
|
|
31
34
|
If you want to test the plugin on an existing Jekyll website while developping,
|
32
35
|
I suggest updating the website `Gemfile` to point to the correct local directory
|
@@ -35,8 +38,7 @@ I suggest updating the website `Gemfile` to point to the correct local directory
|
|
35
38
|
gem "algoliasearch-jekyll", :path => "/path/to/local/gem/folder"
|
36
39
|
```
|
37
40
|
You should also run `rake gemspec` from the `algoliasearch-jekyll` repository if
|
38
|
-
you added
|
39
|
-
|
41
|
+
you added/deleted any file or dependency.
|
40
42
|
|
41
43
|
If you plan on submitting a PR, I suggest you install the git hooks. This will
|
42
44
|
run pre-commit and pre-push checks. Those checks will also be run by TravisCI,
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
guard :rspec, cmd: 'bundle exec rspec --color --format documentation' do
|
1
|
+
guard :rspec, cmd: 'appraisal jekyll-v2 bundle exec rspec --color --format documentation' do
|
2
2
|
watch(%r{^spec/.+_spec\.rb$})
|
3
3
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
4
4
|
watch('spec/spec_helper.rb') { 'spec' }
|
data/Guardfile_jekyllv3
ADDED
data/README.md
CHANGED
@@ -64,6 +64,11 @@ You write api key will be read from the `ALGOLIA_API_KEY` environment variable.
|
|
64
64
|
You can define it on the same line as your command, allowing you to type
|
65
65
|
`ALGOLIA_API_KEY='your_write_api_key' jekyll algolia push`.
|
66
66
|
|
67
|
+
Note that your API key should have write access to both the `index_name` and
|
68
|
+
`_tmp` suffixed version of it (eg. `your_index_name` and `your_index_name_tmp`)
|
69
|
+
in the previous example). This is due to the way we do atomic pushes by pushing
|
70
|
+
to a temporary index and then renaming it.
|
71
|
+
|
67
72
|
### ⚠ Other, unsecure, method ⚠
|
68
73
|
|
69
74
|
You can also store your write api key in a file named `_algolia_api_key`, in
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: algoliasearch-jekyll 0.
|
5
|
+
# stub: algoliasearch-jekyll 0.7.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "algoliasearch-jekyll"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.7.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Tim Carry"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-03-08"
|
15
15
|
s.description = "Index all your pages and posts to an Algolia index with `jekyll algolia push`"
|
16
16
|
s.email = "tim@pixelastic.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -26,7 +26,8 @@ Gem::Specification.new do |s|
|
|
26
26
|
"Appraisals",
|
27
27
|
"CONTRIBUTING.md",
|
28
28
|
"Gemfile",
|
29
|
-
"
|
29
|
+
"Guardfile_jekyllv2",
|
30
|
+
"Guardfile_jekyllv3",
|
30
31
|
"LICENSE.txt",
|
31
32
|
"README.md",
|
32
33
|
"Rakefile",
|
@@ -46,6 +47,7 @@ Gem::Specification.new do |s|
|
|
46
47
|
"scripts/coverage",
|
47
48
|
"scripts/git_hooks/pre-commit",
|
48
49
|
"scripts/git_hooks/pre-push",
|
50
|
+
"scripts/lint",
|
49
51
|
"scripts/release",
|
50
52
|
"scripts/test",
|
51
53
|
"scripts/test_ci",
|
@@ -108,7 +110,6 @@ Gem::Specification.new do |s|
|
|
108
110
|
s.add_runtime_dependency(%q<algoliasearch>, ["~> 1.4"])
|
109
111
|
s.add_runtime_dependency(%q<appraisal>, ["~> 2.1.0"])
|
110
112
|
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.6"])
|
111
|
-
s.add_runtime_dependency(%q<jekyll>, ["~> 2.5"])
|
112
113
|
s.add_runtime_dependency(%q<json>, ["~> 1.8"])
|
113
114
|
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.6"])
|
114
115
|
s.add_runtime_dependency(%q<verbal_expressions>, ["~> 0.1.5"])
|
@@ -124,7 +125,6 @@ Gem::Specification.new do |s|
|
|
124
125
|
s.add_dependency(%q<algoliasearch>, ["~> 1.4"])
|
125
126
|
s.add_dependency(%q<appraisal>, ["~> 2.1.0"])
|
126
127
|
s.add_dependency(%q<awesome_print>, ["~> 1.6"])
|
127
|
-
s.add_dependency(%q<jekyll>, ["~> 2.5"])
|
128
128
|
s.add_dependency(%q<json>, ["~> 1.8"])
|
129
129
|
s.add_dependency(%q<nokogiri>, ["~> 1.6"])
|
130
130
|
s.add_dependency(%q<verbal_expressions>, ["~> 0.1.5"])
|
@@ -141,7 +141,6 @@ Gem::Specification.new do |s|
|
|
141
141
|
s.add_dependency(%q<algoliasearch>, ["~> 1.4"])
|
142
142
|
s.add_dependency(%q<appraisal>, ["~> 2.1.0"])
|
143
143
|
s.add_dependency(%q<awesome_print>, ["~> 1.6"])
|
144
|
-
s.add_dependency(%q<jekyll>, ["~> 2.5"])
|
145
144
|
s.add_dependency(%q<json>, ["~> 1.8"])
|
146
145
|
s.add_dependency(%q<nokogiri>, ["~> 1.6"])
|
147
146
|
s.add_dependency(%q<verbal_expressions>, ["~> 0.1.5"])
|
data/gemfiles/jekyll_v2.gemfile
CHANGED
@@ -5,10 +5,10 @@ source "http://rubygems.org"
|
|
5
5
|
gem "algoliasearch", "~> 1.4"
|
6
6
|
gem "appraisal", "~> 2.1.0"
|
7
7
|
gem "awesome_print", "~> 1.6"
|
8
|
-
gem "jekyll", "~> 2.5"
|
9
8
|
gem "json", "~> 1.8"
|
10
9
|
gem "nokogiri", "~> 1.6"
|
11
10
|
gem "verbal_expressions", "~> 0.1.5"
|
11
|
+
gem "jekyll", "~> 2.5"
|
12
12
|
|
13
13
|
group :development do
|
14
14
|
gem "coveralls", "~> 0.8"
|
data/gemfiles/jekyll_v3.gemfile
CHANGED
@@ -5,10 +5,10 @@ source "http://rubygems.org"
|
|
5
5
|
gem "algoliasearch", "~> 1.4"
|
6
6
|
gem "appraisal", "~> 2.1.0"
|
7
7
|
gem "awesome_print", "~> 1.6"
|
8
|
-
gem "jekyll", "~> 3.0"
|
9
8
|
gem "json", "~> 1.8"
|
10
9
|
gem "nokogiri", "~> 1.6"
|
11
10
|
gem "verbal_expressions", "~> 0.1.5"
|
11
|
+
gem "jekyll", "~> 3.0"
|
12
12
|
gem "jekyll-paginate", "~> 1.1.0"
|
13
13
|
|
14
14
|
group :development do
|
data/lib/error_handler.rb
CHANGED
data/lib/record_extractor.rb
CHANGED
@@ -107,7 +107,7 @@ class AlgoliaSearchRecordExtractor
|
|
107
107
|
# If the node itself is a heading, we include it
|
108
108
|
def node_hierarchy(node, state = { level: 7 })
|
109
109
|
tag_name = node.name
|
110
|
-
level = tag_name.
|
110
|
+
level = tag_name.delete('h').to_i
|
111
111
|
|
112
112
|
if node_heading?(node) && level < state[:level]
|
113
113
|
state[tag_name.to_sym] = node_text(node)
|
@@ -173,9 +173,9 @@ class AlgoliaSearchRecordExtractor
|
|
173
173
|
def weight_tag_name(item)
|
174
174
|
tag_name = item[:tag_name]
|
175
175
|
# No a heading, no weight
|
176
|
-
return 0 unless
|
176
|
+
return 0 unless %w(h1 h2 h3 h4 h5 h6).include?(tag_name)
|
177
177
|
# h1: 100, h2: 90, ..., h6: 50
|
178
|
-
100 - (tag_name.
|
178
|
+
100 - (tag_name.delete('h').to_i - 1) * 10
|
179
179
|
end
|
180
180
|
|
181
181
|
# Returns an object of all weights
|
@@ -190,7 +190,7 @@ class AlgoliaSearchRecordExtractor
|
|
190
190
|
def extract
|
191
191
|
items = []
|
192
192
|
html_nodes.each_with_index do |node, index|
|
193
|
-
next
|
193
|
+
next if node.text.empty?
|
194
194
|
|
195
195
|
item = metadata.clone
|
196
196
|
item.merge!(node_hierarchy(node))
|
data/lib/version.rb
CHANGED
data/scripts/lint
ADDED
data/scripts/release
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
git checkout master || exit 1
|
4
4
|
git pull || exit 1
|
5
|
+
bundle install && appraisal install
|
6
|
+
|
5
7
|
git rebase develop || exit 1
|
8
|
+
bundle install && appraisal install
|
6
9
|
rake release || exit 1
|
10
|
+
|
7
11
|
git checkout develop || exit 1
|
12
|
+
bundle install && appraisal install
|
8
13
|
git rebase master || exit 1
|
14
|
+
bundle install && appraisal install
|
data/scripts/watch
CHANGED
data/scripts/watch_v2
CHANGED
data/scripts/watch_v3
CHANGED
data/spec/push_spec.rb
CHANGED
@@ -44,7 +44,7 @@ describe(AlgoliaSearchRecordExtractor) do
|
|
44
44
|
it 'gets posted_at timestamp based on the configured timezone' do
|
45
45
|
# Given
|
46
46
|
site = get_site(timezone: 'America/New_York')
|
47
|
-
post_file =
|
47
|
+
post_file = extractor.new(site.file_by_name('test-post.md'))
|
48
48
|
actual = post_file.metadata
|
49
49
|
|
50
50
|
# Then
|
data/spec/spec_helper.rb
CHANGED
@@ -31,7 +31,7 @@ def get_site(config = {}, options = {})
|
|
31
31
|
config = Jekyll.configuration(config)
|
32
32
|
|
33
33
|
site = AlgoliaSearchJekyllPush.init_options({}, options, config)
|
34
|
-
|
34
|
+
.jekyll_new(config)
|
35
35
|
|
36
36
|
def site.file_by_name(file_name)
|
37
37
|
each_site_file do |file|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Carry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algoliasearch
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.6'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: jekyll
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.5'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.5'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: json
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,7 +222,8 @@ files:
|
|
236
222
|
- Appraisals
|
237
223
|
- CONTRIBUTING.md
|
238
224
|
- Gemfile
|
239
|
-
-
|
225
|
+
- Guardfile_jekyllv2
|
226
|
+
- Guardfile_jekyllv3
|
240
227
|
- LICENSE.txt
|
241
228
|
- README.md
|
242
229
|
- Rakefile
|
@@ -256,6 +243,7 @@ files:
|
|
256
243
|
- scripts/coverage
|
257
244
|
- scripts/git_hooks/pre-commit
|
258
245
|
- scripts/git_hooks/pre-push
|
246
|
+
- scripts/lint
|
259
247
|
- scripts/release
|
260
248
|
- scripts/test
|
261
249
|
- scripts/test_ci
|