From 164dc27a42876efdbd14db9e2d14311b4c119e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Wed, 27 Jul 2011 22:32:26 +0300 Subject: Cucumber tag steps now pass. --- app/controllers/refinery/blog/posts_controller.rb | 15 +++--- app/controllers/refinery/blog_controller.rb | 2 +- app/helpers/blog_posts_helper.rb | 59 --------------------- app/helpers/refinery/blog_posts_helper.rb | 61 ++++++++++++++++++++++ app/views/refinery/blog/posts/tagged.html.erb | 12 ++--- .../refinery/blog/shared/_categories.html.erb | 2 +- app/views/refinery/blog/shared/_post.html.erb | 10 ++-- app/views/refinery/blog/shared/_posts.html.erb | 2 +- app/views/refinery/blog/shared/_rss_feed.html.erb | 2 +- app/views/refinery/blog/shared/_tags.html.erb | 2 +- features/support/step_definitions/tags_steps.rb | 4 +- refinerycms-blog.gemspec | 3 +- 12 files changed, 88 insertions(+), 86 deletions(-) delete mode 100644 app/helpers/blog_posts_helper.rb create mode 100644 app/helpers/refinery/blog_posts_helper.rb diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb index bdf53f0..f055797 100644 --- a/app/controllers/refinery/blog/posts_controller.rb +++ b/app/controllers/refinery/blog/posts_controller.rb @@ -73,10 +73,9 @@ module Refinery def tagged @tag = ActsAsTaggableOn::Tag.find(params[:tag_id]) @tag_name = @tag.name - @blog_posts = Refinery::BlogPost.tagged_with(@tag_name).paginate({ - :page => params[:page], - :per_page => Refinery::Setting.find_or_set(:blog_posts_per_page, 10) - }) + @blog_posts = Refinery::BlogPost.tagged_with(@tag_name) + .page(params[:page]) + .per(Refinery::Setting.find_or_set(:blog_posts_per_page, 10)) end protected @@ -92,10 +91,10 @@ module Refinery end def find_all_blog_posts - @blog_posts = Refinery::BlogPost.live.includes(:comments, :categories).paginate({ - :page => params[:page], - :per_page => Refinery::Setting.find_or_set(:blog_posts_per_page, 10) - }) + @blog_posts = Refinery::BlogPost.live + .includes(:comments, :categories) + .page(params[:page]) + .per(Refinery::Setting.find_or_set(:blog_posts_per_page, 10)) end def find_tags diff --git a/app/controllers/refinery/blog_controller.rb b/app/controllers/refinery/blog_controller.rb index 6bec0a5..cbafdeb 100644 --- a/app/controllers/refinery/blog_controller.rb +++ b/app/controllers/refinery/blog_controller.rb @@ -1,7 +1,7 @@ module Refinery class BlogController < ::ApplicationController - helper :blog_posts + helper :'refinery/blog_posts' before_filter :find_page, :find_all_blog_categories protected diff --git a/app/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb deleted file mode 100644 index 0848632..0000000 --- a/app/helpers/blog_posts_helper.rb +++ /dev/null @@ -1,59 +0,0 @@ -module BlogPostsHelper - def blog_archive_list - posts = BlogPost.select('published_at').all_previous - return nil if posts.blank? - html = '

' - html << t('archives', :scope => 'blog.shared') - html << '

' - html.html_safe - end - - def next_or_previous?(post) - post.next.present? or post.prev.present? - end - - def blog_post_teaser_enabled? - BlogPost.teasers_enabled? - end - - def blog_post_teaser(post) - if post.respond_to?(:custom_teaser) && post.custom_teaser.present? - post.custom_teaser.html_safe - else - truncate(post.body, { - :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250), - :preserve_html_tags => true - }).html_safe - end - end -end diff --git a/app/helpers/refinery/blog_posts_helper.rb b/app/helpers/refinery/blog_posts_helper.rb new file mode 100644 index 0000000..58b0a3a --- /dev/null +++ b/app/helpers/refinery/blog_posts_helper.rb @@ -0,0 +1,61 @@ +module Refinery + module BlogPostsHelper + def blog_archive_list + posts = Refinery::BlogPost.select('published_at').all_previous + return nil if posts.blank? + html = '

' + html << t('archives', :scope => 'blog.shared') + html << '

' + html.html_safe + end + + def next_or_previous?(post) + post.next.present? or post.prev.present? + end + + def blog_post_teaser_enabled? + Refinery::BlogPost.teasers_enabled? + end + + def blog_post_teaser(post) + if post.respond_to?(:custom_teaser) && post.custom_teaser.present? + post.custom_teaser.html_safe + else + truncate(post.body, { + :length => Refinery::Setting.find_or_set(:blog_post_teaser_length, 250), + :preserve_html_tags => true + }).html_safe + end + end + end +end diff --git a/app/views/refinery/blog/posts/tagged.html.erb b/app/views/refinery/blog/posts/tagged.html.erb index 904150f..f17b123 100644 --- a/app/views/refinery/blog/posts/tagged.html.erb +++ b/app/views/refinery/blog/posts/tagged.html.erb @@ -3,8 +3,8 @@ <% content_for :body_content_left do %> <% if @blog_posts.any? %>
- <%= render :partial => "/blog/shared/post", :collection => @blog_posts %> - <%= will_paginate @blog_posts %> + <%= render :partial => "/refinery/blog/shared/post", :collection => @blog_posts %> + <%= paginate @blog_posts %>
<% else %>

<%= t('.no_blog_articles_yet') %>

@@ -12,11 +12,11 @@ <% end %> <% content_for :body_content_right do %> - <%= render :partial => "/blog/shared/categories" %> - <%= render :partial => "/blog/shared/tags" %> - <%= render :partial => "/blog/shared/rss_feed" %> + <%= render :partial => "/refinery/blog/shared/categories" %> + <%= render :partial => "/refinery/blog/shared/tags" %> + <%= render :partial => "/refinery/blog/shared/rss_feed" %> <%= blog_archive_list %> <% end %> -<%= render :partial => "/shared/content_page" %> +<%= render :partial => "/refinery/content_page" %> <% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %> diff --git a/app/views/refinery/blog/shared/_categories.html.erb b/app/views/refinery/blog/shared/_categories.html.erb index 05cc53f..295cae0 100644 --- a/app/views/refinery/blog/shared/_categories.html.erb +++ b/app/views/refinery/blog/shared/_categories.html.erb @@ -3,7 +3,7 @@ diff --git a/app/views/refinery/blog/shared/_post.html.erb b/app/views/refinery/blog/shared/_post.html.erb index 6cda22d..b5a4af1 100644 --- a/app/views/refinery/blog/shared/_post.html.erb +++ b/app/views/refinery/blog/shared/_post.html.erb @@ -1,7 +1,7 @@ <% if post.live? %>
-

<%= link_to post.title, blog_post_url(post) %>

+

<%= link_to post.title, main_app.blog_post_path(post) %>

@@ -30,10 +30,10 @@