diff options
author | Philip Arndt <parndt@gmail.com> | 2010-08-26 17:41:32 +1200 |
---|---|---|
committer | Philip Arndt <parndt@gmail.com> | 2010-08-26 17:41:32 +1200 |
commit | 5cb85902866dfc0f64885a76ce38f23dd1f89d53 (patch) | |
tree | b9d2110ee59a9bd301ba5648083f5138b17ed0f8 /app | |
parent | da6b5e1f572960533f31026981df57f2d59d1b05 (diff) | |
download | refinerycms-blog-5cb85902866dfc0f64885a76ce38f23dd1f89d53.tar.gz refinerycms-blog-5cb85902866dfc0f64885a76ce38f23dd1f89d53.tar.bz2 refinerycms-blog-5cb85902866dfc0f64885a76ce38f23dd1f89d53.zip |
frontend markup and categories.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/blog_posts_controller.rb | 18 | ||||
-rw-r--r-- | app/views/admin/blog/categories/_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/blog_posts/_sidebar.html.erb | 8 | ||||
-rw-r--r-- | app/views/blog_posts/index.html.erb | 15 | ||||
-rw-r--r-- | app/views/blog_posts/show.html.erb | 15 |
5 files changed, 52 insertions, 6 deletions
diff --git a/app/controllers/blog_posts_controller.rb b/app/controllers/blog_posts_controller.rb index 95169c0..7ddb7b8 100644 --- a/app/controllers/blog_posts_controller.rb +++ b/app/controllers/blog_posts_controller.rb @@ -1,6 +1,6 @@ class BlogPostsController < ApplicationController - before_filter :find_all_blog_posts + before_filter :find_all_blog_posts, :find_all_blog_categories before_filter :find_page def index @@ -20,11 +20,23 @@ class BlogPostsController < ApplicationController protected def find_all_blog_posts - @blog_posts = BlogPost.live + 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("/blogs") + @page = Page.find_by_link_url("/blog") end end diff --git a/app/views/admin/blog/categories/_form.html.erb b/app/views/admin/blog/categories/_form.html.erb index f1ee0bc..0c5b9c4 100644 --- a/app/views/admin/blog/categories/_form.html.erb +++ b/app/views/admin/blog/categories/_form.html.erb @@ -10,6 +10,6 @@ :locals => { :f => f, :continue_editing => false, - :delete_title => t('admin.blogs.categories.delete') + :delete_title => t('admin.blog.categories.category.delete') } %> <% end %>
\ No newline at end of file diff --git a/app/views/blog_posts/_sidebar.html.erb b/app/views/blog_posts/_sidebar.html.erb new file mode 100644 index 0000000..56bd825 --- /dev/null +++ b/app/views/blog_posts/_sidebar.html.erb @@ -0,0 +1,8 @@ +<h2><%= t('.categories') %></h2> +<ul class='categories'> + <% @blog_categories.each do |category| %> + <li> + <%= category.title %> + </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 index 4dddcef..7832a66 100644 --- a/app/views/blog_posts/index.html.erb +++ b/app/views/blog_posts/index.html.erb @@ -1,11 +1,24 @@ <% content_for :body_content_left do %> + <%= @page[Page.default_parts.first.to_sym] %> + <ul id="blog_posts"> <% @blog_posts.each do |blog_post| %> <li> - <%= link_to blog_post.title, blog_post_url(blog_post) %> + <h2><%= link_to blog_post.title, blog_post_url(blog_post) %></h2> + <%= 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 => "sidebar" %> +<% end %> + <%= render :partial => "/shared/content_page" %> diff --git a/app/views/blog_posts/show.html.erb b/app/views/blog_posts/show.html.erb index 2cd39c6..7a4c9c3 100644 --- a/app/views/blog_posts/show.html.erb +++ b/app/views/blog_posts/show.html.erb @@ -1,12 +1,25 @@ <% content_for :body_content_title, @blog_post.title %> <% content_for :body_content_left do %> - <%= @blog_post.body %> + <% if (categories = @blog_post.categories).any? %> + <%= t('.filed_in') %> + <ul> + <% categories.each do |category| %> + <li> + <%= link_to category.title, blog_category_url(category) %> + </li> + <% end %> + </ul> + <% end %> <% end %> <% content_for :body_content_right do %> + <h2><%= t('.created_at_title') %></h2> + <%= t('.created_at', :when => @blog_post.created_at.strftime('%d %B %Y')) %> + <%= render :partial => "sidebar" %> + <h2><%= t('.other') %></h2> <ul id="blog_post"> <% @blog_posts.each do |blog_post| %> |