Skip to content

Commit 0d17ced

Browse files
authored
Merge pull request #54 from MITLibraries/rdi-138-full-record-view-iteration
Updates to full record view
2 parents 1fd4f98 + 1219ee4 commit 0d17ced

File tree

9 files changed

+297
-88
lines changed

9 files changed

+297
-88
lines changed

app/helpers/record_helper.rb

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
module RecordHelper
2+
def doi(metadata)
3+
dois = metadata['identifiers'].select { |id| id['kind'].downcase == 'doi' }
4+
return unless dois.present?
5+
6+
dois.first['value']
7+
end
8+
9+
def date_parse(date)
10+
return unless date.present?
11+
12+
Date.parse(date).to_fs(:long)
13+
rescue Date::Error
14+
date
15+
end
16+
17+
def date_range(range)
18+
return unless range.present?
19+
20+
"#{date_parse(range['gte'])} to #{date_parse(range['lte'])}"
21+
end
22+
23+
def publication_date(metadata)
24+
metadata['dates'].select { |date| date['kind'] == 'Publication date' }.first['value']
25+
end
26+
227
# Display the machine-format key in human-readable text.
328
def render_key(string)
429
string.capitalize.gsub('_', ' ').gsub('Mit', 'MIT')
@@ -10,7 +35,7 @@ def field_list(record, element)
1035

1136
markupclass = 'field-list'
1237

13-
title = "<h2>#{render_key(element)}</h2>"
38+
title = "<h3>#{render_key(element)}</h3>"
1439
values = if record[element].length == 1
1540
"<p class='#{markupclass}'>#{record[element][0]}</p>".html_safe
1641
else
@@ -24,7 +49,7 @@ def field_object(record, element)
2449

2550
markupclass = 'field-object'
2651

27-
title = "<h2>#{render_key(element)}</h2>"
52+
title = "<h3>#{render_key(element)}</h3>"
2853
values = "<ul class='#{markupclass}'>#{render_kind_value(record[element])}</ul>"
2954
(title + values).html_safe
3055
end
@@ -34,13 +59,17 @@ def field_string(record, element)
3459

3560
markupclass = 'field-string'
3661

37-
"<h2>#{render_key(element)}</h2><p class='#{markupclass}'>#{record[element]}</p>".html_safe
62+
"<h3>#{render_key(element)}</h3><p class='#{markupclass}'>#{record[element]}</p>".html_safe
3863
end
3964

40-
def field_table(record, element, fields)
65+
def field_table(record, element, fields, label = '')
4166
return unless record[element].present?
4267

43-
title = "<h2>#{render_key(element)}</h2>"
68+
title = if label.present?
69+
"<h3>#{label}</h3>"
70+
else
71+
"<h3>#{render_key(element)}</h3>"
72+
end
4473
labels = "<table><thead><tr>#{render_table_header(fields)}</tr></thead>"
4574
values = "<tbody>#{render_table_row(record[element], fields)}</tbody></table>"
4675
(title + labels + values).html_safe

app/views/fact/doi.html.erb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<% return unless @json.present? %>
22

3-
<div id="doi-fact" class="panel panel-info fact">
4-
<div class="panel-heading">
5-
<%= @json[:title] %> <br />
6-
</div>
3+
<div id="doi-fact" class="panel fact">
4+
<% unless params[:slim].present? %>
5+
<div class="panel-heading">
6+
<%= @json[:title] %> <br />
7+
</div>
8+
<% end %>
79

810
<div class="panel-body">
911
In: <%= @json[:journal_name] %>, <%= @json[:year] %>

app/views/record/_misc.html.erb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<hr />
2+
3+
<div class="alert alert-banner warning">
4+
<p>Much of the data past this point we don't have good examples of yet. Please share in #rdi slack if you have good examples for anything that appears below. Thanks!</p>
5+
</div>
6+
7+
<%= field_table(@record, 'fundingInformation', %w[awardNumber awardUri funderIdentifier funderIdentifierType funderName], 'Funding Information') %>
8+
9+
<%= field_object(@record, 'alternateTitles' ) %>
10+
11+
<%= field_list(@record, 'callNumbers' ) %>
12+
13+
<%= field_string(@record, 'collection') %>
14+
15+
<%= field_list(@record, 'contents' ) %>
16+
17+
<%= field_list(@record, 'fileFormats') %>
18+
19+
<%= field_string(@record, 'format') %>
20+
21+
<%= field_table(@record, 'holdings', %w[call_number collection format location note]) %>
22+
23+
<%= field_string(@record, 'literaryForm') %>
24+
25+
<%= field_table(@record, 'locations', %w[kind value geopoint]) %>
26+
27+
<%= field_string(@record, 'numbering') %>
28+
29+
<%= field_string(@record, 'physicalDescription') %>
30+
31+
<%= field_list(@record, 'publicationFrequency') %>
32+
33+
<%= field_table(@record, 'relatedItems', %w[description item_type relationship uri]) %>

app/views/record/_record.html.erb

