Module: Blacklight
- Extended by:
- SearchFields
- Defined in:
- lib/blacklight/legacy_controller_methods.rb,
lib/blacklight.rb,
lib/blacklight/utils.rb,
lib/blacklight/routes.rb,
lib/blacklight/engine.rb,
lib/blacklight/version.rb,
lib/blacklight/exceptions.rb,
lib/blacklight/configuration.rb,
lib/blacklight/configuration/fields.rb,
lib/blacklight/configuration/sort_field.rb,
lib/blacklight/configuration/solr_field.rb,
lib/blacklight/configuration/facet_field.rb,
lib/generators/blacklight/jetty_generator.rb,
lib/blacklight/configuration/search_field.rb,
lib/generators/blacklight/assets_generator.rb,
lib/generators/blacklight/test_support_generator.rb
Overview
These controller methods are mixed into the ApplicationController, and are likely things new Blacklight apps won't need (e.g. because of advancements in Rails) but are ideas that are firmly baked into existing application or plugins, so we're keeping around for now. There are probably better ways of doing some of the things in here, but you may find them useful.
Defined Under Namespace
Modules: BlacklightHelperBehavior, Catalog, CatalogHelperBehavior, Configurable, Controller, Exceptions, FacetsHelperBehavior, HashAsHiddenFieldsHelperBehavior, HtmlHeadHelperBehavior, LegacyControllerMethods, RenderConstraintsHelperBehavior, SearchFields, SearchHistoryConstraintsHelperBehavior, Solr, SolrHelper, User Classes: Assets, Configuration, Engine, Jetty, OpenStructWithHashAccess, Routes, SolrResponse, TestSupport
Constant Summary
- VERSION =
self.version
Class Attribute Summary (collapse)
-
+ (Object) solr
Returns the value of attribute solr.
-
+ (Object) solr_config
Returns the value of attribute solr_config.
Class Method Summary (collapse)
- + (Object) add_routes(router, options = {})
- + (Object) controllers_dir
-
+ (Boolean) jruby?
Adding a little jruby support.
-
+ (Object) locate_path(*subpath_fragments)
Searches Rails.root then Blacklight.root for a valid path returns a full path if a valid path is found returns nil if nothing is found.
- + (Object) logger
-
+ (Object) models_dir
This is useful for modifying Blacklight models.
-
+ (Object) root
returns the full path the the blacklight plugin installation.
- + (Object) solr_file
- + (Object) solr_yml
- + (Object) version
Methods included from SearchFields
default_search_field, label_for_search_field, search_field_def_for_key, search_field_list, search_field_options_for_select
Class Attribute Details
+ (Object) solr
Returns the value of attribute solr
35 36 37 |
# File 'lib/blacklight.rb', line 35 def solr @solr end |
+ (Object) solr_config
Returns the value of attribute solr_config
35 36 37 |
# File 'lib/blacklight.rb', line 35 def solr_config @solr_config end |
Class Method Details
+ (Object) add_routes(router, options = {})
47 48 49 |
# File 'lib/blacklight.rb', line 47 def self.add_routes(router, = {}) Blacklight::Routes.new(router, ).draw end |
+ (Object) controllers_dir
119 120 121 |
# File 'lib/blacklight.rb', line 119 def self.controllers_dir "#{root}/app/controllers" end |
+ (Boolean) jruby?
Adding a little jruby support
39 40 41 |
# File 'lib/blacklight.rb', line 39 def self.jruby? defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" end |
+ (Object) locate_path(*subpath_fragments)
Searches Rails.root then Blacklight.root for a valid path returns a full path if a valid path is found returns nil if nothing is found. First looks in Rails.root, then Blacklight.root
Example: full_path_to_solr_marc_jar = Blacklight.locate_path 'solr_marc', 'SolrMarc.jar'
132 133 134 135 136 137 138 |
# File 'lib/blacklight.rb', line 132 def self.locate_path(*subpath_fragments) subpath = subpath_fragments.join('/') base_match = [Rails.root, self.root].find do |base| File.exists? File.join(base, subpath) end File.join(base_match.to_s, subpath) if base_match end |
+ (Object) logger
90 91 92 |
# File 'lib/blacklight.rb', line 90 def self.logger ::Rails.logger end |
+ (Object) models_dir
This is useful for modifying Blacklight models. In the main app you can then do this: require “#MyEngine.models_dir/bookmark” class Bookmark … end BE AWARE - When you do this, you are monkey patching Blacklight we should eventually find a better way - such as the acts_as pattern
115 116 117 |
# File 'lib/blacklight.rb', line 115 def self.models_dir "#{root}/app/models" end |
+ (Object) root
returns the full path the the blacklight plugin installation
103 104 105 |
# File 'lib/blacklight.rb', line 103 def self.root @root ||= File.(File.dirname(File.dirname(__FILE__))) end |
+ (Object) solr_file
43 44 45 |
# File 'lib/blacklight.rb', line 43 def self.solr_file "#{::Rails.root.to_s}/config/solr.yml" end |
+ (Object) solr_yml
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/blacklight.rb', line 62 def self.solr_yml require 'erb' require 'yaml' return @solr_yml if @solr_yml unless File.exists?(solr_file) raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight\"?" end begin @solr_erb = ERB.new(IO.read(solr_file)).result(binding) rescue Exception => e raise("solr.yml was found, but could not be parsed with ERB. \n#{$!.inspect}") end begin @solr_yml = YAML::load(@solr_erb) rescue StandardError => e raise("solr.yml was found, but could not be parsed.\n") end if @solr_yml.nil? || !@solr_yml.is_a?(Hash) raise("solr.yml was found, but was blank or malformed.\n") end return @solr_yml end |
+ (Object) version
4 5 6 |
# File 'lib/blacklight/version.rb', line 4 def self.version @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp end |