blacklight_dynamic_sitemap 0.3.0 → 0.6.0

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
2
  SHA256:
3
- metadata.gz: efd092440ea6b487972636c1b219cf17a6d1afcf2f10f75d2892125719ce7772
4
- data.tar.gz: 96b2a345f4b6b03cf39b3316bb6581b439511214e245c8d6ab47c674ec2d74bf
3
+ metadata.gz: 44231f5414713681e54dddaf7024e14489b518153160fc12d9b8f0ea6afc5fd9
4
+ data.tar.gz: 3d3f645e3b37cee0d16a5301a8a7afb47bf334b2270daa495d10efc633aa7fa9
5
5
  SHA512:
6
- metadata.gz: 017c6c3459d3fb722cf3bc05eea855c8c33f8f63d622cfa3713149f20a932a31b6620b03f865a6f78a02658b631a67071f14780a524503e8e3b244e036888949
7
- data.tar.gz: 11ea817570658dffaf136c425dddc374dcba98d49fab21808d6250e37c7f168d03ceb274f91f0edd1f864299eb5c9dbf3139a2c5a7dda60fad5640462c6dc685
6
+ metadata.gz: ec836640c85ae903245d3de6217eed3e23bdb7f9aa808b6b23357a423e11866b5ea59ad883b6304e724538efc23ea91da992b76f2cd5e2b97dd8e782e40e8b7a
7
+ data.tar.gz: 1808f19193c2f9a8130b8e7f4daf38f0e8a6499fa77467699e34a970da9e78eb215bff1883fc4508b9275ecf8deddcd90e725c8be4e9d0eb6054bc152d6f605a
@@ -0,0 +1,41 @@
1
+
2
+ name: CI
3
+
4
+ on:
5
+ push:
6
+ branches: [ master ]
7
+ pull_request:
8
+ branches: [ master ]
9
+
10
+ jobs:
11
+ tests:
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ['2.7']
16
+ rails: ['6.0.3.7', '6.1.3.2', '7.0.3']
17
+ include:
18
+ - rails: '7.0.3'
19
+ ruby: '3.0'
20
+
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ - uses: actions/cache@v2
29
+ with:
30
+ path: vendor/bundle
31
+ key: ${{ runner.os }}-gems20210506-${{ hashFiles('**/Gemfile.lock') }}
32
+ restore-keys: |
33
+ ${{ runner.os }}-gems20210506-
34
+ - name: Bundle install
35
+ env:
36
+ RAILS_VERSION: ${{ matrix.rails }}
37
+ run: |
38
+ bundle config path vendor/bundle
39
+ bundle install
40
+ - name: Run tests
41
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -3,11 +3,9 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in blacklight_dynamic_sitemap.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rake', '~> 12.0'
7
- gem 'rspec', '~> 3.0'
8
6
  # BEGIN ENGINE_CART BLOCK
9
- # engine_cart: 2.3.0
10
- # engine_cart stanza: 0.10.0
7
+ # engine_cart: 2.4.0
8
+ # engine_cart stanza: 2.5.0
11
9
  # the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
12
10
  file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
13
11
  if File.exist?(file)
@@ -27,15 +25,16 @@ else
27
25
  else
28
26
  gem 'rails', ENV['RAILS_VERSION']
29
27
  end
30
- end
31
28
 
32
- case ENV['RAILS_VERSION']
33
- when /^4.2/
34
- gem 'responders', '~> 2.0'
35
- gem 'sass-rails', '>= 5.0'
36
- gem 'coffee-rails', '~> 4.1.0'
37
- when /^4.[01]/
38
- gem 'sass-rails', '< 5.0'
29
+ case ENV['RAILS_VERSION']
30
+ when /^6.0/
31
+ gem 'sass-rails', '>= 6'
32
+ gem 'webpacker', '~> 4.0'
33
+ when /^5.[12]/
34
+ gem 'sass-rails', '~> 5.0'
35
+ gem 'sprockets', '~> 3.7'
36
+ gem 'thor', '~> 0.20'
37
+ end
39
38
  end
40
39
  end
41
40
  # END ENGINE_CART BLOCK
