Skip to content

Commit

Permalink
Add openseadragon sir-trevor widget
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Mar 11, 2015
1 parent 7daf959 commit dbca88a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//= require spotlight/blocks/solr_documents_block

SirTrevor.Blocks.SolrDocumentsOsd = (function(){

return SirTrevor.Blocks.SolrDocuments.extend({
type: "solr_documents_Osd",
title: function() { return "Item OSD"; },

icon_name: "item_osd",
blockGroup: 'Exhibit item widgets',
description: "This widget displays items in an OpenSeaDragon environment",

item_options: function() { return "" }
});

})();
1 change: 1 addition & 0 deletions app/controllers/spotlight/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class PagesController < Spotlight::ApplicationController
before_filter :authenticate_user!, except: [:show]
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit

helper Openseadragon::OpenseadragonHelper
include Spotlight::Base
include Blacklight::Catalog::SearchContext
include Spotlight::Catalog::AccessControlsEnforcement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module SirTrevorRails::Blocks
class SolrDocumentsOsdBlock < SirTrevorRails::Blocks::SolrDocumentsBlock
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<% solr_documents_osd_block.with_solr_helper(self) %>

<div class="content-block items-block row">

<% if solr_documents_osd_block.text? %>
<div class="text-col col-md-6 pull-<%= solr_documents_osd_block.text_align %>">
<h3><%= solr_documents_osd_block.title %></h3>
<%= sir_trevor_markdown solr_documents_osd_block.text %>
</div>
<% end %>
<% if solr_documents_osd_block.documents? %>

<div class="content-block spotlight-flexbox <%= solr_documents_osd_block.text? ? "col-md-6" : "col-md-12" %> ">
<% solr_documents_osd_block.documents.each do |document| %>
<div class="box" data-id="<%= document.id %>">
<%= render_document_partial document, 'openseadragon', osd_container_class: "" %>
</div>
<% end %>
</div>
<% end %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'spec_helper'

describe 'spotlight/sir_trevor/blocks/_solr_documents_osd_block.html.erb', type: :view do

let(:p) { "spotlight/sir_trevor/blocks/solr_documents_osd_block.html.erb" }
let(:page) { double("Page") }
let(:block) do
SirTrevorRails::Blocks::SolrDocumentsGridBlock.new({type: "block", data: { title: "Some title", text: "Some text", "text-align" => "right" }}, page)
end
let(:doc) { ::SolrDocument.new(id: 1) }

before do
allow(block).to receive(:documents).and_return([doc])
allow(block).to receive(:document_options).and_return({})
end

before do
allow(view).to receive_messages(has_thumbnail?: true, render_thumbnail_tag: 'thumb')
end

it "should have a slideshow block" do
expect(view).to receive(:render_document_partial).with(doc, "openseadragon", hash_including()).and_return("OSD")
render partial: p, locals: { solr_documents_osd_block: block}
expect(rendered).to have_selector 'h3', text: 'Some title'
expect(rendered).to have_content "Some text"
expect(rendered).to have_selector '.box', text: 'OSD'
expect(rendered).to have_selector '.text-col.pull-right'
end
end

0 comments on commit dbca88a

Please sign in to comment.