relaton-render 0.10.2 → 1.0.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.
@@ -5,6 +5,7 @@ nametemplate:
5
5
  # disabled the following: they should be provided in inheriting calls
6
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
9
  authorcitetemplate:
9
10
  one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %}"
10
11
  two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %} {{ labels['author_and'] }} {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1] }}{% endif %}"
@@ -12,8 +13,10 @@ authorcitetemplate:
12
13
  # disabled the following: they should be provided in inheriting calls
13
14
  # etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1] }}{% endif %} <em>et al.</em>"
14
15
  # etal_count: 5
16
+
15
17
  seriestemplate: "{% if series_formatted %}{{ series_formatted }}{%else%}{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ({{series_run}}) {{series_num}}|({{series_partnumber}}){%endif%}"
16
18
  journaltemplate: "<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> ({{series_run}}) {{ labels['volume'] }}_{{series_num}} {{ labels['part'] }}_{{series_partnumber}}"
19
+
17
20
  extenttemplate:
18
21
  book: "{{ volume }}, {{ page }}"
19
22
  booklet: book
@@ -29,39 +32,85 @@ sizetemplate:
29
32
  electronic resource: dataset
30
33
  webresource: dataset
31
34
  misc: "{{ volume }}, {{ issue }}, {{ page }}, {{ data }}, {{ duration }}"
35
+
32
36
  language: en
33
37
  script: Latn
38
+
39
+ citetemplate:
40
+ author_date: "{{ author }} {{ date}}"
41
+ author_date_br: "{{ author }} ({{ date}})"
42
+ author: "{{ author }}"
43
+ date: "{{ date }}"
44
+ reference_tag: "{{ biblio_tag }}"
45
+ title: "{{ title }}"
46
+ title_reference_tag: "{{ title }} {{ biblio_tag }}"
47
+ short:
48
+ book: "{{ creatornames }} ({{role}}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ ({{ series }}$$$|) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{size}}$$$ {{extent}}$$$"
49
+ booklet: book
50
+ manual: book
51
+ proceedings: book
52
+ inbook: "{{ creatornames }} ({{role}}) $$$ {{labels['punct']['open-secondary-title']}}{{ title }}{{labels['punct']['close-secondary-title']}} $$$ {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role}}) : {{labels['punct']['open-title']}}{{host_title}}{{labels['punct']['close-title']}} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ ({{ series }}$$$|) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}$$$ {{date}}$$$ {{size}}$$$ {{extent}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$"
53
+ inproceedings: inbook
54
+ incollection: inbook
55
+ journal: "{{labels['punct']['open-title']}}{{ title}}{{labels['punct']['close-title']}} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ {{place}}: {{publisher}}$$$ {{date}}$$$ {{size}}$$$ {{extent}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$"
56
+ article: "{{ creatornames }} ({{role}}) $$$ {{labels['punct']['open-secondary-title']}}{{ title }}{{labels['punct']['close-secondary-title']}}$$$ {{ series }} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ {{size}}$$$ {{ extent }}$$$ {{place}}: {{publisher}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$"
57
+ software: "{{ creatornames }} ({{ role}}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ labels['version'] | capitalize }}_{{ edition_raw }}$$$ {{medium | capitalize}}$$$ {{place}}: {{publisher}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{size}}$$$ {{ extent}}$$$"
58
+ electronic resource: software
59
+ standard: "{{ creatornames }} ({{ role}}) $$$ {{ authoritative_identifier | join: '|' }}: {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ medium | capitalize }}$$$ {{ edition | capitalize_first }}$$$ {{ place }}: {{ publisher }}$$$ {{date}}$$$ {{size}}$$$ {{ extent }}$$$ {{ other_identifier | join: '$$$ ' }}"
60
+ techreport: standard
61
+ dataset: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ labels['version'] | capitalize }}_{{ edition_raw }}$$$ {{medium | capitalize }}$$$ {{ labels['in'] | capitalize }}:_{{series}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ size }}$$$ {{ extent}}$$$"
62
+ website: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ labels['version'] | capitalize }}_{{ edition_raw }}$$$ {{medium | capitalize }}$$$ {{ place }}: {{ publisher }}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$"
63
+ webresource: website
64
+ unpublished: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ medium | capitalize }}$$$ {{ date }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$"
65
+ thesis: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ medium | capitalize }}$$$ {{ place }}: {{ publisher }}$$$ {{ date }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$"
66
+ misc: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ date }}$$$"
67
+ map: misc
68
+ audiovisual: misc
69
+ film: misc
70
+ video: misc
71
+ broadcast: misc
72
+ graphic_work: misc
73
+ music: misc
74
+ performance: misc
75
+ patent: misc
76
+ archival: misc
77
+ social_media: misc
78
+ alert: misc
79
+ message: misc
80
+ conversation: misc
81
+ internal: misc
82
+
34
83
  template:
