refinerycms-blog 0.9.8.dev1 → 0.9.8.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/app/controllers/admin/blog/categories_controller.rb +3 -1
  2. data/app/controllers/admin/blog/comments_controller.rb +8 -1
  3. data/app/controllers/admin/blog/posts_controller.rb +6 -2
  4. data/app/controllers/admin/blog/settings_controller.rb +11 -2
  5. data/app/controllers/blog_posts_controller.rb +15 -3
  6. data/app/models/blog_comment.rb +40 -5
  7. data/app/models/blog_post.rb +6 -0
  8. data/app/views/admin/blog/_submenu.html.erb +36 -41
  9. data/app/views/admin/blog/categories/_category.html.erb +14 -0
  10. data/app/views/admin/blog/categories/_form.html.erb +15 -0
  11. data/app/views/admin/blog/categories/_sortable_list.html.erb +7 -0
  12. data/app/views/admin/blog/categories/edit.html.erb +1 -0
  13. data/app/views/admin/blog/categories/index.html.erb +30 -0
  14. data/app/views/admin/blog/categories/new.html.erb +1 -0
  15. data/app/views/admin/blog/comments/index.html.erb +13 -11
  16. data/app/views/admin/blog/posts/_form.html.erb +15 -3
  17. data/app/views/admin/blog/posts/index.html.erb +2 -2
  18. data/app/views/admin/blog/settings/notification_recipients.html.erb +24 -0
  19. data/app/views/blog_posts/_side_bar.html.erb +8 -0
  20. data/app/views/blog_posts/index.html.erb +17 -1
  21. data/app/views/blog_posts/show.html.erb +19 -1
  22. data/config/locales/en.yml +27 -5
  23. data/config/routes.rb +11 -3
  24. data/generators/refinery_blog/refinery_blog_generator.rb +16 -1
  25. data/lib/gemspec.rb +1 -0
  26. data/lib/refinerycms-blog.rb +1 -1
  27. data/public/images/refinerycms-blog/icons/cog.png +0 -0
  28. data/public/images/refinerycms-blog/icons/comment.png +0 -0
  29. data/public/images/refinerycms-blog/icons/comment_cross.png +0 -0
  30. data/public/images/refinerycms-blog/icons/comment_tick.png +0 -0
  31. data/public/images/refinerycms-blog/icons/comments.png +0 -0
  32. data/public/images/refinerycms-blog/icons/folder.png +0 -0
  33. data/public/images/refinerycms-blog/icons/folder_add.png +0 -0
  34. data/public/images/refinerycms-blog/icons/folder_edit.png +0 -0
  35. data/public/images/refinerycms-blog/icons/page.png +0 -0
  36. data/public/images/refinerycms-blog/icons/page_add.png +0 -0
  37. data/public/images/refinerycms-blog/icons/page_copy.png +0 -0
  38. data/public/javascripts/refinery/refinerycms-blog.js +40 -0
  39. data/public/stylesheets/refinery/refinerycms-blog.css +33 -0
  40. data/public/stylesheets/refinerycms-blog.css +13 -0
  41. data/spec/factories/blog_categories.rb +4 -0
  42. data/spec/factories/blog_comments.rb +10 -0
  43. data/spec/factories/blog_posts.rb +4 -0
  44. data/spec/models/blog_categories_spec.rb +20 -0
  45. data/spec/models/blog_comments_spec.rb +20 -0
  46. data/spec/models/blog_posts_spec.rb +15 -0
  47. metadata +51 -6
@@ -1,5 +1,7 @@
1
1
  class Admin::Blog::CategoriesController < Admin::BaseController
2
2
 
3
- crudify :blog_category, :title_attribute => :name, :order => 'created_at DESC'
3
+ crudify :blog_category,
4
+ :title_attribute => :title,
5
+ :order => 'title ASC'
4
6
 
5
7
  end
@@ -1,6 +1,13 @@
1
1
  class Admin::Blog::CommentsController < Admin::BaseController
2
2
 
3
- crudify :blog_comment, :title_attribute => :name, :order => 'created_at DESC'
3
+ crudify :blog_comment,
4
+ :title_attribute => :name,
5
+ :order => 'created_at DESC'
6
+
7
+ def index
8
+ @blog_comments = BlogComment.unmoderated
9
+ render :action => 'index'
10
+ end
4
11
 
5
12
  def approved
6
13
  @blog_comments = BlogComment.approved
@@ -1,7 +1,11 @@
1
1
  class Admin::Blog::PostsController < Admin::BaseController
2
2
 
3
- crudify :blog_post, :title_attribute => :title, :order => 'created_at DESC'
4
- before_filter :find_all_categories, :only => [:new, :edit, :create, :update]
3
+ crudify :blog_post,
4
+ :title_attribute => :title,
5
+ :order => 'created_at DESC'
6
+
7
+ before_filter :find_all_categories,
8
+ :only => [:new, :edit, :create, :update]
5
9
 
6
10
  protected
7
11
  def find_all_categories
