faceted_search 3.4.5 → 3.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6770117b9a14dfc64240d042bfc17cea9e3b83eddd2cf89c125aecf9399a601
4
- data.tar.gz: 1be079b99086cb78c98fa107526c5f28dbd5b248e72d041e56ba83f583bb7971
3
+ metadata.gz: '04106970c4095477714e7d1a968b62ed26b5d0bd155995c1bb90570fab2e7534'
4
+ data.tar.gz: 23d62e43c40553664cc941f8e5ec80090c5a7e5a39be72e5c06368427ff1c1cb
5
5
  SHA512:
6
- metadata.gz: c6422333f3c01441c3cc8421ccf5b76494afcf511d4be8d32b4d328a8a88e02eac59675764a51c2d33a77e297320815f67bb553c36185ecadf5f2535ae350041
7
- data.tar.gz: 61b88b0abb2bde9c968aac52b29d0bee547669d0f948817b8a92aa0fe42ca5853fefdeb14b4b3ec35909c4e459e198a18963b4b51a447055b551a9baf9ea7550
6
+ metadata.gz: cfd6cd87a2b7ba8be6ed284337169a9ea487aba35d5f0ffdbf3b0d662c78b0d05aa611b11e75ee9171030929a63fa4fd1a60e24f7e044ee25c8fb37b5bf2bff1
7
+ data.tar.gz: a32ca6d1a6c37bd1b84b246b824415bcae8ec712878606f77f115de4a55cf40341afca91273ba2b5c4e1c269114688a1d61e300b85853017c0ef31030012c1f8
data/README.md CHANGED
@@ -56,6 +56,15 @@ Create a model defining your facets:
56
56
  # children.order(:title)
57
57
  # }
58
58
  # }
59
+
60
+ # Other option, with searchable (SEO) categories
61
+ filter_with_full_tree :categories, {
62
+ habtm: true,
63
+ searchable: true,
64
+ path_pattern: Proc.new { |category_id|
65
+ Rails.application.routes.url_helpers.category_path(category_id)
66
+ }
67
+ }
59
68
  end
60
69
  end
61
70
 
@@ -19,10 +19,18 @@ module FacetedSearch
19
19
  end
20
20
 
21
21
  def path_for(facet, value)
22
- p = path
23
- list.each do |current_facet|
24
- p += current_facet == facet ? current_facet.path_for(value)
25
- : current_facet.path
22
+ if facet.path_pattern?
23
+ p = "#{facet.path_pattern.call(value)}#{path}"
24
+ list.each do |current_facet|
25
+ p += current_facet.path if current_facet != facet
26
+ end
27
+ else
28
+ p = path
29
+ list.each do |current_facet|
30
+ next if current_facet.path_pattern?
31
+ p += current_facet == facet ? current_facet.path_for(value)
32
+ : current_facet.path
33
+ end
26
34
  end
27
35
  p
28
36
  end
@@ -13,6 +13,18 @@ module FacetedSearch
13
13
  @options[:title] || name.to_s.humanize.titleize
14
14
  end
15
15
 
16
+ def searchable
17
+ @options[:searchable] || false
18
+ end
19
+
20
+ def path_pattern
21
+ @options[:path_pattern] || false
22
+ end
23
+
24
+ def path_pattern?
25
+ @options.has_key? :path_pattern
26
+ end
27
+
16
28
  def kind
17
29
  self.class.to_s
18
30
  end
@@ -28,7 +28,7 @@ module FacetedSearch
28
28
  def values
29
29
  unless @values
30
30
  joined_table = facets.model_table_name.to_sym
31
- @values = source.all.joins(joined_table).where(joined_table => { id: facets.model }).distinct
31
+ @values = source.all.joins(joined_table).where(joined_table => { id: facets.results }).distinct
32
32
  end
33
33
  @values
34
34
  end
@@ -6,7 +6,10 @@ reset ||= 'Reset'
6
6
  <% if facets.has_params? %>
7
7
  <ul class="faceted__facets-selected list-inline">
8
8
  <% facets.list.each do |facet| %>
9
- <% partial = "#{facet.kind.underscore}/selected" %>
9
+ <%
10
+ next if facet.path_pattern?
11
+ partial = "#{facet.kind.underscore}/selected"
12
+ %>
10
13
  <%= render partial, facet: facet %>
11
14
  <% end %>
12
15
  </ul>
@@ -18,7 +21,7 @@ reset ||= 'Reset'
18
21
  <%= render partial, facet: facet, anchor: anchor %>
19
22
  <% end %>
20
23
  <li class="faceted__facet__reinit">
21
- <a href="<%= facets.path %>">
24
+ <a href="<%= facets.path %>" rel="nofollow">
22
25
  <i class="fas fa-ban"></i>
23
26
  <%= reset %>
24
27
  </a>
@@ -0,0 +1,5 @@
1
+ <% if searchable %>
2
+ <%= link_to display_value, path %>
3
+ <% else %>
4
+ <%= link_to display_value, path, rel: 'nofollow' %>
5
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <li class=" faceted__facet-selected
2
2
  list-inline-item">
