aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Arndt <p@arndt.io>2013-08-11 22:37:49 -0700
committerPhilip Arndt <p@arndt.io>2013-08-11 22:37:49 -0700
commit0b27bed872bcfc95b0e1688151b0dc20789b2b54 (patch)
treeca37ed264094228cd3813b4012df931114977ea4
parentfaa6922bf8d71ae5c481afcbc7b2e54ec18e6930 (diff)
parent433c541012bd44453d5e9fb826667916706f70fe (diff)
downloadrefinerycms-blog-0b27bed872bcfc95b0e1688151b0dc20789b2b54.tar.gz
refinerycms-blog-0b27bed872bcfc95b0e1688151b0dc20789b2b54.tar.bz2
refinerycms-blog-0b27bed872bcfc95b0e1688151b0dc20789b2b54.zip
Merge pull request #345 from refinery/use_refinerycms-acts-as-indexed_for_search
Use refinerycms-acts-as-indexed for search functionality.
-rw-r--r--app/models/refinery/blog/category.rb2
-rw-r--r--app/models/refinery/blog/comment.rb2
-rw-r--r--app/models/refinery/blog/post.rb4
-rw-r--r--app/views/refinery/blog/admin/_submenu.html.erb2
-rw-r--r--app/views/refinery/blog/admin/categories/index.html.erb22
-rw-r--r--app/views/refinery/blog/admin/comments/index.html.erb37
-rw-r--r--app/views/refinery/blog/admin/posts/index.html.erb22
-rw-r--r--lib/refinery/blog.rb1
8 files changed, 32 insertions, 60 deletions
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb
index 36e6816..acab8bf 100644
--- a/app/models/refinery/blog/category.rb
+++ b/app/models/refinery/blog/category.rb
@@ -10,8 +10,6 @@ module Refinery
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_category_id
has_many :posts, :through => :categorizations, :source => :blog_post
- acts_as_indexed :fields => [:title]
-
validates :title, :presence => true, :uniqueness => true
attr_accessible :title
diff --git a/app/models/refinery/blog/comment.rb b/app/models/refinery/blog/comment.rb
index afd806f..7661e81 100644
--- a/app/models/refinery/blog/comment.rb
+++ b/app/models/refinery/blog/comment.rb
@@ -10,8 +10,6 @@ module Refinery
belongs_to :post, :foreign_key => 'blog_post_id'
- acts_as_indexed :fields => [:name, :email, :message]
-
alias_attribute :message, :body
validates :name, :message, :presence => true
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 7252c47..f0278f4 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -22,8 +22,6 @@ module Refinery
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_post_id
has_many :categories, :through => :categorizations, :source => :blog_category
- acts_as_indexed :fields => [:title, :body]
-
validates :title, :presence => true, :uniqueness => true
validates :body, :presence => true
validates :published_at, :author, :presence => true
@@ -106,7 +104,7 @@ module Refinery
end
def published_dates_older_than(date)
- published_before(date).pluck(:published_at)
+ published_before(date).select(:published_at).map(&:published_at)
end
def recent(count)
diff --git a/app/views/refinery/blog/admin/_submenu.html.erb b/app/views/refinery/blog/admin/_submenu.html.erb
index 3de05e5..03426b7 100644
--- a/app/views/refinery/blog/admin/_submenu.html.erb
+++ b/app/views/refinery/blog/admin/_submenu.html.erb
@@ -1,7 +1,7 @@
<nav id='actions' class='multilist'>
<ul class='search_list'>
<li class='not_a_link'>
- <%= render "/refinery/admin/search", :url => refinery.blog_admin_posts_path %>
+ <%= render "/refinery/admin/search", :url => request.path %>
</li>
</ul>
diff --git a/app/views/refinery/blog/admin/categories/index.html.erb b/app/views/refinery/blog/admin/categories/index.html.erb
index 451abc5..f5e021a 100644
--- a/app/views/refinery/blog/admin/categories/index.html.erb
+++ b/app/views/refinery/blog/admin/categories/index.html.erb
@@ -1,21 +1,15 @@
<%= render '/refinery/blog/admin/submenu' %>
+<%= render 'refinery/admin/search_header', :url => request.path %>
<div id='records'>
- <% if searching? %>
- <h2><%= t('results_for', :scope => 'refinery.admin.search',
- :query => params[:search]) %></h2>
- <% if @categories.any? %>
- <%= render :partial => "blog_categories",
- :collection => @categories %>
- <% else %>
- <p><%= t('no_results', :scope => 'refinery.admin.search') %></p>
- <% end %>
- <% else %>
- <% if @categories.any? %>
- <%= will_paginate @categories %>
+ <% if @categories.any? %>
+ <%= will_paginate @categories %>
- <%= render "sortable_list" %>
+ <%= render "sortable_list" %>
- <%= will_paginate @categories %>
+ <%= will_paginate @categories %>
+ <% else %>
+ <% if searching? %>
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
<% else %>
<p>
<strong>
diff --git a/app/views/refinery/blog/admin/comments/index.html.erb b/app/views/refinery/blog/admin/comments/index.html.erb
index 53c368e..c09e59b 100644
--- a/app/views/refinery/blog/admin/comments/index.html.erb
+++ b/app/views/refinery/blog/admin/comments/index.html.erb
@@ -1,30 +1,21 @@
-<%= render '/refinery/blog/admin/submenu' %>
+<%= render 'refinery/blog/admin/submenu' %>
+<%= render 'refinery/admin/search_header', :url => request.path %>
<div id='records'>
- <% if searching? %>
- <h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
- <% if @comments.any? %>
- <%= will_paginate @comments %>
+ <% if @comments.any? %>
+ <%= will_paginate @comments %>
- <ul>
- <%= render :partial => "blog_comments",
- :collection => @comments %>
- </ul>
+ <%= render "sortable_list" %>
- <%= will_paginate @comments %>
- <% else %>
- <p><%= t('search_no_results', :scope => 'admin') %></p>
- <% end %>
+ <%= will_paginate @comments %>
<% else %>
- <% if @comments.any? %>
- <%= will_paginate @comments %>
-
- <%= render "sortable_list" %>
-
- <%= will_paginate @comments %>
+ <% if searching? %>
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
<% else %>
- <h3>
- <%= t('.no_items_yet', :type => action_name.gsub('index', 'new').downcase) %>
- </h3>
- <% end %>
+ <p>
+ <strong>
+ <%= t('.no_items_yet', :type => action_name.gsub('index', 'new').downcase) %>
+ </strong>
+ </p>
<% end %>
+<% end %>
</div>
diff --git a/app/views/refinery/blog/admin/posts/index.html.erb b/app/views/refinery/blog/admin/posts/index.html.erb
index 19c4ccf..03da02c 100644
--- a/app/views/refinery/blog/admin/posts/index.html.erb
+++ b/app/views/refinery/blog/admin/posts/index.html.erb
@@ -1,21 +1,15 @@
<%= render '/refinery/blog/admin/submenu' %>
+<%= render 'refinery/admin/search_header', :url => request.path %>
<div id='records'>
- <% if searching? %>
- <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
- <% if @posts.any? %>
- <ul>
- <%= render :partial => "post", :collection => @posts %>
- </ul>
- <% else %>
- <p><%= t('no_results', :scope => 'refinery.admin.search') %></p>
- <% end %>
- <% else %>
- <% if @posts.any? %>
- <%= will_paginate @posts %>
+ <% if @posts.any? %>
+ <%= will_paginate @posts %>
- <%= render "sortable_list" %>
+ <%= render "sortable_list" %>
- <%= will_paginate @posts %>
+ <%= will_paginate @posts %>
+ <% else %>
+ <% if searching? %>
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
<% else %>
<p>
<strong>
diff --git a/lib/refinery/blog.rb b/lib/refinery/blog.rb
index 3fc0ce1..c86f43b 100644
--- a/lib/refinery/blog.rb
+++ b/lib/refinery/blog.rb
@@ -2,7 +2,6 @@ require 'refinerycms-core'
require 'refinerycms-settings'
require 'filters_spam'
require 'rails_autolink'
-require 'acts_as_indexed'
require 'friendly_id'
module Refinery