Skip to content

Commit

Permalink
Make collection thumbnails show in the views
Browse files Browse the repository at this point in the history
This commit will make the collection thumbnails show up in the views
such as in the dashboard list of collections and also in the catalog
search results.  The gitignore was updated to ignore the path where the
thumbnails are stored.
  • Loading branch information
kirkkwang committed May 7, 2024
1 parent fb4654b commit d6dd1d2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ docker-compose.override.yml
*~undo-tree~
.DS_Store
/bundler.d/
/uploads
23 changes: 23 additions & 0 deletions app/assets/stylesheets/hyku.scss
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,26 @@ span.constraint-value p, .facet-values p {
tr[data-feature="use-iiif-print"] {
display: none;
}

// collection branding thumbnail
div.branding-thumbnail-row {
border-top: solid 1px #dddddd;
padding-top: 10px;
}

input.branding-thumbnail-input {
width: 250px;
}

div.branding-thumbnail-input {
text-align: right;
}

button.branding-thumbnail-remove,
button.branding-thumbnail-remove:hover {
background-color: #ffffff;
border-color: #ffffff;
color: $brand-danger;
font-weight: normal;
text-decoration: underline;
}
3 changes: 2 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def group_navigation_presenter
@group_navigation_presenter ||= Hyku::Admin::Group::NavigationPresenter.new(params:)
end

def collection_thumbnail(_document, _image_options = {}, _url_options = {})
def collection_thumbnail(document, _image_options = {}, _url_options = {})
return image_tag(document['thumbnail_path_ss']) if document['thumbnail_path_ss'].present?
return super if Site.instance.default_collection_image.blank?

image_tag(Site.instance.default_collection_image&.url)
Expand Down
9 changes: 9 additions & 0 deletions app/services/hyrax/thumbnail_path_service_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

module Hyrax
module ThumbnailPathServiceDecorator
def call(object)
return super unless object.collection?

collection_thumbnail = CollectionBrandingInfo.where(collection_id: object.id.to_s, role: "thumbnail").first
return collection_thumbnail.local_path.gsub(Rails.public_path.to_s, '') if collection_thumbnail

default_image
end

def default_image
Site.instance.default_work_image&.url || super
end
Expand Down
7 changes: 5 additions & 2 deletions app/views/hyrax/dashboard/collections/_form_branding.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
</div> <!-- end row branding-logo-list -->
</div> <!-- end fileuploadlogo -->

<label><strong><%= t('.thumbnail.label') %></strong></label>
<p><%= t('.thumbnail.description') %></p>

<div id="fileuploadthumbnail">
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<noscript><input type="hidden" name="redirect" value="<%= main_app.root_path %>" /></noscript>
Expand Down Expand Up @@ -203,7 +206,7 @@
<i><%= image_tag(f.object.thumbnail_info[:relative_path],
height: "36",
alt: f.object.thumbnail_info[:alttext].presence || f.object.thumbnail_info[:file]) %></i>
<span><%= f.object.thumbnail_info[:file] %></span>
<span><%= f.object.thumbnail_info[:file] %></span>
<input type="hidden" name="thumbnail_unchanged" value="true" />
</span>
</div>
Expand Down Expand Up @@ -236,5 +239,5 @@
</div> <!-- end row branding-thumbnail-list -->
</div> <!-- end row branding-thumbnail-list -->
</div> <!-- fileuploadthumbnail -->

</div> <!-- end set-access-controls -->

0 comments on commit d6dd1d2

Please sign in to comment.