3
- <%= link_to path, class: 'badge badge-light' do %>
3
+ <%= link_to path, class: 'badge badge-light', rel: 'nofollow' do %>
4
4
  <% unless title %>
5
5
  <span class="faceted__facet-selected__title d-none">
6
6
  <%= title %>
@@ -14,9 +14,12 @@
14
14
  onclick="window.location.href='<%= path %>'"
15
15
  <%= 'checked' if selected %>
16
16
  />
17
- <%= link_to name, path %>
17
+ <%= render 'faceted_search/link',
18
+ display_value: name,
19
+ path: path,
20
+ searchable: facet.searchable %>
18
21
  </li>
19
22
  <% end %>
20
23
  </ul>
21
24
  </li>
22
- <% end %>
25
+ <% end %>
@@ -4,9 +4,12 @@
4
4
  <ol class="faceted__facet__date list-unstyled">
5
5
  <% facet.values.each do |year| %>
6
6
  <li class="faceted__facet__date__value <%= 'faceted__facet__date__value--selected' if facet.value_selected?(year) %>">
7
- <%= link_to year, facet.facets.path_for(facet, year) + anchor %>
7
+ <%= render 'faceted_search/link',
8
+ display_value: year,
9
+ path: facet.facets.path_for(facet, year) + anchor,
10
+ searchable: facet.searchable %>
8
11
  </li>
9
12
  <% end %>
10
13
  </ol>
11
14
  </li>
12
- <% end %>
15
+ <% end %>
@@ -1,11 +1,10 @@
1
1
  <% values.each do |value| %>
2
- <%
3
- display_value = facet.display_method.call(value)
4
- identifier = value.send facet.find_by
5
- path = facet.facets.path_for(facet, identifier)
6
- %>
2
+ <% identifier = value.send facet.find_by %>
7
3
  <li class="faceted__facet__full_tree__value<%= '--selected' if facet.value_selected?(identifier) %> dd-item <%= 'dd-item--selected' if facet.value_selected?(identifier) %>">
8
- <%= link_to display_value, path %>
4
+ <%= render 'faceted_search/link',
5
+ display_value: facet.display_method.call(value),
6
+ path: facet.facets.path_for(facet, identifier),
7
+ searchable: facet.searchable %>
9
8
  <% child_values = facet.values_with_parent(value.id) %>
10
9
  <% if child_values.any? %>
11
10
  <ol class="dd-list">
@@ -8,9 +8,12 @@
8
8
  display_value = facet.display_method.call(value)
9
9
  %>
10
10
  <li class="faceted__facet__list__value <%= 'faceted__facet__list__value--selected' if facet.value_selected?(identifier) %>">
11
- <%= link_to display_value, facet.facets.path_for(facet, identifier) + anchor %>
11
+ <%= render 'faceted_search/link',
12
+ display_value: display_value,
13
+ path: facet.facets.path_for(facet, identifier) + anchor,
14
+ searchable: facet.searchable %>
12
15
  </li>
13
16
  <% end %>
14
17
  </ol>
15
18
  </li>
16
- <% end %>
19
+ <% end %>
@@ -12,7 +12,10 @@
12
12
  onclick="window.location.href='<%= path %>'"
13
13
  <%= 'checked' if selected %>
14
14
  />
15
- <%= link_to identifier, path %>
15
+ <%= render 'faceted_search/link',
16
+ display_value: identifier,
17
+ path: path,
18
+ searchable: facet.searchable %>
16
19
  </li>
17
20
  <% end %>
18
21
  </ul>
@@ -9,7 +9,7 @@
9
9
  path = facet.facets.path_for(facet, identifier)
10
10
  %>
11
11
  <div class="faceted__facet__tree__back">
12
- <%= link_to path do %>
12
+ <%= link_to path, rel: 'nofollow' do %>
13
13
  <i class="fas fa-arrow-left"></i> <%= display_value %>
14
14
  <% end %>
15
15
  </div>
@@ -23,10 +23,13 @@
23
23
  path = facet.facets.path_for(facet, identifier)
24
24
  %>
25
25
  <li class="faceted__facet__tree__value">
26
- <%= link_to display_value, path %>
26
+ <%= render 'faceted_search/link',
27
+ display_value: display_value,
28
+ path: path,
29
+ searchable: facet.searchable %>
27
30
  </li>
28
31
  <% end %>
29
32
  </ol>
30
33
  </div>
31
34
  </li>
32
- <% end %>
35
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module FacetedSearch
2
- VERSION = '3.4.5'
2
+ VERSION = '3.5.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faceted_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.5
4
+ version: 3.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-05 00:00:00.000000000 Z
13
+ date: 2021-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -140,6 +140,7 @@ files:
140
140
  - app/models/faceted_search/facets/text.rb
141
141
  - app/models/faceted_search/facets/tree.rb
142
142
  - app/views/faceted_search/_facets.html.erb
143
+ - app/views/faceted_search/_link.html.erb
143
144
  - app/views/faceted_search/facets/_facet-selected.html.erb
144
145
  - app/views/faceted_search/facets/checkboxes/_all.html.erb
145
146
  - app/views/faceted_search/facets/checkboxes/_selected.html.erb