From 52360a07bbb9f1bbf947f1627dca1ae50a7b297c Mon Sep 17 00:00:00 2001 From: "Luis M. Rodriguez-R" Date: Sun, 28 Jul 2024 18:22:56 +0200 Subject: [PATCH] Add citations to wikispecies --- app/models/publication.rb | 21 +++++++++++++++---- .../names/wiki/_wikispecies_page.html.erb | 5 +++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/models/publication.rb b/app/models/publication.rb index c3e14ba..839948a 100644 --- a/app/models/publication.rb +++ b/app/models/publication.rb @@ -210,11 +210,24 @@ def journal_html ERB::Util.h(journal || '[%s]' % pub_type.tr('-', ' ')) end + def long_citation(format = :text) + case format.to_sym + when :html + <<~HTML.html_safe + #{authors_et_al(format)} (#{journal_date.year}). #{title_html}. + #{journal_html}. DOI:#{doi} + HTML + when :wikispecies + <<~WIKI.html_safe + #{authors_et_al(format).gsub(/[^\.]?$/, '.')} #{journal_date.year}: + #{title}. #{journal}. {{Doi|#{doi}}} + WIKI + else + end + end + def long_citation_html - <<~HTML.html_safe - #{authors_et_al_html} (#{journal_date.year}). #{title_html}. - #{journal_html}. DOI:#{doi} - HTML + long_citation(:html) end def title_html diff --git a/app/views/names/wiki/_wikispecies_page.html.erb b/app/views/names/wiki/_wikispecies_page.html.erb index 1d51ec3..25a05f0 100644 --- a/app/views/names/wiki/_wikispecies_page.html.erb +++ b/app/views/names/wiki/_wikispecies_page.html.erb @@ -49,6 +49,11 @@ Species: <%= @name.name_wiki(no_candidatus: true, link: true) %> <%= @name.formal_wiki %> =={{int:References}}== +==={{int:Primary references}}== +<% @name.citations.each do |citation| %> +* <%= citation.long_citation(:wikispecies) %> +<% end %> + ==={{int:Links}}=== <% if @name.ncbi_taxonomy? %> * {{NCBI|<%= @name.ncbi_taxonomy %>}}