Skip to content

Commit

Permalink
Merge pull request #1926 from samvera/iiif-print-demo-copy
Browse files Browse the repository at this point in the history
Iiif print demo copy
  • Loading branch information
Shana Moore authored Mar 15, 2023
2 parents 9b52ec6 + c702844 commit 06aa20d
Show file tree
Hide file tree
Showing 23 changed files with 347 additions and 12 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ group :development do
gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'bulkrax', '~> 3.5.0'
gem 'bulkrax', '~> 5.0'

gem 'blacklight', '~> 6.7'
gem 'blacklight_oai_provider', '~> 6.1', '>= 6.1.1'
Expand All @@ -92,7 +92,9 @@ gem 'hyrax', '~> 3.5.0'

gem 'bolognese', '>= 1.9.10'
gem 'hyrax-doi', git: 'https://github.com/samvera-labs/hyrax-doi.git', branch: 'hyrax_upgrade'
gem 'iiif_print', git: 'https://github.com/scientist-softserv/iiif_print.git', branch: 'main'
gem 'postrank-uri', '>= 1.0.24'
gem 'redlock', '>= 0.1.2', '< 2.0' # lock redlock per https://github.com/samvera/hyrax/pull/5961
gem 'rsolr', '~> 2.0'

gem 'devise'
Expand Down
33 changes: 28 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ GIT
hyrax (>= 2.9, < 4.0)
rails (~> 5.2.4, >= 5.2.4.3)

GIT
remote: https://github.com/scientist-softserv/iiif_print.git
revision: 4f6b67276b57bf4648866408eb136905ca644e34
branch: main
specs:
iiif_print (0.0.1)
blacklight_iiif_search (~> 1.0)
dry-monads (~> 1.4.0)
hyrax (>= 2.5, < 4.0)
nokogiri (>= 1.13.2)
rails (~> 5.0)
rdf-vocab (~> 3.0)

GIT
remote: https://github.com/tawan/active-elastic-job.git
revision: ec51c5d9dedc4a1b47f2db41f26d5fceb251e979
Expand Down Expand Up @@ -126,7 +139,7 @@ GEM
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
bagit (0.4.4)
bagit (0.4.5)
docopt (~> 0.5.0)
validatable (~> 1.6)
bcp47 (0.3.3)
Expand Down Expand Up @@ -155,6 +168,10 @@ GEM
bootstrap-sass (~> 3.0)
openseadragon (>= 0.2.0)
rails
blacklight_iiif_search (1.0.0)
blacklight (~> 6.0)
iiif-presentation
rails (>= 4.2, < 6)
blacklight_oai_provider (6.1.1)
blacklight (~> 6.0)
oai (~> 1.0)
Expand Down Expand Up @@ -200,13 +217,13 @@ GEM
signet (~> 0.8)
typhoeus
builder (3.2.4)
bulkrax (3.5.1)
bulkrax (5.1.0)
bagit (~> 0.4)
coderay
iso8601 (~> 0.9.0)
kaminari
language_list (~> 1.2, >= 1.2.1)
libxml-ruby (~> 3.1.0)
libxml-ruby (~> 3.2.4)
loofah (>= 2.2.3)
oai (>= 0.4, < 2.x)
rack (>= 2.0.6)
Expand Down Expand Up @@ -548,6 +565,10 @@ GEM
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
ice_nine (0.11.2)
iiif-presentation (1.1.0)
activesupport (>= 3.2.18)
faraday (>= 0.9)
json
iiif_manifest (1.3.0)
activesupport (>= 4)
is_it_working (1.1.0)
Expand Down Expand Up @@ -627,7 +648,7 @@ GEM
rdf-vocab (~> 3.0)
legato (0.7.0)
multi_json
libxml-ruby (3.1.0)
libxml-ruby (3.2.4)
link_header (0.0.8)
linkeddata (3.1.6)
equivalent-xml (~> 0.6)
Expand Down Expand Up @@ -1136,7 +1157,7 @@ DEPENDENCIES
blacklight_oai_provider (~> 6.1, >= 6.1.1)
bolognese (>= 1.9.10)
bootstrap-datepicker-rails
bulkrax (~> 3.5.0)
bulkrax (~> 5.0)
byebug
capybara
capybara-screenshot (~> 1.0)
Expand All @@ -1159,6 +1180,7 @@ DEPENDENCIES
hyrax-doi!
i18n-debug
i18n-tasks
iiif_print!
is_it_working
jbuilder (~> 2.5)
jquery-rails
Expand All @@ -1176,6 +1198,7 @@ DEPENDENCIES
rails (~> 5.2.5)
rails-controller-testing
rdf (~> 3.1.15)
redlock (>= 0.1.2, < 2.0)
riiif (~> 1.1)
rolify
rsolr (~> 2.0)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
//= require bulkrax/application

