Skip to content

Commit

Permalink
Initial experiment with adding external dcp resources as items
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisrlc committed Aug 28, 2024
1 parent 43f8f31 commit 2fb9f35
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
7 changes: 7 additions & 0 deletions app/controllers/digital_collections_resources_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class DigitalCollectionsResourcesController < Spotlight::ResourcesController
private

def resource_class
DigitalCollectionsResource
end
end
34 changes: 34 additions & 0 deletions app/models/digital_collections_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class DigitalCollectionsResource < Spotlight::Resource
# TODO: What is this indexing pipeline
def self.indexing_pipeline
@indexing_pipeline ||= super.dup.tap do |pipeline|
pipeline.transforms = [Spotlight::Etl::Sources::SourceMethodSource(:to_solr)] + pipeline.transforms

# PR for implementing an ETL-like pattern for indexing documents
# https://github.com/projectblacklight/spotlight/pull/2625
# # if, say, you wanted to feed the transform with multiple source documents
# # (here, by calling the `#iiif_manifest` method on the DlmeJson instance);
# # previously, the #to_solr method of the document builder would have done this extraction
# # pipeline.sources = [Spotlight::Etl::Sources::SourceMethodSource(:iiif_manifests)]
# pipeline.transforms = [
# ->(data, p) { data.merge(DlmeJsonResourceBuilder.new(p.context.resoure).to_solr) }
# ]

# Spotlight::Resource::IiifHarvester
# pipeline.sources = [Spotlight::Etl::Sources::SourceMethodSource(:iiif_manifests)]
# pipeline.transforms = [
# ->(data, p) { data.merge(p.source.to_solr(exhibit: p.context.resource.exhibit)) }
# ] + pipeline.transforms

# Spotlight::Resource::JsonUpload
# pipeline.sources = [Spotlight::Etl::Sources::StoredData]
# pipeline.transforms = [
# Spotlight::Etl::Transforms::IdentityTransform
# ] + pipeline.transforms
end
end

def to_solr
# TODO
end
end
8 changes: 4 additions & 4 deletions app/views/catalog/_viewer_default.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
Overrides _openseadragon_default.html.erb from blacklight-gallery
Adds sequenceMode to showReferenceStrip for images with count > 1
-->
<%#
Overrides _openseadragon_default.html.erb from blacklight-gallery
Adds sequenceMode to showReferenceStrip for images with count > 1
%>
<%
image = document.to_openseadragon(blacklight_config.view_config(:show))
Expand Down
9 changes: 9 additions & 0 deletions app/views/digital_collections_resources/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= bootstrap_form_for([current_exhibit, @resource.becomes(DigitalCollectionsResource)], as: :resource) do |f| %>
<%= f.text_field :url %>
<div class="form-actions">
<div class="primary-actions">
<%= cancel_link @resource, :back, class: 'btn btn-secondary' %>
<%= f.submit t('.add_item'), class: 'btn btn-primary' %>
</div>
</div>
<% end if can? :manage, @resource %>
4 changes: 3 additions & 1 deletion config/initializers/spotlight_initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# ==> Appearance configuration
# Spotlight::Engine.config.exhibit_main_navigation = [:curated_features, :browse, :about]
Spotlight::Engine.config.resource_partials = [
# 'spotlight/resources/external_resources_form',
'spotlight/resources/external_resources_form',
'spotlight/resources/upload/form',
'spotlight/resources/csv_upload/form',
# 'spotlight/resources/json_upload/form'
'spotlight/resources/iiif/form'
]
Spotlight::Engine.config.external_resources_partials = []
# Spotlight::Engine.config.external_resources_partials = ['digital_collections_resources/form']
# Spotlight::Engine.config.external_resources_partials = ["portal_resources/form"]
# Spotlight::Engine.config.default_browse_index_view_type = :gallery
# Spotlight::Engine.config.default_contact_email = nil
Expand Down

0 comments on commit 2fb9f35

Please sign in to comment.