@@ -1,11 +1,20 @@
1
1
  class Admin::Blog::SettingsController < Admin::BaseController
2
2
 
3
- def update_notified
3
+ def notification_recipients
4
+ @recipients = BlogComment::Notification.recipients
4
5
 
6
+ if request.post?
7
+ BlogComment::Notification.recipients == params[:recipients]
8
+ end
5
9
  end
6
10
 
7
11
  def moderation
8
-
12
+ enabled = BlogComment::Moderation.toggle
13
+ unless request.xhr?
14
+ redirect_back_or_default(admin_blog_posts_path)
15
+ else
16
+ render :json => {:enabled => enabled}
17
+ end
9
18
  end
10
19
 
11
20
  end
@@ -1,6 +1,6 @@
1
1
  class BlogPostsController < ApplicationController
2
2
 
3
- before_filter :find_all_blog_posts
3
+ before_filter :find_all_blog_posts, :find_all_blog_categories
4
4
  before_filter :find_page
5
5
 
6
6
  def index
@@ -20,11 +20,23 @@ class BlogPostsController < ApplicationController
20
20
  protected
21
21
 
22
22
  def find_all_blog_posts
23
- @blog_posts = BlogPost.live
23
+ unless params[:category_id].present?
24
+ @blog_posts = BlogPost.live
25
+ else
26
+ if (category = BlogCategory.find(params[:category_id])).present?
27
+ @blog_posts = category.posts
28
+ else
29
+ error_404
30
+ end
31
+ end
32
+ end
33
+
34
+ def find_all_blog_categories
35
+ @blog_categories = BlogCategory.all
24
36
  end
25
37
 
26
38
  def find_page
27
- @page = Page.find_by_link_url("/blogs")
39
+ @page = Page.find_by_link_url("/blog")
28
40
  end
29
41
 
30
42
  end
@@ -4,9 +4,44 @@ class BlogComment < ActiveRecord::Base
4
4
 
5
5
  acts_as_indexed :fields => [:name, :email, :body]
6
6
 
7
- validates_presence_of :title
8
- validates_uniqueness_of :title
7
+ named_scope :unmoderated, :conditions => {:state => nil}
8
+ named_scope :approved, :conditions => {:state => 'approved'}
9
+ named_scope :rejected, :conditions => {:state => 'rejected'}
9
10
 
10
- named_scope :approved, :conditions => {:approved => true}
11
- named_scope :rejected, :conditions => {:approved => false}
12
- end
11
+ module Moderation
12
+ class << self
13
+ def enabled?
14
+ RefinerySetting.find_or_set(:comment_moderation, true, {
15
+ :scoping => :blog
16
+ })
17
+ end
18
+
19
+ def toggle
20
+ RefinerySetting[:comment_moderation] = {
21
+ :value => !self.enabled?,
22
+ :scoping => :blog
23
+ }
24
+ end
25
+ end
26
+ end
27
+
28
+ module Notification
29
+ class << self
30
+ def recipients
31
+ RefinerySetting.find_or_set(
32
+ :comment_notification_recipients,
33
+ (Role[:refinery].users.first.email rescue ''),
34
+ {:scoping => :blog}
35
+ )
36
+ end
37
+
38
+ def recipients=(emails)
39
+ RefinerySetting[:comment_notification_recipients] = {
40
+ :value => emails,
41
+ :scoping => :blog
42
+ }
43
+ end
44
+ end
45
+ end
46
+
47
+ end
@@ -14,4 +14,10 @@ class BlogPost < ActiveRecord::Base
14
14
 
15
15
  named_scope :live, :conditions => {:draft => false}
16
16
 
17
+ def category_ids=(ids)
18
+ self.categories = ids.reject{|id| id.blank?}.collect {|c_id|
19
+ BlogCategory.find(c_id.to_i) rescue nil
20
+ }.compact
21
+ end
22
+
17
23
  end
@@ -1,5 +1,5 @@
1
- <div id='actions'>
2
- <ul>
1
+ <nav id='actions' class='multilist'>
2
+ <ul class='search_list'>
3
3
  <li>
4
4
  <%= render :partial => "/shared/admin/search",
5
5
  :locals => {
@@ -8,77 +8,72 @@
8
8
  </li>
9
9
  </ul>
10
10
 
11
- <ul>
12
- <li<%= " class='selected'" if request.path == admin_blog_posts_path %>>
13
- <%= link_to t('.posts.title'), admin_blog_posts_path %>
11
+ <ul class='collapsible_menu'>
12
+ <li>
13
+ <%= link_to t('.posts.title'), '#',
14
+ :class => 'page_copy_icon' %>
14
15
  </li>
16
+ <li>
17
+ <%= link_to t('.posts.manage'), admin_blog_posts_path,
18
+ :class => 'page_icon' %>
15
19
  <li>
16
20
  <%= link_to t('.posts.new'), new_admin_blog_post_url,
17
- :class => "add_icon" %>
21
+ :class => 'page_add_icon' %>
18
22
  </li>
19
23
  </ul>
20
24
 
21
- <ul style='margin-top: 30px'>
22
- <li<%= " class='selected'" if request.path == admin_blog_comments_path %>>
25
+ <ul class='collapsible_menu'>
26
+ <li>
27
+ <%= link_to t('.comments.title'), '#',
28
+ :class => 'comments_icon' %>
29
+ </li>
30
+ <li>
23
31
  <%= link_to t('.comments.new'), admin_blog_comments_path,
24
- :class => 'user_comment_icon' %>
32
+ :class => 'comment_icon' %>
25
33
  </li>
26
- <li<%= " class='selected'" if request.path == approved_admin_blog_comments_path %>>
34
+ <li>
27
35
  <%= link_to t('.comments.approved'), approved_admin_blog_comments_path,
28
- :class => 'user_comments_add_icon' %>
36
+ :class => 'comment_tick_icon' %>
29
37
  </li>
30
- <li<%= " class='selected'" if request.path == rejected_admin_blog_comments_path %>>
38
+ <li>
31
39
  <%= link_to t('.comments.rejected'), rejected_admin_blog_comments_path,
32
- :class => 'user_comments_delete_icon' %>
40
+ :class => 'comment_cross_icon' %>
33
41
  </li>
34
42
  </ul>
35
43
 
36
- <ul class='collapsible_menu' style='margin-top: 30px'>
37
- <li<%= " class='selected'" if request.path == admin_blog_categories_path %>>
38
- <%= link_to t('.categories.title'), admin_blog_categories_url,
39
- :class => 'category_icon'%>
44
+ <ul class='collapsible_menu'>
45
+ <li>
46
+ <%= link_to t('.categories.title'), '#',
47
+ :class => 'folder_icon' %>
40
48
  </li>
41
49
  <li>
42
50
  <%= link_to t('.categories.manage'), admin_blog_categories_url,
43
- :class => 'edit_icon' %>
51
+ :class => 'folder_edit_icon' %>
44
52
  </li>
45
53
  <li>
46
- <%= link_to t('.categories.new'), new_admin_blog_category_url(:dialog => true),
47
- :class => 'add_icon' %>
54
+ <%= link_to t('.categories.new'), new_admin_blog_category_url(:dialog => true, :height => 325),
55
+ :class => 'folder_add_icon' %>
48
56
  </li>
49
57
  </ul>
50
58
 
51
- <ul class='collapsible_menu' style='margin-top: 30px'>
52
- <li<%= " class='selected'" if request.path == admin_blog_settings_path %>>
59
+ <ul class='collapsible_menu'>
60
+ <li>
53
61
  <%= link_to t('.settings.title'), admin_blog_settings_path,
54
62
  :class => 'settings_icon' %>
55
63
  </li>
56
64
  <li>
57
65
  <%= link_to t('.settings.moderation'), moderation_admin_blog_settings_url,
58
- :class => 'tick_icon' # TODO: update to tick or cross later
59
- %>
66
+ :class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
60
67
  </li>
61
68
  <li>
62
- <%= link_to t('.settings.update_notified'), update_notified_admin_blog_settings_url(:dialog => true),
69
+ <%= link_to t('.settings.update_notified'),
70
+ notification_recipients_admin_blog_settings_url(:dialog => true, :height => 400),
63
71
  :class => 'user_comment_icon' %>
64
72
  </li>
65
73
  </ul>
66
74
 
67
- </div>
75
+ </nav>
68
76
  <% content_for :head do %>
69
- <script type='text/javascript'>
70
- $(document).ready(function(){
71
- $('ul.collapsible_menu').each(function(i, ul) {
72
- (first_li = $(this).children('li:first')).after(div=$("<div style='display: none'></div>"));
73
- $(this).children('li:not(:first)').appendTo(div);
74
- first_li.find('> a').click(function(e){
75
- $(this).css('background-image', "url('/images/refinery/ajax-loader.gif') !important");
76
- $(this).parent().next('div').animate({opacity: 'toggle', height: 'toggle'}, 250, $.proxy(function(){
77
- $(this).css('background-image', null);
78
- }, $(this)));
79
- e.preventDefault();
80
- });
81
- });
82
- });
83
- </script>
77
+ <%= stylesheet_link_tag 'refinery/refinerycms-blog' %>
78
+ <%= javascript_include_tag 'refinery/refinerycms-blog' %>
84
79
  <% end %>
@@ -0,0 +1,14 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(category) -%>">
2
+ <span class='title'>
3
+ <%=h category.title %>
4
+ <span class="preview">&nbsp;</span>
5
+ </span>
6
+ <span class='actions'>
7
+ <%= link_to refinery_icon_tag("application_edit.png"),
8
+ edit_admin_blog_category_path(category, :dialog => true, :height => 325),
9
+ :title => t('.edit') %>
10
+ <%= link_to refinery_icon_tag("delete.png"), admin_blog_category_path(category),
11
+ :class => "cancel confirm-delete",
12
+ :title => t('.delete') %>
13
+ </span>
14
+ </li>
@@ -0,0 +1,15 @@
1
+ <% form_for [:admin, @blog_category] do |f| -%>
2
+ <%= f.error_messages %>
3
+
4
+ <div class='field'>
5
+ <%= f.label :title -%>
6
+ <%= f.text_field :title, :class => 'larger widest' -%>
7
+ </div>
8
+
9
+ <%= render :partial => "/shared/admin/form_actions",
10
+ :locals => {
11
+ :f => f,
12
+ :continue_editing => false,
13
+ :delete_title => t('admin.blog.categories.category.delete')
14
+ } %>
15
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <ul id='sortable_list'>
2
+ <%= render :partial => 'category', :collection => @blog_categories %>
3
+ </ul>
4
+ <%= render :partial => "/shared/admin/sortable_list",
5
+ :locals => {
6
+ :continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)
7
+ } %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,30 @@
1
+ <%= render :partial => '/admin/blog/submenu' %>
2
+ <div id='records'>
3
+ <% if searching? %>
4
+ <h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
5
+ <% if @blog_categories.any? %>
6
+ <%= render :partial => "blog_categories",
7
+ :collection => @blog_categories %>
8
+ <% else %>
9
+ <p><%= t('admin.search_no_results') %></p>
10
+ <% end %>
11
+ <% else %>
12
+ <% if @blog_categories.any? %>
13
+ <%= will_paginate @blog_categories,
14
+ :previous_label => '&laquo;',
15
+ :next_label => '&raquo;' %>
16
+
17
+ <%= render :partial => "sortable_list" %>
18
+
19
+ <%= will_paginate @blog_categories,
20
+ :previous_label => '&laquo;',
21
+ :next_label => '&raquo;' %>
22
+ <% else %>
23
+ <p>
24
+ <strong>
25
+ <%= t('.no_items_yet', :create => t('admin.blog.submenu.categories.new')) %>
26
+ </strong>
27
+ </p>
28
+ <% end %>
29
+ <% end %>
30
+ </div>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -1,28 +1,30 @@
1
1
  <%= render :partial => '/admin/blog/submenu' %>