//= require hyrax
//= require iiif_print

//= require jquery.flot.pie
//= require flot_graph
//= require statistics_tab_manager
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/iiif_print.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'iiif_print/iiif_print';
17 changes: 16 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ def self.modified_field
'system_modified_dtsi'
end

# CatalogController-scope behavior and configuration for BlacklightIiifSearch
include BlacklightIiifSearch::Controller

configure_blacklight do |config|
# IiifPrint index fields
config.add_index_field 'all_text_tsimv', highlight: true, helper_method: :render_ocr_snippets

# configuration for Blacklight IIIF Content Search
config.iiif_search = {
full_text_field: 'all_text_tsimv',
object_relation_field: 'is_page_of_ssim',
supported_params: %w[q page],
autocomplete_handler: 'iiif_suggest',
suggester_name: 'iiifSuggester'
}

config.view.gallery.partials = %i[index_header index]
config.view.masonry.partials = [:index]
config.view.slideshow.partials = [:index]
Expand All @@ -30,7 +45,7 @@ def self.modified_field
config.advanced_search[:query_parser] ||= 'dismax'
config.advanced_search[:form_solr_parameters] ||= {}

config.search_builder_class = Hyrax::CatalogSearchBuilder
config.search_builder_class = IiifPrint::CatalogSearchBuilder

# Show gallery view
config.view.gallery.partials = %i[index_header index]
Expand Down
8 changes: 8 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,12 @@ def all_user_and_group_roles
def featured_collection_abilities
can %i[create destroy update], FeaturedCollection if admin?
end

def can_import_works?
can_create_any_work?
end

def can_export_works?
can_create_any_work?
end
end
3 changes: 3 additions & 0 deletions app/models/generic_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
class GenericWork < ActiveFedora::Base
include ::Hyrax::WorkBehavior
include ::Hyrax::BasicMetadata
include IiifPrint.model_configuration(
pdf_split_child_model: self
)

validates :title, presence: { message: 'Your work must have a title.' }

Expand Down
17 changes: 17 additions & 0 deletions app/models/iiif_search_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# SearchBuilder for full-text searches with highlighting and snippets
class IiifSearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior

self.default_processor_chain += [:ocr_search_params]

# set params for ocr field searching
def ocr_search_params(solr_parameters = {})
solr_parameters[:facet] = false
solr_parameters[:hl] = true
solr_parameters[:'hl.fl'] = blacklight_config.iiif_search[:full_text_field]
solr_parameters[:'hl.fragsize'] = 100
solr_parameters[:'hl.snippets'] = 10
end
end
3 changes: 3 additions & 0 deletions app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# `rails generate hyrax:work Image`
class Image < ActiveFedora::Base
include ::Hyrax::WorkBehavior
include IiifPrint.model_configuration(
pdf_split_child_model: self
)

property :extent, predicate: ::RDF::Vocab::DC.extent, multiple: true do |index|
index.as :stored_searchable
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# config.assets.debug = true

# Suppress logger output for asset requests.
config.assets.quiet = true
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@
# Properties that should not be used in imports/exports. They are reserved for use by Hyrax.
# config.reserved_properties += ['my_field']
end

Bulkrax::CreateRelationshipsJob.update_child_records_works_file_sets = true
end
22 changes: 22 additions & 0 deletions config/initializers/iiif_print.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
IiifPrint.config do |config|
# NOTE: WorkTypes and models are used synonymously here.
# Add models to be excluded from search so the user
# would not see them in the search results.
# by default, use the human readable versions like:
# @example
# # config.excluded_model_name_solr_field_values = ['Generic Work', 'Image']
#
# config.excluded_model_name_solr_field_values = []

# Add configurable solr field key for searching,
# default key is: 'human_readable_type_sim'
# if another key is used, make sure to adjust the
# config.excluded_model_name_solr_field_values to match
# @example
# config.excluded_model_name_solr_field_key = 'some_solr_field_key'

# Configure how the manifest sorts the canvases, by default it sorts by :title,
# but a different model property may be desired such as :date_published
# @example
# config.sort_iiif_manifest_canvases_by = :date_published
end
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'sidekiq/web'

Rails.application.routes.draw do

concern :iiif_search, BlacklightIiifSearch::Routes.new
concern :oai_provider, BlacklightOaiProvider::Routes.new

