blacklight_advanced_search 7.0.0 → 8.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +126 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +3 -1
  5. data/Gemfile +2 -9
  6. data/README.md +43 -57
  7. data/VERSION +1 -1
  8. data/blacklight_advanced_search.gemspec +3 -2
  9. data/config/routes.rb +1 -1
  10. data/lib/blacklight_advanced_search/advanced_query_parser.rb +24 -38
  11. data/lib/blacklight_advanced_search/advanced_search_builder.rb +26 -23
  12. data/lib/blacklight_advanced_search/controller.rb +15 -16
  13. data/lib/blacklight_advanced_search/redirect_legacy_params_filter.rb +23 -6
  14. data/lib/blacklight_advanced_search.rb +0 -4
  15. data/lib/generators/blacklight_advanced_search/install_generator.rb +3 -37
  16. data/lib/parsing_nesting/grammar.rb +0 -12
  17. data/solr/conf/solrconfig.xml +2 -1
  18. data/spec/features/blacklight_advanced_search_form_spec.rb +10 -15
  19. data/spec/lib/advanced_search_builder_spec.rb +11 -8
  20. data/spec/spec_helper.rb +46 -14
  21. data/spec/test_app_templates/app/controllers/catalog_controller.rb +1 -3
  22. metadata +36 -51
  23. data/.travis.yml +0 -21
  24. data/app/assets/javascripts/blacklight_advanced_search.js +0 -5
  25. data/app/assets/stylesheets/blacklight_advanced_search/advanced_results.css +0 -21
  26. data/app/assets/stylesheets/blacklight_advanced_search/blacklight_advanced_search_styles.css.scss +0 -62
  27. data/app/assets/stylesheets/blacklight_advanced_search.css +0 -6
  28. data/app/controllers/advanced_controller.rb +0 -25
  29. data/app/controllers/blacklight_advanced_search/advanced_controller.rb +0 -25
  30. data/app/helpers/advanced_helper.rb +0 -4
  31. data/app/helpers/blacklight_advanced_search/advanced_helper_behavior.rb +0 -57
  32. data/app/views/advanced/_advanced_search_facets.html.erb +0 -16
  33. data/app/views/advanced/_advanced_search_facets_as_select.html.erb +0 -30
  34. data/app/views/advanced/_advanced_search_fields.html.erb +0 -8
  35. data/app/views/advanced/_advanced_search_form.html.erb +0 -43
  36. data/app/views/advanced/_advanced_search_help.html.erb +0 -24
  37. data/app/views/advanced/_advanced_search_submit_btns.html.erb +0 -12
  38. data/app/views/advanced/_facet_limit.html.erb +0 -15
  39. data/app/views/advanced/index.html.erb +0 -21
  40. data/app/views/blacklight_advanced_search/_facet_limit.html.erb +0 -16
  41. data/config/jetty.yml +0 -4
  42. data/config/locales/blacklight_advanced_search.en.yml +0 -12
  43. data/lib/blacklight_advanced_search/catalog_helper_override.rb +0 -30
  44. data/lib/blacklight_advanced_search/filter_parser.rb +0 -11
  45. data/lib/blacklight_advanced_search/parsing_nesting_parser.rb +0 -15
  46. data/lib/blacklight_advanced_search/render_constraints_override.rb +0 -136
  47. data/lib/generators/blacklight_advanced_search/assets_generator.rb +0 -53
  48. data/lib/generators/blacklight_advanced_search/templates/advanced_controller.rb +0 -56
  49. data/lib/generators/blacklight_advanced_search/templates/saved_searches_controller.rb +0 -6
  50. data/lib/generators/blacklight_advanced_search/templates/search_history_controller.rb +0 -6
  51. data/spec/helpers/advanced_helper_spec.rb +0 -13
  52. data/spec/lib/blacklight_advanced_search/parsing_nesting_parser_spec.rb +0 -20
  53. data/spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb +0 -39
  54. data/spec/lib/filter_parser_spec.rb +0 -22
