Skip to content

Commit

Permalink
First run at updating Spotlight/Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Feb 20, 2018
1 parent 4ccbf02 commit bf66235
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 25 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ group :development, :test do
gem 'rspec-rails'
gem 'pry-rails'
gem 'pry-byebug'
gem 'simplecov', '~> 0.12', require: false
gem 'simplecov', require: false
gem 'coveralls', require: false
gem 'rubocop-rspec', require: false
gem 'vcr'
Expand Down Expand Up @@ -86,8 +86,8 @@ gem 'sidekiq'
gem 'redis-namespace'
gem 'string_rtl'
gem 'sprockets-es6'
gem 'sprockets-rails', '~> 2.3.3'
gem 'sprockets', '~> 3.5.0'
gem 'sprockets-rails'
gem 'sprockets'
gem 'almond-rails', '~> 0.1'
gem 'pul_uv_rails', github: 'pulibrary/pul_uv_rails', branch: 'master'
gem 'riiif'
Expand Down
32 changes: 16 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ GEM
coffee-script-source (1.10.0)
concurrent-ruby (1.0.5)
connection_pool (2.2.0)
coveralls (0.8.15)
coveralls (0.8.21)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
simplecov (~> 0.14.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (>= 1.6.0, < 2)
thor (~> 0.19.4)
tins (~> 1.6)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.3)
Expand Down Expand Up @@ -463,11 +463,11 @@ GEM
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simplecov (0.12.0)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
simplecov-html (0.10.2)
sir_trevor_rails (0.5.1)
multi_json (~> 1.0)
rails (>= 3, < 6)
Expand All @@ -487,17 +487,17 @@ GEM
rubyzip
spring (2.0.0)
activesupport (>= 4.2)
sprockets (3.5.2)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-es6 (0.9.2)
babel-source (>= 5.8.11)
babel-transpiler
sprockets (>= 3.0.0)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.12)
sshkit (1.11.3)
net-scp (>= 1.1.2)
Expand All @@ -507,15 +507,15 @@ GEM
string_rtl (0.1.0)
susy (2.2.12)
sass (>= 3.3.0, < 3.5)
term-ansicolor (1.4.0)
term-ansicolor (1.6.0)
tins (~> 1.0)
test_xml (0.1.8)
diffy (~> 3.0)
nokogiri (>= 1.3.2)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.5)
tins (1.12.0)
tins (1.16.3)
tophat (2.3.1)
actionpack (>= 3.0.0)
turbolinks (5.0.1)
Expand Down Expand Up @@ -605,14 +605,14 @@ DEPENDENCIES
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
sidekiq
simplecov (~> 0.12)
simplecov
sitemap_generator
sneakers
solr_wrapper
spring
sprockets (~> 3.5.0)
sprockets
sprockets-es6
sprockets-rails (~> 2.3.3)
sprockets-rails
sqlite3
string_rtl
turbolinks
Expand Down
2 changes: 1 addition & 1 deletion app/models/iiif_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class IIIFResource < Spotlight::Resources::IiifHarvester
before_save :set_noid

def iiif_manifests
@iiif_manifests ||= IiifService.parse(url)
@iiif_manifests ||= ::IiifService.parse(url)
end

def cleanup_solr
Expand Down
2 changes: 1 addition & 1 deletion app/services/iiif_manifest.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class IiifManifest < Spotlight::IiifManifest
class IiifManifest < ::Spotlight::Resources::IiifManifest
def to_solr
add_noid
super
Expand Down
2 changes: 1 addition & 1 deletion app/services/iiif_service.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class IiifService < Spotlight::IiifService
class IiifService < ::Spotlight::Resources::IiifService
def self.iiif_response(url)
resp = Faraday.get(url)
if resp.success?
Expand Down
2 changes: 1 addition & 1 deletion app/values/manifest_metadata.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ManifestMetadata < Spotlight::IiifManifest::Metadata
class ManifestMetadata < Spotlight::Resources::IiifManifest::Metadata
def jsonld_url
@manifest["see_also"]["@id"] if @manifest["see_also"]
end
Expand Down
1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += %w( leaflet-src.js.map )
2 changes: 1 addition & 1 deletion config/initializers/spotlight_config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Spotlight::Engine.config.thumbnail_field = :thumbnail_ssim
Spotlight::Engine.config.default_browse_index_view_type = :list
Spotlight::Engine.config.upload_fields = []
Spotlight::Engine.config.metadata_class = -> { ManifestMetadata }
Spotlight::Engine.config.iiif_metadata_class = -> { ManifestMetadata }
Spotlight::Engine.config.iiif_manifest_field = :content_metadata_iiif_manifest_field_ssi
18 changes: 18 additions & 0 deletions db/migrate/20180219235714_migrate_tags_to_sidecars.spotlight.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This migration comes from spotlight (originally 20170803152134)
class MigrateTagsToSidecars < ActiveRecord::Migration[5.0]
def up
Spotlight::SolrDocumentSidecar.reset_column_information
ActsAsTaggableOn::Tagging.reset_column_information

ActsAsTaggableOn::Tagging.where(taggable_type: 'SolrDocument', tagger_type: 'Spotlight::Exhibit').find_each do |e|
sidecar = Spotlight::SolrDocumentSidecar.find_or_create_by(document_id: e.taggable_id, document_type: 'SolrDocument', exhibit_id: e.tagger_id)
e.update(taggable: sidecar)
end
end

def down
ActsAsTaggableOn::Tagging.where(taggable_type: 'Spotlight::SolrDocumentSidecar').find_each do |e|
e.update(taggable: e.taggable.document)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This migration comes from spotlight (originally 20170821165811)
class ChangeIndexStatusToLongblob < ActiveRecord::Migration[5.0]
def change
change_column :spotlight_solr_document_sidecars, :index_status, :binary, limit: 10.megabytes
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This migration comes from spotlight (originally 20171005231502)
# This migration comes from acts_as_taggable_on_engine (originally 6)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
else
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
end
AddMissingIndexesOnTaggings.class_eval do
def change
add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
add_index :taggings, :context unless index_exists? :taggings, :context

unless index_exists? :taggings, [:tagger_id, :tagger_type]
add_index :taggings, [:tagger_id, :tagger_type]
end

unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This migration comes from spotlight (originally 20180119193632)
class AddSearchBoxToSpotlightSearches < ActiveRecord::Migration[5.0]
def change
add_column :spotlight_searches, :search_box, :boolean, default: false
end
end
10 changes: 9 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: 20170227171310) do
ActiveRecord::Schema.define(version: 20180219235717) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -263,6 +263,7 @@
t.integer "masthead_id"
t.integer "thumbnail_id"
t.string "default_index_view_type"
t.boolean "search_box", default: false
t.index ["exhibit_id"], name: "index_spotlight_searches_on_exhibit_id", using: :btree
t.index ["slug", "scope"], name: "index_spotlight_searches_on_slug_and_scope", unique: true, using: :btree
end
Expand Down Expand Up @@ -298,8 +299,15 @@
t.integer "tagger_id"
t.string "context", limit: 128
t.datetime "created_at"
t.index ["context"], name: "index_taggings_on_context", using: :btree
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
t.index ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy", using: :btree
t.index ["taggable_id"], name: "index_taggings_on_taggable_id", using: :btree
t.index ["taggable_type"], name: "index_taggings_on_taggable_type", using: :btree
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type", using: :btree
t.index ["tagger_id"], name: "index_taggings_on_tagger_id", using: :btree
end

create_table "tags", force: :cascade do |t|
Expand Down

0 comments on commit bf66235

Please sign in to comment.