mount Riiif::Engine => 'images', as: :riiif if Hyrax.config.iiif_image_server?
Expand Down Expand Up @@ -59,6 +61,7 @@

resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog' do
concerns :exportable
concerns :iiif_search
end

resources :bookmarks do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This migration comes from iiif_print (originally 20181214181358)
class CreateIiifPrintDerivativeAttachments < ActiveRecord::Migration[5.0]
def change
create_table :iiif_print_derivative_attachments do |t|
t.string :fileset_id
t.string :path
t.string :destination_name

t.timestamps
end
add_index :iiif_print_derivative_attachments, :fileset_id
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from iiif_print (originally 20190107165909)
class CreateIiifPrintIngestFileRelations < ActiveRecord::Migration[5.0]
def change
create_table :iiif_print_ingest_file_relations do |t|
t.string :file_path
t.string :derivative_path

t.timestamps
end
add_index :iiif_print_ingest_file_relations, :file_path
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from iiif_print (originally 20230109000000)
class CreateIiifPrintPendingRelationships < ActiveRecord::Migration[5.1]
def change
create_table :iiif_print_pending_relationships do |t|
t.string :child_title, null: false
t.string :parent_id, null: false
t.string :child_order, null: false
t.timestamps
end
add_index :iiif_print_pending_relationships, :parent_id
end
end
28 changes: 27 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_11_22_001715) do
ActiveRecord::Schema.define(version: 2023_02_08_001228) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -351,6 +351,32 @@
t.string "humanized_name"
end

create_table "iiif_print_derivative_attachments", id: :serial, force: :cascade do |t|
t.string "fileset_id"
t.string "path"
t.string "destination_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["fileset_id"], name: "index_iiif_print_derivative_attachments_on_fileset_id"
end

create_table "iiif_print_ingest_file_relations", id: :serial, force: :cascade do |t|
t.string "file_path"
t.string "derivative_path"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["file_path"], name: "index_iiif_print_ingest_file_relations_on_file_path"
end

create_table "iiif_print_pending_relationships", force: :cascade do |t|
t.string "child_title", null: false
t.string "parent_id", null: false
t.string "child_order", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["parent_id"], name: "index_iiif_print_pending_relationships_on_parent_id"
end

create_table "job_io_wrappers", id: :serial, force: :cascade do |t|
t.integer "user_id"
t.integer "uploaded_file_id"
Expand Down
29 changes: 27 additions & 2 deletions solr/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,24 @@
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
</types>

<!-- BEGIN Blacklight IIIF Search autocomplete config -->
<!-- TODO needs configuration work to enable autocomplete -->
<!-- <fieldType name="textSuggestTokenizer" class="solr.TextField" positionIncrementGap="100"> -->
<!-- <analyzer> -->
<!-- <tokenizer class="solr.WhitespaceTokenizerFactory"/> -->
<!-- <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_en.txt"/> -->
<!-- <filter class="solr.WordDelimiterGraphFilterFactory"/> -->
<!-- <filter class="solr.LowerCaseFilterFactory"/> -->
<!-- <filter class="solr.HyphenatedWordsFilterFactory"/> -->
<!-- <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> -->
<!-- uncomment below to enable multi-word matches -->
<!-- <filter class="solr.ShingleFilterFactory" outputUnigrams="true" outputUnigramsIfNoShingles="true" maxShingleSize="3" /> -->
<!-- </analyzer> -->
<!-- </fieldType> -->
<!-- END Blacklight IIIF Search autocomplete config -->

</types>

<fields>
<!-- If you remove this field, you must _also_ disable the update log in solrconfig.xml
Expand Down Expand Up @@ -323,7 +340,11 @@
<!-- you must define copyField source and dest fields explicity or schemaBrowser doesn't work -->
<field name="all_text_timv" type="text" stored="false" indexed="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>

</fields>
<!-- BEGIN Blacklight IIIF Search autocomplete config -->
<!-- <field name="iiif_suggest" type="textSuggest" indexed="true" stored="true" multiValued="true" /> -->
<!-- END Blacklight IIIF Search autocomplete config -->

</fields>

<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
Expand Down Expand Up @@ -359,4 +380,8 @@
</similarity>
-->

<!-- BEGIN Blacklight IIIF Search autocomplete config -->
<!-- TODO this needs work <copyField source="all_text_tsimv" dest="iiif_suggest"/> -->
<!-- END Blacklight IIIF Search autocomplete config -->

</schema>
Loading

0 comments on commit 06aa20d

Please sign in to comment.