diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/blog/categories_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/blog/posts_controller.rb (renamed from app/controllers/blog_posts_controller.rb) | 29 | ||||
-rw-r--r-- | app/controllers/blog_controller.rb | 15 | ||||
-rw-r--r-- | app/views/admin/blog/comments/show.html.erb | 4 | ||||
-rw-r--r-- | app/views/blog/categories/show.html.erb | 20 | ||||
-rw-r--r-- | app/views/blog/posts/_comment.html.erb | 9 | ||||
-rw-r--r-- | app/views/blog/posts/index.html.erb | 16 | ||||
-rw-r--r-- | app/views/blog/posts/show.html.erb (renamed from app/views/blog_posts/show.html.erb) | 66 | ||||
-rw-r--r-- | app/views/blog/shared/_categories.html.erb | 8 | ||||
-rw-r--r-- | app/views/blog/shared/_post.html.erb | 20 | ||||
-rw-r--r-- | app/views/blog/shared/_posts.html.erb | 8 | ||||
-rw-r--r-- | app/views/blog_posts/_categories.html.erb | 0 | ||||
-rw-r--r-- | app/views/blog_posts/_comments.html.erb | 0 | ||||
-rw-r--r-- | app/views/blog_posts/_side_bar.html.erb | 8 | ||||
-rw-r--r-- | app/views/blog_posts/index.html.erb | 27 |
15 files changed, 131 insertions, 106 deletions
diff --git a/app/controllers/blog/categories_controller.rb b/app/controllers/blog/categories_controller.rb new file mode 100644 index 0000000..71ceec1 --- /dev/null +++ b/app/controllers/blog/categories_controller.rb @@ -0,0 +1,7 @@ +class Blog::CategoriesController < BlogController + + def show + @category = BlogCategory.find(params[:id]) + end + +end
\ No newline at end of file diff --git a/app/controllers/blog_posts_controller.rb b/app/controllers/blog/posts_controller.rb index 73b9dfa..8a10604 100644 --- a/app/controllers/blog_posts_controller.rb +++ b/app/controllers/blog/posts_controller.rb @@ -1,15 +1,8 @@ -class BlogPostsController < ApplicationController +class Blog::PostsController < BlogController - before_filter :find_all_blog_posts, :find_all_blog_categories - before_filter :find_page + before_filter :find_all_blog_posts before_filter :find_blog_post, :only => [:show, :comment] - def index - # you can use meta fields from your model instead (e.g. browser_title) - # by swapping @page for @blogs in the line below: - present(@page) - end - def show @blog_comment = BlogComment.new @@ -40,23 +33,7 @@ protected end def find_all_blog_posts - unless params[:category_id].present? - @blog_posts = BlogPost.live - else - if (category = BlogCategory.find(params[:category_id])).present? - @blog_posts = category.posts - else - error_404 - end - end - end - - def find_all_blog_categories - @blog_categories = BlogCategory.all - end - - def find_page - @page = Page.find_by_link_url("/blog") + @blog_posts = BlogPost.live end end diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb new file mode 100644 index 0000000..0931cbd --- /dev/null +++ b/app/controllers/blog_controller.rb @@ -0,0 +1,15 @@ +class BlogController < ApplicationController + + before_filter :find_page, :find_all_blog_categories + +protected + + def find_page + @page = Page.find_by_link_url("/blog") + end + + def find_all_blog_categories + @blog_categories = BlogCategory.all + end + +end
\ No newline at end of file diff --git a/app/views/admin/blog/comments/show.html.erb b/app/views/admin/blog/comments/show.html.erb index 7dbe519..1cc29bb 100644 --- a/app/views/admin/blog/comments/show.html.erb +++ b/app/views/admin/blog/comments/show.html.erb @@ -60,6 +60,4 @@ </table> </div> -<% content_for :head do %> - <%= stylesheet_link_tag 'refinery/refinerycms-blog' %> -<% end %>
\ No newline at end of file +<% content_for :head, stylesheet_link_tag('refinery/refinerycms-blog') %>
\ No newline at end of file diff --git a/app/views/blog/categories/show.html.erb b/app/views/blog/categories/show.html.erb new file mode 100644 index 0000000..bd9f863 --- /dev/null +++ b/app/views/blog/categories/show.html.erb @@ -0,0 +1,20 @@ +<% content_for :body_content_title, @category.title %> + +<% content_for :body_content_left do %> + <% if @category.posts.any? %> + <ul id="blog_posts"> + <%= render :partial => "/blog/shared/post", :collection => @category.posts %> + </ul> + <% else %> + <p> + <%= t('.no_posts') %> + </p> + <% end %> +<% end %> + +<% content_for :body_content_right do %> + <%= render :partial => "/blog/shared/categories" %> +<% end %> + +<%= render :partial => "/shared/content_page" %> +<% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
\ No newline at end of file diff --git a/app/views/blog/posts/_comment.html.erb b/app/views/blog/posts/_comment.html.erb new file mode 100644 index 0000000..559757b --- /dev/null +++ b/app/views/blog/posts/_comment.html.erb @@ -0,0 +1,9 @@ +<div class='blog_comment_message' id='<%= "comment-#{comment.to_param}" %>'> + <p> + <%= comment.message.to_s.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>") %> + </p> +</div> +<p class='blog_comment_author'> + <%= t('.by', :who => comment.name) %> + <%= t('.time_ago', :time => time_ago_in_words(comment.created_at)) %> +</p>
\ No newline at end of file diff --git a/app/views/blog/posts/index.html.erb b/app/views/blog/posts/index.html.erb new file mode 100644 index 0000000..f2ccbd8 --- /dev/null +++ b/app/views/blog/posts/index.html.erb @@ -0,0 +1,16 @@ +<% content_for :body_content_left do %> + <%= @page[Page.default_parts.first.to_sym] %> + + <ul id="blog_posts"> + <%= render :partial => "/blog/shared/post", :collection => @blog_posts %> + </ul> +<% end %> + +<% content_for :body_content_right do %> + <%= @page[Page.default_parts.second.to_sym] %> + + <%= render :partial => "/blog/shared/categories" %> +<% end %> + +<%= render :partial => "/shared/content_page" %> +<% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
\ No newline at end of file diff --git a/app/views/blog_posts/show.html.erb b/app/views/blog/posts/show.html.erb index e13a442..5b897ad 100644 --- a/app/views/blog_posts/show.html.erb +++ b/app/views/blog/posts/show.html.erb @@ -1,46 +1,38 @@ <% content_for :body_content_title, @blog_post.title %> <% content_for :body_content_left do %> - <%= t('.created_at', :when => @blog_post.created_at.strftime('%d %B %Y')) %> - <%= @blog_post.body %> - - <% if (categories = @blog_post.categories).any? %> - <hr /> - <div class='post_categories'> - <span class='filed_in'><%= t('.filed_in') %></span> - <ul> + <p class='posted_at'> + <%= t('blog.shared.posts.created_at', :when => @blog_post.created_at.strftime('%d %B %Y')) %>. + + <% if (categories = @blog_post.categories).any? %> + <span class='filed_in'> + <%= t('.filed_in') %> <% categories.each_with_index do |category, index| %> - <li> <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %> - </li> <% end %> - </ul> - </div> - <% end %> - - <% if (comments = @blog_post.comments.approved).any? %> - <hr /> + </span> + <% end %> + </p> + <%= @blog_post.body %> + + <% if BlogPost.comments_allowed? %> <h2><%= t('.comments.title') %></h2> - <% comments.each do |comment| %> - <div class='blog_comment_message' id='<%= "comment-#{comment.to_param}" %>'> - <p> - <%= comment.message.to_s.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>") %> - </p> - </div> - <p class='blog_comment_author'> - <%= t('.comments.by', :who => comment.name) %> - <%= t('.comments.time_ago', :time => time_ago_in_words(comment.created_at)) %> + + <% if (comments = @blog_post.comments.approved).any? %> + <%= render :partial => "comment", :collection => comments %> + <% else %> + <p> + <%= t('blog.shared.comments.none') %>. </p> <% end %> - <% end %> - - <% if BlogPost.comments_allowed? %> - <hr /> + <% flash.each do |key, value| %> <div id='flash' class="flash flash_<%= key %>"> <%= value %> </div> <% end %> + + <h2><%= t('.comments.add') %></h2> <% form_for [:blog_post, @blog_comment] do |f| %> <% if Rails.version < '3.0.0'%> <%= f.error_messages %> @@ -71,19 +63,9 @@ <% end %> <% content_for :body_content_right do %> - <%= render :partial => "side_bar" %> - - <h2><%= t('.other') %></h2> - <ul id="blog_posts"> - <% @blog_posts.each do |blog_post| %> - <li> - <%= link_to blog_post.title, blog_post_url(blog_post) %> - </li> - <% end %> - </ul> + <%= render :partial => "/blog/shared/categories" %> + <%= render :partial => "/blog/shared/posts" %> <% end %> <%= render :partial => "/shared/content_page" %> -<% content_for :head do %> - <%= stylesheet_link_tag 'refinerycms-blog' %> -<% end %>
\ No newline at end of file +<% content_for :head, stylesheet_link_tag('refinerycms-blog') %>
\ No newline at end of file diff --git a/app/views/blog/shared/_categories.html.erb b/app/views/blog/shared/_categories.html.erb new file mode 100644 index 0000000..fa26ceb --- /dev/null +++ b/app/views/blog/shared/_categories.html.erb @@ -0,0 +1,8 @@ +<h2><%= t('.title') %></h2> +<ul id='categories'> + <% @blog_categories.each do |category| %> + <li<%= " class='selected'" if @category.present? and @category.id == category.id %>> + <%= link_to "#{category.title} (#{category.posts.count})", blog_category_url(category) %> + </li> + <% end %> +</ul>
\ No newline at end of file diff --git a/app/views/blog/shared/_post.html.erb b/app/views/blog/shared/_post.html.erb new file mode 100644 index 0000000..d8194d3 --- /dev/null +++ b/app/views/blog/shared/_post.html.erb @@ -0,0 +1,20 @@ +<li> + <h2><%= link_to post.title, blog_post_url(post) %></h2> + <p class='posted_at'> + <%= t('blog.shared.posts.created_at', :when => post.created_at.strftime('%d %B %Y')) %> + </p> + <%= truncate(post.body, + :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250), + :preserve_html_tags => true) %> + <p> + <%= link_to t('blog.shared.posts.read_more'), blog_post_url(post) %> + + <span class='comment_count'> + <% if post.comments.any? %> + (<%= pluralize(post.comments.count, t('blog.shared.comments.singular')) %>) + <% else %> + (<%= t('blog.shared.comments.none') %>) + <% end %> + </span> + </p> +</li>
\ No newline at end of file diff --git a/app/views/blog/shared/_posts.html.erb b/app/views/blog/shared/_posts.html.erb new file mode 100644 index 0000000..4a78334 --- /dev/null +++ b/app/views/blog/shared/_posts.html.erb @@ -0,0 +1,8 @@ +<h2><%= t('.other') %></h2> +<ul id="blog_posts"> + <% @blog_posts.each do |blog_post| %> + <li> + <%= link_to blog_post.title, blog_post_url(blog_post) %> + </li> + <% end %> +</ul>
\ No newline at end of file diff --git a/app/views/blog_posts/_categories.html.erb b/app/views/blog_posts/_categories.html.erb deleted file mode 100644 index e69de29..0000000 --- a/app/views/blog_posts/_categories.html.erb +++ /dev/null diff --git a/app/views/blog_posts/_comments.html.erb b/app/views/blog_posts/_comments.html.erb deleted file mode 100644 index e69de29..0000000 --- a/app/views/blog_posts/_comments.html.erb +++ /dev/null diff --git a/app/views/blog_posts/_side_bar.html.erb b/app/views/blog_posts/_side_bar.html.erb deleted file mode 100644 index dfdfaa2..0000000 --- a/app/views/blog_posts/_side_bar.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<h2><%= t('.categories') %></h2> -<ul id='categories'> - <% @blog_categories.each do |category| %> - <li> - <%= link_to category.title, blog_category_url(category) %> - </li> - <% end %> -</ul>
\ No newline at end of file diff --git a/app/views/blog_posts/index.html.erb b/app/views/blog_posts/index.html.erb deleted file mode 100644 index c97ca61..0000000 --- a/app/views/blog_posts/index.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<% content_for :body_content_left do %> - <%= @page[Page.default_parts.first.to_sym] %> - - <ul id="blog_posts"> - <% @blog_posts.each do |blog_post| %> - <li> - <h2><%= link_to blog_post.title, blog_post_url(blog_post) %></h2> - <%= t('.created_at', :when => blog_post.created_at.strftime('%d %B %Y')) %> - <%= truncate(blog_post.body, - :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250), - :preserve_html_tags => true) %> - <%= link_to t('.read_more'), blog_post_url(blog_post) %> - </li> - <% end %> - </ul> -<% end %> - -<% content_for :body_content_right do %> - <%= @page[Page.default_parts.second.to_sym] %> - - <%= render :partial => "side_bar" %> -<% end %> - -<%= render :partial => "/shared/content_page" %> -<% content_for :head do %> - <%= stylesheet_link_tag 'refinerycms-blog' %> -<% end %>
\ No newline at end of file |