35
- book: "{{ creatornames }} ({{role}}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} [{{medium}}] . {{ edition | capitalize_first }}. ({{ series }}.) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]. {{size}}. {{extent}}."
84
+ book: "{{ creatornames }} ({{role}}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ ({{ series }}$$$|) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$ {{size}}$$$ {{extent}}$$$"
36
85
  # TODO: omitted: author ids, subsidiary titles, subsidiary creators, rights metadata, distributor, item attributes, relationships
37
86
  booklet: book
38
87
  manual: book
39
88
  proceedings: book
40
- inbook: "{{ creatornames }} ({{role}}) . {{labels['q-open']}}{{ title }}{{labels['q-close']}} . {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role}}) : {{labels['qq-open']}}{{host_title}}{{labels['qq-close']}} [{{medium}}] . {{ edition | capitalize_first }}. ({{ series }}.) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
89
+ inbook: "{{ creatornames }} ({{role}}) $$$ {{labels['punct']['open-secondary-title']}}{{ title }}{{labels['punct']['close-secondary-title']}} $$$ {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role}}) : {{labels['punct']['open-title']}}{{host_title}}{{labels['punct']['close-title']}} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ ({{ series }}$$$|) {% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}: {{publisher}}$$$ {{date}}$$$ {{size}}$$$ {{extent}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$"
41
90
  inproceedings: inbook
42
91
  incollection: inbook
43
92
  # TODO: omitted: author ids, additional info for component part, subsidiary titles of host resource, rights metadata, distributor, relationships
44
- journal: "{{labels['qq-open']}}{{ title}}{{labels['qq-close']}} [{{medium}}] . {{ edition | capitalize_first }}. {{place}}: {{publisher}}. {{date}}. {{size}}. {{extent}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
93
+ journal: "{{labels['punct']['open-title']}}{{ title}}{{labels['punct']['close-title']}} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ {{place}}: {{publisher}}$$$ {{date}}$$$ {{size}}$$$ {{extent}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$"
45
94
  # TODO subsidiary titles, rights metadata, item attributes, relationships
46
- article: "{{ creatornames }} ({{role}}) . {{labels['q-open']}}{{ title }}{{labels['q-close']}}. {{ series }} [{{medium}}] . {{ edition | capitalize_first }}. {{size}}. {{ extent }}. {{place}}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
95
+ article: "{{ creatornames }} ({{role}}) $$$ {{labels['punct']['open-secondary-title']}}{{ title }}{{labels['punct']['close-secondary-title']}}$$$ {{ series }} [{{medium}}] $$$ {{ edition | capitalize_first }}$$$ {{size}}$$$ {{ extent }}$$$ {{place}}: {{publisher}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$"
47
96
  # TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, item attributes, relationships; newspapers
48
- software: "{{ creatornames }} ({{ role}}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize}}. {{place}}: {{publisher}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{size}}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
97
+ software: "{{ creatornames }} ({{ role}}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ labels['version'] | capitalize }}_{{ edition_raw }}$$$ {{medium | capitalize}}$$$ {{place}}: {{publisher}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{size}}$$$ {{ extent}}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$ "
49
98
  # TODO: omitted: author ids, subsidiary titles, subsidiary creators, copyright, license, distributor, system requirements, relationships
50
99
  electronic resource: software
