Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function SubjectDataBrowse() {
showDetails({ wikidata, dbpedia });
}
};

// Get Image country = P17; territory P131; location P276
async function getWikidata(localname) {
const sparqlQuery = (
Expand Down Expand Up @@ -109,6 +109,8 @@ function SubjectDataBrowse() {
$('#comment-container').removeClass();
$('#comment-container').addClass('col-sm-12').addClass('col-md-12').addClass('col-lg-12');
}
// Show the acknowledgement box if any text is present
toggleAcknowledgements();
};

function qidAndLabel(data) {
Expand All @@ -117,7 +119,7 @@ function SubjectDataBrowse() {
qid: data.entity?.split('/')[4] || 'x'
}
};

// we can use the wikidata QID to get an entity description from DBpedia
async function getDbpediaDescription(data = {}) {
const { qid, label } = qidAndLabel(data);
Expand All @@ -141,6 +143,8 @@ function SubjectDataBrowse() {
$('#dbp-comment').text(wdDescription);
$('#dbp-comment').show();
}
// Show the acknowledgement box if any text is present
toggleAcknowledgements();
};

function showDetails({ dbpedia, wikidata }) {
Expand All @@ -167,6 +171,17 @@ function SubjectDataBrowse() {
return !!value && !ldExcluder.isPropertyExcluded(propertyName);
};

// Removes 'd-none' when either ack span has text.
function toggleAcknowledgements() {
const hasWikiText = $('#wiki-acknowledge').text().trim().length > 0;
const hasImgText = $('#wiki-image-acknowledge').text().trim().length > 0;
const $box = $('#wiki-acknowledge, #wiki-image-acknowledge').closest('.ld-acknowledge');
if (hasWikiText || hasImgText) {
$box.removeClass('d-none');
} else {
$box.addClass('d-none');
}
}
return { renderLinkedData };
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ul.nav-tabs li {
}
#dbp-comment {
display: none;
margin-bottom: 16px;
}
.ld-acknowledge {
font-size: .8rem;
Expand Down
21 changes: 14 additions & 7 deletions blacklight-cornell/app/views/browse/_bio_info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,26 @@
<div class='card-body'>
<div class='row'>
<div id='img-container' class='col-md-4 col-lg-3 text-center d-none'>
<img id='bio-image' src='' title="<%= heading_type %> image" alt='' class='img-fluid mb-4'>
<img id='bio-image' src='' title="<%= heading_type %> image" alt='' class='img-fluid'>
</div>
<div id='comment-container' class='col-md-8 col-lg-9'>
<div id='dbp-comment'></div>
<dl class='dl-horizontal' id='item-details'>
<%# display different data per heading type in <HEADING_TYPE>_info.html.erb %>
<%= yield %>
</dl>
<%# filled in by javascript when needed %>
<div class='ld-acknowledge'>

<%# Only render html if present %>
<% details_html = capture { yield } %>
<% if details_html.to_s.strip.present? %>
<dl class='dl-horizontal' id='item-details'>
<%# display different data per heading type in <HEADING_TYPE>_info.html.erb %>
<%= details_html %>
</dl>
<% end %>

<%# start hidden; JS will unhide if it adds text %>
<div class='ld-acknowledge d-none'>
<span id='wiki-acknowledge'></span>
<span id='wiki-image-acknowledge'></span>
</div>

</div>
</div>
</div>
Expand Down