middleman-search-gds 0.11.0a → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env groovy
2
+
3
+ library("govuk")
4
+
5
+ node {
6
+ govuk.buildProject(
7
+ gemName: "middleman-search-gds",
8
+ overrideTestTask: {
9
+ // there are no tests in this repo, so the default `bundle exec rake` would fail
10
+ },
11
+ )
12
+ }
data/README.md CHANGED
@@ -49,9 +49,19 @@ Where `resources` is a list of the beginning of the URL of the resources to inde
49
49
 
50
50
  Note that a special field `id` is included automatically, with an autogenerated identifier to be used as the `ref` for the document.
51
51
 
52
- All fields values are retrieved from the resource `data` (i.e. its frontmatter), or from the `options` in the `resource.metadata` (i.e. any options specified in a `proxy` page), except for:
53
- - `url` which is the actual resource url
54
- - `content` the text extracted from the rendered resource, without including its layout
52
+ Dynamic resources can be proxied as below:
53
+
54
+ ```ruby
55
+ ProxyPages.resources.each do |resource|
56
+ proxy "/foo/#{resource.filename}.html", "templates/my_template.html", { title: resource.title }
57
+ end
58
+ ```
59
+
60
+ All fields values are retrieved from the resource `data` (i.e. its frontmatter), or from the `options` in the `resource.metadata` (i.e. any options specified in a `proxy` page - the third parameter in the example above). The exceptions are:
61
+
62
+ - `url`, which is the actual resource url
63
+ - `content`, which is by default the text extracted from the rendered resource (without its layout).
64
+ Indexing lots of content can cause performance issues, so you may want to override this field in the resource data (e.g. `content: ""`) if the page contents aren't relevant to the index.
55
65
 