51
- standard: "{{ creatornames }} ({{ role}}) . {{ authoritative_identifier | join: '|' }}: {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ medium | capitalize }}. {{ edition | capitalize_first }}. {{ place }}: {{ publisher }}. {{date}}. {{size}}. {{ extent }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
100
+ standard: "{{ creatornames }} ({{ role}}) $$$ {{ authoritative_identifier | join: '|' }}: {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ medium | capitalize }}$$$ {{ edition | capitalize_first }}$$$ {{ place }}: {{ publisher }}$$$ {{date}}$$$ {{size}}$$$ {{ extent }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$"
52
101
  # TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, persistent identifier, item attributes, relationships
53
102
  techreport: standard
54
- dataset: "{{ creatornames }} ({{ role }}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ labels['in'] | capitalize }}:_{{series}}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. {{ size }}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
103
+ dataset: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ labels['version'] | capitalize }}_{{ edition_raw }}$$$ {{medium | capitalize }}$$$ {{ labels['in'] | capitalize }}:_{{series}}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ {{ size }}$$$ {{ extent}}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$ "
55
104
  # TODO: omitted: author ids, system requirements, host archive, copyright, license, data source, distributor, usage instructions, relationships, provenance
56
- website: "{{ creatornames }} ({{ role }}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ labels['version'] | capitalize }}_{{ edition_raw }}. {{medium | capitalize }}. {{ place }}: {{ publisher }}. {{date}}. {{ labels['updated'] | capitalize }}:_{{date_updated}}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
105
+ website: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ labels['version'] | capitalize }}_{{ edition_raw }}$$$ {{medium | capitalize }}$$$ {{ place }}: {{ publisher }}$$$ {{date}}$$$ {{ labels['updated'] | capitalize }}:_{{date_updated}}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$ "
57
106
  # TODO: omitted: author ids, page title, system requirements, subsidiary creator, rights metadata, distributor, persistent identifier, archive location, archive date and time, relationships
58
107
  webresource: website
59
108
  # TODO: component part
60
- unpublished: "{{ creatornames }} ({{ role }}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ medium | capitalize }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
109
+ unpublished: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ medium | capitalize }}$$$ {{ date }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$"
61
110
  # TODO: omitted: author ids, subsidiary titles, subsidiary creators, host archive, item attributes, relationships
62
111
  presentation: unpublished
63
- thesis: "{{ creatornames }} ({{ role }}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ medium | capitalize }}. {{ place }}: {{ publisher }}. {{ date }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. {{ authoritative_identifier | join: '. ' }}. {{ other_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
64
- misc: "{{ creatornames }} ({{ role }}) . {{labels['qq-open']}}{{ title }}{{labels['qq-close']}} . {{ date }}. {{ uri }}."
112
+ thesis: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ medium | capitalize }}$$$ {{ place }}: {{ publisher }}$$$ {{ date }}$$$ {{ labels['at'] | capitalize}}:_{{ access_location }}$$$ {{ authoritative_identifier | join: '$$$ ' }}$$$ {{ other_identifier | join: '$$$ ' }}$$$ {{ uri }}$$$ [{{ labels['viewed'] }}:_{{date_accessed}}]$$$"
113
+ misc: "{{ creatornames }} ({{ role }}) $$$ {{labels['punct']['open-title']}}{{ title }}{{labels['punct']['close-title']}} $$$ {{ date }}$$$ {{ uri }}$$$"
65
114
  # following are # unsupported types:
66
115
  map: misc
67
116
  audiovisual: misc
@@ -13,16 +13,21 @@ module Relaton
13
13
  class General
14
14
  attr_reader :template, :journaltemplate, :seriestemplate, :nametemplate,
15
15
  :authorcitetemplate, :extenttemplate, :sizetemplate,
16
- :lang, :script, :i18n,
17
- :edition, :edition_ordinal, :date, :fieldsklass, :dateklass
16
+ :citetemplate, :citeshorttemplate, :lang, :script, :i18n,
17
+ :edition, :date, :fieldsklass, :dateklass, :config
18
18
 
19
19
  def initialize(opt = {})
20
- options = read_config.merge(Utils::string_keys(opt))
20
+ @config = read_config
21
+ options = @config.merge(Utils::string_keys(opt))
21
22
  @type = self.class.name.downcase.split("::").last
22
23
  klass_initialize(options)
23
24
  root_initalize(options)
24
25
  render_initialize(options)
25
26
  @parse ||= options["parse"]
27
+ init_misc
28
+ end
29
+
30
+ def init_misc
26
31
  @semaphore = Mutex.new
27
32
  @urlcache = {}
28
33
  @url_warned = {}
@@ -32,9 +37,11 @@ module Relaton
32
37
  YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
33
38
  end
34
39
 
35
- def klass_initialize(_options)
40
+ def klass_initialize(options)
36
41
  @nametemplateklass = Relaton::Render::Template::Name
37
42
  @authorcitetemplateklass = Relaton::Render::Template::AuthorCite
43
+ @citetemplateklass = Relaton::Render::Template::Cite
44
+ @citeshorttemplateklass = Relaton::Render::Template::Cite
38
45
  @seriestemplateklass = Relaton::Render::Template::Series
39
46
  @extenttemplateklass = Relaton::Render::Template::Extent
40
47
  @sizetemplateklass = Relaton::Render::Template::Size
@@ -42,6 +49,7 @@ module Relaton
42
49
  @fieldsklass = Relaton::Render::Fields
43
50
  @dateklass = Relaton::Render::Date
44
51
  @parseklass = Relaton::Render::Parse
52
+ @i18nklass = options["i18nklass"] || Relaton::Render::I18n
45
53
  end
46
54
 
47
55
  def root_initalize(opt)
@@ -49,6 +57,7 @@ module Relaton
49
57
  @parse = @parseklass.new(lang: @lang, script: @script, i18n: @i18n)
50
58
  @nametemplate = @nametemplateklass
51
59
  .new(template: opt["nametemplate"], i18n: @i18n)
60
+ @citetemplate, @citeshorttemplate = citerenderers(opt)
52
61
  @authorcitetemplate = @authorcitetemplateklass
53
62
  &.new(template: opt["authorcitetemplate"], i18n: @i18n)
54
63
  @seriestemplate = @seriestemplateklass
@@ -63,12 +72,17 @@ module Relaton
63
72
  @lang = opt["language"]
64
73
  @script = opt["script"]
65
74
  @locale = opt["locale"]
66
- @i18n = opt["i18n"] ||
75
+ default_i18n = opt["i18n"] ||
67
76
  i18n_klass(language: @lang, script: @script, locale: @locale,
68
77
  i18nhash: opt["i18nhash"])
69
- @edition_ordinal = opt["edition_ordinal"] || @i18n.edition_ordinal
70
- @edition = opt["edition"] || @i18n.edition
71
- @date = opt["date"] || @i18n.get["date_formats"] ||
78
+ @i18n = @i18nklass.new(opt.merge({"i18n" => default_i18n}))
79
+ i18n_default_strs(opt)
80
+ end
81
+
82
+ # avoid using these, they are document-set not citation-specific
83
+ def i18n_default_strs(opt)
84
+ @edition = opt["edition"] || @i18n.select(nil).edition
85
+ @date = opt["date"] || @i18n.select(nil).get["date_formats"] ||
72
86
  { "month_year" => "yMMMM", "day_month_year" => "to_long_s",
73
87
  "date_time" => "to_long_s" }
74
88
  end
@@ -86,9 +100,9 @@ module Relaton
86
100
  def renderers(opt)
87
101
  template_hash_fill(opt["template"]).each_with_object({}) do |(k, v), m|
88
102
  @type == "general" || @type == k or next
89
- m[k] = General.subclass(k)
90
- .new(template: v, parse: @parse, i18n: @i18n,
91
- language: @lang, script: @script)
103
+ m[k] = self.class.subclass(k)
104
+ .new(template: v, parse: @parse, i18n_multi: @i18n.config,
105
+ language: @lang, script: @script, i18nklass: @i18nklass)
92
106
  end
93
107
  end
94
108
 
