Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #23 from europeana/release/v0.4.0
Browse files Browse the repository at this point in the history
v0.4.0 release
  • Loading branch information
rwd committed Jan 25, 2016
2 parents a168829 + 77cd75f commit 6239ebd
Show file tree
Hide file tree
Showing 67 changed files with 773 additions and 95 deletions.
6 changes: 2 additions & 4 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```
gem install rails
rails -v
# Rails 4.2.4
# Rails 4.2.5
```

## Create a new Rails application
Expand All @@ -16,9 +16,7 @@ cd culture_vulture
## Bundle europeana-blacklight
Add to the Gemfile:
```ruby
gem 'europeana-blacklight',
github: 'europeana/europeana-blacklight',
require: 'europeana/blacklight'
gem 'europeana-blacklight', '~> 0.3'
```

## Get a Europeana API key
Expand Down
7 changes: 2 additions & 5 deletions app/controllers/concerns/europeana/blacklight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ module Catalog
include Europeana::Blacklight::SearchHelper

included do
self.search_params_logic = Europeana::Blacklight::SearchBuilder.default_processor_chain

configure_blacklight do |config|
# Adapter classes
config.repository_class = Europeana::Blacklight::ApiRepository
config.repository_class = Europeana::Blacklight::Repository
config.search_builder_class = Europeana::Blacklight::SearchBuilder
config.response_model = Europeana::Blacklight::Response
config.document_model = Europeana::Blacklight::Document
config.document_presenter_class = Europeana::Blacklight::DocumentPresenter
# config.facet_paginator_class = Europeana::Blacklight::FacetPaginator

# Prevent BL's "did you mean" spellcheck feature kicking in
config.spell_max = -1
Expand All @@ -28,7 +25,7 @@ def has_search_parameters?
super || params.key?(:q) || params.key?(:mlt)
end

