middleman-search-gds 0.11.0a → 0.11.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f7a50a523cabca4a87a73bb6a1a87b765f1e0e3b
4
- data.tar.gz: e62e0a792758b31fd98a00acf6bbe2091c6593be
2
+ SHA256:
3
+ metadata.gz: da8fdabed383e3f9b0113de262a53ec7c570e9852d7dd766d6f16ffca553974f
4
+ data.tar.gz: c3f9e64751b03205d21ed946c3df60203fb2a03f0f4ce895ea9b221932ff2161
5
5
  SHA512:
6
- metadata.gz: a51080682bef38d99ea3a27958c34e30768454fc18e04432ca3ae26e6bf79325a7bcdc1b8b5ad6cd27787c183ef4499e3ad672ce2dc63ce2dae283cce18644f8
7
- data.tar.gz: 6fa42ea890e06662dd5b876437a2b9b61cb8f6e57e0623fcedbd7870968130d8cc277baf4b815a751409b4dd9f0040cb1543c983fbd8a33aacad583107cc3aa5
6
+ metadata.gz: 93fbc2ae89a34470cfd9e29dca9d1279637b6a6b900642d8cf44c9b7e024df1bee4802b8307334340ce734eceb79882e0c32b27f8d7815c00122c8988a2d6209
7
+ data.tar.gz: d531d18d40a6b4d985fd4fe0aaf0135545c8476e72fdf1bb039a294cf3c69e920547a5f8a0398521d4a0840e3524683091421e2a4374332438213d6c0b205a87
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 0.11.2
2
+
3
+ * No longer calls `File::exists?`, which was deleted from the standard library in [Ruby 3.2](https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/).
data/README.md CHANGED
@@ -16,6 +16,12 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install middleman-search
18
18
 
19
+ ## Deployment
20
+
21
+ New releases of this gem do not get deployed automatically.
22
+
23
+ To release it you will need to follow the process to [publish to rubygems.org](https://guides.rubygems.org/publishing/#publishing-to-rubygemsorg), using the alphagov credentials - contact someone in GOV.UK senior tech for access.
24
+
19
25
  ## Usage
20
26
 
21
27
  You need to activate the module in your `config.rb`, telling the extension how to index your resources:
@@ -49,9 +55,19 @@ Where `resources` is a list of the beginning of the URL of the resources to inde
49
55
 
50
56
  Note that a special field `id` is included automatically, with an autogenerated identifier to be used as the `ref` for the document.
51
57
 
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
58
+ Dynamic resources can be proxied as below:
59
+
60
+ ```ruby
61
+ ProxyPages.resources.each do |resource|
62
+ proxy "/foo/#{resource.filename}.html", "templates/my_template.html", { title: resource.title }
63
+ end
64
+ ```
65
+
66
+ 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:
67
+
68
+ - `url`, which is the actual resource url
69
+ - `content`, which is by default the text extracted from the rendered resource (without its layout).
70
+ 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
71
 
56
72
  You can then query the index from Javascript via the `lunrIndex` object (see [Index file](#index-file) for more info):
57
73
 
@@ -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)
@@ -150,7 +156,7 @@ module Middleman
150
156
  def lunr_resource(resource_name)
151
157
  @lunr_dirs.flat_map do |dir|
152
158
  [File.join(dir, minified_path(resource_name)), File.join(dir, resource_name)]
153
- end.detect { |file| File.exists? file } or raise "Couldn't find #{resource_name} nor #{minified_path(resource_name)} in #{@lunr_dirs.map {|dir| File.absolute_path dir }.join File::PATH_SEPARATOR}"
159
+ end.detect { |file| File.exist? file } or raise "Couldn't find #{resource_name} nor #{minified_path(resource_name)} in #{@lunr_dirs.map {|dir| File.absolute_path dir }.join File::PATH_SEPARATOR}"
154
160
  end
155
161
  end
156
162
  end
@@ -1,3 +1,3 @@
1
1
  module MiddlemanSearch
2
- VERSION = "0.11.0a"
2
+ VERSION = "0.11.2"
3
3
  end
metadata CHANGED
@@ -1,16 +1,16 @@
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  - Matías García Isaía
9
9
  - Santiago Palladino
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-10-29 00:00:00.000000000 Z
13
+ date: 2023-03-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: middleman-core
@@ -94,6 +94,7 @@ extra_rdoc_files: []
94
94
  files:
95
95
  - ".gitignore"
96
96
  - ".travis.yml"
97
+ - CHANGELOG.md
97
98
  - Gemfile
98
99
  - LICENSE.txt
99
100
  - README.md
@@ -102,7 +103,7 @@ files:
102
103
  - lib/middleman-search/search-index-resource.rb
103
104
  - lib/middleman-search/version.rb
104
105
  - lib/middleman_extension.rb
105
- - middleman-search.gemspec
106
+ - middleman-search-gds.gemspec
106
107
  - vendor/assets/javascripts/lunr.da.js
107
108
  - vendor/assets/javascripts/lunr.de.js
108
109
  - vendor/assets/javascripts/lunr.du.js
@@ -124,7 +125,7 @@ homepage: http://github.com/alphagov/middleman-search
124
125
  licenses:
125
126
  - MIT
126
127
  metadata: {}
127
- post_install_message:
128
+ post_install_message:
128
129
  rdoc_options: []
129
130
  require_paths:
130
131
  - lib
@@ -135,13 +136,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  requirements:
138
- - - ">"
139
+ - - ">="
139
140
  - !ruby/object:Gem::Version
140
- version: 1.3.1
141
+ version: '0'
141
142
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.6.13
144
- signing_key:
143
+ rubygems_version: 3.4.7
144
+ signing_key:
145
145
  specification_version: 4
146
146
  summary: LunrJS-based search for Middleman
147
147
  test_files: []