middleman-search 0.3.0 → 0.4.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 +28 -1
- data/lib/middleman-search/extension.rb +5 -1
- data/lib/middleman-search/version.rb +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c257c2eca0252afe25ef8697e0b9a910c6d163f
|
4
|
+
data.tar.gz: 54436641815b65a80602fd0d6f21e13e9f4b375f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d4d336d5dab3f1289ff8d4183bbda35496a95cb8e55202108e93fdc059f44ae7bd11855cb139f95b0d21e019ddb459b67f1f04e242d787a3feb28e45f34ee8
|
7
|
+
data.tar.gz: 0980e91aca3b874aabfdb34fc200cce59c3504f211c84088d0c564a3a269a91eafa634d80febaff5898190180127cfc1346265ac2a383c2bc3fb88bba18e9487
|
data/README.md
CHANGED
@@ -94,7 +94,7 @@ This will register the `tildes` function in the lunr pipeline and add it when bu
|
|
94
94
|
|
95
95
|
Note that if you add a function to the pipeline, it will also be loaded when de-serialising the index, and lunr will fail with an `Cannot load un-registered function: tildes` error if it has not been re-registered. You can either register them manually, or simply include the following in a `.js.erb` file to be executed __before__ loading the index:
|
96
96
|
```erb
|
97
|
-
<%=
|
97
|
+
<%= search_lunr_js_pipeline %>
|
98
98
|
```
|
99
99
|
|
100
100
|
|
@@ -112,6 +112,33 @@ You should also `require` the `lunr.min.js` file in your main sprockets javascri
|
|
112
112
|
//= require lunr.min
|
113
113
|
```
|
114
114
|
|
115
|
+
### Asset pipeline
|
116
|
+
|
117
|
+
The Middleman pipeline does not include `json` files by default, but you can easily modify this by adding `.json` to the `exts` option of the corresponding extensions, such as `gzip` and `asset_hash`:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
activate :asset_hash do |asset_hash|
|
121
|
+
asset_hash.exts << '.json'
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
Note that if you run the index json file through the asset hash extension, you will need to retrieve the actual destination URL when loading the file in the browser for searching, using the `search_index_path` view helper:
|
126
|
+
|
127
|
+
```javascript
|
128
|
+
var lunrIndex = null;
|
129
|
+
var lunrData = null;
|
130
|
+
|
131
|
+
// Download index data
|
132
|
+
$.ajax({
|
133
|
+
url: "<%= search_index_path %>",
|
134
|
+
cache: true,
|
135
|
+
method: 'GET',
|
136
|
+
success: function(data) {
|
137
|
+
lunrData = data;
|
138
|
+
lunrIndex = lunr.Index.load(lunrData.index);
|
139
|
+
}
|
140
|
+
});
|
141
|
+
```
|
115
142
|
|
116
143
|
## Acknowledgments
|
117
144
|
|
@@ -15,12 +15,16 @@ module Middleman
|
|
15
15
|
end
|
16
16
|
|
17
17
|
helpers do
|
18
|
-
def
|
18
|
+
def search_lunr_js_pipeline
|
19
19
|
# Thanks http://stackoverflow.com/a/20187415/12791
|
20
20
|
extensions[:search].options[:pipeline].map do |name, function|
|
21
21
|
"lunr.Pipeline.registerFunction(#{function}, '#{name}');"
|
22
22
|
end.join("\n")
|
23
23
|
end
|
24
|
+
|
25
|
+
def search_index_path
|
26
|
+
"/" + sitemap.find_resource_by_path(extensions[:search].options[:index_path]).destination_path
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matías García Isaía
|
@@ -9,76 +9,76 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.2'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '3.2'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: therubyracer
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0.12'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0.12'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: nokogiri
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.5'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.5'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.5'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.5'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - '>='
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
description: LunrJS-based search for Middleman
|
@@ -89,8 +89,8 @@ executables: []
|
|
89
89
|
extensions: []
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
|
-
-
|
93
|
-
-
|
92
|
+
- .gitignore
|
93
|
+
- .travis.yml
|
94
94
|
- Gemfile
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
@@ -111,17 +111,17 @@ require_paths:
|
|
111
111
|
- lib
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - '>='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
|
-
- -
|
119
|
+
- - '>='
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.0.14
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: LunrJS-based search for Middleman
|