Featured Collections, Works, or Researchers - UVicLibrary/Vault GitHub Wiki

Cheatsheet (Jump to)

Featured collections and featured works are displayed on the home page (vault.library.uvic.ca). Currently, we can feature up to six collections and up to six works. Click each tab below the main heading to cycle between categories (collections, works, researchers).

To feature a collection or work, these three criteria must be met:

  1. You have the right permissions (e.g. you are an admin) to feature the collection or work
  2. There are five or fewer featured items in that category already (the one you are about to add being the sixth)
  3. The collection or work you want to feature is public

Screenshot of the Vault home page

How to Feature a Collection

To feature a collection, go to its page in the Dashboard by clicking Collections in the sidebar and click the name of the collection from the list. Then click the Feature button. If you can't feature a collection, there will be a message explaining why the button is disabled.

This is the same page for unfeaturing a collection.

screenshot of dashboard sidebar screenshot of toolbar for unfeaturing collections

How to Feature a Work

Go to the public page for the work you want to feature (can be Dashboard > Works > [click the name of a work]). Click Feature/Unfeature button next to the Work title.

How to Feature a Researcher

Go to the Dashboard and click Settings on the sidebar. A dropdown list will appear. Click on Content Blocks and then the Featured Researcher tab. Here, you can edit the text or upload an image/thumbnail to display on the homepage.

Sidebar links for content blocks Interface for changing featured researcher

How to Change the Order of Featured Collections or Works

On the home page below the "Featured" cards, you'll find a sortable list of the currently featured works and collections. Drag and drop the grey handle of the collection or work you want to move. Then click Save Order to save these changes.

home page interface for changing order of featured items

Notes for Developers

Related files

These partials are in views/hyrax/homepage

  • _home_content contains the render statements for other partials
  • _sortable_featured is the partial for the "change order" interface
  • _card is rendered for every featured collection or work. It needs a local variable presenter that takes each item in @featured_collection_list.collection_presenters or Hyrax::WorkShowPresenter.
  • _list_works and list_collections are rendered by _works_table and _collections_table respectively

How Vault determines which button to show (Feature/Unfeature)

To change the max number of featured works or collections, look in app/models/featured_work.rb or app/models/featured_collection.rb. The limit is defined at the top as FEATURE_LIMIT. The view with the feature/unfeature button is views/hyrax/dashboard/collections or works/_show_actions.

<% if @presenter.collection_featurable? && can?(:create, FeaturedCollection) %>
  <% if FeaturedCollection.can_create_another? || FeaturedCollection.pluck(:collection_id).include?(@presenter.id) %>
    <%= link_to "Feature", featured_collections_path(collection_id: params[:id], order: 1, format: :json, remote: true), method: :post,
        data: { behavior: 'feature' },
        class: @presenter.display_unfeature_link? ? 'btn btn-default collapse' : 'btn btn-default',
        id: 'feature-coll-link' %>
    <%= link_to "Unfeature", featured_collection_path(collection_id: params[:id], format: :json, remote: true), method: :delete,
          data: { behavior: 'unfeature' },
          class: @presenter.display_feature_link? ? 'btn btn-default collapse' : 'btn btn-default',
          id: 'unfeature-coll-link' %>
  <% else %>
    <span class="text-muted feature-collection-error">Maximum of 6 featured collections.</span>
    <a class="btn btn-default btn-disabled" disabled="disabled">Feature</a>
  <% end %>
<% elsif [email protected]_document.public? %><%# could just be else statement, but this is more explicit %>
    <span class="text-muted feature-collection-error">Collection must be public.</span>
    <a class="btn btn-default btn-disabled" disabled="disabled">Feature</a>
<% end %>

.collection_featurable? checks if the collection is public and if the user has permission to create new featured collections.

line 2 displays the feature button if there is room for another featured collection (.can_create_another?), or the unfeature button if the collection is already featured (the 2nd condition).

Vault will display a maximum error message if the collection doesn't meet either of the above conditions, or a visibility error if the collection is not public.

⚠️ **GitHub.com Fallback** ⚠️