aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-10-28 13:17:48 -0700
committerJamie Winsor <jamie@enmasse.com>2011-10-28 13:17:48 -0700
commitc2a0ef9f4196fb19da7e168fb2cfb6999ab4e9ff (patch)
tree91cdc020787117c1641431163854c30cbe9999e7 /lib
parent4ab9eccdee10b1f0612822d92d23a925b9c84535 (diff)
parentfd7ce5e692989e5fe76722291caffb4211fd0517 (diff)
downloadrefinerycms-blog-c2a0ef9f4196fb19da7e168fb2cfb6999ab4e9ff.tar.gz
refinerycms-blog-c2a0ef9f4196fb19da7e168fb2cfb6999ab4e9ff.tar.bz2
refinerycms-blog-c2a0ef9f4196fb19da7e168fb2cfb6999ab4e9ff.zip
Merge branch 'use-generated-dummy-for-testing' into rails-3-1
Diffstat (limited to 'lib')
-rw-r--r--lib/generators/blog_generator.rb10
-rw-r--r--lib/generators/refinery/blog/blog_generator.rb16
-rw-r--r--lib/refinery/blog.rb35
-rw-r--r--lib/refinery/blog/engine.rb20
-rw-r--r--lib/refinery/blog/tabs.rb16
-rw-r--r--lib/refinerycms-blog.rb31
6 files changed, 70 insertions, 58 deletions
diff --git a/lib/generators/blog_generator.rb b/lib/generators/blog_generator.rb
deleted file mode 100644
index 8b09bb7..0000000
--- a/lib/generators/blog_generator.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'refinery/generators'
-
-module ::Refinery
- class BlogGenerator < ::Refinery::Generators::EngineInstaller
-
- source_root File.expand_path('../../../', __FILE__)
- engine_name "refinerycms-blog"
-
- end
-end
diff --git a/lib/generators/refinery/blog/blog_generator.rb b/lib/generators/refinery/blog/blog_generator.rb
new file mode 100644
index 0000000..34f6cd2
--- /dev/null
+++ b/lib/generators/refinery/blog/blog_generator.rb
@@ -0,0 +1,16 @@
+module Refinery
+ class BlogGenerator < Rails::Generators::Base
+ source_root File.expand_path('../templates', __FILE__)
+
+ def append_load_seed_data
+ append_file 'db/seeds.rb', :verbose => true do
+ <<-EOH
+
+# Added by RefineryCMS Blog engine
+Refinery::Blog::Engine.load_seed
+ EOH
+ end
+ end
+
+ end
+end
diff --git a/lib/refinery/blog.rb b/lib/refinery/blog.rb
new file mode 100644
index 0000000..326e36a
--- /dev/null
+++ b/lib/refinery/blog.rb
@@ -0,0 +1,35 @@
+require 'refinerycms-core'
+require 'filters_spam'
+require 'rails_autolink'
+
+module Refinery
+ autoload :BlogGenerator, 'generators/refinery/blog/blog_generator'
+
+ module Blog
+ require 'refinery/blog/engine' if defined?(Rails)
+
+ autoload :Version, 'refinery/blog/version'
+ autoload :Tab, 'refinery/blog/tabs'
+
+ class << self
+ attr_writer :root
+ attr_writer :tabs
+
+ def root
+ @root ||= Pathname.new(File.expand_path('../../', __FILE__))
+ end
+
+ def tabs
+ @tabs ||= []
+ end
+
+ def version
+ ::Refinery::Blog::Version.to_s
+ end
+
+ def factory_paths
+ @factory_paths ||= [ File.expand_path("../../spec/factories", __FILE__) ]
+ end
+ end
+ end
+end
diff --git a/lib/refinery/blog/engine.rb b/lib/refinery/blog/engine.rb
index f67d4ab..63b2793 100644
--- a/lib/refinery/blog/engine.rb
+++ b/lib/refinery/blog/engine.rb
@@ -1,23 +1,29 @@
+require 'refinerycms-blog'
+require 'rails'
+
module Refinery
module Blog
class Engine < Rails::Engine
- require 'rails_autolink'
-
- config.to_prepare do
- require 'refinery/blog/tabs'
- end
+ include Refinery::Engine
- initializer "init plugin", :after => :set_routes_reloader do |app|
+ isolate_namespace Refinery
+ engine_name :refinery_blog
+
+ initializer "register refinerycms_blog plugin", :after => :set_routes_reloader do |app|
Refinery::Plugin.register do |plugin|
plugin.pathname = root
plugin.name = "refinerycms_blog"
plugin.url = app.routes.url_helpers.refinery_admin_blog_posts_path
plugin.menu_match = /^\/refinery\/blog\/?(posts|comments|categories)?/
plugin.activity = {
- :class => Refinery::BlogPost
+ :class_name => :'refinery/blog_post'
}
end
end
+
+ config.after_initialize do
+ Refinery.register_engine(Refinery::Blog)
+ end
end
end
end
diff --git a/lib/refinery/blog/tabs.rb b/lib/refinery/blog/tabs.rb
index 083d50b..519b90e 100644
--- a/lib/refinery/blog/tabs.rb
+++ b/lib/refinery/blog/tabs.rb
@@ -1,11 +1,5 @@
module Refinery
- module Blog
- attr_accessor :tabs
-
- def self.tabs
- @tabs ||= []
- end
-
+ module Blog
class Tab
attr_accessor :name, :partial
@@ -18,11 +12,11 @@ module Refinery
raise "A tab MUST have a partial!: #{tab.inspect}" if tab.partial.blank?
end
- protected
+ protected
- def initialize
- ::Refinery::Blog.tabs << self # add me to the collection of registered page tabs
- end
+ def initialize
+ ::Refinery::Blog.tabs << self # add me to the collection of registered page tabs
+ end
end
end
end \ No newline at end of file
diff --git a/lib/refinerycms-blog.rb b/lib/refinerycms-blog.rb
index 135b3e1..e08f070 100644
--- a/lib/refinerycms-blog.rb
+++ b/lib/refinerycms-blog.rb
@@ -1,30 +1 @@
-require 'rubygems'
-require 'bundler'
-Bundler.require
-
-require 'filters_spam'
-require File.expand_path('../generators/blog_generator', __FILE__)
-
-module Refinery
- module Blog
- autoload :Version, 'refinery/blog/version'
- autoload :Tab, 'refinery/blog/tabs'
-
- class << self
- attr_accessor :root
- def root
- @root ||= Pathname.new(File.expand_path('../../', __FILE__))
- end
-
- def version
- ::Refinery::Blog::Version.to_s
- end
-
- def factory_paths
- @factory_paths ||= [ File.expand_path("../../spec/factories", __FILE__) ]
- end
- end
- end
-end
-
-require 'refinery/blog/engine' if defined?(Rails)
+require 'refinery/blog'