blacklight_dynamic_sitemap 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/.github/workflows/ruby.yml +37 -0
- data/README.md +3 -0
- data/app/models/blacklight_dynamic_sitemap/sitemap.rb +19 -6
- data/app/views/blacklight_dynamic_sitemap/sitemap/show.xml.builder +4 -2
- data/blacklight_dynamic_sitemap.gemspec +4 -1
- data/lib/blacklight_dynamic_sitemap/engine.rb +3 -0
- data/lib/blacklight_dynamic_sitemap/version.rb +1 -1
- metadata +3 -9
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0431ca04258abb8bdf5be705182e582d055b095a958ac9d6c5d241a05e50d598
|
4
|
+
data.tar.gz: ad93828dbb262af9346ba3c7dd1fc1b78d86edcc46986c0ba0a06009212a024d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25eb795290afff88d8fc55b597dcc6dd8f0eacb91ca4010a62c0c179324862749918dbe6898f8e27a6edb972e6acf9f84c5f9ceecc208a5a067e34f6e27cc877
|
7
|
+
data.tar.gz: ed8d361d36c650df61fc761316a53f35c1689daac1545e09f6fe8a925fa0e9dcf0d27de4614087e40baf3c2ee918583b28b660057f6fd64db5782cfe7411d856
|
@@ -0,0 +1,37 @@
|
|
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
|
+
rails: ['5.2.4.4', '6.0.3.4']
|
16
|
+
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: 2.7
|
24
|
+
- uses: actions/cache@v2
|
25
|
+
with:
|
26
|
+
path: vendor/bundle
|
27
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
28
|
+
restore-keys: |
|
29
|
+
${{ runner.os }}-gems-
|
30
|
+
- name: Bundle install
|
31
|
+
env:
|
32
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
33
|
+
run: |
|
34
|
+
bundle config path vendor/bundle
|
35
|
+
bundle install
|
36
|
+
- name: Run tests
|
37
|
+
run: bundle exec rake
|
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:
|
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 =
|
50
|
+
expiration = engine_config.max_documents_expiration
|
38
51
|
Rails.cache.fetch(key, expires_in: expiration) do
|
39
|
-
|
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[
|
12
|
-
|
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,7 +24,10 @@ 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
|
-
|
27
|
+
# Rails <5.0 is not covered by the automated test suite (see `.github/workflows/ruby.yml`).
|
28
|
+
# Anecdotally demonstrated to work fine on Rails as low as 4.2, but any lower version
|
29
|
+
# threshold would be arbitrary.
|
30
|
+
spec.add_dependency 'rails', '<= 6.1'
|
28
31
|
spec.add_dependency 'blacklight', '> 6.0'
|
29
32
|
|
30
33
|
spec.add_development_dependency 'capybara'
|
@@ -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
|
metadata
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_dynamic_sitemap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Reed
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5.2'
|
20
17
|
- - "<="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '6.1'
|
@@ -24,9 +21,6 @@ dependencies:
|
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '5.2'
|
30
24
|
- - "<="
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: '6.1'
|
@@ -107,10 +101,10 @@ executables: []
|
|
107
101
|
extensions: []
|
108
102
|
extra_rdoc_files: []
|
109
103
|
files:
|
104
|
+
- ".github/workflows/ruby.yml"
|
110
105
|
- ".gitignore"
|
111
106
|
- ".rspec"
|
112
107
|
- ".solr_wrapper"
|
113
|
-
- ".travis.yml"
|
114
108
|
- Gemfile
|
115
109
|
- LICENSE
|
116
110
|
- README.md
|