europeana-blacklight 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/QUICKSTART.md +2 -4
  3. data/app/controllers/concerns/europeana/blacklight/catalog.rb +2 -5
  4. data/{lib → app/controllers/concerns}/europeana/blacklight/search_helper.rb +3 -0
  5. data/{lib → app/models}/europeana/blacklight/document/lang_maps.rb +0 -0
  6. data/{lib → app/models}/europeana/blacklight/document/more_like_this.rb +0 -0
  7. data/{lib → app/models}/europeana/blacklight/document/relations.rb +0 -0
  8. data/{lib → app/models}/europeana/blacklight/document.rb +0 -5
  9. data/{lib → app/presenters}/europeana/blacklight/document_presenter.rb +0 -0
  10. data/europeana-blacklight.gemspec +7 -10
  11. data/lib/europeana/blacklight/engine.rb +7 -2
  12. data/lib/europeana/blacklight/{api_repository.rb → repository.rb} +1 -1
  13. data/lib/europeana/blacklight/routes.rb +8 -16
  14. data/lib/europeana/blacklight/search_builder.rb +2 -6
  15. data/lib/europeana/blacklight/version.rb +1 -1
  16. data/lib/europeana/blacklight.rb +2 -8
  17. data/spec/dummy/README.rdoc +28 -0
  18. data/spec/dummy/Rakefile +6 -0
  19. data/spec/dummy/app/assets/images/.keep +0 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  21. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  22. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  23. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/mailers/.keep +0 -0
  26. data/spec/dummy/app/models/.keep +0 -0
  27. data/spec/dummy/app/models/concerns/.keep +0 -0
  28. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  29. data/spec/dummy/bin/bundle +3 -0
  30. data/spec/dummy/bin/rails +4 -0
  31. data/spec/dummy/bin/rake +4 -0
  32. data/spec/dummy/bin/setup +29 -0
  33. data/spec/dummy/config/application.rb +31 -0
  34. data/spec/dummy/config/boot.rb +5 -0
  35. data/spec/dummy/config/database.yml +25 -0
  36. data/spec/dummy/config/environment.rb +5 -0
  37. data/spec/dummy/config/environments/development.rb +41 -0
  38. data/spec/dummy/config/environments/production.rb +79 -0
  39. data/spec/dummy/config/environments/test.rb +42 -0
  40. data/spec/dummy/config/initializers/assets.rb +11 -0
  41. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  42. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  43. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  44. data/spec/dummy/config/initializers/inflections.rb +16 -0
  45. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  46. data/spec/dummy/config/initializers/session_store.rb +3 -0
  47. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/spec/dummy/config/locales/en.yml +23 -0
  49. data/spec/dummy/config/routes.rb +56 -0
  50. data/spec/dummy/config/secrets.yml +22 -0
  51. data/spec/dummy/config.ru +4 -0
  52. data/spec/dummy/lib/assets/.keep +0 -0
  53. data/spec/dummy/log/.keep +0 -0
  54. data/spec/dummy/log/test.log +0 -0
  55. data/spec/dummy/public/404.html +67 -0
  56. data/spec/dummy/public/422.html +67 -0
  57. data/spec/dummy/public/500.html +66 -0
  58. data/spec/dummy/public/favicon.ico +0 -0
  59. data/spec/europeana/blacklight/repository_spec.rb +55 -0
  60. data/spec/europeana/blacklight/search_builder_spec.rb +3 -0
  61. data/spec/europeana/blacklight_spec.rb +7 -0
  62. data/spec/models/europeana/blacklight/document/lang_maps_spec.rb +3 -0
  63. data/spec/models/europeana/blacklight/document/more_like_this_spec.rb +59 -0
  64. data/spec/models/europeana/blacklight/document/relations_spec.rb +14 -0
  65. data/spec/models/europeana/blacklight/document_spec.rb +233 -0
  66. data/spec/presenters/europeana/blacklight/document_presenter_spec.rb +6 -0
  67. data/spec/spec_helper.rb +36 -0
  68. metadata +130 -51
  69. data/bin/console +0 -14
  70. data/bin/setup +0 -7
  71. data/lib/europeana/blacklight/facet_paginator.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c009d6e64d47908e4814d19edf92c58764e208e
