aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/blog_posts_helper.rb59
-rw-r--r--app/helpers/refinery/blog_posts_helper.rb61
2 files changed, 61 insertions, 59 deletions
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 = '<section id="blog_archive_list"><h2>'
- html << t('archives', :scope => 'blog.shared')
- html << '</h2><nav><ul>'
- links = []
- super_old_links = []
-
- posts.each do |e|
- if e.published_at >= Time.now.end_of_year.advance(:years => -3)
- links << e.published_at.strftime('%m/%Y')
- else
- super_old_links << e.published_at.strftime('01/%Y')
- end
- end
- links.uniq!
- super_old_links.uniq!
- links.each do |l|
- year = l.split('/')[1]
- month = l.split('/')[0]
- count = BlogPost.by_archive(Time.parse(l)).size
- text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
- html << "<li>"
- html << link_to(text, archive_blog_posts_path(:year => year, :month => month))
- html << "</li>"
- end
- super_old_links.each do |l|
- year = l.split('/')[1]
- count = BlogPost.by_year(Time.parse(l)).size
- text = "#{year} (#{count})"
- html << "<li>"
- html << link_to(text, archive_blog_posts_path(:year => year))
- html << "</li>"
- end
- html << '</ul></nav></section>'
- 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 = '<section id="blog_archive_list"><h2>'
+ html << t('archives', :scope => 'blog.shared')
+ html << '</h2><nav><ul>'
+ links = []
+ super_old_links = []
+
+ posts.each do |e|
+ if e.published_at >= Time.now.end_of_year.advance(:years => -3)
+ links << e.published_at.strftime('%m/%Y')
+ else
+ super_old_links << e.published_at.strftime('01/%Y')
+ end
+ end
+ links.uniq!
+ super_old_links.uniq!
+ links.each do |l|
+ year = l.split('/')[1]
+ month = l.split('/')[0]
+ count = BlogPost.by_archive(Time.parse(l)).size
+ text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
+ html << "<li>"
+ html << link_to(text, main_app.archive_blog_posts_path(:year => year, :month => month))
+ html << "</li>"
+ end
+ super_old_links.each do |l|
+ year = l.split('/')[1]
+ count = Refinery::BlogPost.by_year(Time.parse(l)).size
+ text = "#{year} (#{count})"
+ html << "<li>"
+ html << link_to(text, main_app.archive_blog_posts_path(:year => year))
+ html << "</li>"
+ end
+ html << '</ul></nav></section>'
+ 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