Skip to content

Commit

Permalink
Remove deprecated methods in preparation for 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Sep 21, 2015
1 parent b0eecb9 commit f3db659
Show file tree
Hide file tree
Showing 23 changed files with 20 additions and 792 deletions.
62 changes: 3 additions & 59 deletions app/helpers/blacklight/blacklight_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Blacklight::BlacklightHelperBehavior
include RenderConstraintsHelper
include RenderPartialsHelper
include FacetsHelper
extend Deprecation

##
# Get the name of this application, from either:
Expand Down Expand Up @@ -249,8 +248,6 @@ def document_show_html_title document=nil

##
# Render the document "heading" (title) in a content tag
# @overload render_document_heading(tag)
# @params [Symbol] tag
# @overload render_document_heading(document, options)
# @params [SolrDocument] document
# @params [Hash] options
Expand All @@ -260,17 +257,9 @@ def document_show_html_title document=nil
# @options options [Symbol] :tag
def render_document_heading(*args)
options = args.extract_options!

tag_or_document = args.first

if tag_or_document.is_a? String or tag_or_document.is_a? Symbol
Deprecation.warn(Blacklight::BlacklightHelperBehavior, "#render_document_heading with a tag argument is deprecated; pass e.g. `tag: :h4` instead")
tag = tag_or_document
document = @document
else
tag = options.fetch(:tag, :h4)
document = tag_or_document || @document
end
document = args.first
tag = options.fetch(:tag, :h4)
document = document || @document

content_tag(tag, presenter(document).document_heading, itemprop: "name")
end
Expand All @@ -294,33 +283,6 @@ def get_field_values document, field, field_config, options = {}
presenter(document).get_field_values field, field_config, options
end

##
# Render a value (or array of values) from a field
#
# @deprecated Use DocumentPresenter instead
# @param [String] value or list of values to display
# @param [Blacklight::Solr::Configuration::Field] solr field configuration
# @return [String]
def render_field_value value=nil, field_config=nil
safe_values = Array(value).collect { |x| x.respond_to?(:force_encoding) ? x.force_encoding("UTF-8") : x }

if field_config and field_config.itemprop
safe_values = safe_values.map { |x| content_tag :span, x, :itemprop => field_config.itemprop }
end

safe_join(safe_values, (field_config.separator if field_config) || field_value_separator)
end
deprecation_deprecate render_field_value: "use DocumentPresenter.render_field_value instead"

##
# Default separator to use in #render_field_value
#
# @return [String]
def field_value_separator
', '
end
deprecation_deprecate field_value_separator: "use DocumentPresenter.field_value_separator instead"

##
# Get the current "view type" (and ensure it is a valid type)
#
Expand All @@ -336,24 +298,6 @@ def document_index_view_type query_params=params
end
end

##
# Render the document index heading
#
# @param [SolrDocument] doc
# @param [Hash] opts (deprecated)
# @option opts [Symbol] :label Render the given field from the document
# @option opts [Proc] :label Evaluate the given proc
# @option opts [String] :label Render the given string
# @param [Symbol, Proc, String] field Render the given field or evaluate the proc or render the given string
def render_document_index_label doc, field, opts = {}
if field.is_a? Hash
Deprecation.warn self, "Calling render_document_index_label with a hash is deprecated"
field = field[:label]
end
presenter(doc).render_document_index_label field, opts
end
deprecation_deprecate render_document_index_label: "use presenter(doc).render_document_index_label instead"

##
# Render a partial of an arbitrary format inside a
# template of a different format. (e.g. render an HTML
Expand Down
5 changes: 0 additions & 5 deletions app/helpers/blacklight/catalog_helper_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- encoding : utf-8 -*-
module Blacklight::CatalogHelperBehavior
extend Deprecation
self.deprecation_horizon = "Blacklight 6.x"

##
# Override the Kaminari page_entries_info helper with our own, blacklight-aware
Expand Down Expand Up @@ -242,9 +240,6 @@ def bookmarked? document
current_bookmarks.any? { |x| x.document_id == document.id and x.document_type == document.class }
end

alias_method :is_bookmarked?, :bookmarked?
deprecation_deprecate :is_bookmarked?

def render_sms_action? config, options = {}
!sms_mappings.blank?
end
Expand Down
6 changes: 1 addition & 5 deletions app/helpers/blacklight/configuration_helper_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module Blacklight::ConfigurationHelperBehavior
extend Deprecation
self.deprecation_horizon = 'blacklight 6.0'