Lines changed: 183 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,183 @@
1-
<h1><%= @record['title'] %></h1>
2-
3-
<%= field_object(@record, 'alternateTitles' ) %>
4-
5-
<%= field_list(@record, 'callNumbers' ) %>
6-
7-
<%= field_string(@record, 'citation' ) %>
8-
9-
<%= field_list(@record, 'contentType' ) %>
10-
11-
<%= field_list(@record, 'contents' ) %>
12-
13-
<%= field_table(@record, 'contributors', %w[value kind affiliation identifier mit_affiliated]) %>
14-
15-
<%= field_table(@record, 'dates', %w[kind value range note]) %>
16-
17-
<%= field_string(@record, 'edition') %>
18-
19-
<%= field_list(@record, 'fileFormats') %>
20-
21-
<%= field_string(@record, 'format') %>
22-
23-
<%= field_table(@record, 'fundingInformation', %w[award_number award_uri funder_identifier funder_identifier_type funder_name]) %>
24-
25-
<%= field_table(@record, 'holdings', %w[call_number collection format location note]) %>
26-
27-
<%= field_object(@record, 'identifiers') %>
28-
29-
<%= field_list(@record, 'languages') %>
30-
31-
<%= field_table(@record, 'links', %w[kind text url restrictions]) %>
32-
33-
<%= field_string(@record, 'literaryForm') %>
34-
35-
<%= field_table(@record, 'locations', %w[kind value geopoint]) %>
36-
37-
<%= field_object(@record, 'notes') %>
38-
39-
<%= field_string(@record, 'numbering') %>
40-
41-
<%= field_string(@record, 'physicalDescription') %>
42-
43-
<%= field_list(@record, 'publicationFrequency') %>
44-
45-
<%= field_list(@record, 'publicationInformation') %>
46-
47-
<%= field_table(@record, 'relatedItems', %w[description item_type relationship uri]) %>
48-
49-
<%= field_table(@record, 'rights', %w[description kind uri]) %>
50-
51-
<%= field_string(@record, 'source') %>
52-
53-
<%= field_string(@record, 'sourceLink') %>
54-
55-
<%= field_object(@record, 'subjects') %>
56-
57-
<%= field_list(@record, 'summary') %>
58-
59-
<%= field_string(@record, 'timdexRecordId') %>
1+
<div class="gridband layout-3q1q wrap-full-record">
2+
<div class="col3q box-content region full-record" data-region="Full record">
3+
4+
<h2 class="record-title">
5+
<span class="sr">Title: </span>
6+
<% if @record['title'].present? %>
7+
<%= @record['title'] %>
8+
<% else %>
9+
No title provided for this item.
10+
<% end %>
11+
</h2>
12+
13+
<p>
14+
<span class="record-type">
15+
<% # we need to create separate displays for different types of content types, see https://github.com/MITLibraries/bento/pull/908/files#diff-6718f9b88f6f93e59d8c2509512dc40a62088430ff3cce1165ab414565949415L22-L57 for starting point but we should anticipate wanting to expand to many more unique content types %>
16+
<span class="sr">Type</span> <%= @record['contentType'].join %>
17+
</span>
18+
19+
<% if @record['citation'].present? %>
20+
21+
<span class="record-citation">
22+
<%= @record['citation'] %>
23+
</span>
24+
25+
<% else %>
26+
27+
<% if @record['dates'].map{|date| date if date['kind'] == 'Publication date'}.compact.present? %>
28+
<span class="record-year">
29+
: Published <%= date_parse(publication_date(@record)) %>
30+
</span>
31+
<% end %>
32+
<% if @record['edition'].present? %>
33+
<span class="record-edition">
34+
: Edition <%= @record['edition'] %>
35+
</span>
36+
<% end %>
37+
<% end %>
38+
</p>
39+
40+
<% # we should helper this up to handle insanely large lists of authors %>
41+
<% if @record['contributors'].present? %>
42+
<p class="record-authors">
43+
<span class="sr"><%= "Author".pluralize(@record['contributors'].count) %>: </span>
44+
<% @record['contributors'].each do |author| %>
45+
<span class="record-author">
46+
<%= author['value'] %>
47+
<% if author['affiliation'].present? %>
48+
(<%= author['affiliation'].join %>)
49+
<% end %>;
50+
</span>
51+
<% end %>
52+
</span>
53+
</p>
54+
<% end %>
55+
56+
<% # NOTE: link resolver links are not very useful to most of the content in timdex currently. For dspace and all RDI sources, the source link is better than a link resolver link %>
57+
<h3 class="section-title">Links</h3>
58+
<ul class="list-links">
59+
<li>
60+
<span class="label">Source:</span> <%= link_to(@record['source'], @record['sourceLink']) %>
61+
</li>
62+
63+
<% if @record['links'].present? %>
64+
<% @record['links'].each do |link| %>
65+
<li>
66+
<%= link_to(link['text'] || 'unknown', link['url']) %>
67+
</li>
68+
<% end %>
69+
<% end %>
70+
</ul>
71+
72+
<% if @record['summary'].present? %>
73+
<h3 class="section-title">Summary</h3>
74+
<% @record['summary'].each do |paragraph| %>
75+
<p>
76+
<%= sanitize paragraph, tags: %w(p strong em a), attributes: %w(href) %>
77+
</p>
78+
<% end %>
79+
<% end %>
80+
81+
<h3 class="section-title">More information</h3>
82+
83+
<ul class="list-moreinfo">
84+
<%# pub type%>
85+
86+
<%# pub info%>
87+
<% if @record['publicationInformation'] %>
88+
<li>Publication Information: <%= @record['publicationInformation'].join('; ') %></li>
89+
<% end %>
90+
91+
<%# identifiers %>
92+
<% if @record['identifiers'].present? %>
93+
94+
<% @record['identifiers'].each do |id| %>
95+
<li>
96+
<span class="label"><%= id['kind'].upcase %>:</span>
97+
<span class="<%= id['kind']%>"><%= id['value'] %></span>
98+
</li>
99+
<% end%>
100+
<% end %>
101+
102+
<%# language %>
103+
<% if @record['languages'].present? %>
104+
<li>
105+
<span class="label"><%= "Language".pluralize(@record['languages'].count) %>:</span> <%= @record['languages'].join(',') %>
106+
</li>
107+
<% end %>
108+
</ul>
109+
110+
<%# subjects%>
111+
<% if @record['subjects'].present? %>
112+
<h3 class="section-title">Subjects</h3>
113+
<ul class="list-subjects">
114+
<% @record['subjects'].each do |subject| %>
115+
<li>
116+
<%= "#{subject['kind']}: " if subject['kind'] != "Subject scheme not provided" %>
117+
<%= subject['value'].join(', ') %>
118+
</li>
119+
<% end %>
120+
</ul>
121+
<% end %>
122+
123+
<%# dates%>
124+
<% if @record['dates'].present? %>
125+
<h3 class="section-title">Dates</h3>
126+
<ul class="list-dates">
127+
<% @record['dates'].each do |date| %>
128+
<li>
129+
<%= date['kind'] %>: <%= date_parse(date['value']) %><%= date_range(date['range']) %>
130+
<%= " Note: #{date['note']}" if date['note'].present? %>
131+
</li>
132+
<% end %>
133+
</ul>
134+
<% end %>
135+
136+
<% if @record['notes'].present? %>
137+
<h3 class="section-title">Notes</h3>
138+
<% @record['notes'].each do |note| %>
139+
<% if note['kind'].present? %>
140+
<%= note['kind'] %>:
141+
<% end %>
142+
<% note['value'].each do |paragraph| %>
143+
<%= sanitize paragraph, tags: %w(p strong em a), attributes: %w(href) %>
144+
<% end %>
145+
<% end %>
146+
<% end %>
147+
148+
<% if @record['rights'].present? %>
149+
<h3 class="section-title">Rights</h3>
150+
<ul>
151+
<% @record['rights'].each do |right| %>
152+
<li>
153+
<% if right['kind'].present? %>
154+
<%= right['kind'] %>:
155+
<% end %>
156+
<% if right['uri'].present? %>
157+
158+
<% # note: not all URIs are URLs. Only treat URL-like URIs as links. %>
159+
<% if right['uri'].start_with?('http')%>
160+
<%= link_to(right['uri'], right['uri']) %>
161+
<% else %>
162+
<%= right['uri'] %>
163+
<% end %>
164+
165+
<% end %>
166+
<% if right['description'].present? %>
167+
<%= right['description'] %>
168+
<% end %>
169+
</li>
170+
<% end %>
171+
</ul>
172+
<% end %>
173+
174+
<%= render('misc') %>
175+
</div>
176+
177+
<%= render('sidebar') %>
178+
179+
</div>
180+
181+
<% if params[:debug].present? %>
182+
<%= debug(@record) %>
183+
<% end %>

app/views/record/_sidebar.html.erb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="col1q-r sidebar">
2+
<% if doi(@record) %>
3+
<% data_url = "/doi?doi=#{URI.encode_www_form_component(doi(@record))}&slim=true" %>
4+
5+
<div class="fact-container"
6+
data-controller="content-loader"
7+
data-content-loader-url-value=<%= data_url %>>
8+
</div>
9+
<% end %>
10+
11+
<div class="bit askus">
12+
<h3 class="title">Ask Us</h3>
13+
<p>Not finding what you're looking for? We're here to help with anything from quick questions to in-depth research.</p>
14+
<p>
15+
<a class="btn button-secondary" href="https://libraries.mit.edu/ask/">Ask Us</a>
16+
</p>
17+
</div>
18+
</div>

app/views/record/view.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
<%= render(partial: 'shared/error', collection: @errors) %>
44

5+
<%= render(partial: 'search/form')%>
6+
57
<% if @record.nil? %>
68
<%= render('record_empty') %>
79
<% else %>

0 commit comments

Comments
 (0)