jekyll-algolia 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/{errors → lib/errors}/invalid_credentials.txt +0 -0
- data/{errors → lib/errors}/invalid_credentials_for_tmp_index.txt +0 -0
- data/{errors → lib/errors}/invalid_index_name.txt +0 -0
- data/{errors → lib/errors}/missing_api_key.txt +0 -0
- data/{errors → lib/errors}/missing_application_id.txt +0 -0
- data/{errors → lib/errors}/missing_index_name.txt +0 -0
- data/{errors → lib/errors}/no_records_found.txt +0 -0
- data/{errors → lib/errors}/record_too_big.txt +0 -0
- data/{errors → lib/errors}/unknown_application_id.txt +0 -0
- data/{errors → lib/errors}/unknown_settings.txt +0 -0
- data/lib/jekyll-algolia.rb +19 -6
- data/lib/jekyll/algolia/file_browser.rb +27 -4
- data/lib/jekyll/algolia/indexer.rb +4 -1
- data/lib/jekyll/algolia/logger.rb +1 -1
- data/lib/jekyll/algolia/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2de0f9bc4ac08d49c4f78093c469d778b1d69001
|
4
|
+
data.tar.gz: dcce0aafc47b6661063e645f03bed64b3cc849d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c898016647a648a10d3aeaa270aeca5257399a47a124e55902581ae935cedab196295204f6e4177d58b4a56b544fd54f9825b8dc7198995fa2dfa367de1c875
|
7
|
+
data.tar.gz: 486d9709cd1de0ed485d921e2c22640776c36fc7d45edabceff1f45e9f50f65879b7e0971daa9d038ffbe5d8e5143bb256cd00429203f0590c17a243eba25bca
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ This will push the content of your Jekyll website to your Algolia index.
|
|
19
19
|
## Documentation
|
20
20
|
|
21
21
|
Full documentation can be found on
|
22
|
-
[https://community.algolia.com/jekyll-algolia/](https://community.algolia.com/jekyll-algolia/)
|
22
|
+
[https://community.algolia.com/jekyll-algolia/](https://community.algolia.com/jekyll-algolia/getting-started.html)
|
23
23
|
|
24
24
|
## Installation
|
25
25
|
|
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
|
data/lib/jekyll-algolia.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'jekyll/commands/algolia'
|
4
|
+
require 'date'
|
4
5
|
|
5
6
|
module Jekyll
|
6
7
|
# Requirable file, loading all dependencies.
|
@@ -27,10 +28,17 @@ module Jekyll
|
|
27
28
|
# monkey-patching its `write` method and building it.
|
28
29
|
def self.init(config = {})
|
29
30
|
@config = config
|
31
|
+
@start_time = Time.now
|
30
32
|
@site = Jekyll::Algolia::Site.new(@config)
|
31
33
|
|
32
34
|
exit 1 unless Configurator.assert_valid_credentials
|
33
35
|
|
36
|
+
if Configurator.dry_run?
|
37
|
+
Logger.log('W:==== THIS IS A DRY RUN ====')
|
38
|
+
Logger.log('W: - No records will be pushed to your index')
|
39
|
+
Logger.log('W: - No settings will be updated on your index')
|
40
|
+
end
|
41
|
+
|
34
42
|
self
|
35
43
|
end
|
36
44
|
|
@@ -43,6 +51,7 @@ module Jekyll
|
|
43
51
|
# Note: The internal list of files to be processed will only be created when
|
44
52
|
# calling .process
|
45
53
|
def self.run
|
54
|
+
Logger.log('I:Processing site...')
|
46
55
|
@site.process
|
47
56
|
end
|
48
57
|
|
@@ -61,19 +70,23 @@ module Jekyll
|
|
61
70
|
@site
|
62
71
|
end
|
63
72
|
|
73
|
+
# Public: Get access to the time at which the command was run
|
74
|
+
#
|
75
|
+
# Jekyll will override some date with the current time, and we'll need to
|
76
|
+
# keep them as nil, so we have to compare to this date to assume it has been
|
77
|
+
# overwritten
|
78
|
+
def self.start_time
|
79
|
+
@start_time
|
80
|
+
end
|
81
|
+
|
64
82
|
# A Jekyll::Site subclass that overrides #write from the parent class to
|
65
83
|
# create JSON records out of rendered documents and push those records
|
66
84
|
# to Algolia instead of writing files to disk.
|
67
85
|
class Site < Jekyll::Site
|
68
86
|
def write
|
69
|
-
if Configurator.dry_run?
|
70
|
-
Logger.log('W:==== THIS IS A DRY RUN ====')
|
71
|
-
Logger.log('W: - No records will be pushed to your index')
|
72
|
-
Logger.log('W: - No settings will be updated on your index')
|
73
|
-
end
|
74
|
-
|
75
87
|
records = []
|
76
88
|
files = []
|
89
|
+
Logger.log('I:Extracting records...')
|
77
90
|
each_site_file do |file|
|
78
91
|
# Skip files that should not be indexed
|
79
92
|
is_indexable = FileBrowser.indexable?(file)
|
@@ -43,7 +43,18 @@ module Jekyll
|
|
43
43
|
# `jekyll-paginate` automatically creates pages to paginate through posts.
|
44
44
|
# We don't want to index those
|
45
45
|
def self.pagination_page?(file)
|
46
|
-
|
46
|
+
# paginate_path contains a special `:num` part that is the page number
|
47
|
+
# We convert that to a regexp
|
48
|
+
paginate_path = Configurator.get('paginate_path')
|
49
|
+
paginate_path_as_regexp = paginate_path.gsub(':num', '([0-9]*)')
|
50
|
+
|
51
|
+
regexp = %r{#{paginate_path_as_regexp}/index\.html$}
|
52
|
+
|
53
|
+
# Make sure all file paths start with a / for comparison
|
54
|
+
filepath = file.path
|
55
|
+
filepath = "/#{filepath}" unless filepath[0] == '/'
|
56
|
+
|
57
|
+
Utils.match?(filepath, regexp)
|
47
58
|
end
|
48
59
|
|
49
60
|
# Public: Check if the file has one of the allowed extensions
|
@@ -200,13 +211,25 @@ module Jekyll
|
|
200
211
|
#
|
201
212
|
# file - The Jekyll file
|
202
213
|
#
|
203
|
-
# All collections have a date
|
204
|
-
#
|
205
|
-
# date
|
214
|
+
# All collections (including posts) will have a date taken either from the
|
215
|
+
# front-matter or the filename prefix. If none is set, Jekyll will use the
|
216
|
+
# current date.
|
217
|
+
#
|
218
|
+
# For pages, only dates defined in the front-matter will be used.
|
219
|
+
#
|
220
|
+
# Note that because the default date is the current one if none is
|
221
|
+
# defined, we have to make sure the date is actually nil when we index it.
|
222
|
+
# Otherwise the diff indexing mode will think that records have changed
|
223
|
+
# while they haven't.
|
206
224
|
def self.date(file)
|
207
225
|
date = file.data['date']
|
208
226
|
return nil if date.nil?
|
209
227
|
|
228
|
+
# The date is *exactly* the time where the `jekyll algolia` was run.
|
229
|
+
# What a coincidence! It's a safe bet to assume that the original date
|
230
|
+
# was nil and has been overwritten by Jekyll
|
231
|
+
return nil if date.to_i == Jekyll::Algolia.start_time.to_i
|
232
|
+
|
210
233
|
date.to_i
|
211
234
|
end
|
212
235
|
|
@@ -94,6 +94,9 @@ module Jekyll
|
|
94
94
|
# processed, but makes debugging easier when comparing arrays is needed.
|
95
95
|
def self.remote_object_ids(index)
|
96
96
|
list = []
|
97
|
+
Logger.verbose(
|
98
|
+
"I:Inspecting existing records in index #{index.name}..."
|
99
|
+
)
|
97
100
|
begin
|
98
101
|
index.browse(attributesToRetrieve: 'objectID') do |hit|
|
99
102
|
list << hit['objectID']
|
@@ -154,7 +157,7 @@ module Jekyll
|
|
154
157
|
return
|
155
158
|
end
|
156
159
|
|
157
|
-
Logger.log(
|
160
|
+
Logger.log("I:Updating records in index #{index.name}...")
|
158
161
|
|
159
162
|
# Delete remote records that are no longer available locally
|
160
163
|
delete_records_by_id(index, old_records_ids)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Carry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algolia_html_extractor
|
@@ -256,16 +256,16 @@ extra_rdoc_files: []
|
|
256
256
|
files:
|
257
257
|
- CONTRIBUTING.md
|
258
258
|
- README.md
|
259
|
-
- errors/invalid_credentials.txt
|
260
|
-
- errors/invalid_credentials_for_tmp_index.txt
|
261
|
-
- errors/invalid_index_name.txt
|
262
|
-
- errors/missing_api_key.txt
|
263
|
-
- errors/missing_application_id.txt
|
264
|
-
- errors/missing_index_name.txt
|
265
|
-
- errors/no_records_found.txt
|
266
|
-
- errors/record_too_big.txt
|
267
|
-
- errors/unknown_application_id.txt
|
268
|
-
- errors/unknown_settings.txt
|
259
|
+
- lib/errors/invalid_credentials.txt
|
260
|
+
- lib/errors/invalid_credentials_for_tmp_index.txt
|
261
|
+
- lib/errors/invalid_index_name.txt
|
262
|
+
- lib/errors/missing_api_key.txt
|
263
|
+
- lib/errors/missing_application_id.txt
|
264
|
+
- lib/errors/missing_index_name.txt
|
265
|
+
- lib/errors/no_records_found.txt
|
266
|
+
- lib/errors/record_too_big.txt
|
267
|
+
- lib/errors/unknown_application_id.txt
|
268
|
+
- lib/errors/unknown_settings.txt
|
269
269
|
- lib/jekyll-algolia.rb
|
270
270
|
- lib/jekyll/algolia/configurator.rb
|
271
271
|
- lib/jekyll/algolia/error_handler.rb
|