From 993b4a8b1b8a994ad09f5d5be9cd2fdc7b44669c Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Wed, 26 Oct 2011 13:24:15 -0700 Subject: Update engine definition Isolate engine to Refinery add engine name Add initializer to register engine with Refinery Rename plugin init initializer to be more descriptive Update plugin initializer to conform to latest master of RefineryCMS --- lib/refinery/blog/engine.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/refinery/blog/engine.rb b/lib/refinery/blog/engine.rb index f67d4ab..b335dbc 100644 --- a/lib/refinery/blog/engine.rb +++ b/lib/refinery/blog/engine.rb @@ -1,23 +1,32 @@ +require 'rails_autolink' + module Refinery module Blog class Engine < Rails::Engine - require 'rails_autolink' + include Refinery::Engine + + isolate_namespace Refinery + engine_name :refinery_resources config.to_prepare do require 'refinery/blog/tabs' end - initializer "init plugin", :after => :set_routes_reloader do |app| + 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 -- cgit v1.2.3 From 8cd4a282d8f1173f4d8df496c2dd2b61ad892292 Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Thu, 27 Oct 2011 15:29:02 -0700 Subject: This is the blog engine... not hte resources engine.. --- lib/refinery/blog/engine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/refinery/blog/engine.rb b/lib/refinery/blog/engine.rb index b335dbc..8ca1f0a 100644 --- a/lib/refinery/blog/engine.rb +++ b/lib/refinery/blog/engine.rb @@ -6,7 +6,7 @@ module Refinery include Refinery::Engine isolate_namespace Refinery - engine_name :refinery_resources + engine_name :refinery_blog config.to_prepare do require 'refinery/blog/tabs' -- cgit v1.2.3 From 5a958007c5c4b3ef4af001464d75c4c00adfe870 Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Thu, 27 Oct 2011 18:12:32 -0700 Subject: Update blog generator to use Rails 3.1 base Seeds will now follow Rails 3.1 conventions --- lib/generators/blog_generator.rb | 10 ---------- lib/generators/refinery/blog/blog_generator.rb | 16 ++++++++++++++++ lib/refinerycms-blog.rb | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) delete mode 100644 lib/generators/blog_generator.rb create mode 100644 lib/generators/refinery/blog/blog_generator.rb (limited to 'lib') 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/refinerycms-blog.rb b/lib/refinerycms-blog.rb index 135b3e1..88b8afc 100644 --- a/lib/refinerycms-blog.rb +++ b/lib/refinerycms-blog.rb @@ -3,9 +3,10 @@ require 'bundler' Bundler.require require 'filters_spam' -require File.expand_path('../generators/blog_generator', __FILE__) module Refinery + autoload :BlogGenerator, 'generators/refinery/blog/blog_generator' + module Blog autoload :Version, 'refinery/blog/version' autoload :Tab, 'refinery/blog/tabs' -- cgit v1.2.3 From 14daff297b2c3f2937ef6cf3e72b663903eec97a Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Thu, 27 Oct 2011 19:36:54 -0700 Subject: Refactor require layout to match other engines --- lib/refinery/blog.rb | 29 +++++++++++++++++++++++++++++ lib/refinery/blog/engine.rb | 3 ++- lib/refinerycms-blog.rb | 32 +------------------------------- 3 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 lib/refinery/blog.rb (limited to 'lib') diff --git a/lib/refinery/blog.rb b/lib/refinery/blog.rb new file mode 100644 index 0000000..af39967 --- /dev/null +++ b/lib/refinery/blog.rb @@ -0,0 +1,29 @@ +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_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 diff --git a/lib/refinery/blog/engine.rb b/lib/refinery/blog/engine.rb index 8ca1f0a..078b97f 100644 --- a/lib/refinery/blog/engine.rb +++ b/lib/refinery/blog/engine.rb @@ -1,4 +1,5 @@ -require 'rails_autolink' +require 'refinerycms-blog' +require 'rails' module Refinery module Blog diff --git a/lib/refinerycms-blog.rb b/lib/refinerycms-blog.rb index 88b8afc..e08f070 100644 --- a/lib/refinerycms-blog.rb +++ b/lib/refinerycms-blog.rb @@ -1,31 +1 @@ -require 'rubygems' -require 'bundler' -Bundler.require - -require 'filters_spam' - -module Refinery - autoload :BlogGenerator, 'generators/refinery/blog/blog_generator' - - 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' -- cgit v1.2.3 From e01e9ff9b72e7ea2a2dbb03f04169d54dbe60fdf Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Thu, 27 Oct 2011 19:37:38 -0700 Subject: Tabs are autoloaded, don't need to explicitly require --- lib/refinery/blog/engine.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib') diff --git a/lib/refinery/blog/engine.rb b/lib/refinery/blog/engine.rb index 078b97f..63b2793 100644 --- a/lib/refinery/blog/engine.rb +++ b/lib/refinery/blog/engine.rb @@ -8,10 +8,6 @@ module Refinery isolate_namespace Refinery engine_name :refinery_blog - - config.to_prepare do - require 'refinery/blog/tabs' - end initializer "register refinerycms_blog plugin", :after => :set_routes_reloader do |app| Refinery::Plugin.register do |plugin| -- cgit v1.2.3 From 3165574730abe9515061e07fbc43433a2e4a50ad Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Fri, 28 Oct 2011 12:14:03 -0700 Subject: Move blog tab accessor and class array to blog file from tab file --- lib/refinery/blog.rb | 8 +++++++- lib/refinery/blog/tabs.rb | 16 +++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/refinery/blog.rb b/lib/refinery/blog.rb index af39967..326e36a 100644 --- a/lib/refinery/blog.rb +++ b/lib/refinery/blog.rb @@ -12,10 +12,16 @@ module Refinery autoload :Tab, 'refinery/blog/tabs' class << self - attr_accessor :root + 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 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 -- cgit v1.2.3