4
- data.tar.gz: dae88754b44e1fabf5ba8dd7731559c4aa3fef18
3
+ metadata.gz: fd2eb749d05d56671137600760ee94c54860076f
4
+ data.tar.gz: 3d1fdf6a5191730cea50dc15547f4875217eb395
5
5
  SHA512:
6
- metadata.gz: 8795c06e1000dc9af5538daca798639ccf323db798aa08a2f3708ffc81fb77f390ae929cbe7b74f70a9f1ebf6bd9f1a9593090cc2a7c7a7c65d6aabe17e01cbf
7
- data.tar.gz: b93869c448d02abb45e6cc847bcf65c630988a62a5c261b9d9006ea9afc77bfe680d50de7d106787e5669e3dd39f181e52d809df0c2a0b8f8cc12c3fd210672b
6
+ metadata.gz: 28a19de2bda541663185b1905884d9b00b57a0c381af2df47cab66d7f5d05bae9df4339c70e9fd88fa6bd5fc5665ea2b8b36ca339efb131a332adc571240b9b0
7
+ data.tar.gz: f0bcbbdb6315dcfe4afc20347c3aba852fe747299eb4871566bdce9537c2dc5f6ef7fabdf864782d9c2b8029c6aa9e98222501e3619d0ee0d71ac72edf752ee8
data/QUICKSTART.md CHANGED
@@ -4,7 +4,7 @@
4
4
  ```
5
5
  gem install rails
6
6
  rails -v
7
- # Rails 4.2.4
7
+ # Rails 4.2.5
8
8
  ```
9
9
 
10
10
  ## Create a new Rails application
@@ -16,9 +16,7 @@ cd culture_vulture
16
16
  ## Bundle europeana-blacklight
17
17
  Add to the Gemfile:
18
18
  ```ruby
19
- gem 'europeana-blacklight',
20
- github: 'europeana/europeana-blacklight',
21
- require: 'europeana/blacklight'
19
+ gem 'europeana-blacklight', '~> 0.3'
22
20
  ```
23
21
 
24
22
  ## Get a Europeana API key
@@ -7,16 +7,13 @@ module Europeana
7
7
  include Europeana::Blacklight::SearchHelper
8
8
 
9
9
  included do
10
- self.search_params_logic = Europeana::Blacklight::SearchBuilder.default_processor_chain
11
-
12
10
  configure_blacklight do |config|
13
11
  # Adapter classes
14
- config.repository_class = Europeana::Blacklight::ApiRepository
12
+ config.repository_class = Europeana::Blacklight::Repository
15
13
  config.search_builder_class = Europeana::Blacklight::SearchBuilder
16
14
  config.response_model = Europeana::Blacklight::Response
17
15
  config.document_model = Europeana::Blacklight::Document
18
16
  config.document_presenter_class = Europeana::Blacklight::DocumentPresenter
19
- # config.facet_paginator_class = Europeana::Blacklight::FacetPaginator
20
17
 
21
18
  # Prevent BL's "did you mean" spellcheck feature kicking in
22
19
  config.spell_max = -1
@@ -28,7 +25,7 @@ module Europeana
28
25
  super || params.key?(:q) || params.key?(:mlt)
29
26
  end
30
27
 
31
- def search_results(user_params, _search_params_logic)
28
+ def search_results(user_params)
32
29
  super.tap do |results|
33
30
  if has_search_parameters?
34
31
  results.first[:facet_queries] = europeana_api_query_facet_counts(user_params)
@@ -3,6 +3,9 @@ module Europeana
3
3
  ##
4
4
  # Local overrides for {Blacklight::SearchHelper}
5
5
  module SearchHelper
