aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/blog/posts_controller.rb53
-rw-r--r--app/controllers/admin/blog/settings_controller.rb16
-rw-r--r--app/controllers/blog/posts_controller.rb32
-rw-r--r--app/helpers/blog_posts_helper.rb16
-rw-r--r--app/models/blog_category.rb3
-rw-r--r--app/models/blog_comment.rb9
-rw-r--r--app/models/blog_post.rb46
-rw-r--r--app/models/categorization.rb5
-rw-r--r--app/views/admin/blog/_submenu.html.erb65
-rw-r--r--app/views/admin/blog/posts/_form.html.erb6
-rw-r--r--app/views/admin/blog/posts/_post.html.erb2
-rw-r--r--app/views/admin/blog/posts/index.html.erb6
-rw-r--r--app/views/admin/blog/posts/uncategorized.html.erb26
-rw-r--r--app/views/blog/posts/_post.html.erb2
-rw-r--r--app/views/blog/posts/archive.html.erb3
-rw-r--r--app/views/blog/posts/index.html.erb6
-rw-r--r--app/views/blog/posts/show.html.erb8
-rw-r--r--app/views/blog/posts/tagged.html.erb22
-rw-r--r--app/views/blog/shared/_categories.html.erb18
-rw-r--r--app/views/blog/shared/_post.html.erb23
-rw-r--r--app/views/blog/shared/_posts.html.erb18
-rw-r--r--app/views/blog/shared/_tags.html.erb8
22 files changed, 309 insertions, 84 deletions
diff --git a/app/controllers/admin/blog/posts_controller.rb b/app/controllers/admin/blog/posts_controller.rb
index bd5dd49..e8ffed2 100644
--- a/app/controllers/admin/blog/posts_controller.rb
+++ b/app/controllers/admin/blog/posts_controller.rb
@@ -3,6 +3,59 @@ class Admin::Blog::PostsController < Admin::BaseController
crudify :blog_post,
:title_attribute => :title,
:order => 'published_at DESC'
+
+ def uncategorized
+ @blog_posts = BlogPost.uncategorized.paginate({
+ :page => params[:page],
+ :per_page => BlogPost.per_page
+ })
+ end
+
+ def create
+ # if the position field exists, set this object as last object, given the conditions of this class.
+ if BlogPost.column_names.include?("position")
+ params[:blog_post].merge!({
+ :position => ((BlogPost.maximum(:position, :conditions => "")||-1) + 1)
+ })
+ end
+
+ if BlogPost.column_names.include?("user_id")
+ params[:blog_post].merge!({
+ :user_id => current_user.id
+ })
+ end
+
+ if (@blog_post = BlogPost.create(params[:blog_post])).valid?
+ (request.xhr? ? flash.now : flash).notice = t(
+ 'refinery.crudify.created',
+ :what => "'#{@blog_post.title}'"
+ )
+
+ unless from_dialog?
+ unless params[:continue_editing] =~ /true|on|1/
+ redirect_back_or_default(admin_blog_posts_url)
+ else
+ unless request.xhr?
+ redirect_to :back
+ else
+ render :partial => "/shared/message"
+ end
+ end
+ else
+ render :text => "<script>parent.window.location = '#{admin_blog_posts_url}';</script>"
+ end
+ else
+ unless request.xhr?
+ render :action => 'new'
+ else
+ render :partial => "/shared/admin/error_messages",
+ :locals => {
+ :object => @blog_post,
+ :include_object_name => true
+ }
+ end
+ end
+ end
before_filter :find_all_categories,
:only => [:new, :edit, :create, :update]
diff --git a/app/controllers/admin/blog/settings_controller.rb b/app/controllers/admin/blog/settings_controller.rb
index cc9261b..a805d9c 100644
--- a/app/controllers/admin/blog/settings_controller.rb
+++ b/app/controllers/admin/blog/settings_controller.rb
@@ -10,7 +10,8 @@ class Admin::Blog::SettingsController < Admin::BaseController
unless request.xhr? or from_dialog?
redirect_back_or_default(admin_blog_posts_path)
else
- render :text => "<script type='text/javascript'>parent.window.location = '#{admin_blog_posts_path}';</script>"
+ render :text => "<script type='text/javascript'>parent.window.location = '#{admin_blog_posts_path}';</script>",
+ :layout => false
end
end
end
@@ -20,7 +21,18 @@ class Admin::Blog::SettingsController < Admin::BaseController
unless request.xhr?
redirect_back_or_default(admin_blog_posts_path)
else
- render :json => {:enabled => enabled}
+ render :json => {:enabled => enabled},
+ :layout => false
+ end
+ end
+
+ def comments
+ enabled = BlogComment.toggle!
+ unless request.xhr?
+ redirect_back_or_default(admin_blog_posts_path)
+ else
+ render :json => {:enabled => enabled},
+ :layout => false
end
end
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb
index f7b6f3c..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
@@ -45,13 +46,32 @@ class Blog::PostsController < BlogController
end
def archive
- date = "#{params[:month]}/#{params[:year]}"
- @archive_date = Time.parse(date)
- @blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
+ if params[:month].present?
+ date = "#{params[:month]}/#{params[:year]}"
+ @archive_date = Time.parse(date)
+ @date_title = @archive_date.strftime('%B %Y')
+ @blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
+ else
+ date = "01/#{params[:year]}"
+ @archive_date = Time.parse(date)
+ @date_title = @archive_date.strftime('%Y')
+ @blog_posts = BlogPost.live.by_year(@archive_date).paginate({
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
+ 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)
})
- respond_with (@blog_posts)
end
protected
@@ -72,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/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb
index 965eb8f..6b4066a 100644
--- a/app/helpers/blog_posts_helper.rb
+++ b/app/helpers/blog_posts_helper.rb
@@ -6,11 +6,17 @@ module BlogPostsHelper
html << t('blog.shared.archives')
html << '</h2><nav><ul>'
links = []
+ super_old_links = []
posts.each do |e|
- links << e.published_at.strftime('%m/%Y')
+ if e.published_at >= Time.now.end_of_year.advance(:years => -3)
+ links << e.published_at.strftime('%m/%Y')
+ else
+ super_old_links << e.published_at.strftime('01/%Y')
+ end
end
links.uniq!
+ super_old_links.uniq!
links.each do |l|
year = l.split('/')[1]
month = l.split('/')[0]
@@ -20,6 +26,14 @@ module BlogPostsHelper
html << link_to(text, archive_blog_posts_path(:year => year, :month => month))
html << "</li>"
end
+ super_old_links.each do |l|
+ year = l.split('/')[1]
+ count = BlogPost.by_year(Time.parse(l)).size
+ text = "#{year} (#{count})"
+ html << "<li>"
+ html << link_to(text, archive_blog_posts_path(:year => year))
+ html << "</li>"
+ end
html << '</ul></nav></section>'
html.html_safe
end
diff --git a/app/models/blog_category.rb b/app/models/blog_category.rb
index 8ffe834..bc0165a 100644
--- a/app/models/blog_category.rb
+++ b/app/models/blog_category.rb
@@ -1,6 +1,7 @@
class BlogCategory < ActiveRecord::Base
- has_and_belongs_to_many :posts, :class_name => 'BlogPost'
+ has_many :categorizations
+ has_many :posts, :through => :categorizations, :source => :blog_post
acts_as_indexed :fields => [:title]
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 015b96d..13aceb1 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -13,7 +13,7 @@ class BlogComment < ActiveRecord::Base
alias_attribute :message, :body
validates :name, :message, :presence => true
- validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
+ validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
scope :unmoderated, :conditions => {:state => nil}
scope :approved, :conditions => {:state => 'approved'}
@@ -39,6 +39,13 @@ class BlogComment < ActiveRecord::Base
self.state.nil?
end
+ def self.toggle!
+ currently = RefinerySetting.find_or_set(:comments_allowed, true, {
+ :scoping => 'blog'
+ })
+ RefinerySetting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'})
+ end
+
before_create do |comment|
unless BlogComment::Moderation.enabled?
comment.state = comment.ham? ? 'approved' : 'rejected'
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb
index 1887a97..db85a70 100644
--- a/app/models/blog_post.rb
+++ b/app/models/blog_post.rb
@@ -1,7 +1,17 @@
-class BlogPost < ActiveRecord::Base
+require 'acts-as-taggable-on'
+class BlogPost < ActiveRecord::Base
+
+ default_scope :order => 'published_at DESC'
+ #.first & .last will be reversed -- consider a with_exclusive_scope on these?
+
+ belongs_to :author, :class_name => 'User', :foreign_key => :user_id
+
has_many :comments, :class_name => 'BlogComment', :dependent => :destroy
- has_and_belongs_to_many :categories, :class_name => 'BlogCategory'
+ acts_as_taggable
+
+ has_many :categorizations
+ has_many :categories, :through => :categorizations, :source => :blog_category
acts_as_indexed :fields => [:title, :body]
@@ -11,22 +21,26 @@ class BlogPost < ActiveRecord::Base
has_friendly_id :title, :use_slug => true
scope :by_archive, lambda { |archive_date|
- where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]).order("published_at DESC")
+ where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month])
+ }
+
+ scope :by_year, lambda { |archive_year|
+ where(['published_at between ? and ?', archive_year.beginning_of_year, archive_year.end_of_year])
}
- scope :all_previous, where(['published_at <= ?', Time.now.beginning_of_month]).order("published_at DESC")
-
- scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false).order("published_at DESC") }
+ scope :all_previous, lambda { where(['published_at <= ?', Time.now.beginning_of_month]) }
- scope :previous, lambda { |i| where(["published_at < ? and draft = ?", i.published_at, false]).order("published_at DESC").limit(1) }
- scope :next, lambda { |i| where(["published_at > ? and draft = ?", i.published_at, false]).order("published_at ASC").limit(1) }
+ scope :live, lambda { where( "published_at <= ? and draft = ?", Time.now, false) }
+ scope :previous, lambda { |i| where(["published_at < ? and draft = ?", i.published_at, false]).limit(1) }
+ # next is now in << self
+
def next
- self.class.next(self).first
+ BlogPost.next(self).first
end
def prev
- self.class.previous(self).first
+ BlogPost.previous(self).first
end
def live?
@@ -40,17 +54,27 @@ class BlogPost < ActiveRecord::Base
end
class << self
+ def next current_record
+ self.send(:with_exclusive_scope) do
+ where(["published_at > ? and draft = ?", current_record.published_at, false]).order("published_at ASC")
+ end
+ end
+
def comments_allowed?
RefinerySetting.find_or_set(:comments_allowed, true, {
:scoping => 'blog'
})
end
+
+ def uncategorized
+ BlogPost.live.reject { |p| p.categories.any? }
+ end
end
module ShareThis
DEFAULT_KEY = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
- class << self
+ class << self
def key
RefinerySetting.find_or_set(:share_this_key, BlogPost::ShareThis::DEFAULT_KEY, {
:scoping => 'blog'
diff --git a/app/models/categorization.rb b/app/models/categorization.rb
new file mode 100644
index 0000000..32e9967
--- /dev/null
+++ b/app/models/categorization.rb
@@ -0,0 +1,5 @@
+class Categorization < ActiveRecord::Base
+ set_table_name 'blog_categories_blog_posts'
+ belongs_to :blog_post
+ belongs_to :blog_category
+end \ No newline at end of file
diff --git a/app/views/admin/blog/_submenu.html.erb b/app/views/admin/blog/_submenu.html.erb
index ab662e7..b93e30d 100644
--- a/app/views/admin/blog/_submenu.html.erb
+++ b/app/views/admin/blog/_submenu.html.erb
@@ -1,6 +1,6 @@
<nav id='actions' class='multilist'>
<ul class='search_list'>
- <li>
+ <li class='not_a_link'>
<%= render :partial => "/shared/admin/search",
:locals => {
:url => admin_blog_posts_url
@@ -9,7 +9,7 @@
</ul>
<ul class='collapsible_menu'>
- <li>
+ <li class='not_a_link'>
<%= link_to t('.posts.title'), '#',
:class => 'page_copy_icon' %>
</li>
@@ -18,37 +18,42 @@
:class => 'page_icon' %>
</li>
<li>
- <%= link_to t('.posts.new'), new_admin_blog_post_url,
- :class => 'page_add_icon' %>
- </li>
- </ul>
-
- <ul class='collapsible_menu'>
- <li>
- <% if BlogComment.unmoderated.any? %>
- <% title = t('.comments.title_with_count', :new_count => BlogComment.unmoderated.size) %>
- <% else %>
- <% title = t('.comments.title') %>
- <% end %>
- <%= link_to title, '#',
- :class => 'comments_icon' %>
- </li>
- <li>
- <%= link_to t('.comments.new'), admin_blog_comments_path,
- :class => 'comment_icon' %>
- </li>
- <li>
- <%= link_to t('.comments.approved'), approved_admin_blog_comments_path,
- :class => 'comment_tick_icon' %>
+ <%= link_to t('.posts.uncategorized'), uncategorized_admin_blog_posts_url,
+ :class => 'page_icon' %>
</li>
<li>
- <%= link_to t('.comments.rejected'), rejected_admin_blog_comments_path,
- :class => 'comment_cross_icon' %>
+ <%= link_to t('.posts.new'), new_admin_blog_post_url,
+ :class => 'page_add_icon' %>
</li>
</ul>
+ <% if BlogPost.comments_allowed? %>
+ <ul class='collapsible_menu'>
+ <li class='not_a_link'>
+ <% if BlogComment.unmoderated.any? %>
+ <% title = t('.comments.title_with_count', :new_count => BlogComment.unmoderated.size) %>
+ <% else %>
+ <% title = t('.comments.title') %>
+ <% end %>
+ <%= link_to title, '#',
+ :class => 'comments_icon' %>
+ </li>
+ <li>
+ <%= link_to t('.comments.new'), admin_blog_comments_path,
+ :class => 'comment_icon' %>
+ </li>
+ <li>
+ <%= link_to t('.comments.approved'), approved_admin_blog_comments_path,
+ :class => 'comment_tick_icon' %>
+ </li>
+ <li>
+ <%= link_to t('.comments.rejected'), rejected_admin_blog_comments_path,
+ :class => 'comment_cross_icon' %>
+ </li>
+ </ul>
+ <% end %>
<ul class='collapsible_menu'>
- <li>
+ <li class='not_a_link'>
<%= link_to t('.categories.title'), '#',
:class => 'folder_icon' %>
</li>
@@ -63,11 +68,15 @@
</ul>
<ul class='collapsible_menu'>
- <li>
+ <li class='not_a_link'>
<%= link_to t('.settings.title'), admin_blog_settings_path,
:class => 'settings_icon' %>
</li>
<li>
+ <%= link_to t('.settings.comments'), comments_admin_blog_settings_url,
+ :class => "#{BlogPost.comments_allowed? ? 'success' : 'failure'}_icon" %>
+ </li>
+ <li>
<%= link_to t('.settings.moderation'), moderation_admin_blog_settings_url,
:class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
</li>
diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb
index 0dc6e9b..3c0a351 100644
--- a/app/views/admin/blog/posts/_form.html.erb
+++ b/app/views/admin/blog/posts/_form.html.erb
@@ -14,6 +14,12 @@
<%= f.label :body -%>
<%= f.text_area :body, :rows => 20, :class => 'wymeditor widest' -%>
</div>
+
+ <div class='field'>
+ <%= f.label :tag_list, "Tags" -%>
+ <%= f.text_field :tag_list, :class => 'larger' -%>
+ </div>
+
<div id='more_options_field'>
<p>
<%= link_to t('.advanced_options'), "#",
diff --git a/app/views/admin/blog/posts/_post.html.erb b/app/views/admin/blog/posts/_post.html.erb
index 1f51932..1226082 100644
--- a/app/views/admin/blog/posts/_post.html.erb
+++ b/app/views/admin/blog/posts/_post.html.erb
@@ -1,7 +1,7 @@
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(post) -%>">
<span class='title'>
<%= post.title %>
- <span class="preview">&nbsp;</span>
+ <span class="preview"><%= post.published_at.try(:strftime, '%b %d, %Y') || 'draft' %><%= " by #{post.author.username}" if post.author.present? %></span>
</span>
<span class='actions'>
<%= link_to refinery_icon_tag("application_go.png"), blog_post_url(post),
diff --git a/app/views/admin/blog/posts/index.html.erb b/app/views/admin/blog/posts/index.html.erb
index 888daab..f9baaac 100644
--- a/app/views/admin/blog/posts/index.html.erb
+++ b/app/views/admin/blog/posts/index.html.erb
@@ -3,10 +3,12 @@
<% if searching? %>
<h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
<% if @blog_posts.any? %>
- <%= render :partial => "blog_posts",
+ <ul>
+ <%= render :partial => "post",
:collection => @blog_posts %>
+ </ul>
<% else %>
- <p><%= t('admin.search_no_results') %></p>
+ <p><%= t('shared.admin.search.no_results') %></p>
<% end %>
<% else %>
<% if @blog_posts.any? %>
diff --git a/app/views/admin/blog/posts/uncategorized.html.erb b/app/views/admin/blog/posts/uncategorized.html.erb
new file mode 100644
index 0000000..888daab
--- /dev/null
+++ b/app/views/admin/blog/posts/uncategorized.html.erb
@@ -0,0 +1,26 @@
+<%= render :partial => '/admin/blog/submenu' %>
+<div id='records'>
+ <% if searching? %>
+ <h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
+ <% if @blog_posts.any? %>
+ <%= render :partial => "blog_posts",
+ :collection => @blog_posts %>
+ <% else %>
+ <p><%= t('admin.search_no_results') %></p>
+ <% end %>
+ <% else %>
+ <% if @blog_posts.any? %>
+ <%= will_paginate @blog_posts %>
+
+ <%= render :partial => "sortable_list" %>
+
+ <%= will_paginate @blog_posts %>
+ <% else %>
+ <p>
+ <strong>
+ <%= t('.no_items_yet', :create => t('admin.blog.submenu.posts.new')) %>
+ </strong>
+ </p>
+ <% end %>
+ <% end %>
+</div>
diff --git a/app/views/blog/posts/_post.html.erb b/app/views/blog/posts/_post.html.erb
index 6a16631..d1c204e 100644
--- a/app/views/blog/posts/_post.html.erb
+++ b/app/views/blog/posts/_post.html.erb
@@ -9,7 +9,7 @@
<details>
<time datetime="<%=l @blog_post.published_at.to_date, :format => :default %>" class='posted_at'>
<%= t('blog.shared.posts.created_at', :when => l(@blog_post.published_at.to_date, :format => :short)) %>.
- </time>
+ </time><%= " by #{@blog_post.author.username}" if @blog_post.author.present? %>
<% if (categories = @blog_post.categories).any? %>
<aside class='filed_in'>
<%= t('blog.posts.show.filed_in') %>
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 766d689..8c3801a 100644
--- a/app/views/blog/posts/index.html.erb
+++ b/app/views/blog/posts/index.html.erb
@@ -1,9 +1,10 @@
<% content_for :body_content_left do %>
- <%= @page[Page.default_parts.first.to_sym].html_safe if Page.default_parts.any? %>
+ <%=raw @page[Page.default_parts.first.to_sym] if Page.default_parts.any? %>
<% 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>
@@ -11,9 +12,10 @@
<% end %>
<% content_for :body_content_right do %>
- <%= @page[Page.default_parts.second.to_sym].html_safe if Page.default_parts.many? %>
+ <%=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 5ac4c76..92898a4 100644
--- a/app/views/blog/posts/show.html.erb
+++ b/app/views/blog/posts/show.html.erb
@@ -6,7 +6,6 @@
<% if BlogPost.comments_allowed? %>
<aside id="comments">
<h2><%= t('.comments.title') %></h2>
-
<% if (comments = @blog_post.comments.approved).any? %>
<%= render :partial => "comment", :collection => comments %>
<% else %>
@@ -50,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 %>
@@ -61,7 +61,8 @@
<% content_for :head_libraries, jquery_include_tags(:jquery_ui => false) %>
<% content_for :head do %>
<%= stylesheet_link_tag 'refinerycms-blog' %>
- <%= javascript_include_tag('refinerycms-blog') %>
+ <%# enable AJAX'd post nav at your own risk until html5 history API implemented. %>
+ <%#= javascript_include_tag('refinerycms-blog') %>
<% if BlogPost::ShareThis.enabled? %>
<script src="http://w.sharethis.com/button/buttons.js"></script>
<script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
@@ -71,7 +72,8 @@
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
<% content_for :before_javascript_libraries, jquery_include_tags(:jquery_ui => false) %>
<% content_for :javascripts do %>
- <%= javascript_include_tag 'refinerycms-blog' %>
+ <%# enable AJAX'd post nav at your own risk until html5 history API implemented. %>
+ <%#= javascript_include_tag('refinerycms-blog') %>
<script src="http://w.sharethis.com/button/buttons.js"></script>
<script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
<% end if BlogPost::ShareThis.enabled? %>
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/_categories.html.erb b/app/views/blog/shared/_categories.html.erb
index 675271c..05cc53f 100644
--- a/app/views/blog/shared/_categories.html.erb
+++ b/app/views/blog/shared/_categories.html.erb
@@ -1,8 +1,10 @@
-<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.post_count})", blog_category_url(category) %>
- </li>
- <% end %>
-</ul>
+<% if @blog_categories.any? %>
+ <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.post_count})", blog_category_url(category) %>
+ </li>
+ <% end %>
+ </ul>
+<% end %> \ No newline at end of file
diff --git a/app/views/blog/shared/_post.html.erb b/app/views/blog/shared/_post.html.erb
index 16483a5..716c1ad 100644
--- a/app/views/blog/shared/_post.html.erb
+++ b/app/views/blog/shared/_post.html.erb
@@ -5,13 +5,17 @@
<details>
<time datetime="<%=l post.published_at.to_date, :format => :default %>" class='posted_at'>
<%= t('blog.shared.posts.created_at', :when => l(post.published_at.to_date, :format => :short)) %>.
- </time>
+ </time><%= " by #{post.author.username}" if post.author.present? %>
<% 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>
@@ -24,15 +28,16 @@
<footer>
<p>
<%= link_to t('blog.shared.posts.read_more'), blog_post_url(post) %>
-
- <aside class='comment_count'>
+ </p>
+ <aside class='comment_count'>
+ <% if BlogPost.comments_allowed? %>
<% if post.comments.any? %>
(<%= pluralize(post.comments.approved.count, t('blog.shared.comments.singular')) %>)
<% else %>
- (<%= t('blog.shared.comments.none') %>)
+ (<%= t('blog.shared.comments.none') %>)
<% end %>
- </aside>
- </p>
+ <% end %>
+ </aside>
</footer>
</article>
<% end %>
diff --git a/app/views/blog/shared/_posts.html.erb b/app/views/blog/shared/_posts.html.erb
index cbf865f..24a8199 100644
--- a/app/views/blog/shared/_posts.html.erb
+++ b/app/views/blog/shared/_posts.html.erb
@@ -1,8 +1,10 @@
-<h2><%= t('.other') %></h2>
-<ul id="blog_posts">
- <% @blog_posts.each do |blog_post| %>
- <li class='clearfix'>
- <%= link_to blog_post.title, blog_post_url(blog_post) %>
- </li>
- <% end %>
-</ul>
+<% if @blog_posts.many? %>
+ <h2><%= t('.other') %></h2>
+ <ul id="blog_posts">
+ <% @blog_posts.each do |blog_post| %>
+ <li class='clearfix'>
+ <%= link_to blog_post.title, blog_post_url(blog_post) %>
+ </li>
+ <% end %>
+ </ul>
+<% end %> \ No newline at end of file
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