Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged in Joe's and Steven's forks and updated for compatibility with…

… < 0.9.9. Also, specs now work by including the factories and I have also laid the foundation for cucumber features. Fixed an issue where the javascript file was clashing with the same code we merged to core from this engine relating to submenus. Regenerated gemspec.
  • Loading branch information...
commit e5b9af1054bbd259bde0265acf4386cdaab0ca41 2 parents ebb4c59 + 6d94a0b
@parndt parndt authored
Showing with 152 additions and 78 deletions.
  1. +19 −4 app/models/blog_comment.rb
  2. +9 −6 app/views/admin/blog/_submenu.html.erb
  3. +5 −2 app/views/admin/blog/comments/show.html.erb
  4. +7 −0 app/views/admin/blog/posts/_form.css.erb
  5. +9 −23 app/views/admin/blog/posts/_form.html.erb
  6. +13 −0 app/views/admin/blog/posts/_form.js.erb
  7. +20 −12 app/views/blog/posts/show.html.erb
  8. +1 −1  {spec → features/support}/factories/blog_categories.rb
  9. 0  {spec → features/support}/factories/blog_comments.rb
  10. 0  {spec → features/support}/factories/blog_posts.rb
  11. +24 −0 features/support/paths.rb
  12. +3 −3 generators/{refinery_blog/refinery_blog_generator.rb → refinerycms_blog/refinerycms_blog_generator.rb}
  13. 0  generators/{refinery_blog → refinerycms_blog}/templates/db/migrate/migration.rb
  14. 0  generators/{refinery_blog → refinerycms_blog}/templates/db/seeds/seed.rb
  15. 0  ...ators/{refinery_blog → refinerycms_blog}/templates/db/migrate/migration_number_create_singular_name.rb
  16. 0  lib/generators/{refinery_blog → refinerycms_blog}/templates/db/seeds/seed.rb
  17. +2 −2 lib/generators/{refinery_blog_generator.rb → refinerycms_blog_generator.rb}
  18. +7 −3 readme.md
  19. +25 −17 refinerycms-blog.gemspec
  20. +6 −5 spec/models/blog_categories_spec.rb
  21. +1 −0  spec/models/blog_comments_spec.rb
  22. +1 −0  spec/models/blog_posts_spec.rb
