canonical tag for posts
This commit is contained in:
parent
97ad55cbf0
commit
20cffcee84
1 changed files with 19 additions and 15 deletions
|
@ -9,7 +9,7 @@ module Blog
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
|
# 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|
|
respond_with (@blog_posts) do |format|
|
||||||
format.html
|
format.html
|
||||||
format.rss
|
format.rss
|
||||||
|
@ -18,6 +18,7 @@ module Blog
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@blog_comment = BlogComment.new
|
@blog_comment = BlogComment.new
|
||||||
|
@canonical = url_for(:locale => ::Refinery::I18n.default_frontend_locale) if canonical?
|
||||||
|
|
||||||
respond_with (@blog_post) do |format|
|
respond_with (@blog_post) do |format|
|
||||||
format.html { present(@blog_post) }
|
format.html { present(@blog_post) }
|
||||||
|
@ -41,7 +42,7 @@ module Blog
|
||||||
else
|
else
|
||||||
flash[:notice] = t('thank_you', :scope => 'blog.posts.comments')
|
flash[:notice] = t('thank_you', :scope => 'blog.posts.comments')
|
||||||
redirect_to blog_post_url(params[:id],
|
redirect_to blog_post_url(params[:id],
|
||||||
:anchor => "comment-#{@blog_comment.to_param}")
|
:anchor => "comment-#{@blog_comment.to_param}")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :action => 'show'
|
render :action => 'show'
|
||||||
|
@ -54,17 +55,17 @@ module Blog
|
||||||
@archive_date = Time.parse(date)
|
@archive_date = Time.parse(date)
|
||||||
@date_title = @archive_date.strftime('%B %Y')
|
@date_title = @archive_date.strftime('%B %Y')
|
||||||
@blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
|
@blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
|
||||||
:page => params[:page],
|
:page => params[:page],
|
||||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
date = "01/#{params[:year]}"
|
date = "01/#{params[:year]}"
|
||||||
@archive_date = Time.parse(date)
|
@archive_date = Time.parse(date)
|
||||||
@date_title = @archive_date.strftime('%Y')
|
@date_title = @archive_date.strftime('%Y')
|
||||||
@blog_posts = BlogPost.live.by_year(@archive_date).paginate({
|
@blog_posts = BlogPost.live.by_year(@archive_date).paginate({
|
||||||
:page => params[:page],
|
:page => params[:page],
|
||||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
respond_with (@blog_posts)
|
respond_with (@blog_posts)
|
||||||
end
|
end
|
||||||
|
@ -73,12 +74,12 @@ module Blog
|
||||||
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
|
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
|
||||||
@tag_name = @tag.name
|
@tag_name = @tag.name
|
||||||
@blog_posts = BlogPost.tagged_with(@tag_name).paginate({
|
@blog_posts = BlogPost.tagged_with(@tag_name).paginate({
|
||||||
:page => params[:page],
|
:page => params[:page],
|
||||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_blog_post
|
def find_blog_post
|
||||||
unless (@blog_post = BlogPost.find(params[:id])).try(:live?)
|
unless (@blog_post = BlogPost.find(params[:id])).try(:live?)
|
||||||
|
@ -92,14 +93,17 @@ module Blog
|
||||||
|
|
||||||
def find_all_blog_posts
|
def find_all_blog_posts
|
||||||
@blog_posts = BlogPost.live.includes(:comments, :categories).paginate({
|
@blog_posts = BlogPost.live.includes(:comments, :categories).paginate({
|
||||||
:page => params[:page],
|
:page => params[:page],
|
||||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_tags
|
def find_tags
|
||||||
@tags = BlogPost.tag_counts_on(:tags)
|
@tags = BlogPost.tag_counts_on(:tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def canonical?
|
||||||
|
::Refinery.i18n_enabled? && ::Refinery::I18n.default_frontend_locale != ::Refinery::I18n.current_frontend_locale
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue