Sha256: b416ce71b49c106fca155c6df712f0c824ac83a1c8bd66a2a0ecef21f65b3e88

Contents?: true

Size: 962 Bytes

Versions: 4

Compression:

Stored size: 962 Bytes

Contents

require 'rails/generators'

module BlacklightAdvancedSearch
  class InstallGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    def inject_asset_requires
      generate "blacklight_advanced_search:assets"
    end
    
    
    def install_localized_search_form
      if options[:force] or yes?("Install local search form with advanced link? (y/N)", :green)
        # We're going to copy the search from from actual currently loaded
        # Blacklight into local app as custom local override -- but add our link at the end too. 
        source_file = File.read(File.join(Blacklight.root, "app/views/catalog/_search_form.html.erb"))

        new_file_contents = source_file + "\n\n<%= link_to 'More options', advanced_search_path(params.except(:controller, :action)), :class=>'advanced_search'%>"

        create_file("app/views/catalog/_search_form.html.erb", new_file_contents)      
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight_advanced_search-5.3.1 lib/generators/blacklight_advanced_search/install_generator.rb
blacklight_advanced_search-5.3.0 lib/generators/blacklight_advanced_search/install_generator.rb
blacklight_advanced_search-5.2.1 lib/generators/blacklight_advanced_search/install_generator.rb
blacklight_advanced_search-5.2.0 lib/generators/blacklight_advanced_search/install_generator.rb