@@ -102,6 +116,16 @@ module Relaton
102
116
  .new(template: template_hash_fill(opt["sizetemplate"]), i18n: @i18n)
103
117
  end
104
118
 
119
+ def citerenderers(opt)
120
+ s = opt["citetemplate"]["short"]
121
+ r = opt["citetemplate"].reject { |k, _| k == "short" }
122
+ short = @citetemplateklass
123
+ &.new(template: template_hash_fill(s), i18n: @i18n)
124
+ ret = @citetemplateklass
125
+ &.new(template: r, i18n: @i18n)
126
+ [ret, short]
127
+ end
128
+
105
129
  def default_template
106
130
  "{{creatornames}}. {{title}}. {{date}}."
107
131
  end
@@ -111,18 +135,19 @@ module Relaton
111
135
  i18nhash: i18nhash)
112
136
  end
113
137
 
114
- def render(bib, embedded: false)
138
+ def render(bib, embedded: false, terminator: true)
115
139
  bib = xml2relaton(bib)
116
140
  f = bib.formattedref and
117
141
  return embedded ? f.content : fmtref(f.content)
118
- ret = render1(bib) or return nil
142
+ ret = render1(bib, terminator) or return nil
119
143
  embedded and return ret
120
144
  fmtref(ret)
121
145
  end
122
146
 
123
147
  def xml2relaton(bib)
124
148
  bib.is_a?(Nokogiri::XML::Element) and
125
- bib = bib.to_xml
149
+ bib = bib.to_xml(encoding: "UTF-8", indent: 0,
150
+ save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
126
151
  bib.is_a?(String) && Nokogiri::XML(bib).errors.empty? and
127
152
  bib = RelatonBib::XMLParser.from_xml(bib) or bib
128
153
  end
@@ -144,21 +169,33 @@ module Relaton
144
169
  text.gsub(/<esc>/i, "<esc>").gsub(/<\/esc>/i, "</esc>")
145
170
  end
146
171
 
147
- def render1(doc)
172
+ def render1(doc, terminator)
173
+ obj, str = render_single_bibitem(doc)
174
+ out = [str] + also_pub_as(doc)
175
+ ret1 = out.join(@i18n.select(obj).get["punct"]["biblio-field-delimiter"] || ". ")
176
+ ret = @i18n.select(obj).l10n(esc_cleanup(ret1)
177
+ .gsub(".</esc>.", ".</esc>").gsub(".. ", ". "))
178
+ final = @i18n.select(obj).get["punct"]["biblio-terminator"] || "."
179
+ terminator && !ret.end_with?(final) && !ret.empty? and ret += final
180
+ ret
181
+ end
182
+
183
+ def also_pub_as(doc)
148
184
  r = doc.relation.select { |x| x.type == "hasRepresentation" }
149
- .map { |x| @i18n.also_pub_as + render_single_bibitem(x.bibitem) }
150
- out = [render_single_bibitem(doc)] + r
151
- @i18n.l10n(esc_cleanup(out.join(". ")).gsub(".</esc>.", ".</esc>")
152
- .gsub(".. ", ". "))
185
+ r.map do |x|
186
+ _, out = render_single_bibitem(x.bibitem)
187
+ @i18n.select(nil).also_pub_as + out
188
+ end
153
189
  end
154
190
 
155
191
  def render_single_bibitem(doc)
156
192
  data_liquid, r = parse(doc)
157
- liquid(data_liquid, r)
193
+ out = liquid(data_liquid, r)
194
+ [data_liquid, out]
158
195
  end
159
196
 
160
197
  def liquid(data_liquid, renderer)
161
- valid_parse(renderer.render(data_liquid))
198
+ valid_parse(renderer.render(data_liquid, data_liquid))
162
199
  end
163
200
 
164
201
  def parse(doc)
@@ -172,7 +209,7 @@ module Relaton
172
209
  end
173
210
 
174
211
  def valid_parse(ret)
175
- @i18n.get["no_date"] == ret and return nil
212
+ @i18n.select(nil).get["no_date"] == ret and return nil
176
213
  ret
177
214
  end
178
215
 
@@ -180,10 +217,15 @@ module Relaton
180
217
  # enhance_data is skipped here, and is done in batch inside Citations
181
218
  def render_all(bib, type: "author-date")
182
219
  bib = sanitise_citations_input(bib) or return
183
- Citations.new(type: type, renderer: self, i18n: @i18n)
220
+ Citations.new(type: type, renderer: citation_renderers,
221
+ i18n: @i18n, lang: @lang, script: @script)
184
222
  .render(citations1(bib))
185
223
  end
186
224
 
225
+ def citation_renderers
226
+ { default: self }
227
+ end
228
+
187
229
  def sanitise_citations_input(bib)
188
230
  bib.is_a?(Array) and return bib
189
231
  bib.is_a?(String) and return sanitise_citations_input_string(bib)
@@ -202,7 +244,7 @@ module Relaton
202
244
  data_liquid = @fieldsklass.new(renderer: self)
203
245
  .compound_fields_format(@parse.extract(b))
204
246
  m << { author: data_liquid[:authorcite], date: data_liquid[:date],
205
- ord: i, id: b.id, data_liquid: data_liquid, type: b.type }
247
+ ord: i, id: b.id, data: data_liquid, type: b.type }
206
248
  end
