mods_display 0.9.1 → 1.0.0.alpha2
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 +4 -4
- data/.rubocop.yml +2 -1
- data/.rubocop_todo.yml +433 -35
- data/README.md +0 -95
- data/app/components/mods_display/field_component.html.erb +13 -0
- data/app/components/mods_display/field_component.rb +27 -0
- data/app/components/mods_display/list_field_component.html.erb +11 -0
- data/app/components/mods_display/list_field_component.rb +10 -0
- data/app/components/mods_display/record_component.html.erb +5 -0
- data/app/components/mods_display/record_component.rb +39 -0
- data/app/helpers/mods_display/record_helper.rb +106 -0
- data/app/models/mods_display/record.rb +26 -0
- data/config/locales/en.yml +1 -1
- data/config.ru +9 -0
- data/lib/mods_display/engine.rb +13 -0
- data/lib/mods_display/fields/access_condition.rb +4 -0
- data/lib/mods_display/fields/contents.rb +14 -15
- data/lib/mods_display/fields/field.rb +13 -149
- data/lib/mods_display/fields/genre.rb +4 -0
- data/lib/mods_display/fields/imprint.rb +52 -3
- data/lib/mods_display/fields/location.rb +1 -1
- data/lib/mods_display/fields/name.rb +11 -20
- data/lib/mods_display/fields/nested_related_item.rb +7 -18
- data/lib/mods_display/fields/note.rb +4 -0
- data/lib/mods_display/fields/related_item.rb +4 -0
- data/lib/mods_display/fields/resource_type.rb +1 -1
- data/lib/mods_display/fields/sub_title.rb +3 -3
- data/lib/mods_display/fields/subject.rb +13 -39
- data/lib/mods_display/fields/title.rb +43 -32
- data/lib/mods_display/fields/values.rb +4 -4
- data/lib/mods_display/html.rb +55 -106
- data/lib/mods_display/version.rb +1 -1
- data/lib/mods_display.rb +2 -17
- data/mods_display.gemspec +15 -9
- metadata +45 -105
- data/.github/workflows/ruby.yml +0 -24
- data/.gitignore +0 -21
- data/lib/mods_display/configuration/access_condition.rb +0 -21
- data/lib/mods_display/configuration/base.rb +0 -34
- data/lib/mods_display/configuration/genre.rb +0 -9
- data/lib/mods_display/configuration/imprint.rb +0 -13
- data/lib/mods_display/configuration/name.rb +0 -9
- data/lib/mods_display/configuration/note.rb +0 -9
- data/lib/mods_display/configuration/related_item.rb +0 -9
- data/lib/mods_display/configuration/subject.rb +0 -13
- data/lib/mods_display/configuration/title.rb +0 -9
- data/lib/mods_display/configuration.rb +0 -93
- data/lib/mods_display/controller_extension.rb +0 -32
- data/lib/mods_display/helpers/record_helper.rb +0 -131
- data/lib/mods_display/model_extension.rb +0 -22
- data/lib/mods_display/railtie.rb +0 -10
- data/spec/configuration/access_condition_spec.rb +0 -10
- data/spec/configuration/base_spec.rb +0 -39
- data/spec/fake_app.rb +0 -18
- data/spec/fields/abstract_spec.rb +0 -39
- data/spec/fields/access_condition_spec.rb +0 -107
- data/spec/fields/audience_spec.rb +0 -24
- data/spec/fields/cartographics_spec.rb +0 -38
- data/spec/fields/collection_spec.rb +0 -77
- data/spec/fields/contact_spec.rb +0 -23
- data/spec/fields/contents_spec.rb +0 -39
- data/spec/fields/description_spec.rb +0 -55
- data/spec/fields/extent_spec.rb +0 -31
- data/spec/fields/form_spec.rb +0 -49
- data/spec/fields/genre_spec.rb +0 -34
- data/spec/fields/geo_spec.rb +0 -40
- data/spec/fields/identifier_spec.rb +0 -61
- data/spec/fields/imprint_spec.rb +0 -289
- data/spec/fields/language_spec.rb +0 -51
- data/spec/fields/location_spec.rb +0 -81
- data/spec/fields/name_spec.rb +0 -166
- data/spec/fields/nested_related_item_spec.rb +0 -89
- data/spec/fields/note_spec.rb +0 -72
- data/spec/fields/related_item_spec.rb +0 -72
- data/spec/fields/resource_type_spec.rb +0 -34
- data/spec/fields/sub_title_spec.rb +0 -20
- data/spec/fields/subject_spec.rb +0 -113
- data/spec/fields/title_spec.rb +0 -74
- data/spec/fixtures/access_condition_fixtures.rb +0 -58
- data/spec/fixtures/cartographics_fixtures.rb +0 -52
- data/spec/fixtures/imprint_fixtures.rb +0 -349
- data/spec/fixtures/name_fixtures.rb +0 -398
- data/spec/fixtures/nested_realted_items_fixtures.rb +0 -64
- data/spec/fixtures/related_item_fixtures.rb +0 -107
- data/spec/fixtures/subjects_fixtures.rb +0 -115
- data/spec/fixtures/title_fixtures.rb +0 -101
- data/spec/helpers/record_helper_spec.rb +0 -241
- data/spec/integration/configuration_spec.rb +0 -57
- data/spec/integration/html_spec.rb +0 -87
- data/spec/integration/installation_spec.rb +0 -26
- data/spec/spec_helper.rb +0 -46
- data/spec/test_fr.yml +0 -3
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods_display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jessie Keck
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stanford-mods
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: view_component
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +150,20 @@ dependencies:
|
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '6.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: combustion
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.3'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.3'
|
139
167
|
description: MODS Display is a gem to centralize the display logic of MODS medadata.
|
140
168
|
email:
|
141
169
|
- jessie.keck@gmail.com
|
@@ -143,28 +171,25 @@ executables: []
|
|
143
171
|
extensions: []
|
144
172
|
extra_rdoc_files: []
|
145
173
|
files:
|
146
|
-
- ".github/workflows/ruby.yml"
|
147
|
-
- ".gitignore"
|
148
174
|
- ".rubocop.yml"
|
149
175
|
- ".rubocop_todo.yml"
|
150
176
|
- Gemfile
|
151
177
|
- LICENSE.txt
|
152
178
|
- README.md
|
153
179
|
- Rakefile
|
180
|
+
- app/components/mods_display/field_component.html.erb
|
181
|
+
- app/components/mods_display/field_component.rb
|
182
|
+
- app/components/mods_display/list_field_component.html.erb
|
183
|
+
- app/components/mods_display/list_field_component.rb
|
184
|
+
- app/components/mods_display/record_component.html.erb
|
185
|
+
- app/components/mods_display/record_component.rb
|
186
|
+
- app/helpers/mods_display/record_helper.rb
|
187
|
+
- app/models/mods_display/record.rb
|
188
|
+
- config.ru
|
154
189
|
- config/locales/en.yml
|
155
190
|
- lib/mods_display.rb
|
156
|
-
- lib/mods_display/configuration.rb
|
157
|
-
- lib/mods_display/configuration/access_condition.rb
|
158
|
-
- lib/mods_display/configuration/base.rb
|
159
|
-
- lib/mods_display/configuration/genre.rb
|
160
|
-
- lib/mods_display/configuration/imprint.rb
|
161
|
-
- lib/mods_display/configuration/name.rb
|
162
|
-
- lib/mods_display/configuration/note.rb
|
163
|
-
- lib/mods_display/configuration/related_item.rb
|
164
|
-
- lib/mods_display/configuration/subject.rb
|
165
|
-
- lib/mods_display/configuration/title.rb
|
166
|
-
- lib/mods_display/controller_extension.rb
|
167
191
|
- lib/mods_display/country_codes.rb
|
192
|
+
- lib/mods_display/engine.rb
|
168
193
|
- lib/mods_display/fields/abstract.rb
|
169
194
|
- lib/mods_display/fields/access_condition.rb
|
170
195
|
- lib/mods_display/fields/audience.rb
|
@@ -191,55 +216,11 @@ files:
|
|
191
216
|
- lib/mods_display/fields/subject.rb
|
192
217
|
- lib/mods_display/fields/title.rb
|
193
218
|
- lib/mods_display/fields/values.rb
|
194
|
-
- lib/mods_display/helpers/record_helper.rb
|
195
219
|
- lib/mods_display/html.rb
|
196
|
-
- lib/mods_display/model_extension.rb
|
197
|
-
- lib/mods_display/railtie.rb
|
198
220
|
- lib/mods_display/related_item_concerns.rb
|
199
221
|
- lib/mods_display/relator_codes.rb
|
200
222
|
- lib/mods_display/version.rb
|
201
223
|
- mods_display.gemspec
|
202
|
-
- spec/configuration/access_condition_spec.rb
|
203
|
-
- spec/configuration/base_spec.rb
|
204
|
-
- spec/fake_app.rb
|
205
|
-
- spec/fields/abstract_spec.rb
|
206
|
-
- spec/fields/access_condition_spec.rb
|
207
|
-
- spec/fields/audience_spec.rb
|
208
|
-
- spec/fields/cartographics_spec.rb
|
209
|
-
- spec/fields/collection_spec.rb
|
210
|
-
- spec/fields/contact_spec.rb
|
211
|
-
- spec/fields/contents_spec.rb
|
212
|
-
- spec/fields/description_spec.rb
|
213
|
-
- spec/fields/extent_spec.rb
|
214
|
-
- spec/fields/form_spec.rb
|
215
|
-
- spec/fields/genre_spec.rb
|
216
|
-
- spec/fields/geo_spec.rb
|
217
|
-
- spec/fields/identifier_spec.rb
|
218
|
-
- spec/fields/imprint_spec.rb
|
219
|
-
- spec/fields/language_spec.rb
|
220
|
-
- spec/fields/location_spec.rb
|
221
|
-
- spec/fields/name_spec.rb
|
222
|
-
- spec/fields/nested_related_item_spec.rb
|
223
|
-
- spec/fields/note_spec.rb
|
224
|
-
- spec/fields/related_item_spec.rb
|
225
|
-
- spec/fields/resource_type_spec.rb
|
226
|
-
- spec/fields/sub_title_spec.rb
|
227
|
-
- spec/fields/subject_spec.rb
|
228
|
-
- spec/fields/title_spec.rb
|
229
|
-
- spec/fixtures/access_condition_fixtures.rb
|
230
|
-
- spec/fixtures/cartographics_fixtures.rb
|
231
|
-
- spec/fixtures/imprint_fixtures.rb
|
232
|
-
- spec/fixtures/name_fixtures.rb
|
233
|
-
- spec/fixtures/nested_realted_items_fixtures.rb
|
234
|
-
- spec/fixtures/related_item_fixtures.rb
|
235
|
-
- spec/fixtures/subjects_fixtures.rb
|
236
|
-
- spec/fixtures/title_fixtures.rb
|
237
|
-
- spec/helpers/record_helper_spec.rb
|
238
|
-
- spec/integration/configuration_spec.rb
|
239
|
-
- spec/integration/html_spec.rb
|
240
|
-
- spec/integration/installation_spec.rb
|
241
|
-
- spec/spec_helper.rb
|
242
|
-
- spec/test_fr.yml
|
243
224
|
homepage: https://github.com/sul-dlss/mods_display
|
244
225
|
licenses: []
|
245
226
|
metadata: {}
|
@@ -254,55 +235,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
254
235
|
version: '0'
|
255
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
237
|
requirements:
|
257
|
-
- - "
|
238
|
+
- - ">"
|
258
239
|
- !ruby/object:Gem::Version
|
259
|
-
version:
|
240
|
+
version: 1.3.1
|
260
241
|
requirements: []
|
261
|
-
rubygems_version: 3.2.
|
242
|
+
rubygems_version: 3.2.32
|
262
243
|
signing_key:
|
263
244
|
specification_version: 4
|
264
245
|
summary: The MODS Display gem allows implementers to configure a customized display
|
265
246
|
of MODS metadata. This display implements the specifications defined at Stanford
|
266
247
|
for how to display MODS.
|
267
|
-
test_files:
|
268
|
-
- spec/configuration/access_condition_spec.rb
|
269
|
-
- spec/configuration/base_spec.rb
|
270
|
-
- spec/fake_app.rb
|
271
|
-
- spec/fields/abstract_spec.rb
|
272
|
-
- spec/fields/access_condition_spec.rb
|
273
|
-
- spec/fields/audience_spec.rb
|
274
|
-
- spec/fields/cartographics_spec.rb
|
275
|
-
- spec/fields/collection_spec.rb
|
276
|
-
- spec/fields/contact_spec.rb
|
277
|
-
- spec/fields/contents_spec.rb
|
278
|
-
- spec/fields/description_spec.rb
|
279
|
-
- spec/fields/extent_spec.rb
|
280
|
-
- spec/fields/form_spec.rb
|
281
|
-
- spec/fields/genre_spec.rb
|
282
|
-
- spec/fields/geo_spec.rb
|
283
|
-
- spec/fields/identifier_spec.rb
|
284
|
-
- spec/fields/imprint_spec.rb
|
285
|
-
- spec/fields/language_spec.rb
|
286
|
-
- spec/fields/location_spec.rb
|
287
|
-
- spec/fields/name_spec.rb
|
288
|
-
- spec/fields/nested_related_item_spec.rb
|
289
|
-
- spec/fields/note_spec.rb
|
290
|
-
- spec/fields/related_item_spec.rb
|
291
|
-
- spec/fields/resource_type_spec.rb
|
292
|
-
- spec/fields/sub_title_spec.rb
|
293
|
-
- spec/fields/subject_spec.rb
|
294
|
-
- spec/fields/title_spec.rb
|
295
|
-
- spec/fixtures/access_condition_fixtures.rb
|
296
|
-
- spec/fixtures/cartographics_fixtures.rb
|
297
|
-
- spec/fixtures/imprint_fixtures.rb
|
298
|
-
- spec/fixtures/name_fixtures.rb
|
299
|
-
- spec/fixtures/nested_realted_items_fixtures.rb
|
300
|
-
- spec/fixtures/related_item_fixtures.rb
|
301
|
-
- spec/fixtures/subjects_fixtures.rb
|
302
|
-
- spec/fixtures/title_fixtures.rb
|
303
|
-
- spec/helpers/record_helper_spec.rb
|
304
|
-
- spec/integration/configuration_spec.rb
|
305
|
-
- spec/integration/html_spec.rb
|
306
|
-
- spec/integration/installation_spec.rb
|
307
|
-
- spec/spec_helper.rb
|
308
|
-
- spec/test_fr.yml
|
248
|
+
test_files: []
|
data/.github/workflows/ruby.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
name: CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
tests:
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
strategy:
|
13
|
-
matrix:
|
14
|
-
ruby: [2.6, 2.7, 3.0]
|
15
|
-
steps:
|
16
|
-
- uses: actions/checkout@v2
|
17
|
-
- name: Set up Ruby
|
18
|
-
uses: ruby/setup-ruby@v1
|
19
|
-
with:
|
20
|
-
ruby-version: ${{ matrix.ruby }}
|
21
|
-
- name: Install dependencies
|
22
|
-
run: bundle install
|
23
|
-
- name: Run tests
|
24
|
-
run: bundle exec rake
|
data/.gitignore
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.rvmrc
|
4
|
-
.ruby-version
|
5
|
-
.ruby-gemset
|
6
|
-
.bundle
|
7
|
-
.config
|
8
|
-
.yardoc
|
9
|
-
.rvmrc
|
10
|
-
Gemfile.lock
|
11
|
-
InstalledFiles
|
12
|
-
_yardoc
|
13
|
-
coverage
|
14
|
-
doc/
|
15
|
-
lib/bundler/man
|
16
|
-
pkg
|
17
|
-
rdoc
|
18
|
-
spec/reports
|
19
|
-
test/tmp
|
20
|
-
test/version_tmp
|
21
|
-
tmp
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
class Configuration
|
3
|
-
class AccessCondition < Base
|
4
|
-
def delimiter(delimiter = '<br/>')
|
5
|
-
@delimiter ||= delimiter
|
6
|
-
end
|
7
|
-
|
8
|
-
def ignore?
|
9
|
-
@ignore.nil? ? true : @ignore
|
10
|
-
end
|
11
|
-
|
12
|
-
def display!
|
13
|
-
@ignore = false
|
14
|
-
end
|
15
|
-
|
16
|
-
def cc_license_version(cc_license_version = '3.0')
|
17
|
-
@cc_license_version ||= cc_license_version
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
class Configuration
|
3
|
-
class Base
|
4
|
-
def initialize(&config)
|
5
|
-
instance_eval(&config) if block_given?
|
6
|
-
end
|
7
|
-
|
8
|
-
def label_class(label_class = '')
|
9
|
-
@label_class ||= label_class
|
10
|
-
end
|
11
|
-
|
12
|
-
def value_class(value_class = '')
|
13
|
-
@value_class ||= value_class
|
14
|
-
end
|
15
|
-
|
16
|
-
def delimiter(delimiter = ', ')
|
17
|
-
@delimiter ||= delimiter
|
18
|
-
end
|
19
|
-
|
20
|
-
def link(method_name = '', args = {})
|
21
|
-
return @link if method_name == ''
|
22
|
-
@link ||= [method_name, args]
|
23
|
-
end
|
24
|
-
|
25
|
-
def ignore!
|
26
|
-
@ignore = true
|
27
|
-
end
|
28
|
-
|
29
|
-
def ignore?
|
30
|
-
@ignore || false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
class Configuration
|
3
|
-
class Imprint < Base
|
4
|
-
def full_date_format(full_date_format = '%B %d, %Y')
|
5
|
-
@full_date_format ||= full_date_format
|
6
|
-
end
|
7
|
-
|
8
|
-
def short_date_format(short_date_format = '%B %Y')
|
9
|
-
@short_date_format ||= short_date_format
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
class Configuration
|
3
|
-
class Subject < Base
|
4
|
-
def hierarchical_link(hierarchical_link = false)
|
5
|
-
@hierarchical_link ||= hierarchical_link
|
6
|
-
end
|
7
|
-
|
8
|
-
def delimiter(delimiter = ' > ')
|
9
|
-
@delimiter ||= delimiter
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# We can probably do something smarter here using const_get to assign
|
2
|
-
# special coniguration classes then fall back on the base config class
|
3
|
-
module ModsDisplay
|
4
|
-
class Configuration
|
5
|
-
def initialize(&config)
|
6
|
-
instance_eval(&config)
|
7
|
-
end
|
8
|
-
|
9
|
-
def title(&title)
|
10
|
-
@title ||= ModsDisplay::Configuration::Title.new(&title || proc {})
|
11
|
-
end
|
12
|
-
|
13
|
-
def sub_title(&sub_title)
|
14
|
-
@sub_title ||= ModsDisplay::Configuration::Title.new(&sub_title || proc {})
|
15
|
-
end
|
16
|
-
|
17
|
-
def name(&name)
|
18
|
-
@name ||= ModsDisplay::Configuration::Name.new(&name || proc {})
|
19
|
-
end
|
20
|
-
|
21
|
-
def resource_type(&resource_type)
|
22
|
-
@type_of_resource ||= ModsDisplay::Configuration::Base.new(&resource_type || proc {})
|
23
|
-
end
|
24
|
-
|
25
|
-
def genre(&genre)
|
26
|
-
@genre ||= ModsDisplay::Configuration::Genre.new(&genre || proc {})
|
27
|
-
end
|
28
|
-
|
29
|
-
def imprint(&imprint)
|
30
|
-
@imprint ||= ModsDisplay::Configuration::Imprint.new(&imprint || proc {})
|
31
|
-
end
|
32
|
-
|
33
|
-
def language(&language)
|
34
|
-
@language ||= ModsDisplay::Configuration::Base.new(&language || proc {})
|
35
|
-
end
|
36
|
-
|
37
|
-
def description(&description)
|
38
|
-
@description ||= ModsDisplay::Configuration::Base.new(&description || proc {})
|
39
|
-
end
|
40
|
-
|
41
|
-
def cartographics(&cartographics)
|
42
|
-
@cartographics ||= ModsDisplay::Configuration::Base.new(&cartographics || proc {})
|
43
|
-
end
|
44
|
-
|
45
|
-
def abstract(&abstract)
|
46
|
-
@abstract ||= ModsDisplay::Configuration::Base.new(&abstract || proc {})
|
47
|
-
end
|
48
|
-
|
49
|
-
def contents(&contents)
|
50
|
-
@contents ||= ModsDisplay::Configuration::Base.new(&contents || proc {})
|
51
|
-
end
|
52
|
-
|
53
|
-
def audience(&audience)
|
54
|
-
@audience ||= ModsDisplay::Configuration::Base.new(&audience || proc {})
|
55
|
-
end
|
56
|
-
|
57
|
-
def note(¬e)
|
58
|
-
@note ||= ModsDisplay::Configuration::Note.new(¬e || proc {})
|
59
|
-
end
|
60
|
-
|
61
|
-
def contact(&contact)
|
62
|
-
@contact ||= ModsDisplay::Configuration::Base.new(&contact || proc {})
|
63
|
-
end
|
64
|
-
|
65
|
-
def collection(&collection)
|
66
|
-
@collection ||= ModsDisplay::Configuration::Base.new(&collection || proc {})
|
67
|
-
end
|
68
|
-
|
69
|
-
def related_item(&related_item)
|
70
|
-
@related_item ||= ModsDisplay::Configuration::RelatedItem.new(&related_item || proc {})
|
71
|
-
end
|
72
|
-
|
73
|
-
def nested_related_item(&nested_related_item)
|
74
|
-
@nested_related_item ||= ModsDisplay::Configuration::Base.new(&nested_related_item || proc {})
|
75
|
-
end
|
76
|
-
|
77
|
-
def subject(&subject)
|
78
|
-
@subject ||= ModsDisplay::Configuration::Subject.new(&subject || proc {})
|
79
|
-
end
|
80
|
-
|
81
|
-
def identifier(&identifier)
|
82
|
-
@identifier ||= ModsDisplay::Configuration::Base.new(&identifier || proc {})
|
83
|
-
end
|
84
|
-
|
85
|
-
def location(&location)
|
86
|
-
@location ||= ModsDisplay::Configuration::Base.new(&location || proc {})
|
87
|
-
end
|
88
|
-
|
89
|
-
def access_condition(&access_condition)
|
90
|
-
@access_condition ||= ModsDisplay::Configuration::AccessCondition.new(&access_condition || proc {})
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
module ControllerExtension
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
base.class_eval do
|
6
|
-
def mods_display_config
|
7
|
-
@mods_display_config || self.class.mods_display_config
|
8
|
-
end
|
9
|
-
if base.respond_to?(:helper_method)
|
10
|
-
helper_method :mods_display_config, :render_mods_display
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def render_mods_display(model)
|
16
|
-
return '' if model.mods_display_xml.nil?
|
17
|
-
ModsDisplay::HTML.new(mods_display_config, model.mods_display_xml, self)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
module ClassMethods
|
23
|
-
def configure_mods_display(&config)
|
24
|
-
@mods_display_config = ModsDisplay::Configuration.new(&config)
|
25
|
-
end
|
26
|
-
|
27
|
-
def mods_display_config
|
28
|
-
@mods_display_config || ModsDisplay::Configuration.new {}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ModsDisplay
|
4
|
-
module Helpers
|
5
|
-
module RecordHelper
|
6
|
-
def display_content_field(field)
|
7
|
-
return unless field.respond_to?(:label, :values) && field.values.any?(&:present?)
|
8
|
-
|
9
|
-
display_content_label(field.label) + display_content_values(field.values)
|
10
|
-
end
|
11
|
-
|
12
|
-
def display_content_label(label)
|
13
|
-
content_tag :dt, label
|
14
|
-
end
|
15
|
-
|
16
|
-
def display_content_values(values)
|
17
|
-
values.map do |value|
|
18
|
-
content_tag :dd, value
|
19
|
-
end.join('').html_safe
|
20
|
-
end
|
21
|
-
|
22
|
-
def mods_display_label(label)
|
23
|
-
content_tag(:dt, label.delete(':')) + "\n".html_safe
|
24
|
-
end
|
25
|
-
|
26
|
-
def mods_display_content(values, delimiter = nil)
|
27
|
-
if delimiter
|
28
|
-
content_tag(:dd, values.map do |value|
|
29
|
-
link_urls_and_email(value) if value.present?
|
30
|
-
end.compact.join(delimiter).html_safe)
|
31
|
-
else
|
32
|
-
Array[values].flatten.map do |value|
|
33
|
-
content_tag(:dd, link_urls_and_email(value.to_s).html_safe) if value.present?
|
34
|
-
end.join.html_safe
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def mods_record_field(field, delimiter = nil)
|
39
|
-
return unless field.respond_to?(:label, :values) && field.values.any?(&:present?)
|
40
|
-
|
41
|
-
mods_display_label(field.label) + mods_display_content(field.values, delimiter)
|
42
|
-
end
|
43
|
-
|
44
|
-
def mods_name_field(field, &block)
|
45
|
-
return unless field.respond_to?(:label, :values) && field.values.any?(&:present?)
|
46
|
-
|
47
|
-
mods_display_label(field.label) + mods_display_name(field.values, &block)
|
48
|
-
end
|
49
|
-
|
50
|
-
def mods_display_name(names, &block)
|
51
|
-
names.map do |name|
|
52
|
-
content_tag(:dd) do
|
53
|
-
block_given? ? yield(name.name) : name.name
|
54
|
-
end
|
55
|
-
end.join.html_safe
|
56
|
-
end
|
57
|
-
|
58
|
-
# We need this to remove the ending ":" from the role labels only in data from
|
59
|
-
# mods_display
|
60
|
-
def sanitize_mods_name_label(label)
|
61
|
-
label.sub(/:$/, '')
|
62
|
-
end
|
63
|
-
|
64
|
-
def mods_subject_field(subject, &block)
|
65
|
-
return unless subject.values.any?(&:present?)
|
66
|
-
|
67
|
-
fields = subject.values.map do |subject_line|
|
68
|
-
content_tag :dd, safe_join(link_mods_subjects(subject_line, &block), ' > ')
|
69
|
-
end
|
70
|
-
|
71
|
-
(mods_display_label(subject.label) + safe_join(fields))
|
72
|
-
end
|
73
|
-
|
74
|
-
def mods_genre_field(genre, &block)
|
75
|
-
return unless genre.values.any?(&:present?)
|
76
|
-
|
77
|
-
fields = genre.values.map do |genre_line|
|
78
|
-
content_tag :dd, link_mods_genres(genre_line, &block)
|
79
|
-
end
|
80
|
-
|
81
|
-
mods_display_label(genre.label) + safe_join(fields)
|
82
|
-
end
|
83
|
-
|
84
|
-
def link_mods_genres(genre, &block)
|
85
|
-
link_buffer = []
|
86
|
-
link_to_mods_subject(genre, link_buffer, &block)
|
87
|
-
end
|
88
|
-
|
89
|
-
def link_mods_subjects(subjects, &block)
|
90
|
-
link_buffer = []
|
91
|
-
linked_subjects = []
|
92
|
-
subjects.each do |subject|
|
93
|
-
if subject.present?
|
94
|
-
linked_subjects << link_to_mods_subject(subject, link_buffer, &block)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
linked_subjects
|
98
|
-
end
|
99
|
-
|
100
|
-
def link_to_mods_subject(subject, buffer, &block)
|
101
|
-
subject_text = subject.respond_to?(:name) ? subject.name : subject
|
102
|
-
link = block_given? ? yield(subject_text, buffer) : subject_text
|
103
|
-
buffer << subject_text.strip
|
104
|
-
link << " (#{subject.roles.join(', ')})" if subject.respond_to?(:roles) && subject.roles.present?
|
105
|
-
link
|
106
|
-
end
|
107
|
-
|
108
|
-
# rubocop:disable Layout/LineLength
|
109
|
-
def link_urls_and_email(val)
|
110
|
-
val = val.dup
|
111
|
-
# http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
112
|
-
url = %r{(?i)\b(?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\([^\s()<>]+|\([^\s()<>]+\)*\))+(?:\([^\s()<>]+|\([^\s()<>]+\)*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])}i
|
113
|
-
# http://www.regular-expressions.info/email.html
|
114
|
-
email = %r{[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b}i
|
115
|
-
matches = [val.scan(url), val.scan(email)].flatten.uniq
|
116
|
-
unless val =~ /<a/ # we'll assume that linking has alraedy occured and we don't want to double link
|
117
|
-
matches.each do |match|
|
118
|
-
if match =~ email
|
119
|
-
val.gsub!(match, "<a href='mailto:#{match}'>#{match}</a>")
|
120
|
-
else
|
121
|
-
val.gsub!(match, "<a href='#{match}'>#{match}</a>")
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
val
|
126
|
-
end
|
127
|
-
# rubocop:enable Layout/LineLength
|
128
|
-
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
module ModelExtension
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
base.class_eval do
|
6
|
-
def mods_display_xml
|
7
|
-
xml = self.class.mods_xml_source.call(self)
|
8
|
-
return if xml.nil?
|
9
|
-
mods = Stanford::Mods::Record.new
|
10
|
-
mods.from_str(xml, false)
|
11
|
-
mods
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module ClassMethods
|
17
|
-
def mods_xml_source(&xml)
|
18
|
-
@mods_xml_source ||= xml
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/mods_display/railtie.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ModsDisplay
|
4
|
-
class Railtie < ::Rails::Railtie
|
5
|
-
ActiveSupport.on_load :action_view do
|
6
|
-
require 'mods_display/helpers/record_helper'
|
7
|
-
::ActionView::Base.send :include, ModsDisplay::Helpers::RecordHelper
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|