-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new document component subclass for show page
- Loading branch information
Adam Constabaris
committed
Feb 21, 2025
1 parent
bb440f1
commit a92969e
Showing
7 changed files
with
80 additions
and
27 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
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
...mponents/trln_argon/document_component.rb → ...ts/trln_argon/document_index_component.rb
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
31 changes: 31 additions & 0 deletions
31
app/components/trln_argon/document_show_component.html.erb
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,31 @@ | ||
<%= content_tag @component, | ||
id: @id, | ||
data: { | ||
'document-id': @document.id.to_s.parameterize, | ||
'document-counter': @counter, | ||
}, | ||
itemscope: true, | ||
itemtype: @document.itemtype, | ||
class: classes.flatten.join(' ') do %> | ||
<%= header %> | ||
<% if body.present? %> | ||
<%= body %> | ||
<% else %> | ||
<div class="document-main-section"> | ||
<%= title %> | ||
<%= render with_sub_header %> | ||
<%= content %> | ||
<%= render partial: 'show_thumbnail_default', locals: { document: @document } %> | ||
<% metadata_sections.each do |section| %> | ||
<%= section %> | ||
<% end %> | ||
|
||
<% partials.each do |partial| %> | ||
<%= partial %> | ||
<% end %> | ||
</div> | ||
|
||
<%= thumbnail %> | ||
<% end %> | ||
<%= footer %> | ||
<% 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,21 @@ | ||
module TrlnArgon | ||
# customization of document component for the show page | ||
# subclass used for index page overwrites the `metadata` slot | ||
# with the same content used here for the sub header. | ||
class DocumentShowComponent < Blacklight::DocumentComponent | ||
# easiest way to use this is to call | ||
# <%= render with_sub_header %> | ||
renders_one :sub_header, (lambda do | ||
generate_sub_header | ||
end) | ||
|
||
# returns a component configured for the | ||
# you will still need to call `#render` | ||
def generate_sub_header | ||
# to customize the fields shown in the sub header, set | ||
# blacklight_config.show_sub_header_fields in controller override | ||
fields = helpers.show_sub_header_presenter(@document).field_presenters | ||
TrlnArgon::DocumentHeaderMetadataComponent.new(fields: fields) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
<%= render blacklight_config.view_config(:show).document_header_component.new(document: @document, search_context: @search_context, search_session: search_session) %> | ||
<% @page_title = t('blacklight.search.show.title', document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %> | ||
<% content_for(:head) { render_link_rel_alternates } %> | ||
|
||
<div class="row"> | ||
<div class="<%= show_tools_class %>"> | ||
<%= render :partial => 'show_tools' %> | ||
</div> | ||
</div> | ||
|
||
<% @page_title = t('blacklight.search.show.title', document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %> | ||
<% content_for(:head) { render_link_rel_alternates } %> | ||
|
||
<div id="document" class="document <%= render_document_class %>" itemscope itemtype="<%= @document.itemtype %>" data-document-id="<%= @document.id %>"> | ||
<div id="doc_<%= @document.id.to_s.parameterize %>"> | ||
<div class="row"> | ||
<div id="title-and-thumbnail" class="<%= show_main_content_heading_partials_class %>" aria-label="Title and thumbnail"> | ||
<!-- Title Display --> | ||
<h1 class="document-title"><%= document_presenter(@document).html_title %></h1> | ||
<%= render_document_partials @document, blacklight_config.view_config(:show).heading_partials %> | ||
</div> | ||
<div class="<%= show_main_content_partials_class %>"> | ||
<%= render_document_partials @document, blacklight_config.view_config(:show).partials %> | ||
<div id="librarian-tools"> | ||
<!-- TODO: Placeholder based on wireframes. Not functional yet. | ||
Should probably create a partial for this and wire it through | ||
the blacklight partials config. --> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% document_component = blacklight_config.view_config(:show).document_component -%> | ||
<%= render (document_component).new(document_component.collection_parameter => document_presenter(@document), component: :div, show: true, partials: blacklight_config.view_config(:show).partials) do |component| %> | ||
<% component.with_title(as: 'h1', classes: '', link_to_document: false, actions: false) %> | ||
<% component.with_footer do %> | ||
<% if @document.respond_to?(:export_as_openurl_ctx_kev) %> | ||
<!-- COinS, for Zotero among others. --> | ||
<span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(document_presenter(@document).display_type) %>"></span> | ||
<% end %> | ||
<% 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