Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active April 2, 2019 20:14
Show Gist options
  • Select an option

  • Save jendiamond/cc8d2dd377b5e106e638720ee1f9b022 to your computer and use it in GitHub Desktop.

Select an option

Save jendiamond/cc8d2dd377b5e106e638720ee1f9b022 to your computer and use it in GitHub Desktop.

Update Search Results - List View to Carbon 5 Version 3 design

UCLALibrary/ursus#316

blacklight_701

app/helpers/blacklight/render_partials_helper_behavior.rb

  def render_document_partials(doc, partials = [], locals = {})
    safe_join(partials.map do |action_name|
      render_document_partial(doc, action_name, locals)
    end, "\n")
  end

app/helpers/blacklight/blacklight_helper_behavior.rb

  def document_index_view_type query_params = params
    view_param = query_params[:view]
    view_param ||= session[:preferred_view]
    if view_param && document_index_views.key?(view_param.to_sym)
      view_param.to_sym
    else
      default_document_index_view_type
    end
  end

Ursus

app/views/catalog/_document.html.erb

<% # container for a single doc -%>
<article class="document <%= render_document_class document %> document-position-<%= document_counter%> " data-document-counter="<%= document_counter %>" itemscope itemtype="<%= document.itemtype %>">
  <%= render_document_partials document,
    blacklight_config.view_config(document_index_view_type).partials,
    document_counter: document_counter %>
</article>

I want something like this:

<div id='document'>
  <div id='indices'>
    <div id='index_header'></div>
    <div id='index'></div>
  </div>
  <div id='thumbnail_default'></div>
</div>

or this

<% # container for a single doc -%>
<article class="document <%= render_document_class document %> document-position-<%= document_counter%> " data-document-counter="<%= document_counter %>" itemscope itemtype="<%= document.itemtype %>">
  <%= render_document_partials document,
    blacklight_config.view_config(document_index_view_type).partials,
    document_counter: document_counter %>
    <%#= render 'thumbnail' %>
</article>

Ah ha!

app/controllers/catalog_controller.rb

  configure_blacklight do |config|
    config.view.gallery.partials = [:index_header, :index]
    # config.view.masonry.partials = [:index]
    # config.view.slideshow.partials = [:index]

Changes

Modify app/controllers/catalog_controller.rb

  configure_blacklight do |config|
    config.view.gallery.partials = [:indices, :index_header, :index]

Add app/views/catalog/_indices.html.erb

 <%= render `index_header` %>
 <%= render `index_header` %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment