aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorUģis Ozols <ugis.ozolss@gmail.com>2014-01-20 11:25:47 +0200
committerUģis Ozols <ugis.ozolss@gmail.com>2014-01-20 11:25:47 +0200
commit249af183145b1608686528255af9c031485683b8 (patch)
treeade3dcf168e5bf700154228044d588615e991975 /app
parenta8b5bce609089af8795768230c7dd3a9b87cd5e0 (diff)
parentd891009d8b26cbccfc7fcdec645e1e2382c641bc (diff)
downloadrefinerycms-blog-249af183145b1608686528255af9c031485683b8.tar.gz
refinerycms-blog-249af183145b1608686528255af9c031485683b8.tar.bz2
refinerycms-blog-249af183145b1608686528255af9c031485683b8.zip
Merge branch 'master' into rails4
Conflicts: app/helpers/refinery/blog/controller_helper.rb app/models/refinery/blog/post.rb
Diffstat (limited to 'app')
-rw-r--r--app/helpers/refinery/blog/controller_helper.rb43
-rw-r--r--app/models/refinery/blog/post.rb5
2 files changed, 22 insertions, 26 deletions
diff --git a/app/helpers/refinery/blog/controller_helper.rb b/app/helpers/refinery/blog/controller_helper.rb
index 75c351a..4bec046 100644
--- a/app/helpers/refinery/blog/controller_helper.rb
+++ b/app/helpers/refinery/blog/controller_helper.rb
@@ -4,37 +4,28 @@ module Refinery
protected
- def find_blog_post
- @post = all_blog_posts.friendly.find(params[:id])
- unless @post.try(:live?)
- if refinery_user? && current_refinery_user.authorized_plugins.include?("refinerycms_blog")
- @post = Post.friendly.find(params[:id])
- else
- error_404
+ def find_blog_post
+ @post = all_blog_posts.friendly.find(params[:id])
+ unless @post.try(:live?)
+ if refinery_user? && current_refinery_user.authorized_plugins.include?("refinerycms_blog")
+ @post = Post.friendly.find(params[:id])
+ else
+ error_404
+ end
end
end
- end
- def find_all_blog_posts
- @posts = all_blog_posts.live
- end
-
- def paginate_all_blog_posts
- @posts = find_all_blog_posts.page(params[:page])
- end
-
- def find_tags
- @tags = Post.tag_counts_on(:tags)
- end
+ def find_all_blog_posts
+ @posts = all_blog_posts.live
+ end
- def find_all_blog_categories
- @categories = Category.translated
- end
+ def find_tags
+ @tags = Refinery::Blog::Post.live.tag_counts_on(:tags)
+ end
- private
- def all_blog_posts
- Post.newest_first.includes(:comments, :categories).with_globalize
- end
+ def find_all_blog_categories
+ @categories = Refinery::Blog::Category.translated
+ end
end
end
end
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 11aa5b8..1c2cf04 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -44,6 +44,11 @@ module Refinery
seo_fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten
delegate(*(seo_fields << {:to => :translation}))
+ before_save do |m|
+ m.translation.globalized_model = self
+ m.translation.save if m.translation.new_record?
+ end
+
self.per_page = Refinery::Blog.posts_per_page
def next