##
# Index fields to display for a type of document
Expand Down Expand Up @@ -122,9 +120,7 @@ def field_label *i18n_keys

t(first, default: rest)
end
alias_method :solr_field_label, :field_label
deprecation_deprecate solr_field_label: :field_label


def document_index_views
blacklight_config.view.select do |k, config|
should_render_field? config
Expand Down
10 changes: 0 additions & 10 deletions app/helpers/blacklight/url_helper_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require 'deprecation'
##
# URL helper methods
module Blacklight::UrlHelperBehavior
extend Deprecation
self.deprecation_horizon = 'blacklight 6.0'

##
# Extension point for downstream applications
Expand Down Expand Up @@ -65,13 +62,6 @@ def link_to_next_document(next_document)
end
end

##
# Current search context parameters
def search_session_params counter
{ :'data-counter' => counter, :'data-search_id' => current_search_session.try(:id) }
end
deprecation_deprecate search_session_params: :session_tracking_params

##
# Attributes for a link that gives a URL we can use to track clicks for the current search session
# @param [SolrDocument] document
Expand Down
24 changes: 1 addition & 23 deletions lib/blacklight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
module Blacklight::Catalog
extend ActiveSupport::Concern
extend ActiveSupport::Autoload
extend Deprecation

eager_autoload do
autoload :ComponentConfiguration
Expand All @@ -14,11 +13,6 @@ module Blacklight::Catalog
include Blacklight::Catalog::ComponentConfiguration
include Blacklight::Facet

# rubocop:disable Style/ConstantName
# @deprecated use blacklight_config.search_history_window instead
SearchHistoryWindow = 100 # how many searches to save in session history
# rubocop:enable Style/ConstantName

# The following code is executed when someone includes blacklight::catalog in their
# own controller.
included do
Expand All @@ -28,9 +22,6 @@ module Blacklight::Catalog
# the exception appropriately.
rescue_from Blacklight::Exceptions::RecordNotFound, with: :invalid_document_id_error

# Deprecated:
rescue_from Blacklight::Exceptions::InvalidSolrID, with: :invalid_document_id_error

record_search_parameters
end

Expand Down Expand Up @@ -137,9 +128,6 @@ def store_preferred_view
session[:preferred_view] = params[:view] if params[:view]
end

alias_method :preferred_view, :store_preferred_view
deprecation_deprecate :preferred_view

##
# Render additional response formats for the index action, as provided by the
# blacklight configuration
Expand Down Expand Up @@ -296,16 +284,7 @@ def validate_email_params
# Just returns a 404 response, but you can override locally in your own
# CatalogController to do something else -- older BL displayed a Catalog#inde
# page with a flash message and a 404 status.
def invalid_document_id_error *args
Deprecation.silence(Blacklight::Catalog) do
invalid_solr_id_error *args
end
end

##
# DEPRECATED; this method will be removed in Blacklight 6.0 and the functionality
# moved to invalid_document_id_error
def invalid_solr_id_error(exception)
def invalid_document_id_error(exception)
error_info = {
"status" => "404",
"error" => "#{exception.class}: #{exception.message}"
Expand All @@ -327,7 +306,6 @@ def invalid_solr_id_error(exception)
end
end
end
deprecation_deprecate invalid_solr_id_error: :invalid_document_id_error

def start_new_search_session?
action_name == "index"
Expand Down
31 changes: 2 additions & 29 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class Configuration < OpenStructWithHashAccess
require 'blacklight/configuration/facet_field'
require 'blacklight/configuration/sort_field'
include Fields
extend Deprecation
self.deprecation_horizon = 'blacklight 6.0'

# Set up Blacklight::Configuration.default_values to contain
# the basic, required Blacklight fields
Expand All @@ -34,14 +32,6 @@ def default_values
solr_path: 'select',
# Default values of parameters to send with every search request
default_solr_params: {},
## deprecated; use add_facet_field :include_in_request instead;
# if this is configured true, all facets will be included in the solr request
# unless explicitly disabled.
add_facet_fields_to_solr_request: false,
## deprecated; use add_index_field :include_in_request instead;
# if this is configured true, all show and index will be included in the solr request
# unless explicitly disabled.
add_field_configuration_to_solr_request: false,
##
# === Single document request configuration
##
Expand Down Expand Up @@ -137,8 +127,7 @@ def default_values
per_page: [10,20,50,100],
default_per_page: nil,
# how many searches to save in session history
# (TODO: move the value into the configuration?)
search_history_window: Blacklight::Catalog::SearchHistoryWindow,
search_history_window: 100,
default_facet_limit: 10
}
end
Expand Down Expand Up @@ -185,14 +174,11 @@ def initialize_default_values!
def document_model
super || ::SolrDocument
end
alias_method :solr_document_model, :document_model