6
+ extend ActiveSupport::Concern
7
+ include ::Blacklight::SearchHelper
8
+
6
9
  # index arg counts from 0; API start param counts from 1
7
10
  def previous_and_next_document_params(index, window = 1)
8
11
  start = index + 1
@@ -1,4 +1,3 @@
1
- require 'blacklight'
2
1
  require 'active_model'
3
2
  require 'iso-639'
4
3
 
@@ -7,10 +6,6 @@ module Europeana
7
6
  ##
8
7
  # A Europeana document
9
8
  class Document
10
- autoload :LangMaps, 'europeana/blacklight/document/lang_maps'
11
- autoload :MoreLikeThis, 'europeana/blacklight/document/more_like_this'
12
- autoload :Relations, 'europeana/blacklight/document/relations'
13
-
14
9
  include ActiveModel::Conversion
15
10
  include ::Blacklight::Document
16
11
  include ::Blacklight::Document::ActiveModelShim
@@ -1,6 +1,5 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
4
3
  require 'europeana/blacklight/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
@@ -13,22 +12,20 @@ Gem::Specification.new do |spec|
13
12
  spec.homepage = 'https://github.com/europeana/europeana-blacklight'
14
13
  spec.license = 'EUPL 1.1'
15
14
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = 'bin'
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
17
  spec.require_paths = ['lib']
20
18
 
21
19
  spec.required_ruby_version = '>= 2.0.0'
22
20
 
23
- spec.add_dependency 'activesupport', '>= 4.0', '< 5.0'
24
- spec.add_dependency 'blacklight', '>= 5.12.0', '< 6.0'
21
+ spec.add_dependency 'blacklight', '~> 6.0.0'
25
22
  spec.add_dependency 'europeana-api', '~> 0.4.1'
26
23
  spec.add_dependency 'iso-639', '~> 0.2.5'
27
- spec.add_dependency 'kaminari', '~> 0.16'
24
+ spec.add_dependency 'rails', '>= 4.2.2', '< 5'
28
25
 
29
26
  spec.add_development_dependency 'bundler', '~> 1.8'
30
27
  spec.add_development_dependency 'rake', '~> 10.0'
31
- spec.add_development_dependency 'rspec', '~> 3.2'
28
+ spec.add_development_dependency 'rspec-rails', '~> 3.0'
32
29
  spec.add_development_dependency 'shoulda-matchers', '~> 2.8'
33
30
  spec.add_development_dependency 'webmock', '~> 1.21'
34
31
  end
@@ -3,9 +3,14 @@ module Europeana
3
3
  class Engine < Rails::Engine
4
4
  engine_name 'europeana_blacklight'
5
5
 
6
- initializer 'europeana_blacklight.routes' do |_app|
7
- ::Blacklight::Routes.send(:include, Europeana::Blacklight::Routes)
6
+ config.generators do |g|
7
+ g.test_framework :rspec
8
8
  end
9
+
10
+ config.autoload_paths += %W(
11
+ #{config.root}/app/presenters
12
+ #{config.root}/app/controllers/concerns
13
+ )
9
14
  end
10
15
  end
11
16
  end
@@ -4,7 +4,7 @@ module Europeana
4
4
  # Repository hooked up to Europeana REST API via europeana-api gem
5
5
  #
6
6
  # @see Europeana::API
7
- class ApiRepository < ::Blacklight::AbstractRepository
7
+ class Repository < ::Blacklight::AbstractRepository
8
8
  ##
9
9
  # Finds a single Europeana record via the API
10
10
  #
@@ -1,24 +1,16 @@
1
1
  module Europeana
2
2
  module Blacklight
3
3
  ##
4
- # URL routing for Blacklight
5
- module Routes
6
- extend ActiveSupport::Concern
7
-
8
- included do |klass|
9
- klass.default_route_sets -= [:solr_document]
10
- unless klass.default_route_sets.include?(:europeana_document)
11
- klass.default_route_sets += [:europeana_document]
12
- end
4
+ # URL routing for Europeana records
5
+ class Routes
6
+ def initialize(defaults = {})
7
+ @defaults = defaults
13
8
  end
