Skip to content

Commit

Permalink
Figures & Findings display Regions & Keywords, and by default
Browse files Browse the repository at this point in the history
Bumps #679
  • Loading branch information
lomky committed Dec 12, 2018
1 parent 7bd74eb commit 6f8d1fe
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 46 deletions.
6 changes: 3 additions & 3 deletions lib/Tuba/Controller.pm
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ sub make_tree_for_show {
my $c = shift;
my $obj = shift;
my %params;
$params{with_gcmd} = 1 if $c->param('with_gcmd');
$params{with_regions} = 1 if $c->param('with_regions');
$params{with_gcmd} = 1 unless $c->param('with_gcmd') == 0;
$params{with_regions} = 1 unless $c->param('with_regions' == 0);
$params{bonsai} = 1 if $c->param('brief');
my $ret = $obj->as_tree(c => $c, %params);
if (my $gcid = $ret->{uri}) {
Expand Down Expand Up @@ -248,7 +248,7 @@ sub maybe_include_generic_pub_rels {
my $obj = shift;
my $pub = $obj->get_publication or return ();
my $tree = {};
$tree->{gcmd_keywords} = [ map $_->as_tree(@_), $pub->gcmd_keywords ] if $c->param('with_gcmd');
$tree->{gcmd_keywords} = [ map $_->as_tree(@_), $pub->gcmd_keywords ] unless $c->param('with_gcmd') == 0;
$tree->{regions} = [ map $_->as_tree(@_), $pub->regions] if $c->param('with_regions');
return %$tree;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Tuba/DB/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ sub new_from_reference {
return;
}

sub get_regions {
my $c = shift;
my $pub = $c->get_publication or return;
return $pub->regions;
}

sub keywords {
my $c = shift;
my $pub = $c->get_publication or return;
Expand Down
12 changes: 9 additions & 3 deletions lib/Tuba/Region.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ use Tuba::DB::Objects qw/-nicknames/;
sub list {
my $c = shift;
my $report_id = $c->stash('report_identifier');
my $pub_id = $c->stash('pub_id');
my $count;
my $objects;
if ( $report_id ){
my $report = Report->new( identifier => $report_id );
my $publication = $report->get_publication();
if ( $report_id || $pub_id ){
my $publication;
if ( $report_id ) {
my $report = Report->new( identifier => $report_id );
$publication = $report->get_publication();
} elsif ( $pub_id ) {
$publication = Publication->new( id => $pub_id );
}
$objects = Regions->get_objects(
query => [ publication_id => $publication->id ],
with_objects => [qw/publications/],
Expand Down
88 changes: 53 additions & 35 deletions lib/Tuba/files/templates/figure/object.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,95 @@

%= include 'edit_buttons';
<div class='row well' itemscope itemtype="http://schema.org/ImageObject">

<div class='pull-right col-lg-4 col-md-4 col-sm-8 col-xs-12'>
% my $pub = $figure->get_publication;
% if ($pub) {
% for my $file ($pub->files) {
%= link_to "show_file", { 'file_identifier' => $file->identifier } => class => '' => itemprop => "url" => begin
%= image $file->thumbnail_path, class => 'img-thumbnail img-responsive', itemprop => "thumbnailUrl"
%= end
% }
% }
</div>
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
<h2><%= $figure->title %></h2>
</div>
<div class='col-lg-8 col-md-8 col-sm-12 col-xs-12'>
<h3>Figure <%= $figure->numeric || $figure->identifier %></h3>
<i>
%= include commify => objs => scalar $figure->all_orgs
%= include commify => objs => scalar $figure->all_orgs
</i>
<br>
%= include commify => objs => scalar $figure->all_people
% if (my $chapter = $figure->chapter) {
<p>This figure appears in <%= obj_link_to $chapter,'show', begin %>chapter <%= $chapter->stringify(tiny => 1) %><%= end %>
of the <%= obj_link($figure->report) %> report.</p>
<p>This figure appears in <%= obj_link_to $chapter,'show', begin %>chapter <%= $chapter->stringify(tiny => 1) %><%= end %>
of the <%= obj_link($figure->report) %> report.</p>
% } else {
<p>This figure appears in the <%= obj_link($figure->report) %> report.</p>
<p>This figure appears in the <%= obj_link($figure->report) %> report.</p>
% }
% if (my $to = fix_url($figure->url)) {
<p><%= link_to $to => target => "_blank" => begin %><%= $figure->url %><%= end %></p>
<p><%= link_to $to => target => "_blank" => begin %><%= $figure->url %><%= end %></p>
% }

<p><%= tbibs_to_links($figure->caption) %></p>
% if ($figure->source_citation){
<p>When citing this figure, please reference <%= tbibs_to_links($figure->source_citation) %>.</p>
<p>When citing this figure, please reference <%= tbibs_to_links($figure->source_citation) %>.</p>
% }
% if ($figure->usage_limits) {
<p><%= $figure->usage_limits %></p>
<p><%= $figure->usage_limits %></p>
% }
% if (my @figs = $figure->kindred_figures) {
<p>Other figures containing images in this figure : <%= include 'commify', objs => \@figs %></p>
<p>Other figures containing images in this figure : <%= include 'commify', objs => \@figs %></p>
% }
% if ($figure->time_start && $figure->time_end) {
<p>The time range for this figure is <%= $figure->time_start->strftime('%B %d, %Y (%H:%M %p)') %>
to <%= $figure->time_end->strftime('%B %d, %Y (%H:%M %p)') %>.</p>
<p>The time range for this figure is <%= $figure->time_start->strftime('%B %d, %Y (%H:%M %p)') %>
to <%= $figure->time_end->strftime('%B %d, %Y (%H:%M %p)') %>.</p>
% } elsif ($figure->time_start) {
<p>The time range for this figure starts at <%= $figure->time_start->strftime('%B %d, %Y (%H:%M %p)') %>.</p>
<p>The time range for this figure starts at <%= $figure->time_start->strftime('%B %d, %Y (%H:%M %p)') %>.</p>
% } elsif ($figure->time_end) {
<p>The time range for this figure ends at <%= $figure->time_end->strftime('%B %d, %Y (%H:%M %p)') %>.</p>
<p>The time range for this figure ends at <%= $figure->time_end->strftime('%B %d, %Y (%H:%M %p)') %>.</p>
% }
% if ($figure->create_dt) {
<p>This figure was created on <%= $figure->create_dt->strftime('%B %d, %Y') %>.</p>
<p>This figure was created on <%= $figure->create_dt->strftime('%B %d, %Y') %>.</p>
% }

% if ($figure->submission_dt) {
<p>This figure was submitted on <%= $figure->submission_dt->strftime('%B %d, %Y') %>.</p>
<p>This figure was submitted on <%= $figure->submission_dt->strftime('%B %d, %Y') %>.</p>
% }
% if ($figure->lat_min || $figure->lat_max || $figure->lon_min || $figure->lon_max) {
<p>
The spatial range for this figure is <%= $figure->lat_min // 'unknown' %>° to <%= $figure->lat_max // 'unknown' %>° latitude,
and <%= $figure->lon_min // 'unknown' %>° to <%= $figure->lon_max // 'unknown' %>° longitude.
</p>
<p>The spatial range for this figure is <%= $figure->lat_min // 'unknown' %>° to <%= $figure->lat_max // 'unknown' %>° latitude,
and <%= $figure->lon_min // 'unknown' %>° to <%= $figure->lon_max // 'unknown' %>° longitude.</p>
% }
</div>
<div class='pull-right col-lg-4 col-md-4 col-sm-12 col-xs-12'>
<div class="row">
% my $pub = $figure->get_publication;
% if ($pub) {
% for my $file ($pub->files) {
%= link_to "show_file", { 'file_identifier' => $file->identifier } => class => '' => itemprop => "url" => begin
%= image $file->thumbnail_path, class => 'img-thumbnail img-responsive', itemprop => "thumbnailUrl"
%= end
% }
% }
</div>
% if ($figure->get_regions) {
<div class="row">
% my $regions = $figure->get_regions;
%= include 'h/regions', regions => $regions;
</div>
% }

% if ($figure->keywords) {
<div class="row">
% my $keywords = $figure->keywords;
%= include 'h/keywords', keywords => $keywords;
</div>
% }
</div>

<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
%= include 'h/prov', pub => $figure->get_publication;
%= include 'h/cited_by', pub => $figure->get_publication;
%= include 'h/cites', pub => $figure->get_publication;
% if (my @images = sorted_list($figure,'images')) {
<br>
This figure is composed of <%= @images==1 ? 'this image' : 'these images' %> :
<br />
%= include 'obj_thumbnails', objs => [ sorted_list($figure,'images') ], no_table => 1, tiny_captions => 1;
<br>
This figure is composed of <%= @images==1 ? 'this image' : 'these images' %> :
<br />
%= include 'obj_thumbnails', objs => [ sorted_list($figure,'images') ], no_table => 1, tiny_captions => 1;
% }

</div>
</div>

<%= include 'h/other_formats'; =%>
%= include 'h/other_formats';
%= include 'h/tbibjs';

17 changes: 15 additions & 2 deletions lib/Tuba/files/templates/finding/object.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

%= include 'edit_buttons';
<div class='row well'>
% my $pub = $report->get_publication;
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
% my $pub = $finding->get_publication;
<p class='lead'><%= tbibs_to_links($finding->statement) %></p>
%= include 'h/contributors_short', object => $finding;
% if ($finding->chapter) {
Expand All @@ -37,9 +38,21 @@
% }
% }
%= include 'h/prov', pub => $finding->get_publication;
<div class='pull-right col-lg-4 col-md-4 col-sm-12 col-xs-12'>
% if ($finding->get_regions) {
% my $regions = $finding->get_regions;
%= include 'h/regions', regions => $regions;
% }

% if ($finding->keywords) {
% my $keywords = $finding->keywords;
%= include 'h/keywords', keywords => $keywords;
% }
</div>
<div class='col-lg-8 col-md-8 col-sm-12 col-xs-12'>
%= include 'h/cited_by', pub => $finding->get_publication;
%= include 'h/cites', pub => $finding->get_publication;

</div>
</div>

%= include 'h/other_formats';
Expand Down
18 changes: 18 additions & 0 deletions lib/Tuba/files/templates/h/keywords.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h5>Related <a href="https://earthdata.nasa.gov/about/gcmd/global-change-master-directory-gcmd-keywords" target="_blank">NASA GCMD</a> keywords</h4>
<p><ul>
% if ( ref $keywords eq 'ARRAY' ) {
% for my $keyword (@$keywords) {
<li>
%= link_to "show_gcmd_keyword", { 'gcmd_keyword_identifier' => $keyword->identifier } => class => '' => itemprop => "url" => begin
%= $keyword->label
%= end
</li>
% }
% } else {
<li>
%= link_to "show_gcmd_keyword", { 'gcmd_keyword_identifier' => $keywords->identifier } => class => '' => itemprop => "url" => begin
%= $keywords->label
%= end
</li>
% }
</ul></p>
4 changes: 2 additions & 2 deletions lib/Tuba/files/templates/h/prov.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
This <%= $object->meta->table %>
<%= ontology_human($parent->{relationship}) %>
<%= link_to 'show_publication' => { publication_identifier => $parent_pub->id } => begin %><%= $parent_pub->stringify %><%= end %>
<% if ($parent->{activity}) { %>using the activity <%= obj_link($parent->{activity}) %><% } %>.
<% if ($parent->{activity}) { %>using the activity <%= obj_link($parent->{activity}) %><% } %>
<% if ($parent->{note}) { =%>(<%= $parent->{note} || "" =%>)<% } =%>
<br>
% }
Expand All @@ -25,7 +25,7 @@
% for my $rel (sort keys %{ $by_type_rel{$type} } ) {
% my $count = @{ $by_type_rel{$type}{$rel} };
<li><%= pl($type,$count) %> <%= ontology_human_pl($rel,$count) %> this <%= $pub->publication_type_identifier %> :
<%= include 'commify', objs => $by_type_rel{$type}{$rel}, short => 1 =%>.
<%= include 'commify', objs => $by_type_rel{$type}{$rel}, short => 1 =%>
</li>
% }
% }
Expand Down
18 changes: 18 additions & 0 deletions lib/Tuba/files/templates/h/regions.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h5>Regions Covered</h4>
<p><ul>
% if ( ref $regions eq 'ARRAY' ) {
% for my $region (@$regions) {
<li>
%= link_to "show_region", { 'region_identifier' => $region->identifier } => class => '' => itemprop => "url" => begin
%= $region->label
%= end
</li>
% }
% } else {
<li>
%= link_to "show_region", { 'region_identifier' => $regions->identifier } => class => '' => itemprop => "url" => begin
%= $regions->label
%= end
</li>
% }
</ul></p>
3 changes: 2 additions & 1 deletion lib/Tuba/files/templates/report/object.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
<p>
This report has
<%== $numeric_link->($chp => 'chapter', 'list_chapter') %>,
<%== $numeric_link->($fig => 'figure') %> <% if ($img > 0) { %> (<%= $numeric_link->($img => 'image', 'list_report_images'); =%>)<% } %>,
<%== $numeric_link->($fig => 'figure') %>
<% if ($img > 0) { %> (<%= $numeric_link->($img => 'image', 'list_report_images'); =%>)<% } %>,
<%== $numeric_link->($fin => 'finding') %>,
<%== $numeric_link->($tab => 'table') %>
and
Expand Down

0 comments on commit 6f8d1fe

Please sign in to comment.