207
249
  end
208
250
 
@@ -17,7 +17,10 @@ module Relaton
17
17
  end
18
18
 
19
19
  def self.subclass(type)
20
- @descendants[type]
20
+ # Always look up from the root General class, not from subclasses
21
+ base = self
22
+ base = base.superclass while base.superclass != Object && base.superclass.name =~ /Relaton::Render/
23
+ base.instance_variable_get(:@descendants)&.[](type)
21
24
  end
22
25
  end
23
26
 
@@ -0,0 +1,40 @@
1
+ module Relaton
2
+ module Render
3
+ class I18n
4
+ # @i18n is a hash of IsoDoc::I18n objects, selected from according to
5
+ # attributes of the parsed Relaton object
6
+ def initialize(opt)
7
+ if opt["i18n_multi"]
8
+ @i18n = opt["i18n_multi"]
9
+ elsif opt["i18n"]
10
+ @i18n = { "" => opt["i18n"] }
11
+ else
12
+ raise error "Bad configuration, Relaton::Render::I18n"
13
+ end
14
+ end
15
+
16
+ # obj is the biblio hash, extracted by Relaton::Render::Fields
17
+ # There must always be a default selection, for obj = nil,
18
+ # being the document language setting. If select is applied on obj,
19
+ # the i18n selected is appropriate to the citation specifically,
20
+ # and potentially to the field specificaly
21
+ def select(obj)
22
+ if obj.nil? then select_default
23
+ else select_obj(obj)
24
+ end
25
+ end
26
+
27
+ def select_default
28
+ @i18n[""]
29
+ end
30
+
31
+ def select_obj(_obj)
32
+ @i18n[""]
33
+ end
34
+
35
+ def config
36
+ @i18n
37
+ end
38
+ end
39
+ end
40
+ end
@@ -15,9 +15,11 @@ module Relaton
15
15
 
16
16
  def extract(doc)
17
17
  host = host(doc)
18
- simple_xml2hash(doc).merge(simple_or_host_xml2hash(doc, host))
18
+ ret = simple_xml2hash(doc).merge(simple_or_host_xml2hash(doc, host))
19
19
  .merge(host_xml2hash(host))
20
20
  .merge(series_xml2hash(doc, host))
21
+ ret
22
+ #i18n(ret)
21
23
  end
22
24
 
23
25
  def simple_xml2hash(doc)
@@ -25,8 +27,9 @@ module Relaton
25
27
  { type: type(doc), title: title(doc), extent_raw: extent(doc),
26
28
  size_raw: size(doc), uri_raw: uri(doc), doi: doi(doc),
27
29
  authoritative_identifier: authoritative_identifier(doc),
28
- other_identifier: other_identifier(doc),
29
- status: status(doc), creators: creators, role_raw: role }
30
+ other_identifier_raw: other_identifier(doc), biblio_tag: biblio_tag(doc),
31
+ status_raw: status(doc), creators: creators, role_raw: role,
32
+ language: language(doc), script: script(doc), locale: locale(doc) }
30
33
  end
