aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb15
-rw-r--r--app/controllers/refinery/blog_controller.rb2
-rw-r--r--app/helpers/blog_posts_helper.rb59
-rw-r--r--app/helpers/refinery/blog_posts_helper.rb61
-rw-r--r--app/views/refinery/blog/posts/tagged.html.erb12
-rw-r--r--app/views/refinery/blog/shared/_categories.html.erb2
-rw-r--r--app/views/refinery/blog/shared/_post.html.erb10
-rw-r--r--app/views/refinery/blog/shared/_posts.html.erb2
-rw-r--r--app/views/refinery/blog/shared/_rss_feed.html.erb2
-rw-r--r--app/views/refinery/blog/shared/_tags.html.erb2
10 files changed, 84 insertions, 83 deletions
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 = '<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
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? %>
<section id="blog_posts">
- <%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
- <%= will_paginate @blog_posts %>
+ <%= render :partial => "/refinery/blog/shared/post", :collection => @blog_posts %>
+ <%= paginate @blog_posts %>
</section>
<% else %>
<p><%= t('.no_blog_articles_yet') %></p>
@@ -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 @@
<ul id='categories'>
<% @blog_categories.each do |category| %>
<li<%= " class='selected'" if @category.present? and @category.id == category.id %>>
- <%= link_to "#{category.title} (#{category.post_count})", blog_category_url(category) %>
+ <%= link_to "#{category.title} (#{category.post_count})", main_app.blog_category_path(category) %>
</li>
<% end %>
</ul>
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? %>
<article class="blog_post" id="<%= dom_id(post) %>">
<header>
- <h1><%= link_to post.title, blog_post_url(post) %></h1>
+ <h1><%= link_to post.title, main_app.blog_post_path(post) %></h1>
<section class='details'>
<time datetime="<%=l post.published_at.to_date, :format => :default %>" class='posted_at'>
<%= t('created_at', :scope => 'blog.shared.posts', :when => l(post.published_at.to_date, :format => :short)) %>
@@ -10,13 +10,13 @@
<% if (categories = post.categories).any? %>
<aside class='filed_in'>
<%= t('filed_in', :scope => 'blog.posts.show') %>
- <%=raw categories.collect { |category| link_to category.title, blog_category_url(category) }.to_sentence %>
+ <%=raw categories.collect { |category| link_to category.title, main_app.blog_category_path(category) }.to_sentence %>
</aside>
<% end %>
<% if (tags = post.tags).any? %>
<aside class='tagged'>
<%= t('tagged', :scope => 'blog.posts.show') %>
- <%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
+ <%=raw tags.collect { |tag| link_to tag, main_app.tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
</aside>
<% end %>
</section>
@@ -30,10 +30,10 @@
</section>
<footer>
<p>
- <%= link_to t('read_more', :scope => 'blog.shared.posts'), blog_post_url(post) if blog_post_teaser_enabled? %>
+ <%= link_to t('read_more', :scope => 'blog.shared.posts'), main_app.blog_post_path(post) if blog_post_teaser_enabled? %>
</p>
<aside class='comment_count'>
- <% if BlogPost.comments_allowed? %>
+ <% if Refinery::BlogPost.comments_allowed? %>
<% if post.comments.any? %>
(<%= pluralize(post.comments.approved.count, t('singular', :scope => 'blog.shared.comments')) %>)
<% else %>
diff --git a/app/views/refinery/blog/shared/_posts.html.erb b/app/views/refinery/blog/shared/_posts.html.erb
index 24a8199..7dc570b 100644
--- a/app/views/refinery/blog/shared/_posts.html.erb
+++ b/app/views/refinery/blog/shared/_posts.html.erb
@@ -3,7 +3,7 @@
<ul id="blog_posts">
<% @blog_posts.each do |blog_post| %>
<li class='clearfix'>
- <%= link_to blog_post.title, blog_post_url(blog_post) %>
+ <%= link_to blog_post.title, main_app.blog_post_path(blog_post) %>
</li>
<% end %>
</ul>
diff --git a/app/views/refinery/blog/shared/_rss_feed.html.erb b/app/views/refinery/blog/shared/_rss_feed.html.erb
index 1c2cef7..5ece5ae 100644
--- a/app/views/refinery/blog/shared/_rss_feed.html.erb
+++ b/app/views/refinery/blog/shared/_rss_feed.html.erb
@@ -1,2 +1,2 @@
<h2><%= t('.title') %></h2>
-<%= link_to t('.subscribe'), blog_rss_feed_url, :id => "rss_feed_subscribe"%>
+<%= link_to t('.subscribe'), main_app.blog_rss_feed_path, :id => "rss_feed_subscribe"%>
diff --git a/app/views/refinery/blog/shared/_tags.html.erb b/app/views/refinery/blog/shared/_tags.html.erb
index b0b11ee..5a72b81 100644
--- a/app/views/refinery/blog/shared/_tags.html.erb
+++ b/app/views/refinery/blog/shared/_tags.html.erb
@@ -2,7 +2,7 @@
<h2><%= t('.title') %></h2>
<nav id='tags'>
<% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %>
- <%= link_to tag.name, tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
+ <%= link_to tag.name, main_app.tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
<% end %>
</nav>
<% end %> \ No newline at end of file