diff --git a/_includes/localized-concept.html b/_includes/localized-concept.html index 030525c..0f08abc 100644 --- a/_includes/localized-concept.html +++ b/_includes/localized-concept.html @@ -3,6 +3,7 @@ {%- assign term_status = english.entry_status -%} {%- assign classification = english.terms.first.normative_status -%} {%- assign english_authoritative_source = english.sources | get_authoritative -%} +{%- assign english_authoritative_sources = english.sources | get_all_authoritative_sources -%} {%- assign localized_authoritative_source = localized_term.sources | get_authoritative -%}
Translated term missing in this language.

{% if lang == "eng" %} [SOURCE: - {% for source in english.sources %} + {% for source in english_authoritative_sources %} {{ source | display_authoritative_source }}{% unless forloop.last %};{% endunless %} {%- endfor -%} ] diff --git a/lib/jekyll/geolexica/filters.rb b/lib/jekyll/geolexica/filters.rb index af9148f..53bdbfe 100644 --- a/lib/jekyll/geolexica/filters.rb +++ b/lib/jekyll/geolexica/filters.rb @@ -204,6 +204,10 @@ def deprecated?(term) def get_authoritative(sources) sources&.find { |source| source["type"] == "authoritative" } end + + def get_all_authoritative_sources(sources) + sources&.select { |source| source["type"] == "authoritative" } + end end end end diff --git a/spec/unit/jekyll/geolexica/filters_spec.rb b/spec/unit/jekyll/geolexica/filters_spec.rb index 83b4239..6b004ae 100644 --- a/spec/unit/jekyll/geolexica/filters_spec.rb +++ b/spec/unit/jekyll/geolexica/filters_spec.rb @@ -184,6 +184,33 @@ def wrapper.escape_once(str); "!#{str}!"; end end end + describe "#get_all_authoritative_sources" do + subject { wrapper.method(:get_all_authoritative_sources) } + + it "returns all authoritative sources if available in given sources" do + sources = [ + { "type" => "authoritative" }, + { "type" => "authoritative" }, + { "type" => "authoritative" }, + { "type" => "lineage" }, + ] + + expect(subject.call(sources)).to eq(sources[0..-2]) + end + + it "returns empty array if authoritative source is not in given sources" do + sources = [ + { "type" => "lineage" }, + ] + + expect(subject.call(sources)).to eq([]) + end + + it "returns nil if given sources are nil" do + expect(subject.call(nil)).to eq(nil) + end + end + describe "with term" do let(:term) do {