jekyll-algolia 1.1.5 → 1.2.0
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/lib/errors/invalid_credentials.txt +5 -6
- data/lib/errors/invalid_index_name.txt +5 -7
- data/lib/errors/missing_api_key.txt +9 -11
- data/lib/errors/missing_application_id.txt +7 -8
- data/lib/errors/missing_index_name.txt +11 -12
- data/lib/errors/no_records_found.txt +8 -14
- data/lib/errors/record_too_big.txt +16 -21
- data/lib/errors/settings_manually_edited.txt +17 -0
- data/lib/errors/unknown_application_id.txt +9 -13
- data/lib/errors/unknown_settings.txt +8 -11
- data/lib/jekyll-algolia.rb +108 -29
- data/lib/jekyll/algolia/configurator.rb +38 -44
- data/lib/jekyll/algolia/extractor.rb +2 -2
- data/lib/jekyll/algolia/file_browser.rb +91 -68
- data/lib/jekyll/algolia/indexer.rb +132 -62
- data/lib/jekyll/algolia/logger.rb +8 -7
- data/lib/jekyll/algolia/overwrites.rb +13 -0
- data/lib/jekyll/algolia/progress_bar.rb +27 -0
- data/lib/jekyll/algolia/utils.rb +52 -4
- data/lib/jekyll/algolia/version.rb +1 -1
- data/lib/jekyll/commands/algolia.rb +3 -14
- metadata +21 -4
@@ -29,18 +29,19 @@ module Jekyll
|
|
29
29
|
# "X:Your content"
|
30
30
|
# Where X is either I, W or E for marking respectively an info, warning or
|
31
31
|
# error display
|
32
|
-
def self.log(
|
33
|
-
type, content = /^(I|W|E):(.*)
|
32
|
+
def self.log(input)
|
33
|
+
type, content = /^(I|W|E):(.*)/m.match(input).captures
|
34
34
|
logger_mapping = {
|
35
35
|
'E' => :error,
|
36
36
|
'I' => :info,
|
37
37
|
'W' => :warn
|
38
38
|
}
|
39
39
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
# Display by chunk of 80-characters lines
|
41
|
+
lines = Utils.split_lines(content, 80)
|
42
|
+
lines.each do |line|
|
43
|
+
Jekyll.logger.send(logger_mapping[type], line)
|
44
|
+
end
|
44
45
|
end
|
45
46
|
|
46
47
|
# Public: Only display a log line if verbose mode is enabled
|
@@ -78,7 +79,7 @@ module Jekyll
|
|
78
79
|
# Convert all variables
|
79
80
|
content = File.open(file).read
|
80
81
|
metadata.each do |key, value|
|
81
|
-
content = content.gsub("{#{key}}", value)
|
82
|
+
content = content.gsub("{#{key}}", value.to_s)
|
82
83
|
end
|
83
84
|
|
84
85
|
# Display each line differently
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
# Overwriting the Jekyll::Document class
|
5
|
+
class Document
|
6
|
+
# By default, Jekyll will set the current date (time of build) to any
|
7
|
+
# collection item. This will break our diff algorithm, so we monkey patch
|
8
|
+
# this call to return nil if no date is defined instead.
|
9
|
+
def date
|
10
|
+
data['date'] || nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'progressbar'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
module Algolia
|
8
|
+
# Module to push records to Algolia and configure the index
|
9
|
+
module ProgressBar
|
10
|
+
include Jekyll::Algolia
|
11
|
+
|
12
|
+
def self.should_be_silenced?
|
13
|
+
Configurator.verbose?
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create(options)
|
17
|
+
if should_be_silenced?
|
18
|
+
fake_bar = OpenStruct.new
|
19
|
+
fake_bar.increment = nil
|
20
|
+
return fake_bar
|
21
|
+
end
|
22
|
+
|
23
|
+
::ProgressBar.create(options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/jekyll/algolia/utils.rb
CHANGED
@@ -31,10 +31,10 @@ module Jekyll
|
|
31
31
|
# input - the variable to test
|
32
32
|
# classname - the string representation of the class
|
33
33
|
def self.instance_of?(input, classname)
|
34
|
-
|
34
|
+
input.instance_of? Object.const_get(classname)
|
35
35
|
rescue StandardError
|
36
36
|
# The class might not even exist
|
37
|
-
|
37
|
+
false
|
38
38
|
end
|
39
39
|
|
40
40
|
# Public: Convert an HTML string to its content only
|
@@ -46,14 +46,14 @@ module Jekyll
|
|
46
46
|
text.tr("\n", ' ').squeeze(' ').strip
|
47
47
|
end
|
48
48
|
|
49
|
-
# Public: Remove all keys with a nil value or an empty
|
49
|
+
# Public: Remove all keys with a nil value or an empty string from a hash
|
50
50
|
#
|
51
51
|
# hash - The input hash
|
52
52
|
def self.compact_empty(hash)
|
53
53
|
new_hash = {}
|
54
54
|
hash.each do |key, value|
|
55
55
|
next if value.nil?
|
56
|
-
next if value.
|
56
|
+
next if value.is_a?(String) && value.empty?
|
57
57
|
new_hash[key] = value
|
58
58
|
end
|
59
59
|
new_hash
|
@@ -127,6 +127,54 @@ module Jekyll
|
|
127
127
|
|
128
128
|
stringified
|
129
129
|
end
|
130
|
+
|
131
|
+
# Public: Get a hash representing the difference between two hashes
|
132
|
+
#
|
133
|
+
# It only checks that all keys of alpha are also in beta, with the same
|
134
|
+
# value. If not, it remember what was the value of beta and return it in
|
135
|
+
# the output
|
136
|
+
def self.diff_keys(alpha, beta)
|
137
|
+
diff = {}
|
138
|
+
alpha.each do |key, value|
|
139
|
+
diff[key] = beta[key] if beta[key] != value
|
140
|
+
end
|
141
|
+
|
142
|
+
return nil if diff.empty?
|
143
|
+
diff
|
144
|
+
end
|
145
|
+
|
146
|
+
# Public: Split a long text into lines of specific length
|
147
|
+
#
|
148
|
+
# It takes care to not cut words
|
149
|
+
def self.split_lines(input, max_length)
|
150
|
+
# Force splitting on actual new lines first
|
151
|
+
if input.include?("\n")
|
152
|
+
output = []
|
153
|
+
input.split("\n").each do |line|
|
154
|
+
output += split_lines(line, max_length)
|
155
|
+
end
|
156
|
+
return output
|
157
|
+
end
|
158
|
+
|
159
|
+
output = []
|
160
|
+
words = input.split(' ')
|
161
|
+
current_line = words.shift || ''
|
162
|
+
test_line = '' # must be defined outside of the loop
|
163
|
+
|
164
|
+
words.each do |word|
|
165
|
+
test_line = "#{current_line} #{word}"
|
166
|
+
if test_line.length > max_length
|
167
|
+
output << current_line
|
168
|
+
current_line = word
|
169
|
+
next
|
170
|
+
end
|
171
|
+
current_line = test_line
|
172
|
+
end
|
173
|
+
output << current_line
|
174
|
+
|
175
|
+
# Making sure all lines are the same length
|
176
|
+
output.map { |line| line.ljust(max_length, ' ') }
|
177
|
+
end
|
130
178
|
end
|
131
179
|
end
|
132
180
|
end
|
@@ -14,20 +14,6 @@ module Jekyll
|
|
14
14
|
'--config CONFIG_FILE[,CONFIG_FILE2,...]',
|
15
15
|
Array,
|
16
16
|
'Custom configuration file'
|
17
|
-
command.option 'future',
|
18
|
-
'--future',
|
19
|
-
'Index posts with a future date'
|
20
|
-
command.option 'limit_posts',
|
21
|
-
'--limit_posts MAX_POSTS',
|
22
|
-
Integer,
|
23
|
-
'Limits the number of posts to parse and index'
|
24
|
-
command.option 'show_drafts',
|
25
|
-
'-D',
|
26
|
-
'--drafts',
|
27
|
-
'Index posts in the _drafts folder'
|
28
|
-
command.option 'unpublished',
|
29
|
-
'--unpublished',
|
30
|
-
'Index posts that were marked as unpublished'
|
31
17
|
command.option 'dry_run',
|
32
18
|
'--dry-run',
|
33
19
|
'-n',
|
@@ -35,6 +21,9 @@ module Jekyll
|
|
35
21
|
command.option 'verbose',
|
36
22
|
'--verbose',
|
37
23
|
'Display more information on what is indexed'
|
24
|
+
command.option 'force_settings',
|
25
|
+
'--force-settings',
|
26
|
+
'Force updating of the index settings'
|
38
27
|
|
39
28
|
command.action do |_, options|
|
40
29
|
configuration = configuration_from_options(options)
|
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.
|
4
|
+
version: 1.2.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: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algolia_html_extractor
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.5.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.5.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: algoliasearch
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: progressbar
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.9'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.9'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: verbal_expressions
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -277,6 +291,7 @@ files:
|
|
277
291
|
- lib/errors/missing_index_name.txt
|
278
292
|
- lib/errors/no_records_found.txt
|
279
293
|
- lib/errors/record_too_big.txt
|
294
|
+
- lib/errors/settings_manually_edited.txt
|
280
295
|
- lib/errors/unknown_application_id.txt
|
281
296
|
- lib/errors/unknown_settings.txt
|
282
297
|
- lib/jekyll-algolia.rb
|
@@ -287,6 +302,8 @@ files:
|
|
287
302
|
- lib/jekyll/algolia/hooks.rb
|
288
303
|
- lib/jekyll/algolia/indexer.rb
|
289
304
|
- lib/jekyll/algolia/logger.rb
|
305
|
+
- lib/jekyll/algolia/overwrites.rb
|
306
|
+
- lib/jekyll/algolia/progress_bar.rb
|
290
307
|
- lib/jekyll/algolia/utils.rb
|
291
308
|
- lib/jekyll/algolia/version.rb
|
292
309
|
- lib/jekyll/commands/algolia.rb
|