def search_results(user_params, _search_params_logic)
def search_results(user_params)
super.tap do |results|
if has_search_parameters?
results.first[:facet_queries] = europeana_api_query_facet_counts(user_params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module Blacklight
##
# Local overrides for {Blacklight::SearchHelper}
module SearchHelper
extend ActiveSupport::Concern
include ::Blacklight::SearchHelper

# index arg counts from 0; API start param counts from 1
def previous_and_next_document_params(index, window = 1)
start = index + 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'blacklight'
require 'active_model'
require 'iso-639'

Expand All @@ -7,10 +6,6 @@ module Blacklight
##
# A Europeana document
class Document
autoload :LangMaps, 'europeana/blacklight/document/lang_maps'
autoload :MoreLikeThis, 'europeana/blacklight/document/more_like_this'
autoload :Relations, 'europeana/blacklight/document/relations'

include ActiveModel::Conversion
include ::Blacklight::Document
include ::Blacklight::Document::ActiveModelShim
Expand Down
14 changes: 0 additions & 14 deletions bin/console

This file was deleted.

7 changes: 0 additions & 7 deletions bin/setup

This file was deleted.

17 changes: 7 additions & 10 deletions europeana-blacklight.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$:.push File.expand_path("../lib", __FILE__)

require 'europeana/blacklight/version'

Gem::Specification.new do |spec|
Expand All @@ -13,22 +12,20 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/europeana/europeana-blacklight'
spec.license = 'EUPL 1.1'

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'bin'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.files = `git ls-files -z`.split("\x0")
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.0.0'

spec.add_dependency 'activesupport', '>= 4.0', '< 5.0'
spec.add_dependency 'blacklight', '>= 5.12.0', '< 6.0'
spec.add_dependency 'blacklight', '~> 6.0.0'
spec.add_dependency 'europeana-api', '~> 0.4.1'
spec.add_dependency 'iso-639', '~> 0.2.5'
spec.add_dependency 'kaminari', '~> 0.16'
spec.add_dependency 'rails', '>= 4.2.2', '< 5'

spec.add_development_dependency 'bundler', '~> 1.8'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.2'
spec.add_development_dependency 'rspec-rails', '~> 3.0'
spec.add_development_dependency 'shoulda-matchers', '~> 2.8'
spec.add_development_dependency 'webmock', '~> 1.21'
end
10 changes: 2 additions & 8 deletions lib/europeana/blacklight.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
require 'active_support/core_ext/hash'
require 'active_support/core_ext/module/delegation'
require 'blacklight'
require 'europeana/api'
require 'europeana/blacklight/engine' if defined?(Rails)
require 'europeana/blacklight/version'
require 'europeana/blacklight/engine'

module Europeana
##
# Adapter to use the Europeana REST API as a {Blacklight} data source
module Blacklight
autoload :ApiRepository, 'europeana/blacklight/api_repository'
autoload :Document, 'europeana/blacklight/document'
autoload :DocumentPresenter, 'europeana/blacklight/document_presenter'
# autoload :FacetPaginator, 'europeana/blacklight/facet_paginator'
autoload :Repository, 'europeana/blacklight/repository'
autoload :Response, 'europeana/blacklight/response'
autoload :Routes, 'europeana/blacklight/routes'
autoload :SearchBuilder, 'europeana/blacklight/search_builder'
Expand Down
9 changes: 7 additions & 2 deletions lib/europeana/blacklight/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ module Blacklight
class Engine < Rails::Engine
engine_name 'europeana_blacklight'

initializer 'europeana_blacklight.routes' do |_app|
::Blacklight::Routes.send(:include, Europeana::Blacklight::Routes)
config.generators do |g|
g.test_framework :rspec
end

config.autoload_paths += %W(
#{config.root}/app/presenters
#{config.root}/app/controllers/concerns
)
end
end
end
8 changes: 0 additions & 8 deletions lib/europeana/blacklight/facet_paginator.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Blacklight
# Repository hooked up to Europeana REST API via europeana-api gem
#
# @see Europeana::API
class ApiRepository < ::Blacklight::AbstractRepository
class Repository < ::Blacklight::AbstractRepository
##
# Finds a single Europeana record via the API
#
Expand Down
24 changes: 8 additions & 16 deletions lib/europeana/blacklight/routes.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
module Europeana
module Blacklight
##
# URL routing for Blacklight
module Routes
extend ActiveSupport::Concern

included do |klass|
klass.default_route_sets -= [:solr_document]
unless klass.default_route_sets.include?(:europeana_document)
klass.default_route_sets += [:europeana_document]
end
# URL routing for Europeana records
class Routes
def initialize(defaults = {})
@defaults = defaults
end

def europeana_document(primary_resource)
add_routes do |options|
args = { only: [:show] }
args[:constraints] = options[:constraints] if options[:constraints]

post 'record/*id/track', args.merge(to: "#{primary_resource}#track", as: 'track_document')
get 'record/*id', args.merge(to: "#{primary_resource}#show", as: 'document')
def call(mapper, _options = {})
constraints id: %r{[^/]+/[^/]+} do
mapper.post 'record/*id/track', action: 'track', as: 'track'
mapper.get 'record/*id', action: 'show', as: 'show'
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions lib/europeana/blacklight/search_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class SearchBuilder < ::Blacklight::SearchBuilder
require 'europeana/blacklight/search_builder/overlay_params'
require 'europeana/blacklight/search_builder/ranges'

attr_accessor :default_processor_chain
self.default_processor_chain = [
:default_api_parameters, :add_profile_to_api,
:add_query_to_api, :add_qf_to_api, :add_facet_qf_to_api, :add_query_facet_to_api,
Expand Down Expand Up @@ -47,11 +46,8 @@ def default_api_parameters(api_parameters)
#
# @see http://labs.europeana.eu/api/search/#profile-parameter
def add_profile_to_api(api_parameters)
if blacklight_config.facet_fields
api_parameters[:profile] = 'params facets rich'
else
api_parameters[:profile] = 'params rich'
end
api_parameters[:profile] = 'params rich'
api_parameters[:profile] << ' facets' if blacklight_config.facet_fields
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/europeana/blacklight/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Europeana
module Blacklight
VERSION = '0.3.3'
VERSION = '0.4.0'.freeze
end
end
28 changes: 28 additions & 0 deletions spec/dummy/README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
== README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...


Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
6 changes: 6 additions & 0 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks
Empty file.
13 changes: 13 additions & 0 deletions spec/dummy/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
15 changes: 15 additions & 0 deletions spec/dummy/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
5 changes: 5 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
Empty file.
2 changes: 2 additions & 0 deletions spec/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
Empty file added spec/dummy/app/mailers/.keep
Empty file.
Empty file added spec/dummy/app/models/.keep
Empty file.
Empty file.
14 changes: 14 additions & 0 deletions spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>
3 changes: 3 additions & 0 deletions spec/dummy/bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
4 changes: 4 additions & 0 deletions spec/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
4 changes: 4 additions & 0 deletions spec/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run
29 changes: 29 additions & 0 deletions spec/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)

Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:

puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"

# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end

puts "\n== Preparing database =="
system "bin/rake db:setup"

puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"

puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end
4 changes: 4 additions & 0 deletions spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
Loading

0 comments on commit 6239ebd

Please sign in to comment.