aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2010-11-22 15:23:25 +1300
committerPhilip Arndt <parndt@gmail.com>2010-11-22 15:26:53 +1300
commite5b9af1054bbd259bde0265acf4386cdaab0ca41 (patch)
treea5a89e83d262aab943c7e3f5d22dc52788de24d8
parentebb4c59cef0eb4e89700275e23579ca6dd18d619 (diff)
parent6d94a0ba7b781f93519183c96bbc718465dccdb4 (diff)
downloadrefinerycms-blog-e5b9af1054bbd259bde0265acf4386cdaab0ca41.tar.gz
refinerycms-blog-e5b9af1054bbd259bde0265acf4386cdaab0ca41.tar.bz2
refinerycms-blog-e5b9af1054bbd259bde0265acf4386cdaab0ca41.zip
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.
-rw-r--r--app/models/blog_comment.rb23
-rw-r--r--app/views/admin/blog/_submenu.html.erb15
-rw-r--r--app/views/admin/blog/comments/show.html.erb7
-rw-r--r--app/views/admin/blog/posts/_form.css.erb7
-rw-r--r--app/views/admin/blog/posts/_form.html.erb32
-rw-r--r--app/views/admin/blog/posts/_form.js.erb13
-rw-r--r--app/views/blog/posts/show.html.erb32
-rw-r--r--features/support/factories/blog_categories.rb (renamed from spec/factories/blog_categories.rb)2
-rw-r--r--features/support/factories/blog_comments.rb (renamed from spec/factories/blog_comments.rb)0
-rw-r--r--features/support/factories/blog_posts.rb (renamed from spec/factories/blog_posts.rb)0
-rw-r--r--features/support/paths.rb24
-rw-r--r--generators/refinerycms_blog/refinerycms_blog_generator.rb (renamed from generators/refinery_blog/refinery_blog_generator.rb)6
-rw-r--r--generators/refinerycms_blog/templates/db/migrate/migration.rb (renamed from generators/refinery_blog/templates/db/migrate/migration.rb)0
-rw-r--r--generators/refinerycms_blog/templates/db/seeds/seed.rb (renamed from generators/refinery_blog/templates/db/seeds/seed.rb)0
-rw-r--r--lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb (renamed from lib/generators/refinery_blog/templates/db/migrate/migration_number_create_singular_name.rb)0
-rw-r--r--lib/generators/refinerycms_blog/templates/db/seeds/seed.rb (renamed from lib/generators/refinery_blog/templates/db/seeds/seed.rb)0
-rw-r--r--lib/generators/refinerycms_blog_generator.rb (renamed from lib/generators/refinery_blog_generator.rb)4
-rw-r--r--readme.md10
-rw-r--r--refinerycms-blog.gemspec42
-rw-r--r--spec/models/blog_categories_spec.rb11
-rw-r--r--spec/models/blog_comments_spec.rb1
-rw-r--r--spec/models/blog_posts_spec.rb1
22 files changed, 152 insertions, 78 deletions
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index b888e35..9b84ece 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -60,11 +60,16 @@ class BlogComment < ActiveRecord::Base
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 @@ class BlogComment < ActiveRecord::Base
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 @@ class BlogComment < ActiveRecord::Base
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
diff --git a/app/views/admin/blog/_submenu.html.erb b/app/views/admin/blog/_submenu.html.erb
index 5db96cf..a966f5b 100644
--- a/app/views/admin/blog/_submenu.html.erb
+++ b/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 -%> \ No newline at end of file
+<% 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 %> \ No newline at end of file
diff --git a/app/views/admin/blog/comments/show.html.erb b/app/views/admin/blog/comments/show.html.erb
index d4c2186..82a5f6f 100644
--- a/app/views/admin/blog/comments/show.html.erb
+++ b/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 %> \ No newline at end of file
diff --git a/app/views/admin/blog/posts/_form.css.erb b/app/views/admin/blog/posts/_form.css.erb
new file mode 100644
index 0000000..d6f2c20
--- /dev/null
+++ b/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> \ No newline at end of file
diff --git a/app/views/admin/blog/posts/_form.html.erb b/app/views/admin/blog/posts/_form.html.erb
index de46afc..5779e4c 100644
--- a/app/views/admin/blog/posts/_form.html.erb
+++ b/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 %> \ No newline at end of file
+<% 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 %>
diff --git a/app/views/admin/blog/posts/_form.js.erb b/app/views/admin/blog/posts/_form.js.erb
new file mode 100644
index 0000000..394975f
--- /dev/null
+++ b/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> \ No newline at end of file
diff --git a/app/views/blog/posts/show.html.erb b/app/views/blog/posts/show.html.erb
index 1c725d5..603a44f 100644
--- a/app/views/blog/posts/show.html.erb
+++ b/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') %> \ No newline at end of file
+
+<% 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 %> \ No newline at end of file
diff --git a/spec/factories/blog_categories.rb b/features/support/factories/blog_categories.rb
index 590e5b5..be28d88 100644
--- a/spec/factories/blog_categories.rb
+++ b/features/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 \ No newline at end of file
diff --git a/spec/factories/blog_comments.rb b/features/support/factories/blog_comments.rb
index 93beaf3..93beaf3 100644
--- a/spec/factories/blog_comments.rb
+++ b/features/support/factories/blog_comments.rb
diff --git a/spec/factories/blog_posts.rb b/features/support/factories/blog_posts.rb
index 6947e81..6947e81 100644
--- a/spec/factories/blog_posts.rb
+++ b/features/support/factories/blog_posts.rb
diff --git a/features/support/paths.rb b/features/support/paths.rb
new file mode 100644
index 0000000..dbd04dd
--- /dev/null
+++ b/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
diff --git a/generators/refinery_blog/refinery_blog_generator.rb b/generators/refinerycms_blog/refinerycms_blog_generator.rb
index 383d237..2945823 100644
--- a/generators/refinery_blog/refinery_blog_generator.rb
+++ b/generators/refinerycms_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 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
end
def banner
- 'Usage: script/generate refinery_blog'
+ 'Usage: script/generate refinerycms_blog'
end
def manifest
@@ -24,7 +24,7 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
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')
diff --git a/generators/refinery_blog/templates/db/migrate/migration.rb b/generators/refinerycms_blog/templates/db/migrate/migration.rb
index 5ba29c6..5ba29c6 100644
--- a/generators/refinery_blog/templates/db/migrate/migration.rb
+++ b/generators/refinerycms_blog/templates/db/migrate/migration.rb
diff --git a/generators/refinery_blog/templates/db/seeds/seed.rb b/generators/refinerycms_blog/templates/db/seeds/seed.rb
index 228fc7b..228fc7b 100644
--- a/generators/refinery_blog/templates/db/seeds/seed.rb
+++ b/generators/refinerycms_blog/templates/db/seeds/seed.rb
diff --git a/lib/generators/refinery_blog/templates/db/migrate/migration_number_create_singular_name.rb b/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb
index badb213..badb213 100644
--- a/lib/generators/refinery_blog/templates/db/migrate/migration_number_create_singular_name.rb
+++ b/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb
diff --git a/lib/generators/refinery_blog/templates/db/seeds/seed.rb b/lib/generators/refinerycms_blog/templates/db/seeds/seed.rb
index f958fab..f958fab 100644
--- a/lib/generators/refinery_blog/templates/db/seeds/seed.rb
+++ b/lib/generators/refinerycms_blog/templates/db/seeds/seed.rb
diff --git a/lib/generators/refinery_blog_generator.rb b/lib/generators/refinerycms_blog_generator.rb
index 4f0cbe6..ba21e9f 100644
--- a/lib/generators/refinery_blog_generator.rb
+++ b/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
diff --git a/readme.md b/readme.md
index d3f2114..20d6187 100644
--- a/readme.md
+++ b/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.
diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec
index 27c304f..accaaaf 100644
--- a/refinerycms-blog.gemspec
+++ b/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
diff --git a/spec/models/blog_categories_spec.rb b/spec/models/blog_categories_spec.rb
index d97172c..90d9e22 100644
--- a/spec/models/blog_categories_spec.rb
+++ b/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 \ No newline at end of file
diff --git a/spec/models/blog_comments_spec.rb b/spec/models/blog_comments_spec.rb
index 145626d..7966b46 100644
--- a/spec/models/blog_comments_spec.rb
+++ b/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
diff --git a/spec/models/blog_posts_spec.rb b/spec/models/blog_posts_spec.rb
index a334c73..3801de8 100644
--- a/spec/models/blog_posts_spec.rb
+++ b/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