Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class SubjectsController < ApplicationController | ||
|
||
|
||
def show | ||
@subject = Subject.find_by(scheme: 'mesh', identifier: params[:id]) | ||
|
||
@trees = [] | ||
|
||
@subject.tree_numbers.each do |tree_number| | ||
|
||
parent_tree_numbers = [tree_number] | ||
|
||
while !tree_number.blank? | ||
|
||
tree_number = tree_number.gsub(/\.?[^\/\.]+\z/, '') | ||
parent_tree_numbers << tree_number unless tree_number.blank? | ||
|
||
end | ||
|
||
@trees << Subject.select('*') | ||
.from("(select *, unnest(tree_numbers) as tree_number from subjects) as subjects") | ||
.where(tree_number: parent_tree_numbers) | ||
.order(:tree_number) | ||
|
||
end | ||
|
||
@records = @subject.records.select(:identifier, :title).limit(50) | ||
|
||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% if records.length > 0 %> | ||
<% if records.length == 50 %> | ||
<h2>50+ Wellcome Library records</h2> | ||
<% else %> | ||
<h2><%= pluralize(@records.length, 'Wellcome Library record') %></h2> | ||
<% end %> | ||
|
||
<ul> | ||
<% records.each do |record| %> | ||
<li><%= link_to record.title, record %></li> | ||
<% end %> | ||
</ul> | ||
<% else %> | ||
<p>There’s nothing in the Wellcome Library collection about this (yet).</p> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<% if related_subjects.length > 0 %> | ||
<p>Related: | ||
<%= related_subjects.collect do |subject| %> | ||
<% link_to(subject.label, subject_path(subject.identifier)) %> | ||
<% end.join(', ').html_safe %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<% @trees.each do |tree| %> | ||
|
||
<p> | ||
<%= link_to 'Top', '/tree' %> / | ||
<%= tree.collect do |subject| %> | ||
<% link_to subject.label, "/tree/#{subject.tree_number.gsub('.', '/')}" %> | ||
<% end.join(" / ").html_safe %> | ||
</p> | ||
|
||
<% end %> | ||
|
||
<h1><%= @subject.label %></h1> | ||
|
||
<% if @subject.all_labels.length > 1 %> | ||
<p>Also known as: <%= (@subject.all_labels - [@subject.label]).collect {|s| content_tag('b', s)}.join(', ').html_safe %>.</p> | ||
<% end %> | ||
<%= render 'shared/related_subjects', related_subjects: @subject.related_subjects %> | ||
|
||
<p class="description"> | ||
<%= @subject.description %> | ||
</p> | ||
|
||
|
||
|
||
<%= render 'shared/records', records: @records %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters