algoliasearch-jekyll 0.5.3 → 0.6.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/.travis.yml +4 -0
- data/Appraisals +8 -0
- data/CONTRIBUTING.md +15 -7
- data/Gemfile +1 -1
- data/Guardfile +14 -4
- data/README.md +1 -1
- data/algoliasearch-jekyll.gemspec +46 -33
- data/gemfiles/jekyll_v2.gemfile +21 -0
- data/gemfiles/jekyll_v3.gemfile +22 -0
- data/lib/record_extractor.rb +30 -12
- data/lib/version.rb +1 -1
- data/scripts/git_hooks/pre-push +1 -1
- data/scripts/test +4 -0
- data/scripts/test_ci +7 -0
- data/scripts/test_v2 +5 -0
- data/scripts/test_v3 +6 -0
- data/scripts/watch +4 -0
- data/scripts/watch_v2 +4 -0
- data/scripts/watch_v3 +4 -0
- data/spec/credential_checker_spec.rb +1 -1
- data/spec/fixtures/{_config.yml → jekyll_version_2/_config.yml} +4 -0
- data/spec/fixtures/{_layouts → jekyll_version_2/_layouts}/default.html +0 -0
- data/spec/fixtures/{_my-collection → jekyll_version_2/_my-collection}/collection-item.html +0 -0
- data/spec/fixtures/{_my-collection → jekyll_version_2/_my-collection}/collection-item.md +0 -0
- data/spec/fixtures/{_posts → jekyll_version_2/_posts}/2015-07-02-test-post.md +0 -0
- data/spec/fixtures/{_posts → jekyll_version_2/_posts}/2015-07-03-test-post-again.md +0 -0
- data/spec/fixtures/{about.md → jekyll_version_2/about.md} +0 -0
- data/spec/fixtures/{api_key_dir → jekyll_version_2/api_key_dir}/_algolia_api_key +0 -0
- data/spec/fixtures/{_site → jekyll_version_2}/assets/ring.png +0 -0
- data/spec/fixtures/{authors.html → jekyll_version_2/authors.html} +0 -0
- data/spec/fixtures/{excluded.html → jekyll_version_2/excluded.html} +0 -0
- data/spec/fixtures/{hierarchy.md → jekyll_version_2/hierarchy.md} +0 -0
- data/spec/fixtures/{index.html → jekyll_version_2/index.html} +0 -0
- data/spec/fixtures/{page2 → jekyll_version_2/page2}/index.html +0 -0
- data/spec/fixtures/{weight.md → jekyll_version_2/weight.md} +0 -0
- data/spec/fixtures/jekyll_version_3/_config.yml +17 -0
- data/spec/fixtures/jekyll_version_3/_layouts/default.html +6 -0
- data/spec/fixtures/{_site/my-collection → jekyll_version_3/_my-collection}/collection-item.html +5 -1
- data/spec/fixtures/jekyll_version_3/_my-collection/collection-item.md +7 -0
- data/spec/fixtures/jekyll_version_3/_posts/2015-07-02-test-post.md +32 -0
- data/spec/fixtures/jekyll_version_3/_posts/2015-07-03-test-post-again.md +7 -0
- data/spec/fixtures/jekyll_version_3/about.md +34 -0
- data/spec/fixtures/jekyll_version_3/api_key_dir/_algolia_api_key +1 -0
- data/spec/fixtures/{assets → jekyll_version_3/assets}/ring.png +0 -0
- data/spec/fixtures/{_site → jekyll_version_3}/authors.html +4 -0
- data/spec/fixtures/{_site → jekyll_version_3}/excluded.html +4 -0
- data/spec/fixtures/jekyll_version_3/hierarchy.md +35 -0
- data/spec/fixtures/jekyll_version_3/index.html +13 -0
- data/spec/fixtures/jekyll_version_3/page2/index.html +6 -0
- data/spec/fixtures/jekyll_version_3/weight.md +19 -0
- data/spec/record_extractor_spec.rb +131 -5
- data/spec/spec_helper.rb +47 -26
- metadata +56 -43
- data/spec/fixtures/_site/2015/07/02/test-post.html +0 -26
- data/spec/fixtures/_site/2015/07/03/test-post-again.html +0 -3
- data/spec/fixtures/_site/about.html +0 -31
- data/spec/fixtures/_site/hierarchy.html +0 -31
- data/spec/fixtures/_site/index.html +0 -17
- data/spec/fixtures/_site/page2/index.html +0 -40
- data/spec/fixtures/_site/weight.html +0 -15
- data/spec/spec_helper_jekyll.rb +0 -4
data/scripts/watch_v2
ADDED
data/scripts/watch_v3
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
collections:
|
2
|
+
my-collection:
|
3
|
+
output: true
|
4
|
+
markdown_ext: 'md,mkd'
|
5
|
+
paginate: 1
|
6
|
+
timezone: Europe/Paris
|
7
|
+
|
8
|
+
algolia:
|
9
|
+
application_id: APPID
|
10
|
+
index_name: INDEXNAME
|
11
|
+
excluded_files:
|
12
|
+
- excluded.html
|
13
|
+
|
14
|
+
# Jekyll 3.0 extracted the secondary features into their own plugins
|
15
|
+
gems:
|
16
|
+
- jekyll-paginate
|
17
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
title: "Test post"
|
3
|
+
tags:
|
4
|
+
- tag
|
5
|
+
- another tag
|
6
|
+
custom: Foo
|
7
|
+
---
|
8
|
+
|
9
|
+
Introduction text that also includes [some link](https://www.algolia.com). To
|
10
|
+
add a bit of fancy, we will also __bold__ and _italicize_ some text.
|
11
|
+
|
12
|
+
# Main title
|
13
|
+
|
14
|
+
We like writing stuff and then indexing it in a very fast engine. Here is why
|
15
|
+
a fast engine is good for you:
|
16
|
+
|
17
|
+
* fast
|
18
|
+
* fast
|
19
|
+
* fast
|
20
|
+
* and fast
|
21
|
+
|
22
|
+
## Built with hands
|
23
|
+
|
24
|
+
All this text was typed with my own hands, on my own keyboard. I also did use
|
25
|
+
a Chair© and a Table™.
|
26
|
+
|
27
|
+
## Features
|
28
|
+
|
29
|
+
The whole plugin is composed of parts of `code`, and sometime even
|
30
|
+
<code><code></code>.
|
31
|
+
|
32
|
+
Code is __✔ checked__ and errors are __✘ deleted__.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
title: About page
|
3
|
+
custom: Foo
|
4
|
+
---
|
5
|
+
|
6
|
+
# Heading 1
|
7
|
+
|
8
|
+
Text 1
|
9
|
+
|
10
|
+
## Heading 2
|
11
|
+
|
12
|
+
Text 2
|
13
|
+
|
14
|
+
### Heading 3
|
15
|
+
|
16
|
+
Text 3
|
17
|
+
|
18
|
+
- item 1
|
19
|
+
- item 2
|
20
|
+
- item 3
|
21
|
+
|
22
|
+
### Another Heading 3
|
23
|
+
|
24
|
+
<p id="text4">Another text 4</p>
|
25
|
+
|
26
|
+
<h2 id="heading2b">Another Heading 2</h2>
|
27
|
+
|
28
|
+
Another `<text>` 5
|
29
|
+
|
30
|
+
### Last Heading 3
|
31
|
+
|
32
|
+
<div>Just a div</div>
|
33
|
+
|
34
|
+
<div><p>Last text 6 </p></div>
|
@@ -0,0 +1 @@
|
|
1
|
+
APIKEY_FROM_FILE
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
title: Hierarchy test
|
3
|
+
---
|
4
|
+
|
5
|
+
# H1
|
6
|
+
|
7
|
+
TEXT1-H1
|
8
|
+
|
9
|
+
## H2A
|
10
|
+
|
11
|
+
TEXT2-H2A-H1
|
12
|
+
|
13
|
+
TEXT3-H2A-H1
|
14
|
+
|
15
|
+
## H2B
|
16
|
+
|
17
|
+
TEXT4-H2B-H1
|
18
|
+
|
19
|
+
### H3A
|
20
|
+
|
21
|
+
TEXT5-H3-H2B-H1
|
22
|
+
|
23
|
+
<div>
|
24
|
+
<h4>H4</h4>
|
25
|
+
<p>TEXT7-H4-H3-H2B-H1</p>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
## H2C
|
29
|
+
|
30
|
+
TEXT8-H2C-H1
|
31
|
+
|
32
|
+
### H3B `<code>`
|
33
|
+
|
34
|
+
TEXT9-H3B-H2C-H1
|
35
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Home
|
4
|
+
---
|
5
|
+
|
6
|
+
This default index page is used to display the paginated posts
|
7
|
+
|
8
|
+
{% for post in paginator.posts %}
|
9
|
+
<a href="{{ site.baseurl }}{{ post.url }}">
|
10
|
+
{{ post.title }}
|
11
|
+
</a>
|
12
|
+
{{ post.content }}
|
13
|
+
{% endfor %}
|
@@ -10,6 +10,12 @@ describe(AlgoliaSearchRecordExtractor) do
|
|
10
10
|
let(:weight_page_file) { extractor.new(site.file_by_name('weight.md')) }
|
11
11
|
let(:document_file) { extractor.new(site.file_by_name('collection-item.md')) }
|
12
12
|
|
13
|
+
before(:each) do
|
14
|
+
# Disabling the logs, while still allowing to spy them
|
15
|
+
Jekyll.logger = double('Specific Mock Logger').as_null_object
|
16
|
+
@logger = Jekyll.logger.writer
|
17
|
+
end
|
18
|
+
|
13
19
|
describe 'metadata' do
|
14
20
|
it 'gets metadata from page' do
|
15
21
|
# Given
|
@@ -28,7 +34,6 @@ describe(AlgoliaSearchRecordExtractor) do
|
|
28
34
|
actual = post_file.metadata
|
29
35
|
|
30
36
|
# Then
|
31
|
-
expect(actual[:type]).to eq 'post'
|
32
37
|
expect(actual[:slug]).to eq 'test-post'
|
33
38
|
expect(actual[:title]).to eq 'Test post'
|
34
39
|
expect(actual[:url]).to eq '/2015/07/02/test-post.html'
|
@@ -57,12 +62,135 @@ describe(AlgoliaSearchRecordExtractor) do
|
|
57
62
|
expect(actual[:url]).to eq '/my-collection/collection-item.html'
|
58
63
|
expect(actual[:custom]).to eq 'Foo'
|
59
64
|
end
|
65
|
+
|
66
|
+
if restrict_jekyll_version(more_than: '3.0')
|
67
|
+
describe 'Jekyll > 3.0' do
|
68
|
+
it 'should not throw any deprecation warnings' do
|
69
|
+
# Given
|
70
|
+
|
71
|
+
# When
|
72
|
+
post_file.metadata
|
73
|
+
|
74
|
+
# Expect
|
75
|
+
expect(@logger).to_not have_received(:warn)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'slug' do
|
83
|
+
it 'gets it from data if available' do
|
84
|
+
# Given
|
85
|
+
post_file.file.data['slug'] = 'foo'
|
86
|
+
allow(post_file.file).to receive(:respond_to?).with(:slug) do
|
87
|
+
false
|
88
|
+
end
|
89
|
+
|
90
|
+
# When
|
91
|
+
actual = post_file.slug
|
92
|
+
|
93
|
+
# Then
|
94
|
+
expect(actual).to eql('foo')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'gets it from the root if not in data' do
|
98
|
+
# Given
|
99
|
+
post_file.file.data.delete 'slug'
|
100
|
+
allow(post_file.file).to receive(:slug).and_return('foo')
|
101
|
+
|
102
|
+
# When
|
103
|
+
actual = post_file.slug
|
104
|
+
|
105
|
+
# Then
|
106
|
+
expect(actual).to eql('foo')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'gets it from the data even if in the root' do
|
110
|
+
# Given
|
111
|
+
post_file.file.data['slug'] = 'foo'
|
112
|
+
allow(post_file.file).to receive(:slug).and_return('bar')
|
113
|
+
|
114
|
+
# When
|
115
|
+
actual = post_file.slug
|
116
|
+
|
117
|
+
# Then
|
118
|
+
expect(actual).to eql('foo')
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'guesses it from the path if not found' do
|
122
|
+
# Given
|
123
|
+
post_file.file.data.delete 'slug'
|
124
|
+
allow(post_file.file).to receive(:respond_to?).with(:slug) do
|
125
|
+
false
|
126
|
+
end
|
127
|
+
allow(post_file.file).to receive(:path) do
|
128
|
+
'/path/to/file/foo.html'
|
129
|
+
end
|
130
|
+
|
131
|
+
# When
|
132
|
+
actual = post_file.slug
|
133
|
+
|
134
|
+
# # Then
|
135
|
+
expect(actual).to eql('foo')
|
136
|
+
end
|
60
137
|
end
|
61
138
|
|
62
139
|
describe 'tags' do
|
63
|
-
it 'returns
|
64
|
-
|
140
|
+
it 'returns tags in data if available' do
|
141
|
+
# Given
|
142
|
+
post_file.file.data['tags'] = %w(foo bar)
|
143
|
+
allow(post_file.file).to receive(:respond_to?).with(:tags) do
|
144
|
+
false
|
145
|
+
end
|
146
|
+
|
147
|
+
# When
|
148
|
+
actual = post_file.tags
|
149
|
+
|
150
|
+
# Then
|
151
|
+
expect(actual).to include('foo', 'bar')
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'returns tags at the root if not in data' do
|
155
|
+
# Given
|
156
|
+
post_file.file.data.delete 'tags'
|
157
|
+
allow(post_file.file).to receive(:tags).and_return(%w(foo bar))
|
158
|
+
|
159
|
+
# When
|
160
|
+
actual = post_file.tags
|
161
|
+
|
162
|
+
# Then
|
163
|
+
expect(actual).to include('foo', 'bar')
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'returns tags in data even if in root' do
|
167
|
+
# Given
|
168
|
+
post_file.file.data['tags'] = %w(foo bar)
|
169
|
+
allow(post_file.file).to receive(:tags).and_return(%w(js css))
|
170
|
+
|
171
|
+
# When
|
172
|
+
actual = post_file.tags
|
173
|
+
|
174
|
+
# Then
|
175
|
+
expect(actual).to include('foo', 'bar')
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'parses tags as string if they are another type' do
|
179
|
+
# Given
|
180
|
+
tag_foo = double('Extended Tag', to_s: 'foo')
|
181
|
+
tag_bar = double('Extended Tag', to_s: 'bar')
|
182
|
+
post_file.file.data['tags'] = [tag_foo, tag_bar]
|
183
|
+
allow(post_file.file).to receive(:respond_to?).with(:tags) do
|
184
|
+
false
|
185
|
+
end
|
186
|
+
|
187
|
+
# When
|
188
|
+
actual = post_file.tags
|
189
|
+
|
190
|
+
# Then
|
191
|
+
expect(actual).to include('foo', 'bar')
|
65
192
|
end
|
193
|
+
|
66
194
|
it 'extract tags from front matter' do
|
67
195
|
# Given
|
68
196
|
actual = post_file.tags
|
@@ -390,8 +518,6 @@ describe(AlgoliaSearchRecordExtractor) do
|
|
390
518
|
|
391
519
|
# Then
|
392
520
|
expect(actual).to eq 1
|
393
|
-
|
394
|
-
# I don't seem fit for that
|
395
521
|
end
|
396
522
|
|
397
523
|
it 'should still work with non-string keys' do
|