relaton-render 0.4.1 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +6 -1
- data/lib/relaton/render/general/citations.rb +13 -7
- data/lib/relaton/render/general/config.yml +4 -4
- data/lib/relaton/render/parse/parse_contributors.rb +8 -5
- data/lib/relaton/render/parse/parse_extract.rb +3 -2
- data/lib/relaton/render/version.rb +1 -1
- data/relaton-render.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e355ba215a67c891399708f72baabeba37cddfc01a43df6d722c0a1aa769878
|
4
|
+
data.tar.gz: cdc21aa38ecdadab907db21b1b0cf58b8ce1f2ebc7966be7a894b4f58ffc3919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f52456f0d7708e911a731fb6f584aed61cced226ed4f7a5de54407b0563ccaa5e5d182472cc0d01d2a59e13d1955910b8cfed1fd601d79ac88745ec6cab45743
|
7
|
+
data.tar.gz: aeb47b97f4146f90bdc86a3e2b5637e35675c67e37bb79b49010a450d34adcfb5c2792b3334ecedf8ff2749bc3511afaeb42442cf35eb8ef840f56d2599f654c
|
data/README.adoc
CHANGED
@@ -191,6 +191,7 @@ The Liquid template surrounds each field by preceding and following punctuation.
|
|
191
191
|
* Underscore is escaped by \. So `<span_class="std\_note">` maps to `<span class="std_note">`.
|
192
192
|
* If punctuation is space delimited, it is inserted regardless of preceding content. So `{{ creatornames }} ({{date}}) .` will insert the full stop whether or not the date is present.
|
193
193
|
* Space between punctuation and before punctuation is automatically removed.
|
194
|
+
* Spaces within fields are globally converted to underscores. For that reason, any filter operations in Liquid need to refer to underscore instead of space.
|
194
195
|
|
195
196
|
For example:
|
196
197
|
|
@@ -218,7 +219,7 @@ draws on the following fields drawn from the bibliographic item:
|
|
218
219
|
| surname[0] | ./contributor[1]/person/name/surname \| ./contributor[1]/person/name/completename | | i.e. surname is the name default
|
219
220
|
| surname[1] | ./contributor[2]/name/surname | |
|
220
221
|
| surname[2] | ./contributor[3]/name/surname | |
|
221
|
-
| initials[0] | ./contributor[1]/name/initial | | If not supplied, the first letter of each given name is used instead
|
222
|
+
| initials[0] | ./contributor[1]/name/formatted-initials \| ./contributor[1]/name/forename/@initial | | If not supplied, the first letter of each given name is used instead
|
222
223
|
| initials[1] | ./contributor[2]/name/initial | |
|
223
224
|
| given[0] | ./contributor[1]/name/forename[1] | | If not supplied, initials are used instead
|
224
225
|
| given[1] | ./contributor[2]/name/forename[1] | |
|
@@ -228,6 +229,10 @@ draws on the following fields drawn from the bibliographic item:
|
|
228
229
|
| nonpersonal[1] |./contributor[2]/organization/name | Y |
|
229
230
|
|===
|
230
231
|
|
232
|
+
The `formatted-initials` field is presumed to contain full stops, and so do the surrogates of that field done by using individual
|
233
|
+
forenames' `initial` attributes, or the forename initials. If the full stops are to be stripped, that needs to occur within the
|
234
|
+
Liquid template.
|
235
|
+
|
231
236
|
There are at least three distinct `nametemplate` instances that need to be provided, one for a single contributor (`one:`), one for two contributors (`two:`), one for three or more (`more:`), and optionally one for "et al." (`etal:`). The number of contributors for which "et al." starts being used is indicated by `etal_count`.
|
232
237
|
|
233
238
|
For example:
|
@@ -61,19 +61,25 @@ module Relaton
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def suffix_date(ret)
|
64
|
-
ret.
|
65
|
-
v.
|
66
|
-
next if v1.size < 2
|
64
|
+
ret.each do |k, v|
|
65
|
+
v.each do |k1, v1|
|
66
|
+
next if v1.reject { |b| b[:date].nil? }.size < 2
|
67
67
|
|
68
|
-
|
69
|
-
b[:date] += ("a".ord + i).chr.to_s
|
70
|
-
b[:data_liquid][:date] = b[:date]
|
71
|
-
end
|
68
|
+
suffix_date1(ret, k, k1)
|
72
69
|
end
|
73
70
|
end
|
74
71
|
ret
|
75
72
|
end
|
76
73
|
|
74
|
+
def suffix_date1(ret, key1, key2)
|
75
|
+
ret[key1][key2].each_with_index do |b, i|
|
76
|
+
next if b[:date].nil?
|
77
|
+
|
78
|
+
b[:date] += ("a".ord + i).chr.to_s
|
79
|
+
b[:data_liquid][:date] = b[:date]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
77
83
|
def to_hash(ret)
|
78
84
|
ret.each_with_object({}) do |(_k, v), m|
|
79
85
|
v.each do |_k1, v1|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
nametemplate:
|
2
|
-
one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase }} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: '
|
3
|
-
two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: '
|
4
|
-
more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: '
|
2
|
+
one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase }} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %}"
|
3
|
+
two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %} {{ labels['and'] }} {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{%if given[1]%}{{given[1]}} {{middle[1]}}{%else%}{{initials[1] | join: ' '}}.{%endif%} {{surname[1] | upcase}}{% endif %}"
|
4
|
+
more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{%if given[1]%}{{given[1]}} {{middle[1]}}{%else%}{{initials[1] | join: ' '}}.{%endif%} {{surname[1] | upcase}}{% endif %} {{ labels['and'] }} {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{%if given[2]%}{{given[2]}} {{middle[2]}}{%else%}{{initials[2] | join: ' '}}.{%endif%} {{surname[2] | upcase}}{% endif %}"
|
5
5
|
# disabled the following: they should be provided in inheriting calls
|
6
|
-
# etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: '
|
6
|
+
# etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] | upcase}} ,_{%if given[0]%}{{given[0]}} {{middle[0]}}{%else%}{{initials[0] | join: ' '}}.{%endif%}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{%if given[1]%}{{given[1]}} {{middle[1]}}{%else%}{{initials[1] | join: ' '}}.{%endif%} {{surname[1] | upcase}}{% endif %} <em>et al.</em>"
|
7
7
|
# etal_count: 5
|
8
8
|
authorcitetemplate:
|
9
9
|
one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %}"
|
@@ -15,12 +15,15 @@ module Relaton
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def given_and_middle_name(person)
|
18
|
-
forenames = person.name.forename.map
|
19
|
-
|
20
|
-
|
18
|
+
forenames = person.name.forename.map do |x|
|
19
|
+
x.content.empty? ? "#{x.initial}." : x.content
|
20
|
+
end
|
21
|
+
initials = person.name.initials&.content&.sub(/(.)\.?$/, "\\1.")
|
22
|
+
initials ||= person.name.forename.map(&:initial)
|
23
|
+
.compact.map { |x| x.sub(/(.)\.?$/, "\\1.") }
|
21
24
|
forenames.empty? and initials.empty? and return [nil, nil, nil]
|
22
|
-
initials.empty? and initials = forenames.map { |x| x[0] }
|
23
|
-
[forenames.first, forenames[1..-1], initials]
|
25
|
+
initials.empty? and initials = forenames.map { |x| "#{x[0]}." }
|
26
|
+
[forenames.first, forenames[1..-1], Array(initials)]
|
24
27
|
end
|
25
28
|
|
26
29
|
def extractname(contributor)
|
@@ -56,9 +56,10 @@ module Relaton
|
|
56
56
|
def series_title(series, _doc)
|
57
57
|
return nil if series.nil?
|
58
58
|
|
59
|
-
series.title.respond_to?(:titles) and
|
59
|
+
series.title.respond_to?(:titles) && !series.title.titles.empty? and
|
60
60
|
return series.title.titles.first.title.content
|
61
|
-
series.title
|
61
|
+
series.title.respond_to?(:title) and return series.title.title&.content
|
62
|
+
series.title.respond_to?(:formattedref) and series.formattedref.content
|
62
63
|
end
|
63
64
|
|
64
65
|
def series_formatted(series, _doc)
|
data/relaton-render.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "isodoc-i18n"
|
32
32
|
spec.add_dependency "liquid", "~> 4"
|
33
33
|
spec.add_dependency "nokogiri"
|
34
|
-
spec.add_dependency "relaton-bib", ">= 1.
|
34
|
+
spec.add_dependency "relaton-bib", ">= 1.13.0"
|
35
35
|
spec.add_dependency "twitter_cldr"
|
36
36
|
spec.add_dependency "tzinfo-data" # we need this for windows only
|
37
37
|
#spec.metadata["rubygems_mfa_required"] = "true"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
145
|
+
version: 1.13.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
152
|
+
version: 1.13.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: twitter_cldr
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|