aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJoe Sak <joe@joesak.com>2011-03-11 14:23:44 -0600
committerJoe Sak <joe@joesak.com>2011-03-11 14:23:44 -0600
commit3748c1d9efabde0b62db7b92281c711c6411cfce (patch)
tree82f494d8cea40c009a70050c1a99491e58385612 /app
parentb3f95341c3b67123084563bd38f9145b8ef4da78 (diff)
downloadrefinerycms-blog-3748c1d9efabde0b62db7b92281c711c6411cfce.tar.gz
refinerycms-blog-3748c1d9efabde0b62db7b92281c711c6411cfce.tar.bz2
refinerycms-blog-3748c1d9efabde0b62db7b92281c711c6411cfce.zip
Closes GH-29. Blog posts act as taggable. rspec & cukes passing
Diffstat (limited to 'app')
-rw-r--r--app/controllers/blog/posts_controller.rb13
-rw-r--r--app/views/blog/posts/archive.html.erb3
-rw-r--r--app/views/blog/posts/index.html.erb1
-rw-r--r--app/views/blog/posts/show.html.erb1
-rw-r--r--app/views/blog/posts/tagged.html.erb22
-rw-r--r--app/views/blog/shared/_post.html.erb10
-rw-r--r--app/views/blog/shared/_tags.html.erb8
7 files changed, 53 insertions, 5 deletions
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb
index 576073e..9c413ed 100644
--- a/app/controllers/blog/posts_controller.rb
+++ b/app/controllers/blog/posts_controller.rb
@@ -2,6 +2,7 @@ class Blog::PostsController < BlogController
before_filter :find_all_blog_posts, :except => [:archive]
before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
+ before_filter :find_tags
respond_to :html, :js, :rss
@@ -64,6 +65,14 @@ class Blog::PostsController < BlogController
end
respond_with (@blog_posts)
end
+
+ def tagged
+ @tag_name = params[:tag_name]
+ @blog_posts = BlogPost.tagged_with(@tag_name.titleize).paginate({
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
+ end
protected
@@ -83,5 +92,9 @@ protected
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
})
end
+
+ def find_tags
+ @tags = BlogPost.tag_counts_on(:tags)
+ end
end
diff --git a/app/views/blog/posts/archive.html.erb b/app/views/blog/posts/archive.html.erb
index d44aa7f..a2044e8 100644
--- a/app/views/blog/posts/archive.html.erb
+++ b/app/views/blog/posts/archive.html.erb
@@ -1,5 +1,4 @@
<% content_for :body_content_left do %>
- <%= @page[Page.default_parts.first.to_sym] %>
<h1><%= t('.blog_archive_for', :date => @archive_date.strftime('%B %Y')) %></h1>
<% if @blog_posts.any? %>
<section id="blog_posts">
@@ -11,8 +10,8 @@
<% end %>
<% content_for :body_content_right do %>
- <%= @page[Page.default_parts.second.to_sym] %>
<%= render :partial => "/blog/shared/categories" %>
+ <%= render :partial => "/blog/shared/tags" %>
<%= render :partial => "/blog/shared/rss_feed" %>
<%= blog_archive_list %>
<% end %>
diff --git a/app/views/blog/posts/index.html.erb b/app/views/blog/posts/index.html.erb
index 08e3578..8c3801a 100644
--- a/app/views/blog/posts/index.html.erb
+++ b/app/views/blog/posts/index.html.erb
@@ -15,6 +15,7 @@
<%=raw @page[Page.default_parts.second.to_sym] if Page.default_parts.many? %>
<%= render :partial => "/blog/shared/categories" %>
+ <%= render :partial => "/blog/shared/tags" %>
<%= render :partial => "/blog/shared/rss_feed" %>
<%= blog_archive_list %>
<% end %>
diff --git a/app/views/blog/posts/show.html.erb b/app/views/blog/posts/show.html.erb
index 504db2c..92898a4 100644
--- a/app/views/blog/posts/show.html.erb
+++ b/app/views/blog/posts/show.html.erb
@@ -49,6 +49,7 @@
<% content_for :body_content_right do %>
<%= render :partial => "/blog/shared/categories" %>
+ <%= render :partial => "/blog/shared/tags" %>
<%= render :partial => "/blog/shared/posts" %>
<%= render :partial => "/blog/shared/rss_feed" %>
<%= blog_archive_list %>
diff --git a/app/views/blog/posts/tagged.html.erb b/app/views/blog/posts/tagged.html.erb
new file mode 100644
index 0000000..29de791
--- /dev/null
+++ b/app/views/blog/posts/tagged.html.erb
@@ -0,0 +1,22 @@
+<% content_for :body_content_title, "Posts tagged &#8220;#{@tag_name.titleize}&#8221;".html_safe -%>
+
+<% content_for :body_content_left do %>
+ <% if @blog_posts.any? %>
+ <section id="blog_posts">
+ <%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
+ <%= will_paginate @blog_posts %>
+ </section>
+ <% else %>
+ <p><%= t('.no_blog_articles_yet') %></p>
+ <% end %>
+<% end %>
+
+<% content_for :body_content_right do %>
+ <%= render :partial => "/blog/shared/categories" %>
+ <%= render :partial => "/blog/shared/tags" %>
+ <%= render :partial => "/blog/shared/rss_feed" %>
+ <%= blog_archive_list %>
+<% end %>
+
+<%= render :partial => "/shared/content_page" %>
+<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
diff --git a/app/views/blog/shared/_post.html.erb b/app/views/blog/shared/_post.html.erb
index 2e92f73..716c1ad 100644
--- a/app/views/blog/shared/_post.html.erb
+++ b/app/views/blog/shared/_post.html.erb
@@ -9,9 +9,13 @@
<% if (categories = post.categories).any? %>
<aside class='filed_in'>
<%= t('filed_in', :scope => 'blog.posts.show') %>
- <% categories.each_with_index do |category, index| %>
- <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
- <% end %>
+ <%=raw categories.collect { |category| link_to category.title, blog_category_url(category) }.to_sentence %>
+ </aside>
+ <% end %>
+ <% if (tags = post.tag_list).any? %>
+ <aside class='tagged'>
+ <%= t('tagged', :scope => 'blog.posts.show') %>
+ <%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.parameterize) }.to_sentence %>
</aside>
<% end %>
</details>
diff --git a/app/views/blog/shared/_tags.html.erb b/app/views/blog/shared/_tags.html.erb
new file mode 100644
index 0000000..f8833f1
--- /dev/null
+++ b/app/views/blog/shared/_tags.html.erb
@@ -0,0 +1,8 @@
+<% unless @tags.nil? %>
+ <h2><%= t('.title') %></h2>
+ <nav id='tags'>
+ <% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %>
+ <%= link_to tag.name, tagged_posts_path(tag.name.parameterize), :class => css_class %>
+ <% end %>
+ </nav>
+<% end %> \ No newline at end of file