From b72598485ace03615a1c39f6a8720c6fe6cfa458 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 25 Dec 2013 14:04:38 +0100 Subject: More sidebar module fixes. There was some problems with the approach in the previous commits. - render_collection (render @sidebar_modules in our case) requires that all objects return the same partial path. Ours may not do that, so we wrote our own `render_sidebar_modules`-helper. - The way render_partial finds the correct path to the partial is to append what's returned by to_partial_path with whatever root the parent view is in. That would require duplication of the partials under all the different engines namespaces. Our `render_sidebar_modules` does it differently, and just looks up the partial according to the root namespace. This means the sidebar_module code can move back under the root application so we don't mess up the refinery namespaces. - Finally found the proper way to link to a blog_post so that it works from all namespaces. The correct way is: refinery.blog_post_path(post) This works in views (and presumably helpers,) but not in controllers which is why we struggled with it before. --- app/views/common/_left_sidebar.html.erb | 2 +- app/views/common/_right_sidebar.html.erb | 2 +- app/views/common/_sidebar_module.html.erb | 5 ----- .../refinery/sidebar_modules/_sidebar_blog_category.html.erb | 8 -------- app/views/sidebar_modules/_sidebar_blog_category.html.erb | 8 ++++++++ app/views/sidebar_modules/_sidebar_module.html.erb | 5 +++++ 6 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 app/views/common/_sidebar_module.html.erb delete mode 100644 app/views/refinery/sidebar_modules/_sidebar_blog_category.html.erb create mode 100644 app/views/sidebar_modules/_sidebar_blog_category.html.erb create mode 100644 app/views/sidebar_modules/_sidebar_module.html.erb (limited to 'app/views') diff --git a/app/views/common/_left_sidebar.html.erb b/app/views/common/_left_sidebar.html.erb index 1a55f7e..3cdbe0c 100644 --- a/app/views/common/_left_sidebar.html.erb +++ b/app/views/common/_left_sidebar.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/common/_right_sidebar.html.erb b/app/views/common/_right_sidebar.html.erb index 9a40a11..082e4f1 100644 --- a/app/views/common/_right_sidebar.html.erb +++ b/app/views/common/_right_sidebar.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/common/_sidebar_module.html.erb b/app/views/common/_sidebar_module.html.erb deleted file mode 100644 index c7a24e9..0000000 --- a/app/views/common/_sidebar_module.html.erb +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/app/views/refinery/sidebar_modules/_sidebar_blog_category.html.erb b/app/views/refinery/sidebar_modules/_sidebar_blog_category.html.erb deleted file mode 100644 index c1d80f1..0000000 --- a/app/views/refinery/sidebar_modules/_sidebar_blog_category.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% content_for "sidebar_module_#{sidebar_blog_category.title}_body" do %> - <% sidebar_blog_category.body.each do |post| %> - <%= content_tag :div, :class => :sidebar_blog_headline do %> - <%= link_to post.title, blog_post_path(post) %> - <% end %> - <% end %> -<% end %> -<%= render 'common/sidebar_module', :sidebar_module => sidebar_blog_category %> diff --git a/app/views/sidebar_modules/_sidebar_blog_category.html.erb b/app/views/sidebar_modules/_sidebar_blog_category.html.erb new file mode 100644 index 0000000..53556e7 --- /dev/null +++ b/app/views/sidebar_modules/_sidebar_blog_category.html.erb @@ -0,0 +1,8 @@ +<% content_for "sidebar_module_#{sidebar_module.title}_body" do %> + <% sidebar_module.body.each do |post| %> + <%= content_tag :div, :class => :sidebar_blog_headline do %> + <%= link_to post.title, refinery.blog_post_path(post) %> + <% end %> + <% end %> +<% end %> +<%= render 'sidebar_modules/sidebar_module', :sidebar_module => sidebar_module %> diff --git a/app/views/sidebar_modules/_sidebar_module.html.erb b/app/views/sidebar_modules/_sidebar_module.html.erb new file mode 100644 index 0000000..c7a24e9 --- /dev/null +++ b/app/views/sidebar_modules/_sidebar_module.html.erb @@ -0,0 +1,5 @@ + + -- cgit v1.2.3