diff options
author | Uģis Ozols <ugis.ozolss@gmail.com> | 2013-08-07 15:57:47 +0300 |
---|---|---|
committer | Uģis Ozols <ugis.ozolss@gmail.com> | 2013-08-07 16:06:10 +0300 |
commit | c44f919890cd4e46b0420caa5fdf96c8e65af4a5 (patch) | |
tree | fe38eec557731bc8e83141aee533fe568f1a4eda | |
parent | faa6922bf8d71ae5c481afcbc7b2e54ec18e6930 (diff) | |
download | refinerycms-blog-c44f919890cd4e46b0420caa5fdf96c8e65af4a5.tar.gz refinerycms-blog-c44f919890cd4e46b0420caa5fdf96c8e65af4a5.tar.bz2 refinerycms-blog-c44f919890cd4e46b0420caa5fdf96c8e65af4a5.zip |
Use refinerycms-acts-as-indexed for search functionality.
Also simplify index views for posts, categories and comments by
removing redundant code.
-rw-r--r-- | app/models/refinery/blog/category.rb | 2 | ||||
-rw-r--r-- | app/models/refinery/blog/comment.rb | 2 | ||||
-rw-r--r-- | app/models/refinery/blog/post.rb | 2 | ||||
-rw-r--r-- | app/views/refinery/blog/admin/_submenu.html.erb | 2 | ||||
-rw-r--r-- | app/views/refinery/blog/admin/categories/index.html.erb | 22 | ||||
-rw-r--r-- | app/views/refinery/blog/admin/comments/index.html.erb | 37 | ||||
-rw-r--r-- | app/views/refinery/blog/admin/posts/index.html.erb | 22 | ||||
-rw-r--r-- | lib/refinery/blog.rb | 1 |
8 files changed, 31 insertions, 59 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..9cf66d6 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 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 |