data/README.md CHANGED
@@ -44,6 +44,9 @@ This gem offers several configuration options that can be configured in a Rails
44
44
 
45
45
  See [engine.rb](https://github.com/sul-dlss/blacklight_dynamic_sitemap/blob/master/lib/blacklight_dynamic_sitemap/engine.rb) for available configurations.
46
46
 
47
+ ### Rails version compatibility note
48
+ Note that the gemspec does not list a lower threshold for Rails version compatibility. This gem has been anecdotally demonstrated to work fine as low as Rails 4.2, but maintaining compatibility of the test suite with rails <5.0 was more complex than practical benefits warranted. Exercise caution when using with Rails <5.0.
49
+
47
50
  ## Development
48
51
 
49
52
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake ci` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -7,14 +7,19 @@ module BlacklightDynamicSitemap
7
7
  delegate :hashed_id_field, :unique_id_field, :last_modified_field, to: :engine_config
8
8
 
9
9
  def get(id)
10
+ # if someone's hacking URLs (in ways that could potentially generate enormous requests),
11
+ # just return an empty response
12
+ return [] if id.length != exponent
13
+
10
14
  index_connection.select(
11
- params: {
12
- q: "{!prefix f=#{hashed_id_field} v=#{id}}",
15
+ params: show_params(id, {
16
+ q: '*:*',
17
+ fq: ["{!prefix f=#{hashed_id_field} v=#{id}}"],
13
18
  fl: [unique_id_field, last_modified_field].join(','),
14
19
  rows: 2_000_000, # Ensure that we do not page this result
15
20
  facet: false,
16
21
  defType: 'lucene'
17
- }
22
+ })
18
23
  ).dig('response', 'docs')
19
24
  end
20
25
 
@@ -24,6 +29,14 @@ module BlacklightDynamicSitemap
24
29
 
25
30
  private
26
31
 
32
+ def show_params(id, default_params)
33
+ engine_config.modify_show_params&.call(id, default_params) || default_params
34
+ end
35
+
36
+ def index_params(default_params)
37
+ engine_config.modify_index_params&.call(default_params) || default_params
38
+ end
39
+
27
40
  def index_connection
28
41
  @index_connection ||= Blacklight.default_index.connection
29
42
  end
@@ -34,10 +47,10 @@ module BlacklightDynamicSitemap
34
47
 
35
48
  def max_documents
36
49
  key = 'blacklight_dynamic_sitemap.index_max_docs'
37
- expiration = BlacklightDynamicSitemap::Engine.config.max_documents_expiration
50
+ expiration = engine_config.max_documents_expiration
38
51
  Rails.cache.fetch(key, expires_in: expiration) do
39
- Blacklight.default_index.connection.select(
40
- params: { q: '*:*', rows: 0, facet: false }
52
+ index_connection.select(
53
+ params: index_params({ q: '*:*', rows: 0, facet: false })
41
54
  )['response']['numFound']
42
55
  end
43
56
  end
@@ -6,10 +6,12 @@ xml.urlset(
6
6
  'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
7
7
  'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'
8
8
  ) do
9
+ config = BlacklightDynamicSitemap::Engine.config
9
10
  @sitemap_entries.each do |doc|
10
11
  xml.url do
11
- xml.loc(main_app.solr_document_url(doc[BlacklightDynamicSitemap::Engine.config.unique_id_field]))
12
- xml.lastmod(doc[BlacklightDynamicSitemap::Engine.config.last_modified_field])
12
+ xml.loc(main_app.solr_document_url(doc[config.unique_id_field]))
13
+ last_modified = doc[config.last_modified_field]
14
+ xml.lastmod(config.format_last_modified&.call(last_modified) || last_modified)
13
15
  end
14
16
  end
15
17
  end
@@ -24,11 +24,12 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'rails', '>= 5.2', '<= 6.1'
27
+ spec.add_dependency 'rails'
28
28
  spec.add_dependency 'blacklight', '> 6.0'
29
29
 
30
30
  spec.add_development_dependency 'capybara'
31
31
  spec.add_development_dependency 'engine_cart', '~> 2.0'
32
32
  spec.add_development_dependency 'rspec-rails'
33
33
  spec.add_development_dependency 'solr_wrapper'
34
+ spec.add_development_dependency 'rake'
34
35
  end
@@ -8,5 +8,8 @@ module BlacklightDynamicSitemap
8
8
  config.hashed_id_field = 'hashed_id_ssi'
9
9
  config.unique_id_field = 'id'
10
10
  config.last_modified_field = 'timestamp'
11
+ config.modify_show_params = nil # lambda { |id, default_params| default_params }
12
+ config.modify_index_params = nil # lambda { |default_params| default_params }
13
+ config.format_last_modified = nil # lambda { |raw_last_modified| raw_last_modified }
11
14
  end
12
15
  end
@@ -1,3 +1,3 @@
1
1
  module BlacklightDynamicSitemap
2
- VERSION = '0.3.0'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -31,6 +31,7 @@
31
31
 
32
32
  <!-- solr lib dirs -->
33
33
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" />
34
+ <lib dir="${solr.install.dir:../../../..}/modules/analysis-extras/lib" />
34
35
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" />
35
36
 
36
37
  <dataDir>${solr.data.dir:}</dataDir>
@@ -10,7 +10,7 @@ task ci: ['blacklight_dynamic_sitemap:generate'] do
10
10
  SolrWrapper.wrap do |solr|
11
11
  solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path('..', File.dirname(__FILE__)), 'solr', 'conf')) do
12
12
  within_test_app do
13
- system 'RAILS_ENV=test rake blacklight:index:seed'
13
+ system 'RAILS_ENV=test bundle exec rake blacklight:index:seed'
14
14
  end
15
15
  Rake::Task['spec'].invoke
16
16
  end
@@ -36,7 +36,7 @@ namespace :blacklight_dynamic_sitemap do
36
36
  solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path('..', File.dirname(__FILE__)), 'solr', 'conf')) do
37
37
 
38
38
  within_test_app do
39
- system 'RAILS_ENV=development rake blacklight:index:seed'
39
+ system 'RAILS_ENV=development bundle exec rake blacklight:index:seed'
40
40
  system "bundle exec rails s #{args[:rails_server_args]}"
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_dynamic_sitemap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Reed
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2022-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
20
- - - "<="
21
- - !ruby/object:Gem::Version
22
- version: '6.1'
19
+ version: '0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '5.2'
30
- - - "<="
31
- - !ruby/object:Gem::Version
32
- version: '6.1'
26
+ version: '0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: blacklight
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +94,20 @@ dependencies:
100
94
  - - ">="
101
95
  - !ruby/object:Gem::Version
102
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
103
111
  description: Dynamic sitemap.xml for BLacklight
104
112
  email:
105
113
  - phillipjreed@gmail.com
@@ -107,10 +115,10 @@ executables: []
107
115
  extensions: []
108
116
  extra_rdoc_files: []
109
117
  files:
118
+ - ".github/workflows/ruby.yml"
110
119
  - ".gitignore"
111
120
  - ".rspec"
112
121
  - ".solr_wrapper"
113
- - ".travis.yml"
114
122
  - Gemfile
115
123
  - LICENSE
116
124
  - README.md
@@ -150,7 +158,7 @@ licenses:
150
158
  metadata:
151
159
  homepage_uri: https://github.com/sul-dlss/blacklight_dynamic_sitemap
152
160
  source_code_uri: https://github.com/sul-dlss/blacklight_dynamic_sitemap
153
- post_install_message:
161
+ post_install_message:
154
162
  rdoc_options: []
155
163
  require_paths:
156
164
  - lib
@@ -165,8 +173,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
173
  - !ruby/object:Gem::Version
166
174
  version: '0'
167
175
  requirements: []
168
- rubygems_version: 3.1.2
169
- signing_key:
176
+ rubygems_version: 3.2.32
177
+ signing_key:
170
178
  specification_version: 4
171
179
  summary: Dynamic sitemap.xml for BLacklight
172
180
  test_files: []
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
-
5
- matrix:
6
- include:
7
- - env: RAILS_VERSION=6.0.3.2
8
- - env: RAILS_VERSION=5.2.4.3
9
-
10
- rvm:
11
- - 2.7.1
12
- notifications:
13
- email: false
14
- jdk: openjdk11