diff options
61 files changed, 1558 insertions, 421 deletions
diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 84f127c..0000000 --- a/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -gem 'filters_spam', '~> 0.3' -gem "will_paginate", ">= 2.3.14"
\ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index ae2c41e..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,11 +0,0 @@ -GEM - specs: - filters_spam (0.3) - will_paginate (2.3.14) - -PLATFORMS - ruby - -DEPENDENCIES - filters_spam (~> 0.3) - will_paginate (>= 2.3.14) 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"> </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 “#{@tag_name.titleize}”".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 diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..e861958 --- /dev/null +++ b/changelog.md @@ -0,0 +1,40 @@ +## 1.4 [UNRELEASED] + +* Spanish language fixes [scambra](https://github.com/scambra) +* Bug fixes [scambra](https://github.com/scambra) +* Tags [joemsak](https://github.com/joemsak) +* Tagged posts route / view [joemsak](https://github.com/joemsak) +* Tag cloud in sidebar +* Czech & slovak translations [karem](https://github.com/keram) +* [See full list](https://github.com/resolve/refinerycms-blog/compare/1.3...1.4) + +## 1.3 [03 March 2011] + +* Moved to EngineInstaller [parndt](https://github.com/parndt) +* Off Rails 2 support [parndt](https://github.com/parndt) +* [See full list](https://github.com/resolve/refinerycms-blog/compare/1.2...1.3) + +## 1.2 [01 March 2011] + +* Posts can be authored [joemsak](https://github.com/joemsak) +* Front-end pagination [joemsak](https://github.com/joemsak) +* Archives start grouping by year after 2 years [joemsak](https://github.com/joemsak) +* Removed ajax blog post navigation [joemsak](https://github.com/joemsak) +* Administrate uncategorized posts [joemsak](https://github.com/joemsak) +* Categories in has_many :through relationship [joemsak](https://github.com/joemsak) +* General bug fixing & test coverage [parndt](https://github.com/parndt) [joemsak](https://github.com/joemsak) +* Russian translation [iband](https://github.com/iband) +* French translation [AdrienGiboire](https://github.com/AdrienGiboire) +* Polish translation [murbanski](https://github.com/murbanski) +* German translation [gern](https://github.com/gern) +* Spanish translation help [xavib](https://github.com/xavib) +* Rails 3 cleanup & optimization [ugisozols](https://github.com/ugisozols) +* [See full list](https://github.com/resolve/refinerycms-blog/compare/1.1...1.2) + + +## 1.1 [02 December 2010] + +* Rails 3 Support +* Archives +* Categories +* [See full list](https://github.com/resolve/refinerycms-blog/compare/1.0...1.1)
\ No newline at end of file diff --git a/config/locales/cs.yml b/config/locales/cs.yml new file mode 100644 index 0000000..8d8d81d --- /dev/null +++ b/config/locales/cs.yml @@ -0,0 +1,128 @@ +cs: + plugins: + refinerycms_blog: + title: Blog + admin: + blog: + categories: + category: + edit: Upravit kategorii + delete: Smazat kategorii + index: + no_items_yet: 'Nejsou zde žádné kategorie. Klikni na "%{create}" pro přidání první.' + comments: + approved: 'Komentář od "%{author}" byl schválen.' + comment: + view_live_html: 'Zobrazit živý náhled <br/><em>(otevře nové okno)</em>' + read: Zobrazit komentář + reject: Zamítnout komentář + approve: Schválit + rejected: 'Komentář od "%{author}" byl zamítnut.' + index: + no_items_yet: 'Nejsou zde žádné %{type} komentáře.' + show: + comment: Komentář + blog_post: Blog článek + from: Odeslal + date: Datum + message: Komentář + details: Detaily + age: Věk + actions: Akce + back: Zpět na seznam komentářů + reject: Zamítnout komentář + approve: Schváliť komentář + posts: + form: + advanced_options: Pokročilé nastavení + toggle_advanced_options: Klikni pro přístup k nastavením meta tagů a menu + save_as_draft: Uložit jako koncept + published_at: Datum publikování + index: + no_items_yet: 'Nejsou žádné články na blogu. Klikni na "%{create}" pro přidání prvního.' + uncategorized: + no_items_yet: 'Nejsou žádné nekategorizované články.' + post: + view_live_html: 'Zobrazit článek <br/><em>(otevře jej v novém okně)</em>' + edit: Upravit článek + delete: Smazat článek + settings: + notification_recipients: + value: Poslat notifikaci pro + explanation: 'Vždycky když někdo přidá komentář, Refinery zašle oznámení.' + hint: 'Vždycky když někdo přidá komentář, Refinery ti pošle oznámení.' + example: "Zadej tvou emailovou adresu(y) jako například: jack@work.com, jill@office.com" + updated: 'Seznam příjemců notifikací "%{recipients}"' + submenu: + categories: + title: Kategorie + manage: Spravovat + new: Nová kategórie + comments: + title: Komentáře + title_with_count: 'Komentáře (%{new_count} nových)' + new: Nový + unmoderated: Nový + approved: Schválený + rejected: Zamítnutý + posts: + title: Články + manage: Spravovat články + new: Vytvořit nový článek + uncategorized: Nekategorizované články + settings: + title: Nastavení + moderation: Moderování + update_notified: Upravit seznam notifikovaných + comments: Komentáře + blog: + comment_mailer: + notification: + greeting: Ahoj + you_recieved_new_comment: Máš nový komentář na stránce + comment_starts: --- začátek komentáře --- + comment_ends: --- konec komentáře --- + from: Od + email: Email + message: Zpráva + closing_line: S pozdravem + ps: 'P.S. Všechny komentáře jsou uloženy v sekci "Blog" pod záložkou "Komentáře" v případě pokud by je bylo třeba zobrazit později.' + shared: + categories: + title: Kategorie + rss_feed: + title: RSS zdroj článků + subscribe: Přihlásit k odběru + posts: + other: Další články + created_at: 'Publikován %{when}' + read_more: Celý článek + comments: + singular: komentář + none: žiadne komentáře + archives: Archiv + categories: + show: + no_posts: Nejsou zde žádné články. + posts: + post: + filed_in: Podaný + comment: komentář + comments: + by: 'Odeslal %{who}' + time_ago: '%{time} zpět' + thank_you: 'Díky za komentář.' + thank_you_moderated: 'Děkujeme za Váš komentář. Vaše zpráva čeká na schválení a objeví se v nejbližší době.' + index: + no_blog_articles_yet: Právě nejsou žádné články na blogu. Zůstaňte naladěni. + show: + blog_home: Hlavní stránka blogu + comments: + title: Komentáře + add: Přidat komentář + other: Další články + filed_in: Podaný + submit: Odeslat komentář + archive: + blog_archive_for: 'Blog archiv pro %{date}' + no_blog_articles_posted: 'Nejsou žádné články publikované %{date}.' diff --git a/config/locales/de.yml b/config/locales/de.yml new file mode 100644 index 0000000..1209b5f --- /dev/null +++ b/config/locales/de.yml @@ -0,0 +1,128 @@ +de: + plugins: + refinerycms_blog: + title: Blog + admin: + blog: + categories: + category: + edit: Diese Kategorie bearbeiten + delete: Diese Kategorie dauerhaft entfernen + index: + no_items_yet: 'Es sind noch keine Kategorien vorhanden. Klicken Sie auf "%{create}", um Ihre erste Kategorie hinzuzufügen.' + comments: + approved: 'Der Kommentar von "%{author}" wurde genehmigt.' + comment: + view_live: 'Diesen Kommentar live betrachten <br/><em>(öffnet sich in einem neuen Fenster)</em>' + read: Kommentar lesen + reject: Kommentar ablehnen + approve: Kommentar genehmigen + rejected: 'Der Kommentar von "%{author}" wurde abgelehnt.' + index: + no_items_yet: 'Es sind keine %{type}en Kommentare vorhanden.' + show: + comment: Kommentar + blog_post: Artikel + from: Verfasst von + date: Verfasst am + message: Kommentar + details: Details + age: Alter + actions: Aktionen + back: Zurück zu allen Kommentaren + reject: Kommentar ablehnen + approve: Kommentar genehmigen + posts: + form: + advanced_options: Erweiterte Optionen + toggle_advanced_options: 'Klicken, um auf Meta-Tag-Einstellungen und Menüoptionen zuzugreifen' + save_as_draft: Als Entwurf speichern + published_at: Veröffentlichungsdatum + index: + no_items_yet: 'Es sind noch keine Artikel vorhanden. Klicken Sie auf "%{create}", um Ihren ersten Artikel hinzuzufügen.' + uncategorized: + no_items_yet: 'Es sind keine unkategorisierten Artikel vorhanden.' + post: + view_live: 'Diesen Artikel live betrachten <br/><em>(öffnet sich in einem neuen Fenster)</em>' + edit: Diesen Artikel bearbeiten + delete: Diesen Artikel dauerhaft entfernen + settings: + notification_recipients: + value: Sende Benachrichtigungen an + explanation: 'Jedes Mal, wenn jemand einen Artikel kommentiert, sendet Refinery eine E-Mail Benachrichtigung aus, um über den neuen Kommentar zu informieren.' + hint: 'Refinery sendet eine E-Mail Benachrichtigung an Sie, wenn ein neuer Kommentar hinzugefügt wurde.' + example: 'Geben Sie Ihre E-Mail-Adresse(n) wie folgt ein: jack@work.com, jill@office.com' + updated: 'Empfänger für Benachrichtigungen wurden auf "%{recipients}" gesetzt' + submenu: + categories: + title: Kategorien + manage: Verwalten + new: Neue Kategorie anlegen + comments: + title: Kommentare + title_with_count: 'Kommentare (%{new_count} neu)' + new: Neu + unmoderated: Neu + approved: Genehmigt + rejected: Abgelehnt + posts: + title: Artikel + manage: Artikel verwalten + new: Neuen Artikel anlegen + uncategorized: Unkategorisierte Artikel + settings: + title: Einstellungen + moderation: Moderation + update_notified: Empfänger für Benachrichtigungen bearbeiten + comments: Kommentare + blog: + comment_mailer: + notification: + greeting: Hallo + you_recieved_new_comment: Auf Ihrer Website wurde soeben ein neuer Kommentar hinzugefügt. + comment_starts: --- Kommentar beginnt --- + comment_ends: --- Kommentar endet --- + from: Von + email: E-Mail + message: Nachricht + closing_line: Mit besten Grüßen + ps: 'P.S. Alle Kommentare sind im "Blog" Abschnitt von Refinery - im Untermenü "Kommentare" - gespeichert, falls Sie diese später dort lesen möchten.' + shared: + categories: + title: Kategorien + rss_feed: + title: RSS Feed + subscribe: Abonnieren + posts: + other: Andere Artikel + created_at: 'Verfasst am %{when}' + read_more: Mehr lesen + comments: + singular: Kommentar + none: Keine Kommentare + archives: Archiv + categories: + show: + no_posts: Es sind noch keine Artikel vorhanden. + posts: + post: + filed_in: Gespeichert unter + comment: Kommentar + comments: + by: 'Verfasst von %{who}' + time_ago: 'vor %{time}' + thank_you: 'Danke für den Kommentar.' + thank_you_moderated: 'Danke für den Kommentar. Die Nachricht wurde in die Warteschlange der Moderation gestellt und erscheint in Kürze.' + index: + no_blog_articles_yet: Es wurden noch keine Artikel verfasst. + show: + blog_home: Blog Startseite + comments: + title: Kommentare + add: Neuen Kommentar hinzufügen + other: Andere Artikel + filed_in: Gespeichert unter + submit: Kommentar senden + archive: + blog_archive_for: 'Blog Archiv für %{date}' + no_blog_articles_posted: 'Für %{date} wurden keine Artikel verfasst.' diff --git a/config/locales/en.yml b/config/locales/en.yml index 7a6e49a..f5b5461 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -13,7 +13,7 @@ en: comments: approved: 'The comment from "%{author}" has been approved.' comment: - view_live_html: View this comment live <br/><em>(opens in a new window)</em> + view_live_html: 'View this comment live <br/><em>(opens in a new window)</em>' read: Read this comment reject: Reject this comment approve: Approve this comment @@ -40,8 +40,10 @@ en: published_at: Publish Date index: no_items_yet: 'There are no Blog Posts yet. Click "%{create}" to add your first blog post.' + uncategorized: + no_items_yet: 'There are no Uncategorized Blog Posts.' post: - view_live_html: View this blog post live <br/><em>(opens in a new window)</em> + view_live_html: 'View this blog post live <br/><em>(opens in a new window)</em>' edit: Edit this blog post delete: Remove this blog post forever settings: @@ -67,10 +69,12 @@ en: title: Posts manage: Manage posts new: Create new post + uncategorized: Uncategorized posts settings: title: Settings moderation: Moderation update_notified: Update who gets notified + comments: Comments blog: comment_mailer: notification: @@ -82,7 +86,7 @@ en: email: Email message: Message closing_line: Kind Regards - ps: P.S. All your comments are stored in the "Blog" section of Refinery under the "Comments" submenu should you ever want to view it later there. + ps: 'P.S. All your comments are stored in the "Blog" section of Refinery under the "Comments" submenu should you ever want to view it later there.' shared: categories: title: Categories @@ -97,10 +101,14 @@ en: singular: comment none: no comments archives: Archives + tags: + title: "Tags" categories: show: no_posts: There are no posts here yet. posts: + post: + filed_in: Filed in comment: comment comments: by: 'Posted by %{who}' @@ -116,7 +124,10 @@ en: add: Make a Comment other: Other Blog Posts filed_in: Filed in + tagged: Tagged submit: Send comment + tagged: + no_blog_articles_yet: There are no blog articles posted yet. Stay tuned. archive: - blog_archive_for: Blog Archive for %{date} - no_blog_articles_posted: There are no blog articles posted for %{date}. Stay tuned. + blog_archive_for: 'Blog Archive for %{date}' + no_blog_articles_posted: 'There are no blog articles posted for %{date}. Stay tuned.' diff --git a/config/locales/es.yml b/config/locales/es.yml index 10b533c..bd9c383 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -9,17 +9,17 @@ es: edit: Editar esta categoría delete: Borrar esta categoría para siempre index: - no_items_yet: Todavía no hay categorías. Haz click en "%{create}" para añadir la primera. + no_items_yet: 'Todavía no hay categorías. Haz click en "%{create}" para añadir la primera.' comments: - approved: El comentario de "%{author}" ha sido aprobado. + approved: 'El comentario de "%{author}" ha sido aprobado.' comment: - view_live_html:Ver este comentario<br/><em>(se abrirá en una ventana nueva)</em> + view_live_html: 'Ver este comentario<br/><em>(se abrirá en una ventana nueva)</em>' read: Leer este comentario reject: Rechazar este comentario approve: Aprovar este comentario - rejected: El comentario de "%{author}" ha sido rechazado. + rejected: 'El comentario de "%{author}" ha sido rechazado.' index: - no_items_yet: No hay comentarios %{type}. + no_items_yet: 'No hay comentarios %{type}.' show: comment: Comentario blog_post: Entrada en el Blog @@ -39,18 +39,20 @@ es: save_as_draft: Guardar Borrador published_at: Fecha de publicación index: - no_items_yet: Aún no hay entradas en el Blog. Haz click en "%{create}" para añadir el primero + no_items_yet: 'Aún no hay entradas en el Blog. Haz click en "%{create}" para añadir el primero' + uncategorized: + no_items_yet: 'No hay entradas en el Blog sin categoría.' post: - view_live_html: Ver entrada <br/><em>(se abrirá en una ventana nueva)</em> + view_live_html: 'Ver entrada <br/><em>(se abrirá en una ventana nueva)</em>' edit: Editar esta entrada delete: Eliminar esta entrada para siempre settings: notification_recipients: value: Enviar notificaciones a - explanation: Cada vez que alguien comente en una entrada, Refinery envia un email para avisar de que hay un nuevo comentario. - hint: Refinery te avisará con un email cada vez que haya un nuevo comentario en tu Blog. + explanation: 'Cada vez que alguien comente en una entrada, Refinery envia un email para avisar de que hay un nuevo comentario.' + hint: 'Refinery te avisará con un email cada vez que haya un nuevo comentario en tu Blog.' example: 'Si deseas que las notificaciones lleguen a más de una cuenta, puedes usar comas para separarlas (pepe@direccionpersonal.com, jose@direccionlaboral.com, ...)' - updated: Las notifiaciones han sido enviadas a "%{recipients}" + updated: 'Las notifiaciones han sido enviadas a "%{recipients}"' submenu: categories: title: Categorías @@ -58,7 +60,7 @@ es: new: Añadir categoría comments: title: Comentarios - title_with_count: Comentarios (%{new_count} nuevos) + title_with_count: 'Comentarios (%{new_count} nuevos)' new: Nuevo unmoderated: Nuevos approved: Aprobados @@ -67,10 +69,12 @@ es: title: Entradas manage: Gestionar entradas new: Crear nueva entrada + uncategorized: Entradas sin categoría settings: title: Configuración moderation: Moderación - update_notified: ¿Quién recibe las notificaciones? + update_notified: '¿Quién recibe las notificaciones?' + comments: Comentarios blog: comment_mailer: notification: @@ -82,7 +86,7 @@ es: email: Email message: Mensaje closing_line: Saludos - ps: P.D. Recuerda que puedes ver todos los comentarios en el apartado "Comentarios" dentro de la sección "Blog". + ps: 'P.D. Recuerda que puedes ver todos los comentarios en el apartado "Comentarios" dentro de la sección "Blog".' shared: categories: title: Categorías @@ -91,31 +95,34 @@ es: subscribe: Suscribirse posts: other: Otras entradas - created_at: Enviado hace %{when} + created_at: 'Enviado hace %{when}' read_more: Leer más comments: singular: comentario none: no hay comentarios + archives: Archivos categories: show: no_posts: Todavía no hay entradas. posts: + post: + filed_in: Archivado en comment: comentario comments: - by: Enviado por %{who} - time_ago: Hace %{time} + by: 'Enviado por %{who}' + time_ago: 'Hace %{time}' thank_you: Gracias por tu comentario. - thank_you_moderated: Gracias por tu comentario. Ha sido enviado a la cola de moderación y, si lo aprobamos, aparecerá dentro de poco. + thank_you_moderated: 'Gracias por tu comentario. Ha sido enviado a la cola de moderación y, si lo aprobamos, aparecerá dentro de poco.' index: - no_blog_articles_yet: Todavía no hay artículos. ¡Pero vuelve pronto! + no_blog_articles_yet: 'Todavía no hay artículos. ¡Pero vuelve pronto!' show: - blog_home: Página principal del Blog + blog_home: 'Página principal del Blog' comments: title: Comentarios - add: Envía tu comentario + add: 'Envía tu comentario' other: Otros posts - filed_in: Envía en + filed_in: Archivado en submit: Enviar comentario archive: - blog_archive_for: Archivo del blog en %{date} - no_blog_articles_posted: No hay entradas publicadas en %{date}. + blog_archive_for: 'Archivo del blog en %{date}' + no_blog_articles_posted: 'No hay entradas publicadas en %{date}.' diff --git a/config/locales/fr.yml b/config/locales/fr.yml new file mode 100644 index 0000000..c71a01f --- /dev/null +++ b/config/locales/fr.yml @@ -0,0 +1,125 @@ +fr: + plugins: + refinerycms_blog: + title: Blog + admin: + blog: + categories: + category: + edit: Modifier cette catégorie + delete: Supprimer cett catégorie + index: + no_items_yet: 'Il n''y a aucune catégorie pour le moment. Cliquez sur "%{create}" pour ajouter votre première catégorie.' + comments: + approved: 'Le commentaire de "%{author}" a été approuvé.' + comment: + view_live_html: 'Voir ce commentaire <br/><em>(Ouvre une nouvelle fenêtre)</em>' + read: Lire ce commentaire + reject: Rejeter ce commentaire + approve: Approuver ce commentaire + rejected: 'Le commentaire de "%{author}" a été rejeté.' + index: + no_items_yet: 'Il n''y aucun %{type} de commentaires.' + show: + comment: Commenter + blog_post: Article + from: Écrit par + date: Écrit le + message: Commentaire + details: Détails + age: Âge + actions: Actions + back: Retour à la liste des commentaires + reject: Rejeter ce commentaire + approve: Approuver ce commentaire + posts: + form: + advanced_options: Options avancées + toggle_advanced_options: Cliquez ici pour accéder aux paramêtres des meta-tags et au menu des options + save_as_draft: Enregistrer comme Brouillon + published_at: Date de publication + index: + no_items_yet: 'Il n''y a aucun article pour l''instant. Cliquez sur "%{create}" pour ajouter votre premier article.' + post: + view_live_html: 'Voir cet article sur le site<br/><em>(Ouvre une nouvelle fenêtre)</em>' + edit: Modifier cet article + delete: Supprimer cet article + settings: + notification_recipients: + value: Envoyer les notifications à + explanation: 'Chaque fois que quelqu''un écrit un commentaire sur un article, Refinery envoie un e-mail pour prévenir qu''il y a un nouveau commentaire.' + hint: 'Quand un nouveau commentaire est ajouté, Refinery vous enverra un e-mail de notifications.' + example: "Entrez une/des adresse(s) e-mail comme : jack@work.com, jill@office.com" + updated: 'Les destinataires des notifications sont définis : "%{recipients}"' + submenu: + categories: + title: Catégories + manage: Gérer + new: Créer une nouvelle catégorie + comments: + title: Commentaires + title_with_count: 'Commentaires (%{new_count} nouveau(x))' + new: Nouveau + unmoderated: Nouveau + approved: Approuvé + rejected: Rejeté + posts: + title: Articles + manage: Gérer les articles + new: Créer un nouvel article + settings: + title: Paramêtres + moderation: Modération + update_notified: Mettre à jour les personnes à notifier + comments: Commentaires + blog: + comment_mailer: + notification: + greeting: Bonjour + you_recieved_new_comment: Il y a un nouveau commentaire sur le blog. + comment_starts: --- comment starts --- + comment_ends: --- comment ends --- + from: De + email: Email + message: Message + closing_line: Cordialement + ps: P.S. Tous les commentaires sont stockés dans la section "Blog" de Refinery dans le menu "Commentaires" si vous voulez les revoir plus tard. + shared: + categories: + title: Catégories + rss_feed: + title: RSS Feed + subscribe: Souscrire + posts: + other: Autres articles + created_at: 'Écrit le %{when}' + read_more: Lire la suite + comments: + singular: commentaire + none: aucun commentaire + archives: Archives + categories: + show: + no_posts: 'Il n''y a aucun article pour cette catégorie.' + posts: + post: + filed_in: Classé dans + comment: commentaire + comments: + by: 'Écrit par %{who}' + time_ago: 'il y a %{time} ' + thank_you: 'Merci pour votre commentaire.' + thank_you_moderated: 'Merci pour votre commentaire. Votre message a été placé en attente de validation et apparaitra bientôt.' + index: + no_blog_articles_yet: "Il n'y a aucun article pour l'instant. Restez en alerte." + show: + blog_home: Accueil du blog + comments: + title: Commentaires + add: Ajouter un commentaire + other: Autres articles + filed_in: Classé dans + submit: Envoyer le commentaire + archive: + blog_archive_for: 'Archive du blog pour le %{date}' + no_blog_articles_posted: "Il n'y a aucun article pour la date du %{date}. Restez à l'écoute." diff --git a/config/locales/it.yml b/config/locales/it.yml index e0c9c79..24023b6 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -13,7 +13,7 @@ it: comments: approved: 'Il commento di "%{author}" è stato approvato.' comment: - view_live: Visualizza questo commento <em> <br/> live (si apre in una nuova finestra) </ em> + view_live: 'Visualizza questo commento <em> <br/> live (si apre in una nuova finestra) </em>' read: Leggi questo commento reject: Rifiuta questo commento approve: Approva questo commento @@ -41,7 +41,7 @@ it: index: no_items_yet: 'Non ci sono ancora Messaggi per questo Blog. Clicca "%{create}" per aggiungere il tuo primo messaggio.' post: - view_live: Visualizza questo messaggio live <br/><em>(si apre in una nuova finestra)</em> + view_live: 'Visualizza questo messaggio live <br/><em>(si apre in una nuova finestra)</em>' edit: Modifica questo messaggio delete: Rimuovi questo messaggio per sempre settings: @@ -58,7 +58,7 @@ it: new: Crea nuova categoria comments: title: Commenti - title_with_count: 'Comment1 (%{new_count} nuovi)' + title_with_count: 'Commenti (%{new_count} nuovi)' new: Nuovo unmoderated: Nuovo approved: Approvato @@ -71,6 +71,7 @@ it: title: Impostazioni moderation: Moderazione update_notified: Aggiornare destinatario notifica + comments: Commenti blog: shared: categories: diff --git a/config/locales/nb.yml b/config/locales/nb.yml index de79479..54cb73b 100644 --- a/config/locales/nb.yml +++ b/config/locales/nb.yml @@ -6,9 +6,9 @@ nb: blog: posts: index: - no_items_yet: Det er ingen Blog Posts enda. Klikk på "Lag en ny Blog Posts" for å legge til din første blog posts. + no_items_yet: 'Det er ingen Blog Posts enda. Klikk på "Lag en ny Blog Posts" for å legge til din første blog posts.' post: - view_live: Vis hvordan denne blog post ser ut offentlig <br/><em>(åpner i et nytt vindu)</em> + view_live: 'Vis hvordan denne blog post ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>' edit: Rediger denne blog post delete: Fjern denne blog post permanent submenu: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 41077ac..cb58d69 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -8,7 +8,7 @@ nl: index: no_items_yet: Er zijn nog geen Blog Post. Druk op 'Maak een nieuwe Blog Post' om de eerste aan te maken. post: - view_live: Bekijk deze blog posts op de website <br/><em>(opent een nieuw venster)</em> + view_live: 'Bekijk deze blog posts op de website <br/><em>(opent een nieuw venster)</em>' edit: Bewerk deze blog post delete: Verwijder deze blog post voor eeuwig submenu: diff --git a/config/locales/pl.yml b/config/locales/pl.yml new file mode 100644 index 0000000..5a9fe9d --- /dev/null +++ b/config/locales/pl.yml @@ -0,0 +1,134 @@ +pl: + activerecord: + attributes: + blog_comment: + name: "Imię" + email: "Email" + message: "Treść" + plugins: + refinerycms_blog: + title: Blog + admin: + blog: + categories: + category: + edit: Edytuj tą kategorię + delete: Usuń na zawsze + index: + no_items_yet: 'W tej chwili nie ma żadnych kategorii. Kliknij "%{create}" aby dodać pierwszą.' + comments: + approved: 'Komentarz "%{author}" został zaakceptowany.' + comment: + view_live: 'Zobacz ten komentarz na żywo<br/><em>(otwiera w nowym oknie)</em>' + read: Pokaż ten komentarz + reject: Odrzuć ten komentarz + approve: Zaakceptuj ten komentarz + rejected: 'Komentarz "%{author}" został odrzucony.' + index: + no_items_yet: 'Nie ma więcej komentarzy typu "%{type}".' + show: + comment: Komentarz + blog_post: Post + from: Autor + date: Data + message: Komentarz + details: Szczegóły + age: Wiek + actions: Akcje + back: Powrót do listy komentarzy + reject: Odrzuć ten komentarz + approve: Zaakceptuj ten komentarz + posts: + form: + advanced_options: Opcje zaawansowane + toggle_advanced_options: 'Kliknij, aby zarządzać meta-ustawieniami' + save_as_draft: Zapisz jako szkic + published_at: Data publikacji + index: + no_items_yet: 'Na blogu nie ma jeszcze żadnych wpisów. Kliknij "%{create}" aby dodać pierwszy post.' + uncategorized: + no_items_yet: 'Brak nieskategoryzowanych wpisów na blogu.' + post: + view_live: 'Zobacz ten post na żywo<br/><em>(otwiera w nowym oknie)</em>' + edit: Edytuj ten post + delete: Usuń ten post na zawsze + settings: + notification_recipients: + value: Powiadomienia wysyłane do + explanation: 'Gdy zostanie dodany nowy komentarz, system wyśle powiadomienie przez e-mail.' + hint: 'Gdy zostanie dodany nowy komentarz, system wyśle powiadomienie przez e-mail.' + example: 'Podaj adresy e-mail oddzielone przecinkiem, np: jack@work.com, jill@office.com' + updated: 'Powiadomienia będą wysyłane do "%{recipients}"' + submenu: + categories: + title: Kategorie + manage: Zarządzaj kategoriami + new: Dodaj nową kategorię + comments: + title: Komentarze + title_with_count: 'Komentarze (%{new_count} nowych)' + new: Nowe + unmoderated: Nowe + approved: Zaakceptowane + rejected: Odrzucone + posts: + title: Posty + manage: Zarządzaj postami + new: Dodaj nowy post + uncategorized: Posty bez kategorii + settings: + title: Ustawienia + moderation: Wł./wył. moderację + update_notified: Powiadamianie przez e-mail + comments: Komentarze + blog: + comment_mailer: + notification: + greeting: Witaj:) + you_recieved_new_comment: Właśnie otrzymałeś nowy komentarz na swojej stronie! + comment_starts: --- początek komentarza --- + comment_ends: --- koniec komentarza --- + from: Od + email: Email + message: Treść + closing_line: Pozdrawiamy + ps: 'P.S. Wszystkie komentarze przechowywane są w panelu zarządzania, w sekcji "Blog" i podmenu "Komentarze". ' + shared: + categories: + title: Kategorie + rss_feed: + title: RSS Feed + subscribe: Sukskrybuj + posts: + other: Pozostałe posty + created_at: 'Data: %{when}' + read_more: Więcej + comments: + singular: komentarz + none: brak komentarzy + archives: Archiwum + categories: + show: + no_posts: Nie ma jeszcze żadnych postów. + posts: + post: + filed_in: 'kategorie:' + comment: komentarz + comments: + by: 'Autor: %{who}' + time_ago: '%{time} temu' + thank_you: 'Dziękujemy za Twój komentarz.' + thank_you_moderated: 'Dziękujemy za Twój komentarz. Został on przekazany do moderacji i niedługo pojawi się na stronie.' + index: + no_blog_articles_yet: W tej chwili nie ma jeszcze żadnych postów. Cierpliwości:) + show: + blog_home: Blog + comments: + title: Komentarze + add: Dodaj komentarz + other: Pozostałe wpisy + filed_in: 'kategorie:' + submit: Dodaj komentarz + archive: + blog_archive_for: 'Archiwum dla %{date}' + no_blog_articles_posted: 'Brak wpisów dla daty %{date}.' diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index f2e2fdc..706f34c 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -13,7 +13,7 @@ pt-BR: comments: approved: 'O comentário de "%{author}" foi aprovado.' comment: - view_live_html: Ver este comentário <br/><em>(será aberto em outra janela)</em> + view_live_html: 'Ver este comentário <br/><em>(será aberto em outra janela)</em>' read: Ler este comentário reject: Rejeitar este comentário approve: Aprovar este comentário @@ -43,7 +43,7 @@ pt-BR: uncategorized: no_items_yet: 'Ainda não há posts sem categoria.' post: - view_live_html: Ver este comentário <br/><em>(será aberto em outra janela)</em> + view_live_html: 'Ver este comentário <br/><em>(será aberto em outra janela)</em>' edit: Editar este post delete: Remover esse post para sempre settings: @@ -51,7 +51,7 @@ pt-BR: value: Enviar notificações para explanation: 'Cada vez que alguém comenta em um post no blog, é enviado um e-mail para informar que há um novo comentário.' hint: 'Quando um novo comentário é adicionado, será enviado uma notificação por e-mail para você.' - example: "Entre com o(s) seu(s) endereço(s) de email, como: jack@work.com, jill@office.com" + example: 'Entre com o(s) seu(s) endereço(s) de email, como: jack@work.com, jill@office.com' updated: 'As notificações foram enviadas para "%{recipients}"' submenu: categories: @@ -74,6 +74,7 @@ pt-BR: title: Configurações moderation: Moderação update_notified: Quem receberá a notificação? + comments: Comentários blog: comment_mailer: notification: @@ -85,7 +86,7 @@ pt-BR: email: Email message: Mensagem closing_line: Atenciosamente - ps: P.S. Lembre-se que você pode ver todos os comentários em "Comentários" dentro da seção "Blog". + ps: 'P.S. Lembre-se que você pode ver todos os comentários em "Comentários" dentro da seção "Blog".' shared: categories: title: Categorias @@ -121,7 +122,7 @@ pt-BR: filed_in: Arquivado em submit: Enviar comentário archive: - blog_archive_for: Arquivo do blog em %{date} - no_blog_articles_posted: Não há arquivos do blog em %{date}. - post: + blog_archive_for: 'Arquivo do blog em %{date}' + no_blog_articles_posted: 'Não há arquivos do blog em %{date}.' + post: filed_in: Arquivado em diff --git a/config/locales/ru.yml b/config/locales/ru.yml new file mode 100644 index 0000000..98b22fc --- /dev/null +++ b/config/locales/ru.yml @@ -0,0 +1,125 @@ +ru: + plugins: + refinerycms_blog: + title: Блог + admin: + blog: + categories: + category: + edit: Редактировать эту категорию + delete: Удалить эту категорию навсегда + index: + no_items_yet: 'Категории пока не созданы. Нажмите "%{create}", чтобы добавить вашу первую категорию.' + comments: + approved: 'Комментарий от "%{author}" был опубликован.' + comment: + view_live_html: Посмотреть комментарий на сайте <br/><em>(откроется в новом окне)</em> + read: Прочитать комментарий + reject: Отклонить комментарий + approve: Принять комментарий + rejected: 'Комментарий от "%{author}" был отклонен.' + index: + no_items_yet: '%{type} комментарии: отсутствуют.' + show: + comment: Комментарий + blog_post: Запись в блоге + from: Опубликовал + date: Опубликовано + message: Комментарий + details: Детали + age: Возраст + actions: Действия + back: Вернуться к списку комментариев + reject: Отклонить этот комментарий + approve: Принять этот комментарий + posts: + form: + advanced_options: Дополнительные настройки + toggle_advanced_options: 'Нажмите, чтобы получить доступ к настройкам мета-тегов и меню' + save_as_draft: Сохранить как черновик + published_at: Дата публикации + index: + no_items_yet: 'Записи в блоге отстутствуют. Нажмите "%{create}", чтобы добавить первую запись.' + post: + view_live_html: Посмотреть запись на сайте <br/><em>(откроется в новом окне)</em> + edit: Редактировать запись + delete: Удалить запись + settings: + notification_recipients: + value: Отправлять уведомления + explanation: 'При появлении новых комментариев Refinery пришлет уведомление на email.' + hint: 'При появлении новых комментариев Refinery пришлет уведомление на email.' + example: "Введите адреса эл. почты, например: jack@work.com, jill@office.com" + updated: 'Получателем уведомлений является "%{recipients}"' + submenu: + categories: + title: Категории + manage: Редактировать категории + new: Создать новую категорию + comments: + title: Комментарии + title_with_count: 'Комментарии (%{new_count} новых)' + new: Новые + unmoderated: Новые + approved: Принятые + rejected: Отклоненные + posts: + title: Записи + manage: Редактировать записи + new: Создать новую запись + settings: + title: Настройки + moderation: Модерирование + update_notified: Настроить уведомления + comments: Комментарии + blog: + comment_mailer: + notification: + greeting: Здравствуйте + you_recieved_new_comment: Новый комментарий опубликован на вашем сайте. + comment_starts: --- начало комментария --- + comment_ends: --- конец комментария --- + from: От + email: Эл. почта + message: Сообщение + closing_line: С уважением + ps: P.S. Все комментарии находятся в разделе "Блог" Refinery CMS в подменю "Комментарии". + shared: + categories: + title: Категории + rss_feed: + title: RSS-лента + subscribe: Подписаться + posts: + other: Другие записи + created_at: 'Опубликовано %{when}' + read_more: Читать дальше + comments: + singular: комментарий + none: нет комментариев + archives: Архивы + categories: + show: + no_posts: Записей пока нет. + posts: + post: + filed_in: Категория + comment: комментарий + comments: + by: 'Опубликовал %{who}' + time_ago: '%{time} назад' + thank_you: 'Спасибо за комментарий.' + thank_you_moderated: 'Спасибо за комментарий. Ваше сообщение модерируется и скоро появится на сайте.' + index: + no_blog_articles_yet: Пока ни одной записи не опубликовано. Следите за новостями. + show: + blog_home: Вернуться к списку записей + comments: + title: Комментарии + add: Написать комментарий + other: Другие записи + filed_in: Категория + submit: Отправить комментарий + archive: + blog_archive_for: 'Архив %{date}' + no_blog_articles_posted: 'Ни одной записи за %{date} не опубликовано. Следите за новостями.' diff --git a/config/locales/sk.yml b/config/locales/sk.yml new file mode 100644 index 0000000..fea514d --- /dev/null +++ b/config/locales/sk.yml @@ -0,0 +1,128 @@ +sk: + plugins: + refinerycms_blog: + title: Blog + admin: + blog: + categories: + category: + edit: Upraviť kategóriu + delete: Zmazať kategóriu + index: + no_items_yet: 'Niesu tu žiadne kategórie. Klikni "%{create}" pre pridanie prvej.' + comments: + approved: 'Komentár od "%{author}" bol schválený.' + comment: + view_live_html: 'Zobraziť živý náhľad <br/><em>(otvorí nové okno)</em>' + read: Zobraziť komentár + reject: Zamietnuť komentár + approve: Schváliť + rejected: 'Komentár od "%{author}" bol zamietnutý.' + index: + no_items_yet: 'Niesu tu žiadne %{type} komentáre.' + show: + comment: Komentár + blog_post: Blog článok + from: Odoslal + date: Dátum + message: Správa + details: Detaily + age: Vek + actions: Akcie + back: Späť na zoznam komentárov. + reject: Zamietnuť komentár + approve: Schváliť komentár + posts: + form: + advanced_options: Pokročilé nastavenia + toggle_advanced_options: Klikni pre prístup k nastaveniam meta tagov a menu + save_as_draft: Uložiť ako koncept + published_at: Dátum publikovania + index: + no_items_yet: 'Niesu žiadne články na blogu. Klikni na "%{create}" pre pridanie prvého.' + uncategorized: + no_items_yet: 'Niesu žiadne nekategorizované články.' + post: + view_live_html: 'Zobraziť článok<br/><em>(otvorí ho v novom okne)</em>' + edit: Upraviť článok + delete: Zmazať článok + settings: + notification_recipients: + value: Poslať notifikáciu pre + explanation: 'Vždy keď niekto pridá komentár, Refinery pošle notifikáciu.' + hint: 'Vždy keď niekto pridá komentár, Refinery ti pošle notifikáciu.' + example: "Zadaj tvoju emailovú adresu(y) ako napríklad: jack@work.com, jill@office.com" + updated: 'Zoznam príjemcov notifikácií "%{recipients}"' + submenu: + categories: + title: Kategórie + manage: Spravovať + new: Nová kategória + comments: + title: Komentáre + title_with_count: 'Komentáre (%{new_count} nových)' + new: Nový + unmoderated: Nový + approved: Schválený + rejected: Zamietnutý + posts: + title: Články + manage: Spravovať články + new: Vytvoriť nový článok + uncategorized: Nekategorizované články + settings: + title: Nastavenia + moderation: Moderovanie + update_notified: Upraviť zoznam notifikovaných + comments: Komentáre + blog: + comment_mailer: + notification: + greeting: Ahoj + you_recieved_new_comment: Máš nový komentár na stránke + comment_starts: --- začiatok komentára --- + comment_ends: --- koniec komentára --- + from: Od + email: Email + message: Správa + closing_line: S pozdravom + ps: 'P.S. Všetky komentáre su uložené v sekcii "Blog" pod záložkou "Komentáre" v prípade ak by ich bolo potrebné zobraziť neskôr.' + shared: + categories: + title: Kategórie + rss_feed: + title: RSS zdroj článkov + subscribe: Prihlásiť k odberu + posts: + other: Ďaľšie články + created_at: 'Publikovaný %{when}' + read_more: Celý článok + comments: + singular: komentár + none: Niesu tu žiadne komentáre + archives: Archív + categories: + show: + no_posts: Niesu tu žiadne články momentálne. + posts: + post: + filed_in: Podaný + comment: komentár + comments: + by: 'Odoslal %{who}' + time_ago: '%{time} späť' + thank_you: 'Vďaka za komentár.' + thank_you_moderated: 'Ďakujeme za Váš komentár. Vaša správa čaká na schválenie a objaví sa v najbližšej dobe.' + index: + no_blog_articles_yet: Práve niesu žiadne články na blogu. Zostante naladení. + show: + blog_home: Hlavná stránka blogu + comments: + title: Komentáre + add: Pridať komentár + other: Ďalšie články + filed_in: Podaný + submit: Odoslať komentár + archive: + blog_archive_for: 'Blog archív pre %{date}' + no_blog_articles_posted: 'Niesu žiadne články publikované %{date}.' diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml new file mode 100644 index 0000000..a3cafe5 --- /dev/null +++ b/config/locales/zh-CN.yml @@ -0,0 +1,128 @@ +zh-CN: + plugins: + refinerycms_blog: + title: 博客 + admin: + blog: + categories: + category: + edit: 编辑此类别 + delete: 永久删除此类别 + index: + no_items_yet: '没有此类别。 点击 "%{create}" 添加第一次类别。' + comments: + approved: '评论来自 "%{author}" 已被审批。' + comment: + view_live_html: '查看此评论 <br/><em>(opens in a new window)</em>' + read: 阅读此评论 + reject: 驳回此评论 + approve: 批准此评论 + rejected: '评论来自 "%{author}" 已被驳回。' + index: + no_items_yet: '没有 %{type} 评论。' + show: + comment: 评论 + blog_post: 发博 + from: 发布由 + date: 发布在 + message: 评论 + details: 详情 + age: 年龄 + actions: 行动 + back: 返回至所有评论 + reject: 驳回此评论 + approve: 批准此评论 + posts: + form: + advanced_options: 高级选项 + toggle_advanced_options: 点击进入标签详解设置和菜单选项 + save_as_draft: 保存为草稿 + published_at: 发布日期 + index: + no_items_yet: '目前尚未发博。 点击 "%{create}" 添加您的第一篇博文。' + uncategorized: + no_items_yet: '没有未归类的博文。' + post: + view_live_html: '查看此博 <br/><em>(opens in a new window)</em>' + edit: 编辑此博 + delete: 永久删除此博 + settings: + notification_recipients: + value: 发送通知 + explanation: '每次有人发表评论,发送邮件告知有新评论。' + hint: '增加新评论时,将会发送邮件告知您。' + example: "输入您的邮件地址,如: jack@work.com, jill@office.com" + updated: '通知收件人已被设为 "%{recipients}"' + submenu: + categories: + title: 分类 + manage: 管理 + new: 创建新的类别 + comments: + title: 评论 + title_with_count: '评论 (%{new_count} new)' + new: 新 + unmoderated: 新 + approved: 批准 + rejected: 驳回 + posts: + title: 博文 + manage: 管理博文 + new: 创建新博文 + uncategorized: 未归类博文 + settings: + title: 设置 + moderation: 等待审核 + update_notified: 更新获得通知的人 + comments: 评论 + blog: + comment_mailer: + notification: + greeting: 您好 + you_recieved_new_comment: 您刚收到来自网站的一条新评论 + comment_starts: --- 评论开始 --- + comment_ends: --- 评论结束 --- + from: 来自 + email: 邮件 + message: 信息 + closing_line: 亲切问候 + ps: 'P.S. All your comments are stored in the "Blog" section of Refinery under the "Comments" submenu should you ever want to view it later there.' + shared: + categories: + title: 分类 + rss_feed: + title: RSS源 + subscribe: 订阅 + posts: + other: 其他博文 + created_at: '发表于 %{when}' + read_more: 阅读更多 + comments: + singular: 评论 + none: 没有评论 + archives: 档案 + categories: + show: + no_posts: 此处没有文章。 + posts: + post: + filed_in: 用户体验 + comment: 评论 + comments: + by: '发布由 %{who}' + time_ago: '%{time} 之前' + thank_you: '感谢您的评论。' + thank_you_moderated: '感谢您的评论。 您的信息已被列入等待审核队列,并会在短期内出现。' + index: + no_blog_articles_yet: 尚未发布文章。敬请关注。 + show: + blog_home: 博客首页 + comments: + title: 评论 + add: 发表评论 + other: 其他博文 + filed_in: 用户体验 + submit: 发送评论 + archive: + blog_archive_for: '博客存档 %{date}' + no_blog_articles_posted: '没有发布文章 %{date}。敬请关注。' diff --git a/config/routes.rb b/config/routes.rb index 20fa1b1..421e845 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,13 +5,16 @@ Refinery::Application.routes.draw do match ':id', :to => 'posts#show', :as => 'blog_post' match 'categories/:id', :to => 'categories#show', :as => 'blog_category' match ':id/comments', :to => 'posts#comment', :as => 'blog_post_blog_comments' - get 'archive/:year/:month', :to => 'posts#archive', :as => 'archive_blog_posts' + get 'archive/:year(/:month)', :to => 'posts#archive', :as => 'archive_blog_posts' + get 'tagged/:tag_name' => 'posts#tagged', :as => 'tagged_posts' end scope(:path => 'refinery', :as => 'admin', :module => 'admin') do scope(:path => 'blog', :as => 'blog', :module => 'blog') do root :to => 'posts#index' - resources :posts + resources :posts do + get 'uncategorized', :on => :collection + end resources :categories @@ -32,6 +35,7 @@ Refinery::Application.routes.draw do post :notification_recipients get :moderation + get :comments end end end diff --git a/db/migrate/1_create_blog_structure.rb b/db/migrate/1_create_blog_structure.rb new file mode 100644 index 0000000..197efb1 --- /dev/null +++ b/db/migrate/1_create_blog_structure.rb @@ -0,0 +1,54 @@ +class CreateBlogStructure < ActiveRecord::Migration + + def self.up + create_table :blog_posts, :id => true do |t| + t.string :title + t.text :body + t.boolean :draft + t.datetime :published_at + t.timestamps + end + + add_index :blog_posts, :id + + create_table :blog_comments, :id => true do |t| + t.integer :blog_post_id + t.boolean :spam + t.string :name + t.string :email + t.text :body + t.string :state + t.timestamps + end + + add_index :blog_comments, :id + + create_table :blog_categories, :id => true do |t| + t.string :title + t.timestamps + end + + add_index :blog_categories, :id + + create_table :blog_categories_blog_posts, :id => false do |t| + t.integer :blog_category_id + t.integer :blog_post_id + end + + add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp' + + load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s) + end + + def self.down + UserPlugin.destroy_all({:name => "refinerycms_blog"}) + + Page.delete_all({:link_url => "/blog"}) + + drop_table :blog_posts + drop_table :blog_comments + drop_table :blog_categories + drop_table :blog_categories_blog_posts + end + +end diff --git a/db/migrate/2_add_user_id_to_blog_posts.rb b/db/migrate/2_add_user_id_to_blog_posts.rb new file mode 100644 index 0000000..cd62524 --- /dev/null +++ b/db/migrate/2_add_user_id_to_blog_posts.rb @@ -0,0 +1,11 @@ +class AddUserIdToBlogPosts < ActiveRecord::Migration + + def self.up + add_column :blog_posts, :user_id, :integer + end + + def self.down + remove_column :blog_posts, :user_id + end + +end
\ No newline at end of file diff --git a/db/migrate/3_acts_as_taggable_on_migration.rb b/db/migrate/3_acts_as_taggable_on_migration.rb new file mode 100644 index 0000000..1661061 --- /dev/null +++ b/db/migrate/3_acts_as_taggable_on_migration.rb @@ -0,0 +1,28 @@ +class ActsAsTaggableOnMigration < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.string :name + end + + create_table :taggings do |t| + t.references :tag + + # You should make sure that the column created is + # long enough to store the required class names. + t.references :taggable, :polymorphic => true + t.references :tagger, :polymorphic => true + + t.string :context + + t.datetime :created_at + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + drop_table :taggings + drop_table :tags + end +end diff --git a/lib/generators/refinerycms_blog/templates/db/seeds/seed.rb b/db/seeds/refinerycms_blog.rb index f958fab..f958fab 100644 --- a/lib/generators/refinerycms_blog/templates/db/seeds/seed.rb +++ b/db/seeds/refinerycms_blog.rb diff --git a/features/authors.feature b/features/authors.feature new file mode 100644 index 0000000..1042c9f --- /dev/null +++ b/features/authors.feature @@ -0,0 +1,15 @@ +@blog +Feature: Blog Post Authors + Blog posts can be assigned authors through the given user model + current_user is assumed through admin screens + + Scenario: Saving a blog post in blog_posts#new associates the current_user as the author + Given I am a logged in refinery user + + When I am on the new blog post form + And I fill in "Title" with "This is my blog post" + And I fill in "Body" with "And I love it" + And I press "Save" + + Then there should be 1 blog post + And the blog post should belong to me
\ No newline at end of file diff --git a/features/support/factories/blog_posts.rb b/features/support/factories/blog_posts.rb index 24436b8..3eecf53 100644 --- a/features/support/factories/blog_posts.rb +++ b/features/support/factories/blog_posts.rb @@ -2,5 +2,6 @@ Factory.define(:post, :class => BlogPost) do |f| f.sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" } f.body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it." f.draft false + f.tag_list "chicago, shopping, fun times" f.published_at Time.now end diff --git a/features/support/step_definitions/authors_steps.rb b/features/support/step_definitions/authors_steps.rb new file mode 100644 index 0000000..d78ca90 --- /dev/null +++ b/features/support/step_definitions/authors_steps.rb @@ -0,0 +1,7 @@ +Then /^there should be (\d+) blog posts?$/ do |num| + BlogPost.all.size == num +end + +Then /^the blog post should belong to me$/ do + BlogPost.first.author.login == User.last.login +end
\ No newline at end of file diff --git a/features/support/step_definitions/tags_steps.rb b/features/support/step_definitions/tags_steps.rb new file mode 100644 index 0000000..5d4dced --- /dev/null +++ b/features/support/step_definitions/tags_steps.rb @@ -0,0 +1,11 @@ +Given /^there is a blog post titled "([^"]*)" and tagged "([^"]*)"$/ do |title, tag_name| + @blog_post = Factory(:post, :title => title, :tag_list => tag_name) +end + +When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name| + visit tagged_posts_path(tag_name.parameterize) +end + +Then /^the blog post should have the tags "([^"]*)"$/ do |tag_list| + BlogPost.last.tag_list == tag_list.split(', ') +end diff --git a/features/tags.feature b/features/tags.feature new file mode 100644 index 0000000..07c73cd --- /dev/null +++ b/features/tags.feature @@ -0,0 +1,26 @@ +@blog_tags +Feature: Blog Post Tags + Blog posts can be assigned tags + + Background: + Given I am a logged in refinery user + + Scenario: The blog post new/edit form has tag_list + When I am on the new blog post form + Then I should see "Tags" + + Scenario: The blog post new/edit form saves tag_list + When I am on the new blog post form + And I fill in "Title" with "This is my blog post" + And I fill in "Body" with "And I love it" + And I fill in "Tags" with "chicago, bikes, beers, babes" + And I press "Save" + + Then there should be 1 blog post + And the blog post should have the tags "chicago, bikes, beers, babes" + + Scenario: The blog has a "tagged" route & view + Given there is a blog post titled "I love my city" and tagged "chicago" + When I visit the tagged posts page for "chicago" + Then I should see "Chicago" + And I should see "I love my city"
\ No newline at end of file diff --git a/generators/refinerycms_blog/refinerycms_blog_generator.rb b/generators/refinerycms_blog/refinerycms_blog_generator.rb deleted file mode 100644 index f967df3..0000000 --- a/generators/refinerycms_blog/refinerycms_blog_generator.rb +++ /dev/null @@ -1,69 +0,0 @@ -class RefinerycmsBlogGenerator < Rails::Generator::NamedBase - - def initialize(*runtime_args) - # set argument for the user. - runtime_args[0] = %w(refinerycms_blog) - super(*runtime_args) - end - - def banner - 'Usage: script/generate refinerycms_blog' - end - - def manifest - record do |m| - matches = Dir[ - File.expand_path('../../../public/images/**/*', __FILE__), - File.expand_path('../../../public/stylesheets/**/*', __FILE__), - File.expand_path('../../../public/javascripts/**/*', __FILE__), - ] - matches.reject{|d| !File.directory?(d)}.each do |dir| - m.directory((%w(public) | dir.split('public/').last.split('/')).join('/')) - end - matches.reject{|f| File.directory?(f)}.each do |image| - path = (%w(public) | image.split('public/').last.split('/'))[0...-1].join('/') - m.template "../../../#{path}/#{image.split('/').last}", "#{path}/#{image.split('/').last}" - end - - m.directory('db/seeds') - m.template('db/seeds/seed.rb', 'db/seeds/refinerycms_blog.rb') - - m.migration_template('db/migrate/migration.rb', 'db/migrate', - :migration_file_name => 'create_blog_structure', - :assigns => { - :migration_name => 'CreateBlogStructure', - :tables => [{ - :table_name => 'blog_posts', - :attributes => [ - Rails::Generator::GeneratedAttribute.new('title', 'string'), - Rails::Generator::GeneratedAttribute.new('body', 'text'), - Rails::Generator::GeneratedAttribute.new('draft', 'boolean'), - Rails::Generator::GeneratedAttribute.new('published_at', 'datetime') - ], :id => true - },{ - :table_name => 'blog_comments', - :attributes => [ - Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer'), - Rails::Generator::GeneratedAttribute.new('spam', 'boolean'), - Rails::Generator::GeneratedAttribute.new('name', 'string'), - Rails::Generator::GeneratedAttribute.new('email', 'string'), - Rails::Generator::GeneratedAttribute.new('body', 'text'), - Rails::Generator::GeneratedAttribute.new('state', 'string'), - ], :id => true - },{ - :table_name => 'blog_categories', - :attributes => [ - Rails::Generator::GeneratedAttribute.new('title', 'string') - ], :id => true - },{ - :table_name => 'blog_categories_blog_posts', - :attributes => [ - Rails::Generator::GeneratedAttribute.new('blog_category_id', 'integer'), - Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer') - ], :id => false - }] - }) - end - end - -end if defined?(Rails::Generator::NamedBase) diff --git a/generators/refinerycms_blog/templates/db/migrate/migration.rb b/generators/refinerycms_blog/templates/db/migrate/migration.rb deleted file mode 100644 index 5ba29c6..0000000 --- a/generators/refinerycms_blog/templates/db/migrate/migration.rb +++ /dev/null @@ -1,26 +0,0 @@ -class <%= migration_name %> < ActiveRecord::Migration - - def self.up<% tables.each do |table| %> - create_table :<%= table[:table_name] %>, :id => <%= table[:id].to_s %> do |t| -<% table[:attributes].each do |attribute| -%> - t.<%= attribute.type %> :<%= attribute.name %> -<% end -%> - <%= 't.timestamps' if table[:id] %> - end - - <%= "add_index :#{table[:table_name]}, :id" if table[:id] %> -<% end -%> - load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s) - end - - def self.down - UserPlugin.destroy_all({:name => "refinerycms_blog"}) - - Page.delete_all({:link_url => "/blog"}) - -<% tables.each do |table| -%> - drop_table :<%= table[:table_name] %> -<% end -%> - end - -end diff --git a/generators/refinerycms_blog/templates/db/seeds/seed.rb b/generators/refinerycms_blog/templates/db/seeds/seed.rb deleted file mode 100644 index 228fc7b..0000000 --- a/generators/refinerycms_blog/templates/db/seeds/seed.rb +++ /dev/null @@ -1,16 +0,0 @@ -User.find(:all).each do |user| - user.plugins.create(:name => "<%= singular_name %>", - :position => (user.plugins.maximum(:position) || -1) +1) -end - -page = Page.create( - :title => "Blog", - :link_url => "/blog", - :deletable => false, - :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1), - :menu_match => "^/blogs?(\/|\/.+?|)$" -) - -RefinerySetting.find_or_set(:default_page_parts, %w(Body Side\ Body)).each do |default_page_part| - page.parts.create(:title => default_page_part, :body => nil) -end diff --git a/lib/gemspec.rb b/lib/gemspec.rb index 7902d37..ec6ace7 100644 --- a/lib/gemspec.rb +++ b/lib/gemspec.rb @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.homepage = %q{http://refinerycms.com} s.authors = %w(Resolve\\ Digital Neoteric\\ Design) s.require_paths = %w(lib) + s.add_dependency 'refinerycms', '>= 0.9.8' s.add_dependency 'filters_spam', '~> 0.2' diff --git a/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb b/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb deleted file mode 100644 index badb213..0000000 --- a/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb +++ /dev/null @@ -1,26 +0,0 @@ -class Create<%= singular_name.camelize %> < ActiveRecord::Migration - - def self.up<% @refinerycms_blog_tables.each do |table| %> - create_table :<%= table[:table_name] %>, :id => <%= table[:id].to_s %> do |t| -<% table[:attributes].each do |attribute| -%> - t.<%= attribute.type %> :<%= attribute.name %> -<% end -%> - <%= 't.timestamps' if table[:id] %> - end - - <%= "add_index :#{table[:table_name]}, :id" if table[:id] %> -<% end -%> - load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s) - end - - def self.down - UserPlugin.destroy_all({:name => "refinerycms_blog"}) - - Page.delete_all({:link_url => "/blog"}) - -<% @refinerycms_blog_tables.each do |table| -%> - drop_table :<%= table[:table_name] %> -<% end -%> - end - -end diff --git a/lib/generators/refinerycms_blog_generator.rb b/lib/generators/refinerycms_blog_generator.rb index a801353..6fca607 100644 --- a/lib/generators/refinerycms_blog_generator.rb +++ b/lib/generators/refinerycms_blog_generator.rb @@ -1,80 +1,8 @@ -require 'rails/generators/migration' +require 'refinery/generators' -class RefinerycmsBlogGenerator < Rails::Generators::NamedBase - include Rails::Generators::Migration +class RefinerycmsBlogGenerator < ::Refinery::Generators::EngineInstaller - source_root File.expand_path('../refinerycms_blog/templates/', __FILE__) - argument :name, :type => :string, :default => 'blog_structure', :banner => '' + source_root File.expand_path('../../../', __FILE__) + engine_name "refinerycms-blog" - def generate - # seed file - template 'db/seeds/seed.rb', Rails.root.join('db/seeds/refinerycms_blog.rb') - - # migration file - @refinerycms_blog_tables = [{ - :table_name => 'blog_posts', - :attributes => [ - Rails::Generators::GeneratedAttribute.new('title', 'string'), - Rails::Generators::GeneratedAttribute.new('body', 'text'), - Rails::Generators::GeneratedAttribute.new('draft', 'boolean'), - Rails::Generators::GeneratedAttribute.new('published_at', 'datetime') - ], :id => true - },{ - :table_name => 'blog_comments', - :attributes => [ - Rails::Generators::GeneratedAttribute.new('blog_post_id', 'integer'), - Rails::Generators::GeneratedAttribute.new('spam', 'boolean'), - Rails::Generators::GeneratedAttribute.new('name', 'string'), - Rails::Generators::GeneratedAttribute.new('email', 'string'), - Rails::Generators::GeneratedAttribute.new('body', 'text'), - Rails::Generators::GeneratedAttribute.new('state', 'string'), - ], :id => true - },{ - :table_name => 'blog_categories', - :attributes => [ - Rails::Generators::GeneratedAttribute.new('title', 'string') - ], :id => true - },{ - :table_name => 'blog_categories_blog_posts', - :attributes => [ - Rails::Generators::GeneratedAttribute.new('blog_category_id', 'integer'), - Rails::Generators::GeneratedAttribute.new('blog_post_id', 'integer') - ], :id => false - }] - next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__)) - template('db/migrate/migration_number_create_singular_name.rb', - Rails.root.join("db/migrate/#{next_migration_number}_create_#{singular_name}.rb")) - - puts "------------------------" - puts "Now run:" - puts "rake db:migrate" - puts "------------------------" - end -end - -# Below is a hack until this issue: -# https://rails.lighthouseapp.com/projects/8994/tickets/3820-make-railsgeneratorsmigrationnext_migration_number-method-a-class-method-so-it-possible-to-use-it-in-custom-generators -# is fixed on the Rails project. - -require 'rails/generators/named_base' -require 'rails/generators/migration' -require 'rails/generators/active_model' -require 'active_record' - -module ActiveRecord - module Generators - class Base < Rails::Generators::NamedBase #:nodoc: - include Rails::Generators::Migration - - # Implement the required interface for Rails::Generators::Migration. - def self.next_migration_number(dirname) #:nodoc: - next_migration_number = current_migration_number(dirname) + 1 - if ActiveRecord::Base.timestamped_migrations - [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max - else - "%.3d" % next_migration_number - end - end - end - end -end +end
\ No newline at end of file diff --git a/lib/refinerycms-blog.rb b/lib/refinerycms-blog.rb index 9a5cf56..0158e0b 100644 --- a/lib/refinerycms-blog.rb +++ b/lib/refinerycms-blog.rb @@ -1,8 +1,4 @@ -if defined?(Bundler) and !defined?(FiltersSpam) - # this will tell the user what to do - load(File.expand_path('../../Gemfile', __FILE__)) - require 'filters_spam' -end +require 'filters_spam' module Refinery module Blog @@ -42,7 +38,7 @@ module Refinery class << self def version - %q{1.1} + %q{1.3.2} end end end diff --git a/public/javascripts/refinery/refinerycms-blog.js b/public/javascripts/refinery/refinerycms-blog.js index 3ddbcc2..e730c6f 100644 --- a/public/javascripts/refinery/refinerycms-blog.js +++ b/public/javascripts/refinery/refinerycms-blog.js @@ -1,5 +1,5 @@ $(document).ready(function(){ - $('nav#actions.multilist > ul:not(.search_list) li a[href$=' + window.location.pathname + ']') + $('nav#actions.multilist > ul:not(.search_list) li a[href$="' + window.location.pathname + '"]') .parent().addClass('selected'); if($('nav#actions.multilist > ul:not(.search_list) li.selected').length == 0) { $('nav#actions.multilist > ul:not(.search_list) li a:nth(1)').parent().addClass('selected'); @@ -15,9 +15,9 @@ $(document).ready(function(){ $('ul.collapsible_menu').each(function(i, ul) { (first_li = $(this).children('li:first')).after(div=$("<div></div>")); - + $("<span class='arrow'> </span>").appendTo(first_li) - + if (($(this).children('li.selected')).length == 0) { div.hide(); first_li.addClass("closed"); diff --git a/rails/init.rb b/rails/init.rb deleted file mode 100644 index 658936e..0000000 --- a/rails/init.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.expand_path('../../lib/refinerycms-blog', __FILE__) - -Refinery::Plugin.register do |plugin| - plugin.name = "refinerycms_blog" - plugin.url = {:controller => '/admin/blog/posts', :action => 'index'} - plugin.menu_match = /^\/?(admin|refinery)\/blog\/?(posts|comments|categories)?/ - plugin.activity = { - :class => BlogPost - } -end @@ -17,7 +17,7 @@ Refinery CMS version 0.9.8 or above. Open up your ``Gemfile`` and add at the bottom this line: - gem 'refinerycms-blog', '~> 1.1' + gem 'refinerycms-blog', '~> 1.3' Now, run ``bundle install`` diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec index 070664d..42ba28d 100644 --- a/refinerycms-blog.gemspec +++ b/refinerycms-blog.gemspec @@ -1,15 +1,17 @@ Gem::Specification.new do |s| s.name = %q{refinerycms-blog} - s.version = %q{1.1} + s.version = %q{1.3.2} s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.} - s.date = %q{2010-12-03} + s.date = %q{2011-03-09} s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.} s.email = %q{info@refinerycms.com} s.homepage = %q{http://refinerycms.com} s.authors = %w(Resolve\ Digital Neoteric\ Design) s.require_paths = %w(lib) + s.add_dependency 'refinerycms', '>= 0.9.8' s.add_dependency 'filters_spam', '~> 0.2' + s.add_dependency 'acts-as-taggable-on', '~> 2.0.6' s.files = %w( app @@ -35,6 +37,7 @@ Gem::Specification.new do |s| app/models/blog_category.rb app/models/blog_comment.rb app/models/blog_post.rb + app/models/categorization.rb app/views app/views/admin app/views/admin/blog @@ -60,6 +63,7 @@ Gem::Specification.new do |s| app/views/admin/blog/posts/edit.html.erb app/views/admin/blog/posts/index.html.erb app/views/admin/blog/posts/new.html.erb + app/views/admin/blog/posts/uncategorized.html.erb app/views/admin/blog/settings app/views/admin/blog/settings/notification_recipients.html.erb app/views/blog @@ -80,41 +84,41 @@ Gem::Specification.new do |s| app/views/blog/shared/_post.html.erb app/views/blog/shared/_posts.html.erb app/views/blog/shared/_rss_feed.html.erb + changelog.md config config/locales + config/locales/de.yml config/locales/en.yml + config/locales/es.yml + config/locales/fr.yml config/locales/it.yml config/locales/nb.yml config/locales/nl.yml + config/locales/pl.yml + config/locales/pt-BR.yml + config/locales/ru.yml config/routes.rb + db + db/migrate + db/migrate/1_create_blog_structure.rb + db/migrate/2_add_user_id_to_blog_posts.rb + db/seeds + db/seeds/refinerycms_blog.rb features + features/authors.feature features/support features/support/factories features/support/factories/blog_categories.rb features/support/factories/blog_comments.rb features/support/factories/blog_posts.rb features/support/paths.rb - Gemfile - Gemfile.lock - generators - generators/refinerycms_blog - generators/refinerycms_blog/refinerycms_blog_generator.rb - generators/refinerycms_blog/templates - generators/refinerycms_blog/templates/db - generators/refinerycms_blog/templates/db/migrate - generators/refinerycms_blog/templates/db/migrate/migration.rb - generators/refinerycms_blog/templates/db/seeds - generators/refinerycms_blog/templates/db/seeds/seed.rb + features/support/step_definitions + features/support/step_definitions/authors_steps.rb lib lib/gemspec.rb lib/generators lib/generators/refinerycms_blog lib/generators/refinerycms_blog/templates - lib/generators/refinerycms_blog/templates/db - lib/generators/refinerycms_blog/templates/db/migrate - lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb - lib/generators/refinerycms_blog/templates/db/seeds - lib/generators/refinerycms_blog/templates/db/seeds/seed.rb lib/generators/refinerycms_blog_generator.rb lib/refinerycms-blog.rb public @@ -143,8 +147,6 @@ Gem::Specification.new do |s| public/stylesheets/refinery public/stylesheets/refinery/refinerycms-blog.css public/stylesheets/refinerycms-blog.css - rails - rails/init.rb readme.md spec spec/models diff --git a/spec/models/blog_categories_spec.rb b/spec/models/blog_categories_spec.rb index 904e4c8..53bc345 100644 --- a/spec/models/blog_categories_spec.rb +++ b/spec/models/blog_categories_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory} describe BlogCategory do - describe "validations" do - before(:each) do - @attr = { :title => "RefineryCMS" } - end + before(:each) do + @attr = { :title => "RefineryCMS" } + end + describe "validations" do it "requires title" do BlogCategory.new(@attr.merge(:title => "")).should_not be_valid end @@ -18,9 +18,17 @@ describe BlogCategory do end describe "blog posts association" do - it "have a posts attribute" do + it "has a posts attribute" do BlogCategory.new.should respond_to(:posts) end + + it "returns posts by published_at date in descending order" do + @category = BlogCategory.create!(@attr) + @first_post = @category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday }) + @latest_post = @category.posts.create!({ :title => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now }) + @category.posts.first.should == @latest_post + end + end describe "#post_count" do diff --git a/spec/models/blog_posts_spec.rb b/spec/models/blog_posts_spec.rb index ef9d700..1b96ece 100644 --- a/spec/models/blog_posts_spec.rb +++ b/spec/models/blog_posts_spec.rb @@ -17,7 +17,7 @@ describe BlogPost do end it "requires body" do - BlogPost.new(@attr.merge(:body => "")).should_not be_valid + BlogPost.new(@attr.merge(:body => nil)).should_not be_valid end end @@ -46,11 +46,24 @@ describe BlogPost do @blog_post.should respond_to(:categories) end end + + describe "tags" do + it "acts as taggable" do + (post = Factory(:post)).should respond_to(:tag_list) + post.tag_list.should include("chicago") + end + end + + describe "authors" do + it "are authored" do + BlogPost.instance_methods.map(&:to_sym).should include(:author) + end + end describe "by_archive scope" do it "returns all posts from specified month" do - blog_post1 = Factory(:post, :published_at => Time.now - 2.minutes) - blog_post2 = Factory(:post, :published_at => Time.now - 1.minute) + blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2)) + blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) Factory(:post, :published_at => Time.now - 2.months) date = "#{Time.now.month}/#{Time.now.year}" BlogPost.by_archive(Time.parse(date)).count.should == 2 @@ -60,8 +73,8 @@ describe BlogPost do describe "all_previous scope" do it "returns all posts from previous months" do - blog_post1 = Factory(:post, :published_at => Time.now - 1.month) - blog_post2 = Factory(:post, :published_at => Time.now - 1.month) + blog_post1 = Factory(:post, :published_at => Time.now.advance(:months => -2)) + blog_post2 = Factory(:post, :published_at => Time.now.advance(:months => -1)) Factory(:post, :published_at => Time.now) BlogPost.all_previous.count.should == 2 BlogPost.all_previous.should == [blog_post2, blog_post1] @@ -70,8 +83,8 @@ describe BlogPost do describe "live scope" do it "returns all posts which aren't in draft and pub date isn't in future" do - blog_post1 = Factory(:post, :published_at => Time.now - 2.minutes) - blog_post2 = Factory(:post, :published_at => Time.now - 1.minute) + blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2)) + blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) Factory(:post, :draft => true) Factory(:post, :published_at => Time.now + 1.minute) BlogPost.live.count.should == 2 @@ -81,17 +94,29 @@ describe BlogPost do describe "next scope" do it "returns next article based on given article" do - blog_post1 = Factory(:post) - blog_post2 = Factory(:post, :published_at => Time.now + 1.minute) + blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) + blog_post2 = Factory(:post) BlogPost.next(blog_post1).should == [blog_post2] end end describe "previous scope" do it "returns previous article based on given article" do - blog_post1 = Factory(:post) - blog_post2 = Factory(:post, :published_at => Time.now + 1.minute) - BlogPost.next(blog_post1).should == [blog_post2] + blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) + blog_post2 = Factory(:post) + BlogPost.previous(blog_post2).should == [blog_post1] + end + end + + describe "uncategorized scope" do + it "returns uncategorized posts if they exist" do + uncategorized_blog_post = Factory(:post) + categorized_blog_post = Factory(:post) + + categorized_blog_post.categories << Factory(:blog_category) + + BlogPost.uncategorized.should include uncategorized_blog_post + BlogPost.uncategorized.should_not include categorized_blog_post end end @@ -105,23 +130,23 @@ describe BlogPost do end it "returns false if post pub date is in future" do - Factory(:post, :published_at => Time.now + 1.minute).live?.should be_false + Factory(:post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false end end describe "#next" do it "returns next article when called on current article" do - Factory(:post) - blog_post = Factory(:post, :published_at => Time.now + 1.minute) + Factory(:post, :published_at => Time.now.advance(:minutes => -1)) + blog_post = Factory(:post) blog_posts = BlogPost.all - blog_posts.first.next.should == blog_post + blog_posts.last.next.should == blog_post end end describe "#prev" do it "returns previous article when called on current article" do Factory(:post) - blog_post = Factory(:post, :published_at => Time.now - 1.minute) + blog_post = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) blog_posts = BlogPost.all blog_posts.first.prev.should == blog_post end @@ -150,10 +175,9 @@ describe BlogPost do BlogPost.comments_allowed?.should be_true end - # TODO: fix this test - # it "returns false if comments_allowed setting is set to false" do - # RefinerySetting.set(:comments_allowed, false) - # BlogPost.comments_allowed?.should be_false - # end + it "returns false if comments_allowed setting is set to false" do + RefinerySetting.set(:comments_allowed, {:scoping => 'blog', :value => false}) + BlogPost.comments_allowed?.should be_false + end end end |