aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-11-09 22:19:07 +1300
committerPhilip Arndt <parndt@gmail.com>2011-11-09 22:19:07 +1300
commit36c005ecd112b76d3c9c2d7092f22d6e06755d73 (patch)
tree23e37055e6c6aa79a9c5285387052acdc708ba30 /app/helpers
parentd18364d359359fa6564ad187d7303f8c167154cd (diff)
downloadrefinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.gz
refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.bz2
refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.zip
Refactored everything (models, helpers) into proper namespace of Refinery::Blog. Requires refinery commit 25162b585b9c4023d39fd1a9796140bfa4ecb909
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/refinery/blog/controller_helper.rb10
-rw-r--r--app/helpers/refinery/blog/posts_helper.rb51
-rw-r--r--app/helpers/refinery/blog_posts_helper.rb49
3 files changed, 56 insertions, 54 deletions
diff --git a/app/helpers/refinery/blog/controller_helper.rb b/app/helpers/refinery/blog/controller_helper.rb
index c1c2a6a..035275c 100644
--- a/app/helpers/refinery/blog/controller_helper.rb
+++ b/app/helpers/refinery/blog/controller_helper.rb
@@ -5,9 +5,9 @@ module Refinery
protected
def find_blog_post
- unless (@blog_post = Refinery::BlogPost.find(params[:id])).try(:live?)
+ unless (@blog_post = Refinery::Blog::Post.find(params[:id])).try(:live?)
if refinery_user? and current_refinery_user.authorized_plugins.include?("refinerycms_blog")
- @blog_post = Refinery::BlogPost.find(params[:id])
+ @blog_post = Refinery::Blog::Post.find(params[:id])
else
error_404
end
@@ -15,15 +15,15 @@ module Refinery
end
def find_all_blog_posts
- @blog_posts = Refinery::BlogPost.live.includes(:comments, :categories).page(params[:page])
+ @blog_posts = Refinery::Blog::Post.live.includes(:comments, :categories).page(params[:page])
end
def find_tags
- @tags = Refinery::BlogPost.tag_counts_on(:tags)
+ @tags = Refinery::Blog::Post.tag_counts_on(:tags)
end
def find_all_blog_categories
- @blog_categories = Refinery::BlogCategory.all
+ @blog_categories = Refinery::Blog::Category.all
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..418f360
--- /dev/null
+++ b/app/helpers/refinery/blog/posts_helper.rb
@@ -0,0 +1,51 @@
+module Refinery
+ module Blog
+ module PostsHelper
+ def blog_archive_widget
+ posts = Refinery::Blog::Post.select('published_at').all_previous
+ return nil if posts.blank?
+
+ render :partial => "/refinery/blog/widgets/blog_archive", :locals => { :posts => posts }
+ end
+ alias_method :blog_archive_list, :blog_archive_widget
+
+ def next_or_previous?(post)
+ post.next.present? or post.prev.present?
+ end
+
+ def blog_post_teaser_enabled?
+ Refinery::Blog::Post.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
+
+ def archive_link(post)
+ if post.published_at >= Time.now.end_of_year.advance(:years => -3)
+ post_date = post.published_at.strftime('%m/%Y')
+ year = post_date.split('/')[1]
+ month = post_date.split('/')[0]
+ count = Blog::Post.by_archive(Time.parse(post_date)).size
+ text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
+
+ link_to(text, main_app.archive_blog_posts_path(:year => year, :month => month))
+ else
+ post_date = post.published_at.strftime('01/%Y')
+ year = post_date.split('/')[1]
+ count = Refinery::Blog::Post.by_year(Time.parse(post_date)).size
+ text = "#{year} (#{count})"
+
+ link_to(text, main_app.archive_blog_posts_path(:year => year))
+ end
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/app/helpers/refinery/blog_posts_helper.rb b/app/helpers/refinery/blog_posts_helper.rb
deleted file mode 100644
index bfc3f40..0000000
--- a/app/helpers/refinery/blog_posts_helper.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-module Refinery
- module BlogPostsHelper
- def blog_archive_widget
- posts = Refinery::BlogPost.select('published_at').all_previous
- return nil if posts.blank?
-
- render :partial => "/refinery/blog/widgets/blog_archive", :locals => { :posts => posts }
- end
- alias_method :blog_archive_list, :blog_archive_widget
-
- 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
-
- def archive_link(post)
- if post.published_at >= Time.now.end_of_year.advance(:years => -3)
- post_date = post.published_at.strftime('%m/%Y')
- year = post_date.split('/')[1]
- month = post_date.split('/')[0]
- count = BlogPost.by_archive(Time.parse(post_date)).size
- text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
-
- link_to(text, main_app.archive_blog_posts_path(:year => year, :month => month))
- else
- post_date = post.published_at.strftime('01/%Y')
- year = post_date.split('/')[1]
- count = Refinery::BlogPost.by_year(Time.parse(post_date)).size
- text = "#{year} (#{count})"
-
- link_to(text, main_app.archive_blog_posts_path(:year => year))
- end
- end
- end
-end