aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-11-10 09:23:02 +1300
committerPhilip Arndt <parndt@gmail.com>2011-11-10 09:23:02 +1300
commitf9f56c6f1c5ee277f5b0a335ca12a4eea275d42d (patch)
tree37bccbf5da9e688e5d6c8be5d3f10d03c4c25e75 /app/controllers
parent81475ff3809d83e46ff28f39523abfc5cb1635a4 (diff)
parent12164fd95a1884a340283554ed5dbeedce916b80 (diff)
downloadrefinerycms-blog-f9f56c6f1c5ee277f5b0a335ca12a4eea275d42d.tar.gz
refinerycms-blog-f9f56c6f1c5ee277f5b0a335ca12a4eea275d42d.tar.bz2
refinerycms-blog-f9f56c6f1c5ee277f5b0a335ca12a4eea275d42d.zip
Merge branch 'master' into rails-3-1
Conflicts: app/controllers/admin/blog/posts_controller.rb app/controllers/blog/posts_controller.rb
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/refinery/admin/blog/posts_controller.rb20
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb10
2 files changed, 16 insertions, 14 deletions
diff --git a/app/controllers/refinery/admin/blog/posts_controller.rb b/app/controllers/refinery/admin/blog/posts_controller.rb
index aa40c85..8b3816d 100644
--- a/app/controllers/refinery/admin/blog/posts_controller.rb
+++ b/app/controllers/refinery/admin/blog/posts_controller.rb
@@ -20,18 +20,14 @@ module Refinery
end
def tags
- op = case ActiveRecord::Base.connection.adapter_name.downcase
- when 'postgresql'
- '~*'
- else
- 'LIKE'
- end
- wildcard = case ActiveRecord::Base.connection.adapter_name.downcase
- when 'postgresql'
- '.*'
- else
- '%'
- end
+ if ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql'
+ op = '~*'
+ wildcard = '.*'
+ else
+ op = 'LIKE'
+ wildcard = '%'
+ end
+
@tags = Refinery::Blog::Post.tag_counts_on(:tags).where(
["tags.name #{op} ?", "#{wildcard}#{params[:term].to_s.downcase}#{wildcard}"]
).map { |tag| {:id => tag.id, :value => tag.name}}
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb
index d3cd7a1..1c8cffd 100644
--- a/app/controllers/refinery/blog/posts_controller.rb
+++ b/app/controllers/refinery/blog/posts_controller.rb
@@ -1,7 +1,7 @@
module Refinery
module Blog
class PostsController < BaseController
-
+
caches_page :index
before_filter :find_all_blog_posts, :except => [:archive]
@@ -12,7 +12,7 @@ module Refinery
def index
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
- (@blog_posts = Refinery::Blog::Post.live.includes(:comments, :categories).all) if request.format.rss?
+ (@blog_posts = Refinery::Blog::Post.live.includes(:comments, :categories).all) if request.format.rss?
respond_with (@blog_posts) do |format|
format.html
format.rss
@@ -22,6 +22,8 @@ module Refinery
def show
@blog_comment = Refinery::Blog::Comment.new
+ @canonical = url_for(:locale => ::Refinery::I18n.default_frontend_locale) if canonical?
+
respond_with (@blog_post) do |format|
format.html { present(@blog_post) }
format.js { render :partial => 'post', :layout => false }
@@ -71,6 +73,10 @@ module Refinery
@tag_name = @tag.name
@blog_posts = Refinery::Blog::Post.tagged_with(@tag_name).page(params[:page])
end
+
+ def canonical?
+ ::Refinery.i18n_enabled? && ::Refinery::I18n.default_frontend_locale != ::Refinery::I18n.current_frontend_locale
+ end
end
end
end