31
34
 
32
35
  def simple_or_host_xml2hash(doc, host)
@@ -54,17 +57,29 @@ module Relaton
54
57
  end
55
58
 
56
59
  def series_xml2hash1(series, doc)
57
- return {} unless series
60
+ series or return {}
61
+ ret = { series_formatted: series_formatted(series, doc),
62
+ series_title: series_title(series, doc),
63
+ series_abbr: series_abbr(series, doc),
64
+ series_run: series_run(series, doc),
65
+ series_num: series_num(series, doc),
66
+ series_partnumber: series_partnumber(series, doc),
67
+ series_place: series_place(series, doc),
68
+ series_org: series_org(series, doc),
69
+ series_dates: series_dates(series, doc) }
70
+ ret.each do |k, v|
71
+ %i(series_num series_dates).include?(k) and next
72
+ ret[k] = esc(v)
73
+ end
74
+ ret
75
+ end
58
76
 
59
- { series_formatted: series_formatted(series, doc),
60
- series_title: series_title(series, doc),
61
- series_abbr: series_abbr(series, doc),
62
- series_run: series_run(series, doc),
63
- series_num: series_num(series, doc),
64
- series_partnumber: series_partnumber(series, doc),
65
- series_place: series_place(series, doc),
66
- series_org: series_org(series, doc),
67
- series_dates: series_dates(series, doc) }
77
+ #KILL
78
+ def other_identifier_i18n(hash)
79
+ #ret << "#{type}: #{esc id.id}"
80
+ hash[:other_identifier]&.map! do |i|
81
+ i.include?("<esc>") ? @i18n.select(hash).l10n(i) : i
82
+ end
68
83
  end
69
84
 
70
85
  private
@@ -72,6 +87,19 @@ module Relaton
72
87
  def blank?(text)
73
88
  text.nil? || text.empty?
74
89
  end
90
+
91
+ def esc(text)
92
+ blank?(text) and return text
93
+ "<esc>#{text}</esc>"
94
+ end
95
+
96
+ def wrap_in_esc(obj)
97
+ case obj
98
+ when String then esc(obj)
99
+ when Array then obj.map { |e| wrap_in_esc(e) }
100
+ else obj
101
+ end
102
+ end
75
103
  end
76
104
  end
77
105
  end
@@ -4,8 +4,10 @@ module Relaton
4
4
  def content(node)
5
5
  node.nil? and return node
6
6
  node.content.is_a?(Array) and return node.content.map { |x| content(x) }
7
- node.content.strip
7
+ ret = node.content.strip
8
8
  .gsub("</title>", "").gsub("<title>", "")
9
+ # safeguard against indented XML
10
+ ret.gsub(/>\n\s*</, "><").gsub(/\n\s*/, " ")
9
11
  # node.children.map { |n| n.text? ? n.content : n.to_xml }.join
10
12
  # node.text? ? node.content.strip : node.to_xml.strip
11
13
  end
@@ -32,14 +34,6 @@ module Relaton
32
34
  wrap_in_esc(Array(initials))]
33
35
  end
34
36
 
35
- def wrap_in_esc(obj)
36
- case obj
37
- when String then "<esc>#{obj}</esc>"
38
- when Array then obj.map { |e| wrap_in_esc(e) }
39
- else obj
40
- end
41
- end
42
-
43
37
  def extract_initials(person)
44
38
  initials = content(person.name.initials)&.sub(/(.)\.?$/, "\\1.")
45
39
  &.split /(?<=\.) /
@@ -50,7 +44,7 @@ module Relaton
50
44
 
51
45
  def forenames_parse(person)
52
46
  person.name.forename.map do |x|
53
- x.content.empty? ? "<esc>#{x.initial}.</esc>" : content(x)
47
+ x.content.empty? ? esc("#{x.initial}.") : content(x)
54
48
  end
55
49
  end
56
50
 
