Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use refinerycms-acts-as-indexed for search functionality. #345

Merged
merged 2 commits into from

2 participants

@ugisozols
Owner

Also simplify index views for posts, categories and comments by removing redundant code.

@parndt parndt merged commit 0b27bed into master
@parndt parndt deleted the use_refinerycms-acts-as-indexed_for_search branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 7, 2013
  1. @ugisozols

    Use refinerycms-acts-as-indexed for search functionality.

    ugisozols authored
    Also simplify index views for posts, categories and comments by
    removing redundant code.
Commits on Aug 12, 2013
  1. @ugisozols
This page is out of date. Refresh to see the latest.
View
2  app/models/refinery/blog/category.rb
@@ -10,8 +10,6 @@ class Category < ActiveRecord::Base
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
View
2  app/models/refinery/blog/comment.rb
@@ -10,8 +10,6 @@ class Comment < ActiveRecord::Base
belongs_to :post, :foreign_key => 'blog_post_id'
- acts_as_indexed :fields => [:name, :email, :message]
-
alias_attribute :message, :body
validates :name, :message, :presence => true
View
4 app/models/refinery/blog/post.rb
@@ -22,8 +22,6 @@ class Post < ActiveRecord::Base
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 @@ def by_year(date)
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)
View
2  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>
View
22 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>
View
37 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>
View
22 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>
View
1  lib/refinery/blog.rb
@@ -2,7 +2,6 @@
require 'refinerycms-settings'
require 'filters_spam'
require 'rails_autolink'
-require 'acts_as_indexed'
require 'friendly_id'
module Refinery
Something went wrong with that request. Please try again.