@@ -1,25 +0,0 @@
1
- # This class should NOT be generated into local app. If you generated
2
- # into local app in a previous version, remove that, config is done
3
- # in CatalogController now.
4
- #
5
- # Note that this NEEDS to sub-class CatalogController, so it gets any
6
- # custom searching behavior you've added, and uses when fetching facets
7
- # etc. It does that right now because BlacklightAdvancedSearch::AdvancedController
8
- # is hard-coded to subclass CatalogController.
9
- #
10
- # TODO:
11
- # This seperate controller may not need to exist at all -- it just exists
12
- # to provide the advanced search form (and fetching of facets to display
13
- # on that form). Instead, mix-in a new "advanced" action to CatalogController?
14
- # (Make a backwards compat route though).
15
- #
16
- # Alternately, if this does exist as a seperate controller, it should
17
- # _directly_ < CatalogController, and BlacklightAdvancedSearch::AdvancedController
18
- # should be a mix-in that does not assume parent controller. Then, if you have
19
- # multi-controllers, you just need to create new `AdvancedControllerForX < XController`
20
- # which still mixes in BlacklightAdvancedSearch::AdvancedController. There
21
- # are probably some other edges that need to be smoothed for that approach, but
22
- # that'd be the direction.
23
- class AdvancedController < BlacklightAdvancedSearch::AdvancedController
24
- copy_blacklight_config_from(CatalogController)
25
- end
@@ -1,25 +0,0 @@
1
- # Need to sub-class CatalogController so we get all other plugins behavior
2
- # for our own "inside a search context" lookup of facets.
3
- class BlacklightAdvancedSearch::AdvancedController < CatalogController
4
- def index
5
- @response = get_advanced_search_facets unless request.method == :post
6
- end
7
-
8
- protected
9
-
10
- # Override to use the engine routes
11
- def search_action_url(options = {})
12
- blacklight_advanced_search_engine.url_for(options.merge(action: 'index'))
13
- end
14
-
15
- def get_advanced_search_facets
16
- # We want to find the facets available for the current search, but:
17
- # * IGNORING current query (add in facets_for_advanced_search_form filter)
18
- # * IGNORING current advanced search facets (remove add_advanced_search_to_solr filter)
19
- response, _ = search_service.search_results do |search_builder|
20
- search_builder.except(:add_advanced_search_to_solr).append(:facets_for_advanced_search_form)
21
- end
22
-
23
- response
24
- end
25
- end
@@ -1,4 +0,0 @@
1
- # Helper methods for the advanced search form
2
- module AdvancedHelper
3
- include BlacklightAdvancedSearch::AdvancedHelperBehavior
4
- end
@@ -1,57 +0,0 @@
1
- module BlacklightAdvancedSearch
2
- # implementation for AdvancedHelper
3
- module AdvancedHelperBehavior
4
- # Fill in default from existing search, if present
5
- # -- if you are using same search fields for basic
6
- # search and advanced, will even fill in properly if existing
7
- # search used basic search on same field present in advanced.
8
- def label_tag_default_for(key)
9
- if !params[key].blank?
10
- return params[key]
11
- elsif params["search_field"] == key
12
- return params["q"]
13
- else
14
- return nil
15
- end
16
- end
17
-
18
- # Is facet value in adv facet search results?
19
- def facet_value_checked?(field, value)
20
- BlacklightAdvancedSearch::QueryParser.new(params, blacklight_config).filters_include_value?(field, value)
21
- end
22
-
23
- def select_menu_for_field_operator
24
- options = {
25
- t('blacklight_advanced_search.all') => 'AND',
26
- t('blacklight_advanced_search.any') => 'OR'
27
- }.sort
28
-
29
- select_tag(:op, options_for_select(options, params[:op]), class: 'input-small')
30
- end
31
-
32
- # Current params without fields that will be over-written by adv. search,
33
- # or other fields we don't want.
34
- def advanced_search_context
35
- my_params = search_state.params_for_search.except :page, :f_inclusive, :q, :search_field, :op, :index, :sort
36
-
37
- my_params.except!(*search_fields_for_advanced_search.map { |_key, field_def| field_def[:key] })
38
- end
39
-
40
- def search_fields_for_advanced_search
41
- @search_fields_for_advanced_search ||= begin
42
- blacklight_config.search_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
43
- end
44
- end
45
-
46
- def facet_field_names_for_advanced_search
47
- @facet_field_names_for_advanced_search ||= begin
48
- blacklight_config.facet_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }.values.map(&:field)
49
- end
50
- end
51
-
52
- # Use configured facet partial name for facet or fallback on 'catalog/facet_limit'
53
- def advanced_search_facet_partial_name(display_facet)
54
- facet_configuration_for_field(display_facet.name).try(:partial) || "catalog/facet_limit"
55
- end
56
- end
57
- end
@@ -1,16 +0,0 @@
1
- <%# used to render facets with checkboxes on advanced search form,
2
- we pretty much just use the built-in blacklight render_facet_partials
3
- helper.
4
-
5
- But we've provided a local override of the _facet_limit
6
- partial in our own `views/advanced/_facet_limit.html.erb`,
7
- that is written to include checkboxes for form selection.
8
-
9
- This is the default display of facets, but you can
10
- also choose to use _advanced_search_facets_as_select,
11
- for a chosen.js-compatible multi-select.
12
- %>
13
-
14
- <div class="advanced-facet-limits panel-group">
15
- <%= render_facet_partials facet_field_names_for_advanced_search %>
16
- </div>
@@ -1,30 +0,0 @@
1
- <%# alternate version of facets on form that renders using multi-select.
2
- Has to copy and paste more code from blacklight than default, making
3
- it somewhat more fragile.
4
-
5
- Logic taken from facets_helper_behavior.rb, #render_facet_partials and
6
- #render_facet_limit.
7
- %>
8
-
9
- <% facets_from_request(facet_field_names).each do |display_facet| %>
10
- <% if display_facet.items.present? %>
11
- <div class="form-group advanced-search-facet">
12
- <%= label_tag display_facet.name.parameterize, :class => "col-sm-3 control-label" do %>
13
- <%= facet_field_label(display_facet.name) %>
14
- <% end %>
15
-
16
- <div class="col-sm-9">
17
- <%= content_tag(:select, :multiple => true,
18
- :name => "f_inclusive[#{display_facet.name}][]",
19
- :id => display_facet.name.parameterize,
20
- :class => "form-control advanced-search-facet-select") do %>
21
- <% display_facet.items.each do |facet_item| %>
22
- <%= content_tag :option, :value => facet_item.value, :selected => facet_value_checked?(display_facet.name, facet_item.value) do %>
23
- <%= facet_item.label %>&nbsp;&nbsp;(<%= number_with_delimiter facet_item.hits %>)
24
- <% end %>
25
- <% end %>
26
- <% end %>
27
- </div>
28
- </div>
29
- <% end %>
30
- <% end %>
@@ -1,8 +0,0 @@
1
- <%- search_fields_for_advanced_search.each do |key, field_def| -%>
2
- <div class="form-group advanced-search-field">
3
- <%= label_tag key, "#{field_def.label }", :class => "col-sm-3 control-label" %>
4
- <div class="col-sm-9">
5
- <%= text_field_tag key, label_tag_default_for(key), :class => 'form-control' %>
6
- </div>
7
- </div>
8
- <%- end -%>
@@ -1,43 +0,0 @@
1
- <% unless (search_context_str = render_search_to_s( advanced_search_context)).blank? %>
2
- <div class="constraints well search_history">
3
- <h4><%= t 'blacklight_advanced_search.form.search_context' %></h4>
4
- <%= search_context_str %>
5
- </div>
6
- <% end %>
7
-
8
- <%= form_tag search_catalog_path, :class => 'advanced form-horizontal', :method => :get do %>
9
-
10
- <%= render_hash_as_hidden_fields(advanced_search_context) %>
11
-
12
- <div class="input-criteria">
13
-
14
- <div class="query-criteria">
15
- <h3 class="query-criteria-heading">
16
- <%= t('blacklight_advanced_search.form.query_criteria_heading_html', :select_menu => select_menu_for_field_operator ) %>
17
- </h3>
18
-
19
- <div id="advanced_search">
20
- <%= render 'advanced/advanced_search_fields' %>
21
- </div>
22
- </div>
23
-
24
- <div class="limit-criteria">
25
- <h3 class="limit-criteria-heading"><%= t('blacklight_advanced_search.form.limit_criteria_heading_html')%></h3>
26
-
27
- <div id="advanced_search_facets" class="limit_input">
28
- <% if blacklight_config.try(:advanced_search).try {|h| h[:form_facet_partial] } %>
29
- <%= render blacklight_config.advanced_search[:form_facet_partial] %>
30
- <% else %>
31
- <%= render 'advanced_search_facets' %>
32
- <% end %>
33
- </div>
34
- </div>
35
- </div>
36
-
37
- <hr>
38
-
39
- <div class="sort-submit-buttons clearfix">
40
- <%= render 'advanced_search_submit_btns' %>
41
- </div>
42
-
43
- <% end %>
@@ -1,24 +0,0 @@
1
- <div class='card card-default'>
2
- <div class="card-body">
3
- <h4 class="card-title">Search tips</h4>
4
- <ul class="advanced-help">
5
- <li>Select "match all" to require all fields.
6
- </li>
7
-
8
- <li>Select "match any" to find at least one field.
9
- </li>
10
-
11
- <li>Combine keywords and attributes to find specific items.
12
- </li>
13
-
14
- <li>Use quotation marks to search as a phrase.
15
-
16
- <li>Use "+" before a term to make it required. (Otherwise results matching only some of your terms may be included).</li>
17
-
18
- <li>Use "-" before a word or phrase to exclude.
19
-
20
- <li>Use "OR", "AND", and "NOT" to create complex boolean logic. You can use parentheses in your complex expressions. </li>
21
- <li>Truncation and wildcards are not supported - word-stemming is done automatically.</li>
22
- </ul>
23
- </div>
24
- </div>
@@ -1,12 +0,0 @@
1
- <div class="sort-buttons pull-left">
2
- <%= label_tag(:sort, t('blacklight_advanced_search.form.sort_label'), :class => "control-label") %>
3
- <%- sort_fields = active_sort_fields.values.map { |field_config| [sort_field_label(field_config.key), field_config.key] } %>
4
- <%= select_tag(:sort, options_for_select(sort_fields, h(current_sort_field && current_sort_field.key)), :class => "form-control sort-select") %>
5
- <%= hidden_field_tag(:search_field, blacklight_config.advanced_search[:url_key]) %>
6
- </div>
7
-
8
- <div class="submit-buttons pull-right">
9
- <%= link_to t('blacklight_advanced_search.form.start_over'), blacklight_advanced_search_engine.advanced_search_path, :class =>"btn btn-secondary advanced-search-start-over" %>
10
-
11
- <%= submit_tag t('blacklight_advanced_search.form.search_btn'), :class=>'btn btn-primary advanced-search-submit', :id => "advanced-search-submit" %>
12
- </div>
@@ -1,15 +0,0 @@
1
- <ul class="facet-values list-unstyled blacklight-advanced-facet-select">
2
- <% display_facet.items.each do |item| -%>
3
- <li>
4
- <span class="facet-checkbox">
5
- <%= check_box_tag "f_inclusive[#{field_name}][]", item.value.to_sym, facet_value_checked?(field_name, item.value), id: "f_inclusive_#{field_name}_#{item.value.parameterize}"%>
6
- </span>
7
-
8
- <span class="label-and-count">
9
- <%= label_tag "f_inclusive_#{field_name}_#{item.value.parameterize}" do %>
10
- <%= render_facet_value(facet_field, item, suppress_link: true) %>
11
- <% end %>
12
- <span>
13
- </li>
14
- <% end -%>
15
- </ul>
@@ -1,21 +0,0 @@
1
- <% @page_title = "More Search Options - #{application_name}" %>
2
-
3
- <div class="advanced-search-form col-sm-12">
4
-
5
- <h1 class="advanced page-header">
6
- <%= t('blacklight_advanced_search.form.title') %>
7
- <%= link_to t('blacklight_advanced_search.form.start_over'), blacklight_advanced_search_engine.advanced_search_path, :class =>"btn btn-secondary pull-right advanced-search-start-over" %>
8
- </h1>
9
-
10
- <div class="row">
11
-
12
- <div class="col-md-8">
13
- <%= render 'advanced_search_form' %>
14
- </div>
15
- <div class="col-md-4">
16
- <%= render "advanced_search_help" %>
17
- </div>
18
-
19
- </div>
20
-
21
- </div>
@@ -1,16 +0,0 @@
1
- <div class="advanced_facet_limit">
2
- <div class="inclusive_or card card-body bg-light mb-3">
3
- <h5>Any of:</h5>
4
- <ul class="list-unstyled facet-values">
5
- <% advanced_query.filters[facet_field.key].each do |value| %>
6
- <li>
7
- <span class="selected"><%= h(value) %></span>
8
- <%= link_to(remove_advanced_facet_param(facet_field.key, value, params), :class => "remove") do %>
9
- <span class="remove-icon"></span>✖<span class="sr-only">[remove]</span>
10
- <% end %>
11
- </li>
12
- <% end %>
13
- </ul>
14
- </div>
15
- <%= render_facet_limit display_facet, :layout => nil, :partial => advanced_search_facet_partial_name(display_facet) %>
16
- </div>
data/config/jetty.yml DELETED
@@ -1,4 +0,0 @@
1
- default:
2
- startup_wait: 15
3
- jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
4
- <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
@@ -1,12 +0,0 @@
1
- en:
2
- blacklight_advanced_search:
3
- all: all
4
- any: any
5
- form:
6
- title: More Search Options
7
- search_context: Within search
8
- limit_criteria_heading_html: "<strong>AND</strong> have these attributes"
9
- query_criteria_heading_html: "Find items that match %{select_menu} of"
10
- sort_label: "Sort results by"
11
- start_over: "Start over"
12
- search_btn: 'Search'
@@ -1,30 +0,0 @@
1
- module BlacklightAdvancedSearch::CatalogHelperOverride
2
- # Special display for facet limits that include adv search inclusive
3
- # or limits.
4
- def facet_partial_name(display_facet = nil)
5
- return "blacklight_advanced_search/facet_limit" if advanced_query && advanced_query.filters.keys.include?(display_facet.name)
6
- super
7
- end
8
-
9
- def remove_advanced_facet_param(field, value, my_params = params)
10
- my_params = Blacklight::SearchState.new(my_params, blacklight_config).to_h
11
- if (my_params[:f_inclusive] &&
12
- my_params[:f_inclusive][field] &&
13
- my_params[:f_inclusive][field].include?(value))
14
-
15
- my_params[:f_inclusive] = my_params[:f_inclusive].dup
16
- my_params[:f_inclusive][field] = my_params[:f_inclusive][field].dup
17
- my_params[:f_inclusive][field].delete(value)
18
-
19
- my_params[:f_inclusive].delete(field) if my_params[:f_inclusive][field].empty?
20
-
21
- my_params.delete(:f_inclusive) if my_params[:f_inclusive].empty?
22
- end
23
-
24
- my_params.delete_if do |key, _value|
25
- [:page, :id, :counter, :commit].include?(key)
26
- end
27
-
28
- my_params
29
- end
30
- end
@@ -1,11 +0,0 @@
1
- module BlacklightAdvancedSearch::FilterParser
2
- # Returns an array of solr :fq params. taking advanced search inclusive
3
- # facet value lists out of params.
4
- def generate_solr_fq
5
- filters.map do |solr_field, value_list|
6
- "#{solr_field}:(" +
7
- Array(value_list).collect { |v| '"' + v.gsub('"', '\"') + '"' }.join(" OR ") +
8
- ")"
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- require 'parsing_nesting/tree'
2
- module BlacklightAdvancedSearch::ParsingNestingParser
3
- def process_query(_params, config)
4
- queries = keyword_queries.map do |field, query|
5
- ParsingNesting::Tree.parse(query, config.advanced_search[:query_parser]).to_query(local_param_hash(field, config))
6
- end
7
- queries.join(" #{keyword_op} ")
8
- end
9
-
10
- def local_param_hash(key, config)
11
- field_def = config.search_fields[key] || {}
12
-
13
- (field_def[:solr_adv_parameters] || field_def[:solr_parameters] || {}).merge(field_def[:solr_local_parameters] || {})
14
- end
15
- end
@@ -1,136 +0,0 @@
1
- # Meant to be applied on top of Blacklight view helpers, to over-ride
2
- # certain methods from RenderConstraintsHelper (newish in BL),
3
- # to effect constraints rendering and search history rendering,
4
- module BlacklightAdvancedSearch::RenderConstraintsOverride
5
- def query_has_constraints?(localized_params = params)
6
- if is_advanced_search? localized_params
7
- true
8
- else
9
- !(localized_params[:q].blank? && localized_params[:f].blank? && localized_params[:f_inclusive].blank?)
10
- end
11
- end
12
-
13
- # Over-ride of Blacklight method, provide advanced constraints if needed,
14
- # otherwise call super.
15
- def render_constraints_query(my_params = params)
16
- if (advanced_query.nil? || advanced_query.keyword_queries.empty?)
17
- return super(my_params)
18
- else
19
- content = []
20
- advanced_query.keyword_queries.each_pair do |field, query|
21
- label = blacklight_config.search_fields[field][:label]
22
- content << render_constraint_element(
23
- label, query,
24
- :remove =>
25
- search_action_path(remove_advanced_keyword_query(field, my_params).except(:controller, :action))
26
- )
27
- end
28
- if (advanced_query.keyword_op == "OR" &&
29
- advanced_query.keyword_queries.length > 1)
30
- content.unshift content_tag(:span, "Any of:", class: 'operator')
31
- content_tag :span, class: "inclusive_or appliedFilter well" do
32
- safe_join(content.flatten, "\n")
33
- end
34
- else
35
- safe_join(content.flatten, "\n")
36
- end
37
- end
38
- end
39
-
40
- # Over-ride of Blacklight method, provide advanced constraints if needed,
41
- # otherwise call super.
42
- def render_constraints_filters(my_params = params)
43
- content = super(my_params)
44
-
45
- if advanced_query
46
- advanced_query.filters.each_pair do |field, value_list|
47
- label = facet_field_label(field)
48
- content << render_constraint_element(label,
49
- safe_join(Array(value_list), " <strong class='text-muted constraint-connector'>OR</strong> ".html_safe),
50
- :remove => search_action_path(remove_advanced_filter_group(field, my_params).except(:controller, :action))
51
- )
52
- end
53
- end
54
-
55
- content
56
- end
57
-
58
- # override of BL method, so our inclusive facet selections
59
- # are still recgonized for eg highlighting facet with selected
60
- # values.
61
- def facet_field_in_params?(field)
62
- return true if super
63
-
64
- # otherwise use our own logic.
65
- query = BlacklightAdvancedSearch::QueryParser.new(params, self.blacklight_config)
66
- return true if query.filters.keys.include?(field)
67
-
68
- false
69
- end
70
-
71
- def render_search_to_s_filters(my_params)
72
- content = super(my_params)
73
-
74
- advanced_query = BlacklightAdvancedSearch::QueryParser.new(my_params, blacklight_config)
75
-
76
- unless advanced_query.filters.empty?
77
- advanced_query.filters.each_pair do |field, values|
78
- # old-style, may still be in history
79
- values = values.keys if values.is_a? Hash
80
-
81
- label = facet_field_label(field)
82
-
83
- content << render_search_to_s_element(
84
- label,
85
- values.join(" OR ")
86
- )
87
- end
88
- end
89
- content
90
- end
91
-
92
- def render_search_to_s_q(my_params)
93
- content = super(my_params)
94
-
95
- advanced_query = BlacklightAdvancedSearch::QueryParser.new(my_params, blacklight_config)
96
-
97
- if (advanced_query.keyword_queries.length > 1 &&
98
- advanced_query.keyword_op == "OR")
99
- # Need to do something to make the inclusive-or search clear
100
-
101
- display_as = advanced_query.keyword_queries.collect do |field, query|
102
- h(blacklight_config.search_fields[field][:label] + ": " + query)
103
- end.join(" ; ")
104
-
105
- content << render_search_to_s_element("Any of",
106
- display_as,
107
- :escape_value => false
108
- )
109
- elsif !advanced_query.keyword_queries.empty?
110
- advanced_query.keyword_queries.each_pair do |field, query|
111
- label = blacklight_config.search_fields[field][:label]
112
-
113
- content << render_search_to_s_element(label, query)
114
- end
115
- end
116
-
117
- content
118
- end
119
-
120
- def remove_advanced_keyword_query(field, my_params = params)
121
- my_params = Blacklight::SearchState.new(my_params, blacklight_config).to_h
122
- my_params.delete(field)
123
- my_params
124
- end
125
-
126
- def remove_advanced_filter_group(field, my_params = params)
127
- if (my_params[:f_inclusive])
128
- my_params = Blacklight::SearchState.new(my_params, blacklight_config).to_h
129
- my_params[:f_inclusive] = my_params[:f_inclusive].dup
130
- my_params[:f_inclusive].delete(field)
131
-
132
- my_params.delete :f_inclusive if my_params[:f_inclusive].empty?
133
- end
134
- my_params
135
- end
136
- end
@@ -1,53 +0,0 @@
1
- # Copy BlacklightAdvancedSearch assets to public folder in current app.
2
- # If you want to do this on application startup, you can
3
- # add this next line to your one of your environment files --
4
- # generally you'd only want to do this in 'development', and can
5
- # add it to environments/development.rb:
6
- # require File.join(BlacklightAdvancedSearch.root, "lib", "generators", "blacklight", "assets_generator.rb")
7
- # BlacklightAdvancedSearch::AssetsGenerator.start(["--force", "--quiet"])
8
-
9
- # Need the requires here so we can call the generator from environment.rb
10
- # as suggested above.
11
- require 'rails/generators'
12
- require 'rails/generators/base'
13
- module BlacklightAdvancedSearch
14
- class AssetsGenerator < Rails::Generators::Base
15
- source_root File.join(BlacklightAdvancedSearch::Engine.root, 'app', 'assets')
16
-
17
- def css_asset
18
- application_css_location = Dir["app/assets/stylesheets/application{.css,.scss,.css.scss}"].first
19
-
20
- unless application_css_location
21
- say_status "skipped", "Can not find an application.css, did not insert our require", :red
22
- return
23
- end
24
-
25
- original_css = File.binread(application_css_location)
26
- if original_css.include?("require 'blacklight_advanced_search'")
27
- say_status("skipped", "insert into app/assets/stylesheets/application.css", :yellow)
28
- else
29
- insert_into_file application_css_location, :before => "*/" do
30
- "\n *= require 'blacklight_advanced_search'\n\n"
31
- end
32
- end
33
- end
34
-
35
- def js_asset
36
- application_js_location = Dir["app/assets/javascripts/application{.js,.coffee,.js.coffee}"].first
37
-
38
- unless application_js_location
39
- say_status "skipped", "Can not find an application.js, did not insert our require", :red
40
- return
41
- end
42
-
43
- original_js = File.binread(application_js_location)
44
- if original_js.include?("require 'blacklight_advanced_search'")
45
- say_status("skipped", "insert into app/assets/javascripts/application.js", :yellow)
46
- else
47
- insert_into_file application_js_location, :after => %r{//= require ['"]?jquery['"]?$} do
48
- "\n//= require 'blacklight_advanced_search'\n\n"
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,56 +0,0 @@
1
- class AdvancedController < BlacklightAdvancedSearch::AdvancedController
2
- blacklight_config.configure do |config|
3
- # name of Solr request handler, leave unset to use the same one your Blacklight
4
- # is ordinarily using (recommended if possible)
5
- # config.advanced_search.qt = 'advanced'
6
-
7
- ##
8
- # The advanced search form displays facets as a limit option.
9
- # By default it will use whatever facets, if any, are returned
10
- # by the Solr request handler in use. However, you can use
11
- # this config option to have it request other facet params than
12
- # default in the Solr request handler, in desired.
13
- config.advanced_search.form_solr_parameters = {}
14
-
15
- # name of key in Blacklight URL, no reason to change usually.
16
- config.advanced_search.url_key = 'advanced'
17
-
18
- # We are going to completely override the inherited search fields
19
- config.search_fields.clear
20
-
21
- config.add_search_field 'author' do |field|
22
- field.solr_local_parameters = {
23
- :pf => "$pf_author",
24
- :qf => "$qf_author"
25
- }
26
- end
27
-
28
- config.add_search_field 'title' do |field|
29
- field.solr_local_parameters = {
30
- :pf => "$pf_title",
31
- :qf => "$qf_title"
32
- }
33
- end
34
-
35
- config.add_search_field 'subject' do |field|
36
- field.solr_local_parameters = {
37
- :pf => "$pf_subject",
38
- :qf => "$qf_subject"
39
- }
40
- end
41
-
42
- config.add_search_field 'keyword' do |field|
43
- field.solr_local_parameters = {
44
- :pf => "$pf_keyword",
45
- :qf => "$qf_keyword"
46
- }
47
- end
48
-
49
- config.add_search_field 'number' do |field|
50
- field.solr_local_parameters = {
51
- :pf => "$pf_number",
52
- :qf => "$qf_number"
53
- }
54
- end
55
- end
56
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- class SavedSearchesController < ApplicationController
3
- include Blacklight::SavedSearches
4
-
5
- helper BlacklightAdvancedSearch::RenderConstraintsOverride
6
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- class SearchHistoryController < ApplicationController
3
- include Blacklight::SearchHistory
4
-
5
- helper BlacklightAdvancedSearch::RenderConstraintsOverride
6
- end