aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarek <keraml@gmail.com>2011-09-11 00:10:07 +0200
committerMarek <keraml@gmail.com>2011-09-11 00:10:07 +0200
commit20cffcee84c407a40943f616db0aa3678b45a19f (patch)
treef27e58e80fd3a7b64ff1ac76feb18111b2369584 /app
parent97ad55cbf0350752fdbb01b64980b592b463f19f (diff)
downloadrefinerycms-blog-20cffcee84c407a40943f616db0aa3678b45a19f.tar.gz
refinerycms-blog-20cffcee84c407a40943f616db0aa3678b45a19f.tar.bz2
refinerycms-blog-20cffcee84c407a40943f616db0aa3678b45a19f.zip
canonical tag for posts
Diffstat (limited to 'app')
-rw-r--r--app/controllers/blog/posts_controller.rb34
1 files changed, 19 insertions, 15 deletions
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb
index edac5ab..5ec6ec1 100644
--- a/app/controllers/blog/posts_controller.rb
+++ b/app/controllers/blog/posts_controller.rb
@@ -9,7 +9,7 @@ module Blog
def index
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
- (@blog_posts = BlogPost.live.includes(:comments, :categories).all) if request.format.rss?
+ (@blog_posts = BlogPost.live.includes(:comments, :categories).all) if request.format.rss?
respond_with (@blog_posts) do |format|
format.html
format.rss
@@ -18,6 +18,7 @@ module Blog
def show
@blog_comment = BlogComment.new
+ @canonical = url_for(:locale => ::Refinery::I18n.default_frontend_locale) if canonical?
respond_with (@blog_post) do |format|
format.html { present(@blog_post) }
@@ -41,7 +42,7 @@ module Blog
else
flash[:notice] = t('thank_you', :scope => 'blog.posts.comments')
redirect_to blog_post_url(params[:id],
- :anchor => "comment-#{@blog_comment.to_param}")
+ :anchor => "comment-#{@blog_comment.to_param}")
end
else
render :action => 'show'
@@ -54,17 +55,17 @@ module Blog
@archive_date = Time.parse(date)
@date_title = @archive_date.strftime('%B %Y')
@blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
- :page => params[:page],
- :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
- })
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
else
date = "01/#{params[:year]}"
@archive_date = Time.parse(date)
@date_title = @archive_date.strftime('%Y')
@blog_posts = BlogPost.live.by_year(@archive_date).paginate({
- :page => params[:page],
- :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
- })
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
end
respond_with (@blog_posts)
end
@@ -73,12 +74,12 @@ module Blog
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
@tag_name = @tag.name
@blog_posts = BlogPost.tagged_with(@tag_name).paginate({
- :page => params[:page],
- :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
- })
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
end
- protected
+ protected
def find_blog_post
unless (@blog_post = BlogPost.find(params[:id])).try(:live?)
@@ -92,14 +93,17 @@ module Blog
def find_all_blog_posts
@blog_posts = BlogPost.live.includes(:comments, :categories).paginate({
- :page => params[:page],
- :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
- })
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
end
def find_tags
@tags = BlogPost.tag_counts_on(:tags)
end
+ def canonical?
+ ::Refinery.i18n_enabled? && ::Refinery::I18n.default_frontend_locale != ::Refinery::I18n.current_frontend_locale
+ end
end
end \ No newline at end of file