# only here to support alias_method
def document_model= *args
super
end
alias_method :solr_document_model=, :document_model=
deprecation_deprecate solr_document_model: :document_model, :solr_document_model= => :document_model=

def document_presenter_class
super || Blacklight::DocumentPresenter
Expand All @@ -201,13 +187,10 @@ def document_presenter_class
def response_model
super || Blacklight::SolrResponse
end
alias_method :solr_response_model, :response_model
# only here to support alias_method

def response_model= *args
super
end
alias_method :solr_response_model=, :response_model=
deprecation_deprecate solr_response_model: :response_model, :solr_response_model= => :response_model=

def repository_class
super || Blacklight::SolrRepository
Expand Down Expand Up @@ -317,16 +300,6 @@ def add_field_configuration_to_solr_request! *fields
end
end

##
# Deprecated. Get the list of facet fields to explicitly
# add to the solr request
def facet_fields_to_add_to_solr
facet_fields.select { |k,v| v.include_in_request }
.reject { |k,v| v[:query] || v[:pivot] }
.map { |k,v| v.field }
end
deprecation_deprecate :facet_fields_to_add_to_solr

##
# Provide a 'deep copy' of Blacklight::Configuration that can be modifyed without affecting
# the original Blacklight::Configuration instance.
Expand Down
6 changes: 1 addition & 5 deletions lib/blacklight/configuration/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ class Configuration
# solr fields configuration
module Fields
extend ActiveSupport::Concern
extend Deprecation
self.deprecation_horizon = "blacklight 6.0"

module ClassMethods

Expand Down Expand Up @@ -118,10 +116,8 @@ def add_blacklight_field config_key, *args, &block

raise "A #{config_key} with the key #{field_config.key} already exists." if self[config_key.pluralize][field_config.key].present?

self[config_key.pluralize][ field_config.key ] = field_config
self[config_key.pluralize][ field_config.key ] = field_config
end
alias_method :add_solr_field, :add_blacklight_field
deprecation_deprecate add_solr_field: :add_blacklight_field

protected
def luke_fields
Expand Down
62 changes: 0 additions & 62 deletions lib/blacklight/configuration/view_config.rb
Original file line number Diff line number Diff line change
@@ -1,71 +1,9 @@
require 'deprecation'

class Blacklight::Configuration
class ViewConfig < Blacklight::OpenStructWithHashAccess
class Show < ViewConfig
extend Deprecation
self.deprecation_horizon = 'blacklight 6.0'

def html_title
Deprecation.warn(self.class, "config.show.html_title is deprecated; use config.show.title_field instead")
fetch(:html_title, title_field)
end

def heading
Deprecation.warn(self.class, "config.show.heading is deprecated; use config.show.title_field instead")
fetch(:heading, title_field)
end

def display_type
Deprecation.warn(self.class, "config.show.display_type is deprecated; use config.show.display_type_field instead")
fetch(:display_type, display_type_field)
end

def html_title= value
Deprecation.warn(self.class, "config.show.html_title is deprecated; use config.show.title_field instead")
super value
self.title_field = value
end

def heading= value
Deprecation.warn(self.class, "config.show.heading is deprecated; use config.show.title_field instead")
super value
self.title_field = value
end

def display_type= value
Deprecation.warn(self.class, "config.show.display_type is deprecated; use config.show.display_type_field instead")
super value
self.display_type_field = value
end
end

class Index < ViewConfig
extend Deprecation
self.deprecation_horizon = 'blacklight 6.0'

def record_display_type
Deprecation.warn(self.class, "config.index.record_display_type is deprecated; use config.index.display_type_field instead")
fetch(:record_display_type, display_type_field)
end

def record_display_type= value
Deprecation.warn(self.class, "config.index.record_display_type is deprecated; use config.index.display_type_field instead")
super value
self.display_type_field = value
end

def show_link
Deprecation.warn(self.class, "config.index.show_link is deprecated; use config.index.title_field instead")
fetch(:show_link, title_field)
end

def show_link= value
Deprecation.warn(self.class, "config.index.show_link is deprecated; use config.index.title_field instead")
super value
self.title_field = value
end

end
end
end
Loading

0 comments on commit f3db659

Please sign in to comment.