56
66
  You can then query the index from Javascript via the `lunrIndex` object (see [Index file](#index-file) for more info):
57
67
 
@@ -128,17 +128,23 @@ module Middleman
128
128
  def value_for(resource, field, opts={})
129
129
  case field.to_s
130
130
  when 'content'
131
+ overridden_content = retrieve_custom_value(resource, field)
132
+ return overridden_content unless overridden_content.nil?
131
133
 
132
134
  html = resource.render( { :layout => false }, { :current_path => resource.path } )
133
135
  Nokogiri::HTML(html).xpath("//text()").text
134
136
  when 'url'
135
137
  resource.url
136
138
  else
137
- value = resource.data.send(field) || resource.metadata.fetch(:options, {}).fetch(field, nil)
138
- value ? Array(value).compact.join(" ") : nil
139
+ retrieve_custom_value(resource, field)
139
140
  end
140
141
  end
141
142
 
143
+ def retrieve_custom_value(resource, field)
144
+ value = resource.data.send(field) || resource.metadata.fetch(:options, {}).fetch(field, nil)
145
+ value ? Array(value).compact.join(" ") : nil
146
+ end
147
+
142
148
  private
143
149
 
144
150
  def minified_path(resource_name)
@@ -1,3 +1,3 @@
1
1
  module MiddlemanSearch
2
- VERSION = "0.11.0a"
2
+ VERSION = "0.11.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-search-gds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0a
4
+ version: 0.11.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Government Digital Service
@@ -10,76 +11,86 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2018-10-29 00:00:00.000000000 Z
14
+ date: 2020-05-18 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: middleman-core
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - ">="
21
+ - - ! '>='
20
22
  - !ruby/object:Gem::Version
21
23
  version: '3.2'
22
24
  type: :runtime
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
- - - ">="
29
+ - - ! '>='
27
30
  - !ruby/object:Gem::Version
28
31
  version: '3.2'
29
32
  - !ruby/object:Gem::Dependency
30
33
  name: execjs
31
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
32
36
  requirements:
33
- - - "~>"
37
+ - - ~>
34
38
  - !ruby/object:Gem::Version
35
39
  version: '2.6'
36
40
  type: :runtime
37
41
  prerelease: false
38
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
39
44
  requirements:
40
- - - "~>"
45
+ - - ~>
41
46
  - !ruby/object:Gem::Version
42
47
  version: '2.6'
43
48
  - !ruby/object:Gem::Dependency
44
49
  name: nokogiri
45
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
46
52
  requirements:
47
- - - "~>"
53
+ - - ~>
48
54
  - !ruby/object:Gem::Version
49
55
  version: '1.6'
50
56
  type: :runtime
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
53
60
  requirements:
54
- - - "~>"
61
+ - - ~>
55
62
  - !ruby/object:Gem::Version
56
63
  version: '1.6'
57
64
  - !ruby/object:Gem::Dependency
58
65
  name: bundler
59
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
- - - "~>"
69
+ - - ~>
62
70
  - !ruby/object:Gem::Version
63
71
  version: '1.5'
64
72
  type: :development
65
73
  prerelease: false
66
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
67
76
  requirements:
68
- - - "~>"
77
+ - - ~>
69
78
  - !ruby/object:Gem::Version
70
79
  version: '1.5'
71
80
  - !ruby/object:Gem::Dependency
72
81
  name: rake
73
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
74
84
  requirements:
75
- - - ">="
85
+ - - ! '>='
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
78
88
  type: :development
79
89
  prerelease: false
80
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
81
92
  requirements:
82
- - - ">="
93
+ - - ! '>='
83
94
  - !ruby/object:Gem::Version
84
95
  version: '0'
85
96
  description: LunrJS-based search for Middleman. This is an unofficial fork of the
@@ -92,9 +103,10 @@ executables: []
92
103
  extensions: []
93
104
  extra_rdoc_files: []
94
105
  files:
95
- - ".gitignore"
96
- - ".travis.yml"
106
+ - .gitignore
107
+ - .travis.yml
97
108
  - Gemfile
109
+ - Jenkinsfile
98
110
  - LICENSE.txt
99
111
  - README.md
100
112
  - lib/middleman-search.rb
@@ -102,7 +114,7 @@ files:
102
114
  - lib/middleman-search/search-index-resource.rb
103
115
  - lib/middleman-search/version.rb
104
116
  - lib/middleman_extension.rb
105
- - middleman-search.gemspec
117
+ - middleman-search-gds.gemspec
106
118
  - vendor/assets/javascripts/lunr.da.js
107
119
  - vendor/assets/javascripts/lunr.de.js
108
120
  - vendor/assets/javascripts/lunr.du.js
@@ -123,25 +135,26 @@ files:
123
135
  homepage: http://github.com/alphagov/middleman-search
124
136
  licenses:
125
137
  - MIT
126
- metadata: {}
127
138
  post_install_message:
128
139
  rdoc_options: []
129
140
  require_paths:
130
141
  - lib
131
142
  required_ruby_version: !ruby/object:Gem::Requirement
143
+ none: false
132
144
  requirements:
133
- - - ">="
145
+ - - ! '>='
134
146
  - !ruby/object:Gem::Version
135
147
  version: '0'
136
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
137
150
  requirements:
138
- - - ">"
151
+ - - ! '>='
139
152
  - !ruby/object:Gem::Version
140
- version: 1.3.1
153
+ version: '0'
141
154
  requirements: []
142
155
  rubyforge_project:
143
- rubygems_version: 2.6.13
156
+ rubygems_version: 1.8.23
144
157
  signing_key:
145
- specification_version: 4
158
+ specification_version: 3
146
159
  summary: LunrJS-based search for Middleman
147
160
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: f7a50a523cabca4a87a73bb6a1a87b765f1e0e3b
4
- data.tar.gz: e62e0a792758b31fd98a00acf6bbe2091c6593be
5
- SHA512:
6
- metadata.gz: a51080682bef38d99ea3a27958c34e30768454fc18e04432ca3ae26e6bf79325a7bcdc1b8b5ad6cd27787c183ef4499e3ad672ce2dc63ce2dae283cce18644f8
7
- data.tar.gz: 6fa42ea890e06662dd5b876437a2b9b61cb8f6e57e0623fcedbd7870968130d8cc277baf4b815a751409b4dd9f0040cb1543c983fbd8a33aacad583107cc3aa5