Skip to content

Commit

Permalink
add display name function and use em for titles
Browse files Browse the repository at this point in the history
  • Loading branch information
kf8a committed Aug 12, 2024
1 parent f6a489d commit 50292b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
40 changes: 20 additions & 20 deletions app/models/citation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,26 @@ def ld_json
}
end

def author_and_year(options = {})
return pub_year_with_punctuation.to_s if authors.empty?

if options[:long]
author_and_pub_year_string(author_string)
else
author_and_pub_year_string(short_author_string)
end
end

def volume_and_page
if volume.blank?
doi_citation_part(doi)
elsif page_numbers.blank?
"#{volume}."
else
"#{volume}:#{page_numbers}."
end
end

private

def bibtex_type
Expand All @@ -383,16 +403,6 @@ def endnote_publication_data
end
end

def volume_and_page
if volume.blank?
doi_citation_part(doi)
elsif page_numbers.blank?
"#{volume}."
else
"#{volume}:#{page_numbers}."
end
end

def doi_citation_part(doi)
if doi.blank?
''
Expand Down Expand Up @@ -479,16 +489,6 @@ def pub_year_with_punctuation
pub_year ? "#{pub_year}." : ''
end

def author_and_year(options = {})
return pub_year_with_punctuation.to_s if authors.empty?

if options[:long]
author_and_pub_year_string(author_string)
else
author_and_pub_year_string(short_author_string)
end
end

def author_and_pub_year_string(author_string)
"#{author_string} #{pub_year_with_punctuation}".rstrip
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/treatment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ def has_citations?
end
false
end

def display_name
self.parent ? "#{self.parent.description} > #{self.name} #{self.description}" : "#{self.name} #{self.description}"
end
end
2 changes: 1 addition & 1 deletion app/views/citations/_citation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<% end %>
<% cache(citation, action: 'index') do %>
<div>
<p><%=citation.formatted(long: true) %>
<p><%=citation.author_and_year(long: true) %><em><%= citation.title %></em>. <%= citation.publication %> <%= citation.volume_and_page %>,
<% if citation.doi.present? %>
<span> <em>DOI: <%= link_to citation.doi, normalize_doi(citation.doi) %></em></span>
<% end %>
Expand Down

0 comments on commit 50292b2

Please sign in to comment.