@@ -12,7 +12,8 @@ module Relaton
12
12
  t.empty? and t = doc.title
13
13
  t1 = t.select { |x| x.type == "main" }
14
14
  t1.empty? and t1 = t
15
- content(t1.first&.title)
15
+ t1.first or return
16
+ esc(content(t1.first.title))
16
17
  end
17
18
 
18
19
  def medium(doc, host)
@@ -31,7 +32,9 @@ module Relaton
31
32
  end
32
33
 
33
34
  def edition(doc, host)
34
- content(doc.edition || host&.edition)
35
+ ret = content(doc.edition || host&.edition)
36
+ ret &&= esc(ret)
37
+ ret
35
38
  end
36
39
 
37
40
  def edition_num(doc, host)
@@ -51,7 +54,8 @@ module Relaton
51
54
  n = place.country
52
55
  c.nil? && r.empty? && n.empty? and return place.name
53
56
  ret = [c] + r.map(&:name) + n.map(&:name)
54
- @i18n.l10n(ret.compact.join(", "))
57
+ ret.compact
58
+ #@i18n.l10n(ret.compact.join(", "))
55
59
  end
56
60
 
57
61
  def series(doc)
@@ -121,6 +125,19 @@ module Relaton
121
125
  "book"
122
126
  end
123
127
 
128
+ def language(doc)
129
+ doc.language&.first || @lang
130
+ end
131
+
132
+ def script(doc)
133
+ doc.script&.first || @script
134
+ end
135
+
136
+ def locale(doc)
137
+ # TODO not yet implemented in relaton-bib
138
+ # doc.locale&.first
139
+ end
140
+
124
141
  def extent1(localities)
125
142
  localities.each_with_object({}) do |l, ret|
126
143
  ret[(l.type || "page").to_sym] = {
@@ -168,7 +185,7 @@ module Relaton
168
185
 
169
186
  def status(doc)
170
187
  v = doc&.status&.stage&.value
171
- @i18n.get.dig("stage", v) || v
188
+ #@i18n.get.dig("stage", v) || v
172
189
  end
173
190
  end
174
191
  end
@@ -49,7 +49,7 @@ module Relaton
49
49
  out.empty? or break
50
50
  end
51
51
  # prevent l10n of identifier contents
52
- out.map(&:id).map { |i| "<esc>#{i.strip}</esc>" }
52
+ out.map(&:id).map { |i| esc(i.strip) }
53
53
  end
54
54
 
55
55
  def authoritative_identifier_select(idents)
@@ -65,14 +65,14 @@ module Relaton
65
65
  end
66
66
 
67
67
  def authoritative_identifier_exclude
68
- %w(METANORMA METANORMA-ORDINAL TITLE) + other_identifier_include
68
+ %w(METANORMA METANORMA-ORDINAL TITLE URN ISO-REFERENCE) + other_identifier_include
69
69
  end
70
70
 
71
71
  def other_identifier(doc)
72
72
  doc.docidentifier.each_with_object([]) do |id, ret|
73
73
  type = id_type_norm(id)
74
74
  other_identifier_include.include? type or next
75
- ret << @i18n.l10n("#{type}: <esc>#{id.id}</esc>")
75
+ ret << [type, id.id]
76
76
  end
77
77
  end
78
78
 
@@ -86,7 +86,7 @@ module Relaton
86
86
  type.casecmp("doi").zero? or next
87
87
  ret << id.id
88
88
  end
89
- out.empty? ? nil : out.map { |i| "<esc>#{i.strip}</esc>" }
89
+ out.empty? ? nil : out.map { |i| esc(i.strip) }
90
90
  end
91
91
 
92
92
  def id_type_norm(id)
@@ -95,6 +95,13 @@ module Relaton
95
95
  m[1].upcase
96
96
  end
97
97
 
98
+ def biblio_tag(doc)
99
+ ret = doc.docidentifier.detect do |id|
100
+ id.scope&.downcase == "biblio-tag"
101
+ end
102
+ ret&.id
103
+ end
104
+
98
105
  def uri(doc)
99
106
  uri = nil
100
107
  %w(citation uri src).each do |t|