aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/blog_posts_controller.rb18
-rw-r--r--app/views/admin/blog/categories/_form.html.erb2
-rw-r--r--app/views/blog_posts/_sidebar.html.erb8
-rw-r--r--app/views/blog_posts/index.html.erb15
-rw-r--r--app/views/blog_posts/show.html.erb15
-rw-r--r--config/locales/en.yml22
-rw-r--r--config/routes.rb4
7 files changed, 68 insertions, 16 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| %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3aef157..7263e70 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -4,6 +4,13 @@ en:
title: Blog
admin:
blog:
+ categories:
+ category:
+ edit: Edit this category
+ delete: Delete this category forever
+ comments:
+ index:
+ no_items_yet: There are no {{type}} comments yet.
posts:
form:
advanced_options: Advanced Options
@@ -15,9 +22,12 @@ en:
view_live: View this blog post live <br/><em>(opens in a new window)</em>
edit: Edit this blog post
delete: Remove this blog post forever
- comments:
- index:
- no_items_yet: There are no {{type}} comments yet.
+ settings:
+ notification_recipients:
+ value: Send notifications to
+ explanation: "Every time someone comments on a blog post, Refinery sends out an email to say there is a new comment."
+ hint: "When a new comment is added, Refinery will send an email notification to you."
+ example: "Enter your email address(es) like: jack@work.com, jill@office.com"
submenu:
categories:
title: Categories
@@ -37,12 +47,6 @@ en:
title: Settings
moderation: Moderation
update_notified: Update who gets notified
- settings:
- notification_recipients:
- value: Send notifications to
- explanation: "Every time someone comments on a blog post, Refinery sends out an email to say there is a new comment."
- hint: "When a new comment is added, Refinery will send an email notification to you."
- example: "Enter your email address(es) like: jack@work.com, jill@office.com"
blog_posts:
show:
other: Other Blog Posts \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 2478f1b..36e80f9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,7 @@
ActionController::Routing::Routes.draw do |map|
- map.resources :blog_posts, :as => :blog
+ map.blog_post '/blog', :controller => :blog_posts, :action => :index
+ map.blog_post '/blog/:id', :controller => :blog_posts, :action => :show
+ map.blog_category '/blog/categories/:category_id', :controller => :blog_posts, :action => :index
map.namespace(:admin, :path_prefix => 'refinery') do |admin|
admin.namespace :blog do |blog|