2
2
  <div id='records'>
3
3
  <% if searching? %>
4
- <h2><%= t('admin.search_results_for', :query => params[:search]) %></h2>
4
+ <h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
5
5
  <% if @blog_comments.any? %>
6
- <%= render :partial => "blog_comments",
7
- :collection => @blog_comments %>
6
+ <%= will_paginate @blog_comments %>
7
+
8
+ <ul>
9
+ <%= render :partial => "blog_comments",
10
+ :collection => @blog_comments %>
11
+ </ul>
12
+
13
+ <%= will_paginate @blog_comments %>
8
14
  <% else %>
9
15
  <p><%= t('admin.search_no_results') %></p>
10
16
  <% end %>
11
17
  <% else %>
12
18
  <% if @blog_comments.any? %>
13
- <%= will_paginate @blog_comments,
14
- :previous_label => '&laquo;',
15
- :next_label => '&raquo;' %>
19
+ <%= will_paginate @blog_comments %>
16
20
 
17
21
  <%= render :partial => "sortable_list" %>
18
22
 
19
- <%= will_paginate @blog_comments,
20
- :previous_label => '&laquo;',
21
- :next_label => '&raquo;' %>
23
+ <%= will_paginate @blog_comments %>
22
24
  <% else %>
23
25
  <h3>
24
- <%= t('.no_items_yet',
25
- :type => (t("admin.blog.submenu.comments.#{action_name}").downcase unless action_name == 'index')) %>
26
+ <%= t('.no_items_yet',
27
+ :type => (t("admin.blog.submenu.comments.#{action_name}").downcase unless action_name == 'index')) %>
26
28
  </h3>
27
29
  <% end %>
28
30
  <% end %>
@@ -24,10 +24,15 @@
24
24
  <div id='more_options' style="display:none;">
25
25
  <div class="hemisquare">
26
26
  <h3><%= t('admin.blog.submenu.categories.title') %></h3>
27
- <ul class='categories'>
27
+ <ul class='blog_categories'>
28
28
  <% @blog_categories.each do |category| %>
29
29
  <li>
30
- checkboxes for category <%= category.title %>
30
+ <%= check_box_tag 'blog_post[category_ids][]', category.id,
31
+ @blog_post.categories.include?(category),
32
+ :id => (id="blog_post_category_ids_#{category.id}") %>
33
+ <%= label_tag 'blog_post[category_ids][]', category.title,
34
+ :class => 'stripped',
35
+ :for => id %>
31
36
  </li>
32
37
  <% end %>
33
38
  </ul>
@@ -39,10 +44,17 @@
39
44
  :locals => {
40
45
  :f => f,
41
46
  :continue_editing => true,
42
- :delete_title => t('admin.blogs.blogs.delete')
47
+ :delete_title => t('admin.blog.posts.post.delete')
43
48
  } %>
