Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Rendering a portlet now works.

  • Loading branch information...
commit 7917576e808e0dabd4de2ee00424f1062d89d6b3 1 parent be63af4
@peakpg peakpg authored
View
3  app/helpers/cms/blog_helper.rb
@@ -13,5 +13,8 @@ def feeds_link_tag_for(name)
auto_discovery_link_tag(:rss, blog_feeds_url(:blog_id => blog), :title => "#{blog.name}")
end
+ def new_comment_path(portlet)
+ url_for(:controller=>"cms/portlet", :action=>"execute_handler", :id=>portlet.id, :handler=>"create_comment")
+ end
end
View
6 app/models/blog_observer.rb
@@ -17,11 +17,7 @@ def before_save(blog)
update_section_pages_and_route(blog)
end
end
-
- def after_update(blog)
- blog.publish
- end
-
+
private
# A section, two pages, 6 routes and a portlet are created alongside every blog.
View
12 app/portlets/blog_post_portlet.rb
@@ -1,6 +1,6 @@
class BlogPostPortlet < Portlet
- #render_inline false
- #enable_template_editor false
+
+ enable_template_editor false
def render
scope = Blog.find(self.blog_id).posts
@@ -24,6 +24,8 @@ def render
end
def create_comment
+ work_around_cms_3_3_bug_where_current_user_is_not_correctly_set
+
params[:blog_comment].merge! :ip => request.remote_ip
blog_comment = BlogComment.new(params[:blog_comment])
if blog_comment.valid? && blog_comment.save
@@ -34,5 +36,11 @@ def create_comment
url_for_failure
end
end
+
+ private
+
+ def work_around_cms_3_3_bug_where_current_user_is_not_correctly_set
+ User.current = current_user
+ end
end
View
4 app/views/portlets/blog_post/render.html.erb
@@ -2,9 +2,9 @@
<%= render :partial => "partials/blog_post", :object => @blog_post %>
<div class="blog_comment_form">
- <% form_for @blog_comment, :url => cms_handler_path(@portlet, "create_comment") do |f| %>
+ <% form_for @blog_comment, :url => new_comment_path(@portlet) do |f| %>
<%= f.hidden_field :post_id %>
- <%= f.error_messages %>
+ <%= f.cms_error_messages %>
<div class="fields text_fields">
<%= f.label :author, 'Name *' %>
<%= f.text_field :author %>
Please sign in to comment.
Something went wrong with that request. Please try again.