14
9
 
15
- def europeana_document(primary_resource)
16
- add_routes do |options|
17
- args = { only: [:show] }
18
- args[:constraints] = options[:constraints] if options[:constraints]
19
-
20
- post 'record/*id/track', args.merge(to: "#{primary_resource}#track", as: 'track_document')
21
- get 'record/*id', args.merge(to: "#{primary_resource}#show", as: 'document')
10
+ def call(mapper, _options = {})
11
+ constraints id: %r{[^/]+/[^/]+} do
12
+ mapper.post 'record/*id/track', action: 'track', as: 'track'
13
+ mapper.get 'record/*id', action: 'show', as: 'show'
22
14
  end
23
15
  end
24
16
  end
@@ -8,7 +8,6 @@ module Europeana
8
8
  require 'europeana/blacklight/search_builder/overlay_params'
9
9
  require 'europeana/blacklight/search_builder/ranges'
10
10
 
11
- attr_accessor :default_processor_chain
12
11
  self.default_processor_chain = [
13
12
  :default_api_parameters, :add_profile_to_api,
14
13
  :add_query_to_api, :add_qf_to_api, :add_facet_qf_to_api, :add_query_facet_to_api,
@@ -47,11 +46,8 @@ module Europeana
47
46
  #
48
47
  # @see http://labs.europeana.eu/api/search/#profile-parameter
49
48
  def add_profile_to_api(api_parameters)
50
- if blacklight_config.facet_fields
51
- api_parameters[:profile] = 'params facets rich'
52
- else
53
- api_parameters[:profile] = 'params rich'
54
- end
49
+ api_parameters[:profile] = 'params rich'
50
+ api_parameters[:profile] << ' facets' if blacklight_config.facet_fields
55
51
  end
56
52
 
57
53
  ##
@@ -1,5 +1,5 @@
1
1
  module Europeana
2
2
  module Blacklight
3
- VERSION = '0.3.3'
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -1,18 +1,12 @@
1
- require 'active_support/core_ext/hash'
2
- require 'active_support/core_ext/module/delegation'
3
1
  require 'blacklight'
4
- require 'europeana/api'
5
- require 'europeana/blacklight/engine' if defined?(Rails)
6
- require 'europeana/blacklight/version'
2
+ require 'europeana/blacklight/engine'
7
3
 
8
4
  module Europeana
9
5
  ##
10
6
  # Adapter to use the Europeana REST API as a {Blacklight} data source
11
7
  module Blacklight
12
- autoload :ApiRepository, 'europeana/blacklight/api_repository'
13
- autoload :Document, 'europeana/blacklight/document'
14
8
  autoload :DocumentPresenter, 'europeana/blacklight/document_presenter'
15
- # autoload :FacetPaginator, 'europeana/blacklight/facet_paginator'
9
+ autoload :Repository, 'europeana/blacklight/repository'
16
10
  autoload :Response, 'europeana/blacklight/response'
17
11
  autoload :Routes, 'europeana/blacklight/routes'
18
12
  autoload :SearchBuilder, 'europeana/blacklight/search_builder'
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ # require 'active_record/railtie'
5
+ require 'action_controller/railtie'
6
+ require 'action_mailer/railtie'
7
+ require 'action_view/railtie'
8
+ require 'sprockets/railtie'
9
+ # require 'rails/test_unit/railtie'
10
+
11
+ Bundler.require(*Rails.groups)
12
+ require 'europeana/blacklight'
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
21
+ # Run 'rake -D time' for a list of tasks for finding time zone names. Default is UTC.
22
+ # config.time_zone = 'Central Time (US & Canada)'
23
+
24
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
25
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
26
+ # config.i18n.default_locale = :de
27
+
28
+ # Do not swallow errors in after_commit/after_rollback callbacks.
29
+ # config.active_record.raise_in_transactional_callbacks = true
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)