44
49
  <% end -%>
45
50
  <% content_for :head do %>
51
+ <style type='text/css'>
52
+ ul.blog_categories, ul.blog_categories li {
53
+ list-style: none;
54
+ margin: 0px;
55
+ padding: 0px;
56
+ }
57
+ </style>
46
58
  <script type='text/javascript'>
47
59
  $(document).ready(function(){
48
60
  $('#toggle_advanced_options').click(function(e){
@@ -1,7 +1,7 @@
1
1
  <%= render :partial => '/admin/blog/submenu' %>
2
2
  <div id='records'>
3
3
  <% if searching? %>
4
- <h2><%= t('admin.search_results_for', :query => params[:search]) %></h2>
4
+ <h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
5
5
  <% if @blog_posts.any? %>
6
6
  <%= render :partial => "blog_posts",
7
7
  :collection => @blog_posts %>
@@ -22,7 +22,7 @@
22
22
  <% else %>
23
23
  <p>
24
24
  <strong>
25
- <%= t('.no_items_yet') %>
25
+ <%= t('.no_items_yet', :create => t('admin.blog.submenu.posts.new')) %>
26
26
  </strong>
27
27
  </p>
28
28
  <% end %>
@@ -0,0 +1,24 @@
1
+ <% form_tag do %>
2
+
3
+ <div class='field'>
4
+ <span class='label_with_help'>
5
+ <%= label_tag :recipients, t('.value') %>
6
+ </span>
7
+ <%= text_field_tag :recipients, @recipients, :class => "larger widest" %>
8
+ </div>
9
+
10
+ <p>
11
+ <%= t('.hint') %>
12
+ </p>
13
+ <p>
14
+ <%= t('.example') %>
15
+ </p>
16
+
17
+ <%= render :partial => "/shared/admin/form_actions",
18
+ :locals => {
19
+ :f => nil,
20
+ :continue_editing => false,
21
+ :cancel_url => admin_blog_posts_url,
22
+ :hide_delete => true
23
+ } %>
24
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <h2><%= t('.categories') %></h2>
2
+ <ul class='categories'>
3
+ <% @blog_categories.each do |category| %>
4
+ <li>
5
+ <%= category.title %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
@@ -1,11 +1,27 @@
1
1
  <% content_for :body_content_left do %>
2
+ <%= @page[Page.default_parts.first.to_sym] %>
3
+
2
4
  <ul id="blog_posts">
3
5
  <% @blog_posts.each do |blog_post| %>
4
6
  <li>
5
- <%= link_to blog_post.title, blog_post_url(blog_post) %>
7
+ <h2><%= link_to blog_post.title, blog_post_url(blog_post) %></h2>
8
+ <%= blog_post.created_at.strftime('%d %B %Y') %>
9
+ <%= truncate(blog_post.body,
10
+ :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
11
+ :preserve_html_tags => true) %>
12
+ <%= link_to t('.read_more'), blog_post_url(blog_post) %>
6
13
  </li>
7
14
  <% end %>
8
15
  </ul>
9
16
  <% end %>
10
17
 
18
+ <% content_for :body_content_right do %>
19
+ <%= @page[Page.default_parts.second.to_sym] %>
20
+
21
+ <%= render :partial => "side_bar" %>
22
+ <% end %>
23
+
11
24
  <%= render :partial => "/shared/content_page" %>
25
+ <% content_for :head do %>
26
+ <%= stylesheet_link_tag 'refinerycms-blog' %>
27
+ <% end %>
@@ -1,12 +1,27 @@
1
1
  <% content_for :body_content_title, @blog_post.title %>
2
2
 
3
3
  <% content_for :body_content_left do %>
4
-
5
4
  <%= @blog_post.body %>
6
5
 
6
+ <% if (categories = @blog_post.categories).any? %>
7
+ <div class='post_categories'>
8
+ <span class='filed_in'><%= t('.filed_in') %></span>
9
+ <ul>
10
+ <% categories.each_with_index do |category, index| %>
11
+ <li>
12
+ <%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
13
+ </li>
14
+ <% end %>
15
+ </ul>
16
+ </div>
17
+ <% end %>
7
18
  <% end %>
8
19
 
9
20
  <% content_for :body_content_right do %>
21
+ <h2><%= t('.created_at_title') %></h2>
22
+ <%= t('.created_at', :when => @blog_post.created_at.strftime('%d %B %Y')) %>
23
+ <%= render :partial => "side_bar" %>
24
+
10
25
  <h2><%= t('.other') %></h2>
11
26
  <ul id="blog_post">
12
27
  <% @blog_posts.each do |blog_post| %>
@@ -18,3 +33,6 @@
18
33
  <% end %>
19
34
 
20
35
  <%= render :partial => "/shared/content_page" %>
36
+ <% content_for :head do %>
37
+ <%= stylesheet_link_tag 'refinerycms-blog' %>
38
+ <% end %>
@@ -4,36 +4,58 @@ en:
4
4
  title: Blog
5
5
  admin:
6
6
  blog:
7
+ categories:
8
+ category:
9
+ edit: Edit this category
10
+ delete: Delete this category forever
11
+ index:
12
+ no_items_yet: There are no categories yet. Click "{{create}}" to add your first category.
13
+ comments:
14
+ index:
15
+ no_items_yet: There are no {{type}} comments yet.
7
16
  posts:
8
17
  form:
9
18
  advanced_options: Advanced Options
10
19
  toggle_advanced_options: Click to access meta tag settings and menu options
11
20
  save_as_draft: Save as Draft
12
21
  index:
13
- no_items_yet: There are no Blog Posts yet. Click "Create a new Blog Posts" to add your first blog posts.
22
+ no_items_yet: There are no Blog Posts yet. Click "{{create}}" to add your first blog post.
14
23
  post:
15
24
  view_live: View this blog post live <br/><em>(opens in a new window)</em>
16
25
  edit: Edit this blog post
17
26
  delete: Remove this blog post forever
18
- comments:
19
- index:
20
- no_items_yet: There are no {{type}} comments yet.
27
+ settings:
28
+ notification_recipients:
29
+ value: Send notifications to
30
+ explanation: Every time someone comments on a blog post, Refinery sends out an email to say there is a new comment.
31
+ hint: When a new comment is added, Refinery will send an email notification to you.
32
+ example: "Enter your email address(es) like: jack@work.com, jill@office.com"
21
33
  submenu:
22
34
  categories:
23
35
  title: Categories
24
36
  manage: Manage
25
37
  new: Create new category
26
38
  comments:
39
+ title: Comments
27
40
  new: New
41
+ unmoderated: New
28
42
  approved: Approved
29
43
  rejected: Rejected
30
44
  posts:
31
45
  title: Posts
46
+ manage: Manage posts
32
47
  new: Create new post
33
48
  settings:
34
49
  title: Settings
35
50
  moderation: Moderation
36
51
  update_notified: Update who gets notified
37
52
  blog_posts:
53
+ side_bar:
54
+ categories: Categories
55
+ index:
56
+ read_more: Read more
38
57
  show:
39
- other: Other Blog Posts
58
+ other: Other Blog Posts
59
+ filed_in: Filed in
60
+ created_at_title: Publishing Date
61
+ created_at: Posted on {{when}}
data/config/routes.rb CHANGED
@@ -1,12 +1,20 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
- map.resources :blog_posts, :as => :blog
2
+ map.blog_post '/blog', :controller => :blog_posts, :action => :index
3
+ map.blog_post '/blog/:id', :controller => :blog_posts, :action => :show
4
+ map.blog_category '/blog/categories/:category_id', :controller => :blog_posts, :action => :index
3
5
 
4
6
  map.namespace(:admin, :path_prefix => 'refinery') do |admin|
5
7
  admin.namespace :blog do |blog|
6
8
  blog.resources :posts
7
9
  blog.resources :categories
8
- blog.resources :comments, :collection => {:approved => :get, :rejected => :get}
9
- blog.resources :settings, :collection => {:update_notified => [:get, :post], :moderation => :get}
10
+ blog.resources :comments, :collection => {
11
+ :approved => :get,
12
+ :rejected => :get
13
+ }
14
+ blog.resources :settings, :collection => {
15
+ :notification_recipients => [:get, :post],
16
+ :moderation => :get
17
+ }
10
18
  end
11
19
  end
12
20
  end
@@ -12,6 +12,21 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
12
12
 
13
13
  def manifest
14
14
  record do |m|
15
+ if Rails.version < '3.0.0'
16
+ matches = Dir[
17
+ File.expand_path('../../../public/images/**/*', __FILE__),
18
+ File.expand_path('../../../public/stylesheets/**/*', __FILE__),
19
+ File.expand_path('../../../public/javascripts/**/*', __FILE__),
20
+ ]
21
+ matches.reject{|d| !File.directory?(d)}.each do |dir|
22
+ m.directory((%w(public) | dir.split('public/').last.split('/')).join('/'))
23
+ end
24
+ matches.reject{|f| File.directory?(f)}.each do |image|
25
+ path = (%w(public) | image.split('public/').last.split('/'))[0...-1].join('/')
26
+ m.template "../../../#{path}/#{image.split('/').last}", "#{path}/#{image.split('/').last}"
27
+ end
28
+ end
29
+
15
30
  m.template('seed.rb', 'db/seeds/refinerycms_blog.rb')
16
31
 
17
32
  m.migration_template('migration.rb', 'db/migrate',
@@ -31,7 +46,7 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
31
46
  Rails::Generator::GeneratedAttribute.new('name', 'string'),
32
47
  Rails::Generator::GeneratedAttribute.new('email', 'string'),
33
48
  Rails::Generator::GeneratedAttribute.new('body', 'text'),
34
- Rails::Generator::GeneratedAttribute.new('approved', 'boolean'),
49
+ Rails::Generator::GeneratedAttribute.new('state', 'string'),
35
50
  Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer')
36
51
  ], :id => true
37
52
  },{
data/lib/gemspec.rb CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.homepage = %q{http://refinerycms.com}
18
18
  s.authors = %w(Resolve\\ Digital Neoteric\\ Design)
19
19
  s.require_paths = %w(lib)
20
+ s.add_dependency('refinerycms', '~> 0.9.7.12')
20
21
 
21
22
  s.files = %w(
22
23
  #{files.join("\n ")}
@@ -2,7 +2,7 @@ module Refinery
2
2
  module Blog
3
3
  class << self
4
4
  def version
5
- %q{0.9.8.dev1}
5
+ %q{0.9.8.0.rc1}
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,40 @@
1
+ $(document).ready(function(){
2
+ $('nav#actions.multilist > ul:not(.search_list) li a[href$=' + window.location.pathname + ']')
3
+ .parent().addClass('selected');
4
+
5
+ $('nav#actions.multilist > ul:not(.search_list) li > a').each(function(i,a){
6
+ if ($(this).data('dialog-title') == null) {
7
+ $(this).bind('click', function(){
8
+ $(this).css('background-image', "url('/images/refinery/icons/ajax-loader.gif') !important");
9
+ });
10
+ }
11
+ });
12
+
13
+ $('ul.collapsible_menu').each(function(i, ul) {
14
+ (first_li = $(this).children('li:first')).after(div=$("<div></div>"));
15
+ if (($(this).children('li.selected')).length == 0) {
16
+ div.hide();
17
+ }
18
+ $(this).children('li:not(:first)').appendTo(div);
19
+
20
+ first_li.find('> a').click(function(e){
21
+ $(this).parent().next('div').animate({
22
+ opacity: 'toggle'
23
+ , height: 'toggle'
24
+ }, 250, $.proxy(function(){
25
+ $(this).css('background-image', null);
26
+ }, $(this))
27
+ );
28
+ e.preventDefault();
29
+ });
30
+ });
31
+
32
+ $('.success_icon, .failure_icon').bind('click', function(e) {
33
+ $.get($(this).attr('href'), $.proxy(function(data){
34
+ $(this).css('background-image', null)
35
+ .toggleClass('success_icon')
36
+ .toggleClass('failure_icon');
37
+ }, $(this)));
38
+ e.preventDefault();
39
+ });
40
+ });
@@ -0,0 +1,33 @@
1
+ .comments_icon {
2
+ background-image: url('/images/refinerycms-blog/icons/comments.png');
3
+ }
4
+ .comment_icon {
5
+ background-image: url('/images/refinerycms-blog/icons/comment.png');
6
+ }
7
+ .comment_cross_icon {
8
+ background-image: url('/images/refinerycms-blog/icons/comment_cross.png');
9
+ }
10
+ .comment_tick_icon {
11
+ background-image: url('/images/refinerycms-blog/icons/comment_tick.png');
12
+ }
13
+ .folder_icon {
14
+ background-image: url('/images/refinerycms-blog/icons/folder.png');
15
+ }
16
+ .folder_add_icon {
17
+ background-image: url('/images/refinerycms-blog/icons/folder_add.png');
18
+ }
19
+ .folder_edit_icon {
20
+ background-image: url('/images/refinerycms-blog/icons/folder_edit.png');
21
+ }
22
+ .settings_icon {
23
+ background-image: url('/images/refinerycms-blog/icons/cog.png');
24
+ }
25
+ .page_icon {
26
+ background-image: url('/images/refinerycms-blog/icons/page.png');
27
+ }
28
+ .page_copy_icon {
29
+ background-image: url('/images/refinerycms-blog/icons/page_copy.png');
30
+ }
31
+ .page_add_icon {
32
+ background-image: url('/images/refinerycms-blog/icons/page_add.png');
33
+ }
@@ -0,0 +1,13 @@
1
+ .post_categories .filed_in {
2
+ display: inline;
3
+ }
4
+ .post_categories ul {
5
+ margin: 0px 0px 0px 6px;
6
+ padding: 0px;
7
+ display: inline;
8
+ }
9
+ .post_categories ul li {
10
+ margin: 0px;
11
+ padding: 0px;
12
+ display: inline;
13
+ }
@@ -0,0 +1,4 @@
1
+ Factory.define(:blog_category) do |f|
2
+ f.title "Shopping"
3
+ f.posts {|p| [p.association :post]}
4
+ end
@@ -0,0 +1,10 @@
1
+ Factory.sequence :email do |n|
2
+ "person#{n}@example.com"
3
+ end
4
+
5
+ Factory.define(:blog_comment) do |f|
6
+ f.name "Joe Commenter"
7
+ f.email { Factory.next(:email) }
8
+ f.body "Which one is the best for picking up new shoes?"
9
+ f.association :post
10
+ end
@@ -0,0 +1,4 @@
1
+ Factory.define(:post, :class => BlogPost) do |f|
2
+ f.title "Top Ten Shopping Centers in Chicago"
3
+ 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."
4
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe BlogCategory do
4
+ context "wiring up" do
5
+
6
+ before(:each) do
7
+ @category = Factory(:blog_category)
8
+ end
9
+
10
+ it "saves" do
11
+ @category.should_not be_nil
12
+ end
13
+
14
+ it "has a blog post" do
15
+ BlogPost.last.categories.should include(@category)
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe BlogComment do
4
+
5
+ context "wiring up" do
6
+
7
+ before(:each) do
8
+ @comment = Factory(:blog_comment)
9
+ end
10
+
11
+ it "saves" do
12
+ @comment.should_not be_nil
13
+ end
14
+
15
+ it "has a blog post" do
16
+ @comment.post.should_not be_nil
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe BlogPost do
4
+ context "wiring up" do
5
+
6
+ before(:each) do
7
+ @post = Factory(:post)
8
+ end
9
+
10
+ it "saves to the database" do
11
+ @post.should_not be_nil
12
+ end
13
+
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-blog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1641194447
4
+ hash: 977940590
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 8
10
- - dev1
11
- version: 0.9.8.dev1
10
+ - 0
11
+ - rc1
12
+ version: 0.9.8.0.rc1
12
13
  platform: ruby
13
14
  authors:
14
15
  - Resolve Digital
@@ -17,10 +18,26 @@ autorequire:
17
18
  bindir: bin
18
19
  cert_chain: []
19
20
 
20
- date: 2010-08-09 00:00:00 +12:00
21
+ date: 2010-08-26 00:00:00 +12:00
21
22
  default_executable:
22
- dependencies: []
23
-
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
25
+ name: refinerycms
26
+ prerelease: false
27
+ requirement: &id001 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ hash: 3
33
+ segments:
34
+ - 0
35
+ - 9
36
+ - 7
37
+ - 12
38
+ version: 0.9.7.12
39
+ type: :runtime
40
+ version_requirements: *id001
24
41
  description: A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.
25
42
  email: info@refinerycms.com
26
43
  executables: []
@@ -39,6 +56,12 @@ files:
39
56
  - app/models/blog_comment.rb
40
57
  - app/models/blog_post.rb
41
58
  - app/views/admin/blog/_submenu.html.erb
59
+ - app/views/admin/blog/categories/_category.html.erb
60
+ - app/views/admin/blog/categories/_form.html.erb
61
+ - app/views/admin/blog/categories/_sortable_list.html.erb
62
+ - app/views/admin/blog/categories/edit.html.erb
63
+ - app/views/admin/blog/categories/index.html.erb
64
+ - app/views/admin/blog/categories/new.html.erb
42
65
  - app/views/admin/blog/comments/index.html.erb
43
66
  - app/views/admin/blog/posts/_form.html.erb
44
67
  - app/views/admin/blog/posts/_post.html.erb
@@ -46,6 +69,8 @@ files:
46
69
  - app/views/admin/blog/posts/edit.html.erb
47
70
  - app/views/admin/blog/posts/index.html.erb
48
71
  - app/views/admin/blog/posts/new.html.erb
72
+ - app/views/admin/blog/settings/notification_recipients.html.erb
73
+ - app/views/blog_posts/_side_bar.html.erb
49
74
  - app/views/blog_posts/index.html.erb
50
75
  - app/views/blog_posts/show.html.erb
51
76
  - config/locales/en.yml
@@ -57,8 +82,28 @@ files:
57
82
  - generators/refinery_blog/templates/seed.rb
58
83
  - lib/gemspec.rb
59
84
  - lib/refinerycms-blog.rb
85
+ - public/images/refinerycms-blog/icons/cog.png
86
+ - public/images/refinerycms-blog/icons/comment.png
87
+ - public/images/refinerycms-blog/icons/comment_cross.png
88
+ - public/images/refinerycms-blog/icons/comment_tick.png
89
+ - public/images/refinerycms-blog/icons/comments.png
90
+ - public/images/refinerycms-blog/icons/folder.png
91
+ - public/images/refinerycms-blog/icons/folder_add.png
92
+ - public/images/refinerycms-blog/icons/folder_edit.png
93
+ - public/images/refinerycms-blog/icons/page.png
94
+ - public/images/refinerycms-blog/icons/page_add.png
95
+ - public/images/refinerycms-blog/icons/page_copy.png
96
+ - public/javascripts/refinery/refinerycms-blog.js
97
+ - public/stylesheets/refinery/refinerycms-blog.css
98
+ - public/stylesheets/refinerycms-blog.css
60
99
  - rails/init.rb
61
100
  - readme.md
101
+ - spec/factories/blog_categories.rb
102
+ - spec/factories/blog_comments.rb
103
+ - spec/factories/blog_posts.rb
104
+ - spec/models/blog_categories_spec.rb
105
+ - spec/models/blog_comments_spec.rb
106
+ - spec/models/blog_posts_spec.rb
62
107
  has_rdoc: true
63
108
  homepage: http://refinerycms.com
64
109
  licenses: []