View
23 app/models/blog_comment.rb
@@ -60,11 +60,16 @@ def enabled?
end
def toggle!
- RefinerySetting[:comment_moderation] = {
- :value => !self.enabled?,
+ new_value = {
+ :value => !BlogComment::Moderation.enabled?,
:scoping => :blog,
:restricted => false
}
+ if RefinerySetting.respond_to?(:set)
+ RefinerySetting.set(:comment_moderation, new_value)
+ else
+ RefinerySetting[:comment_moderation] = new_value
+ end
end
end
end
@@ -80,11 +85,16 @@ def recipients
end
def recipients=(emails)
- RefinerySetting[:comment_notification_recipients] = {
+ new_value = {
:value => emails,
:scoping => :blog,
:restricted => false
}
+ if RefinerySetting.respond_to?(:set)
+ RefinerySetting.set(:comment_notification_recipients, new_value)
+ else
+ RefinerySetting[:comment_notification_recipients] = new_value
+ end
end
def subject
@@ -95,11 +105,16 @@ def subject
end
def subject=(subject_line)
- RefinerySetting[:comment_notification_subject] = {
+ new_value = {
:value => subject_line,
:scoping => :blog,
:restricted => false
}
+ if RefinerySetting.respond_to?(:set)
+ RefinerySetting.set(:comment_notification_subject, new_value)
+ else
+ RefinerySetting[:comment_notification_subject] = new_value
+ end
end
end
end
View
15 app/views/admin/blog/_submenu.html.erb
@@ -78,9 +78,12 @@
</ul>
</nav>
-<% content_for :stylesheets do -%>
- <%= stylesheet_link_tag 'refinery/refinerycms-blog' %>
-<% end -%>
-<% content_for :javascripts do -%>
- <%= javascript_include_tag 'refinery/refinerycms-blog' %>
-<% end -%>
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head do %>
+ <%= stylesheet_link_tag('refinery/refinerycms-blog') %>
+ <%# this javascript is not even required in >= 0.9.9 because we made this sort of menu core. %>
+ <%= javascript_link_tag('refinery/refinerycms-blog') %>
+ <% end %>
+<% else %>
+ <% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog')%>
+<% end %>
View
7 app/views/admin/blog/comments/show.html.erb
@@ -59,5 +59,8 @@
</tr>
</table>
</div>
-
-<% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog') %>
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head, stylesheet_link_tag('refinery/refinerycms-blog') %>
+<% else %>
+ <% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog') %>
+<% end %>
View
7 app/views/admin/blog/posts/_form.css.erb
@@ -0,0 +1,7 @@
+<style type='text/css'>
+ ul.blog_categories, ul.blog_categories li {
+ list-style: none;
+ margin: 0px;
+ padding: 0px;
+ }
+</style>
View
32 app/views/admin/blog/posts/_form.html.erb
@@ -57,27 +57,13 @@
:delete_title => t('admin.blog.posts.post.delete')
} %>
<% end -%>
-<% content_for :stylesheets do -%>
- <style type='text/css'>
- ul.blog_categories, ul.blog_categories li {
- list-style: none;
- margin: 0px;
- padding: 0px;
- }
- </style>
-<% end -%>
-<% content_for :after_javascript_libraries do %>
- <script type='text/javascript'>
- $(document).ready(function(){
- $('#toggle_advanced_options').click(function(e){
- e.preventDefault();
-
- $('#more_options').animate({opacity: 'toggle', height: 'toggle'}, 250);
- $('html,body').animate({
- scrollTop: $('#toggle_advanced_options').parent().offset().top
- }, 250);
- });
- });
- </script>
-<% end %>
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head do %>
+ <%= render :partial => 'form.css' %>
+ <%= render :partial => 'form.js' %>
+ <% end %>
+<% else %>
+ <% content_for :stylesheets, render(:partial => 'form.css') -%>
+ <% content_for :javascripts, render(:partial => 'form.js') -%>
+<% end %>
View
13 app/views/admin/blog/posts/_form.js.erb
@@ -0,0 +1,13 @@
+<script>
+ $(document).ready(function(){
+ $('#toggle_advanced_options').click(function(e){
+ e.preventDefault();
+
+ $('#more_options').animate({opacity: 'toggle', height: 'toggle'}, 250);
+
+ $('html,body').animate({
+ scrollTop: $('#toggle_advanced_options').parent().offset().top
+ }, 250);
+ });
+ });
+</script>
View
32 app/views/blog/posts/show.html.erb
@@ -1,17 +1,8 @@
-<% content_for :after_javascript_libraries do %>
- <% if BlogPost::ShareThis.enabled? %>
- <script src="http://w.sharethis.com/button/buttons.js"></script>
- <script>
- stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});
- </script>
- <% end %>
-<% end %>
-
<% content_for :body_content_left do %>
<div id="show_blog_post">
<%= render 'post' %>
</div>
-
+
<% if BlogPost.comments_allowed? %>
<aside id="comments">
<h2><%= t('.comments.title') %></h2>
@@ -73,5 +64,22 @@
<% end %>
<%= render :partial => "/shared/content_page", :locals => { :remove_automatic_sections => true } %>
-<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
-<% content_for :javascripts, javascript_include_tag('jquery','refinerycms-blog') %>
+
+<% if Refinery.version < '0.9.9' %>
+ <% content_for :head_libraries, jquery_include_tags(:jquery_ui => false) %>
+ <% content_for :head do %>
+ <%= stylesheet_link_tag 'refinerycms-blog' %>
+ <%= 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>
+ <% end %>
+<% else %>
+ <% 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' %>
+ <script src="http://w.sharethis.com/button/buttons.js"></script>
+ <script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
+ <% end if BlogPost::ShareThis.enabled? %>
+<% end %>
View
2  spec/factories/blog_categories.rb → ...ures/support/factories/blog_categories.rb
@@ -1,4 +1,4 @@
Factory.define(:blog_category) do |f|
f.title "Shopping"
- f.posts {|p| [p.association :post]}
+ f.posts {|p| [p.association(:post)]}
end
View
0  spec/factories/blog_comments.rb → features/support/factories/blog_comments.rb
File renamed without changes
View
0  spec/factories/blog_posts.rb → features/support/factories/blog_posts.rb
File renamed without changes
View
24 features/support/paths.rb
@@ -0,0 +1,24 @@
+module NavigationHelpers
+ module Refinery
+ module Blog
+ def path_to(page_name)
+ case page_name
+ when /the list of blog posts/
+ admin_blog_posts_path
+ when /the new blog posts? form/
+ new_admin_blog_post_path
+ else
+ begin
+ if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present?
+ self.url_for(page.url)
+ else
+ nil
+ end
+ rescue
+ nil
+ end
+ end
+ end
+ end
+ end
+end
View
6 .../refinery_blog/refinery_blog_generator.rb → ...erycms_blog/refinerycms_blog_generator.rb
@@ -1,4 +1,4 @@
-class RefineryBlogGenerator < Rails::Generator::NamedBase
+class RefinerycmsBlogGenerator < Rails::Generator::NamedBase
def initialize(*runtime_args)
# set argument for the user.
@@ -7,7 +7,7 @@ def initialize(*runtime_args)
end
def banner
- 'Usage: script/generate refinery_blog'
+ 'Usage: script/generate refinerycms_blog'
end
def manifest
@@ -24,7 +24,7 @@ def manifest
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')
View
0  ...ry_blog/templates/db/migrate/migration.rb → ...ms_blog/templates/db/migrate/migration.rb
File renamed without changes
View
0  .../refinery_blog/templates/db/seeds/seed.rb → ...finerycms_blog/templates/db/seeds/seed.rb
File renamed without changes
View
0  .../migration_number_create_singular_name.rb → .../migration_number_create_singular_name.rb
File renamed without changes
View
0  .../refinery_blog/templates/db/seeds/seed.rb → ...finerycms_blog/templates/db/seeds/seed.rb
File renamed without changes
View
4 lib/generators/refinery_blog_generator.rb → lib/generators/refinerycms_blog_generator.rb
@@ -1,9 +1,9 @@
require 'rails/generators/migration'
-class RefineryBlogGenerator < Rails::Generators::NamedBase
+class RefinerycmsBlogGenerator < Rails::Generators::NamedBase
include Rails::Generators::Migration
- source_root File.expand_path('../refinery_blog/templates/', __FILE__)
+ source_root File.expand_path('../refinerycms_blog/templates/', __FILE__)
argument :name, :type => :string, :default => 'blog_structure', :banner => ''
def generate
View
10 readme.md
@@ -11,13 +11,17 @@ Options:
Open up your ``Gemfile`` and add at the bottom this line
- gem 'refinerycms-blog', '~> 1.0.rc16'
+ gem 'refinerycms-blog', '= 1.0.rc16'
Now run ``bundle install``
-Next to install the blog plugin run:
+Next to install the blog plugin run (for Rails 2):
- ruby script/generate refinery_blog
+ ruby script/generate refinerycms_blog
+
+Or, for Rails 3:
+
+ rails generate refinerycms_blog
Finally migrate your database and you're done.
View
42 refinerycms-blog.gemspec
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
s.name = %q{refinerycms-blog}
s.version = %q{1.0.rc16}
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
- s.date = %q{2010-11-15}
+ s.date = %q{2010-11-22}
s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
app/controllers/blog/categories_controller.rb
app/controllers/blog/posts_controller.rb
app/controllers/blog_controller.rb
+ app/helpers
+ app/helpers/blog_posts_helper.rb
app/mailers
app/mailers/blog
app/mailers/blog/comment_mailer.rb
@@ -50,7 +52,9 @@ Gem::Specification.new do |s|
app/views/admin/blog/comments/index.html.erb
app/views/admin/blog/comments/show.html.erb
app/views/admin/blog/posts
+ app/views/admin/blog/posts/_form.css.erb
app/views/admin/blog/posts/_form.html.erb
+ app/views/admin/blog/posts/_form.js.erb
app/views/admin/blog/posts/_post.html.erb
app/views/admin/blog/posts/_sortable_list.html.erb
app/views/admin/blog/posts/edit.html.erb
@@ -65,6 +69,9 @@ Gem::Specification.new do |s|
app/views/blog/comment_mailer/notification.html.erb
app/views/blog/posts
app/views/blog/posts/_comment.html.erb
+ app/views/blog/posts/_nav.html.erb
+ app/views/blog/posts/_post.html.erb
+ app/views/blog/posts/archive.html.erb
app/views/blog/posts/index.html.erb
app/views/blog/posts/index.rss.builder
app/views/blog/posts/show.html.erb
@@ -83,25 +90,25 @@ Gem::Specification.new do |s|
Gemfile
Gemfile.lock
generators
- generators/refinery_blog
- generators/refinery_blog/refinery_blog_generator.rb
- generators/refinery_blog/templates
- generators/refinery_blog/templates/db
- generators/refinery_blog/templates/db/migrate
- generators/refinery_blog/templates/db/migrate/migration.rb
- generators/refinery_blog/templates/db/seeds
- generators/refinery_blog/templates/db/seeds/seed.rb
+ 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
lib
lib/gemspec.rb
lib/generators
- lib/generators/refinery_blog
- lib/generators/refinery_blog/templates
- lib/generators/refinery_blog/templates/db
- lib/generators/refinery_blog/templates/db/migrate
- lib/generators/refinery_blog/templates/db/migrate/migration_number_create_singular_name.rb
- lib/generators/refinery_blog/templates/db/seeds
- lib/generators/refinery_blog/templates/db/seeds/seed.rb
- lib/generators/refinery_blog_generator.rb
+ 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
public/images
@@ -124,6 +131,7 @@ Gem::Specification.new do |s|
public/javascripts
public/javascripts/refinery
public/javascripts/refinery/refinerycms-blog.js
+ public/javascripts/refinerycms-blog.js
public/stylesheets
public/stylesheets/refinery
public/stylesheets/refinery/refinerycms-blog.css
View
11 spec/models/blog_categories_spec.rb
@@ -1,20 +1,21 @@
require 'spec_helper'
+Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
describe BlogCategory do
context "wiring up" do
-
+
before(:each) do
@category = Factory(:blog_category)
end
-
+
it "saves" do
@category.should_not be_nil
end
-
+
it "has a blog post" do
BlogPost.last.categories.should include(@category)
end
-
+
end
-
+
end
View
1  spec/models/blog_comments_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
+Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
describe BlogComment do
View
1  spec/models/blog_posts_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
+Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
describe BlogPost do
context "wiring up" do
Please sign in to comment.
Something went wrong with that request. Please try again.