diff --git a/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb b/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
index 6098ec9..f7ccdb1 100644
--- a/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
+++ b/plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
@@ -1,8 +1,10 @@
require_relative '../helpers/elasticsearch_helper'
+require_relative '../helpers/elasticsearch_plugin_helper'
class ElasticsearchPluginController < ApplicationController
no_design_blocks
include ElasticsearchHelper
+ helper ElasticsearchPluginHelper
def index
search()
@@ -12,6 +14,7 @@ class ElasticsearchPluginController < ApplicationController
def search
define_searchable_types
define_sort_types
+ define_categories
define_results
end
@@ -31,4 +34,8 @@ class ElasticsearchPluginController < ApplicationController
@selected_sort = (params[:filter] || :relevance).to_sym
end
+ def define_categories
+ @categories = Category.where(parent: nil)
+ end
+
end
diff --git a/plugins/elasticsearch/helpers/elasticsearch_plugin_helper.rb b/plugins/elasticsearch/helpers/elasticsearch_plugin_helper.rb
new file mode 100644
index 0000000..d4ae4f3
--- /dev/null
+++ b/plugins/elasticsearch/helpers/elasticsearch_plugin_helper.rb
@@ -0,0 +1,20 @@
+module ElasticsearchPluginHelper
+
+ def render_categories collection
+ content_tag :ul, class: "category-ident" do
+ if collection.respond_to? :each
+ collection.collect do |item|
+ concat ("
".html_safe)
+ concat (check_box_tag item.name)
+ concat (item.name)
+ concat (render_categories item.children) if item.children_count
+ concat ("".html_safe)
+ end
+ else
+ check_box_tag collection.name
+ content_tag :li, collection.name
+ end
+ end
+ end
+
+end
diff --git a/plugins/elasticsearch/lib/ext/text_article.rb b/plugins/elasticsearch/lib/ext/text_article.rb
index bd65f03..5021ffa 100644
--- a/plugins/elasticsearch/lib/ext/text_article.rb
+++ b/plugins/elasticsearch/lib/ext/text_article.rb
@@ -11,7 +11,7 @@ class TextArticle
def self.control_fields
{
:advertise => { type: :boolean },
- :published => { type: 'boolean'},
+ :published => { type: :boolean },
:comments_count => { type: :integer },
:hits => { type: :integer },
:profile => { type: :nested , hash: NestedProfile.hash }
diff --git a/plugins/elasticsearch/public/style.css b/plugins/elasticsearch/public/style.css
index 62e1641..15f17a9 100644
--- a/plugins/elasticsearch/public/style.css
+++ b/plugins/elasticsearch/public/style.css
@@ -50,6 +50,7 @@
font-size: 18px;
}
+.controller-elasticsearch_plugin #content-inner .categories,
.controller-elasticsearch_plugin #content-inner .search-filter,
.controller-elasticsearch_plugin #content-inner ul.search-options {
background: #fff;
@@ -145,3 +146,6 @@
text-decoration: none;
}
+.controller-elasticsearch_plugin #content-inner .categories .category-ident {
+ margin-left: 10px;
+}
diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb
index fa2226c..4c0d2b3 100644
--- a/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb
+++ b/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb
@@ -41,6 +41,11 @@
<% end %>
+
+
+
<%= _("Categories") %>
+ <%= render_categories @categories %>
+
@@ -59,5 +64,6 @@
<%= pagination_links @results if @results.count > 0 %>
+
--
libgit2 0.21.2