diff options
author | James Thompson <james.b.thompson@gmail.com> | 2012-03-14 11:40:16 +0200 |
---|---|---|
committer | James Thompson <james.b.thompson@gmail.com> | 2012-03-14 11:40:16 +0200 |
commit | 56d7747f54e86993415b76c92e101608e5ea44e2 (patch) | |
tree | 025b7b37f50c4c291e7e676286e7767c40adb1f9 /lib | |
download | refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.gz refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.tar.bz2 refinerycms-pc_banners-56d7747f54e86993415b76c92e101608e5ea44e2.zip |
initial commit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/generators/refinery/banners_generator.rb | 18 | ||||
-rw-r--r-- | lib/page_extensions.rb | 17 | ||||
-rw-r--r-- | lib/refinery/banners.rb | 21 | ||||
-rw-r--r-- | lib/refinery/banners/engine.rb | 32 | ||||
-rw-r--r-- | lib/refinerycms-pc_banners.rb | 1 | ||||
-rw-r--r-- | lib/tasks/refinery/banners.rake | 13 |
6 files changed, 102 insertions, 0 deletions
diff --git a/lib/generators/refinery/banners_generator.rb b/lib/generators/refinery/banners_generator.rb new file mode 100644 index 0000000..f799d9d --- /dev/null +++ b/lib/generators/refinery/banners_generator.rb @@ -0,0 +1,18 @@ +module Refinery + class BannersGenerator < Rails::Generators::Base + + def rake_db + rake("refinery_banners:install:migrations") + end + + def append_load_seed_data + create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb')) + append_file 'db/seeds.rb', :verbose => true do + <<-EOH + +Refinery::Banners::Engine.load_seed + EOH + end + end + end +end diff --git a/lib/page_extensions.rb b/lib/page_extensions.rb new file mode 100644 index 0000000..973c177 --- /dev/null +++ b/lib/page_extensions.rb @@ -0,0 +1,17 @@ +module Refinery + module Banners + module Extensions + module Page + module ClassMethods + def add_banners_relationship + has_and_belongs_to_many :banners, :class_name => '::Refinery::Banners::Banner', :join_table => 'refinery_banners_pages' + end + end + + def self.included(base) + base.extend(ClassMethods).add_banners_relationship + end + end + end + end +end
\ No newline at end of file diff --git a/lib/refinery/banners.rb b/lib/refinery/banners.rb new file mode 100644 index 0000000..0004091 --- /dev/null +++ b/lib/refinery/banners.rb @@ -0,0 +1,21 @@ +require 'refinerycms-core' + +module Refinery + autoload :BannersGenerator, 'generators/refinery/banners_generator' + + module Banners + require 'refinery/banners/engine' + + class << self + attr_writer :root + + def root + @root ||= Pathname.new(File.expand_path('../../../', __FILE__)) + end + + def factory_paths + @factory_paths ||= [ root.join('spec', 'factories').to_s ] + end + end + end +end diff --git a/lib/refinery/banners/engine.rb b/lib/refinery/banners/engine.rb new file mode 100644 index 0000000..0299bb8 --- /dev/null +++ b/lib/refinery/banners/engine.rb @@ -0,0 +1,32 @@ +module Refinery + module Banners + class Engine < Rails::Engine + include Refinery::Engine + isolate_namespace Refinery::Banners + + engine_name :refinery_banners + + initializer "register refinerycms_banners plugin" do + Refinery::Plugin.register do |plugin| + plugin.name = "banners" + plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.banners_admin_banners_path } + plugin.pathname = root + plugin.activity = { + :class_name => :'refinery/banners/banner', + :title => 'name' + } + + end + end + + config.to_prepare do + require 'page_extensions' + Refinery::Page.send :include, Refinery::Banners::Extensions::Page + end + + config.after_initialize do + Refinery.register_extension(Refinery::Banners) + end + end + end +end diff --git a/lib/refinerycms-pc_banners.rb b/lib/refinerycms-pc_banners.rb new file mode 100644 index 0000000..01a5409 --- /dev/null +++ b/lib/refinerycms-pc_banners.rb @@ -0,0 +1 @@ +require 'refinery/banners'
\ No newline at end of file diff --git a/lib/tasks/refinery/banners.rake b/lib/tasks/refinery/banners.rake new file mode 100644 index 0000000..b82fb87 --- /dev/null +++ b/lib/tasks/refinery/banners.rake @@ -0,0 +1,13 @@ +namespace :refinery do + + namespace :banners do + + # call this task by running: rake refinery:banners:my_task + # desc "Description of my task below" + # task :my_task => :environment do + # # add your logic here + # end + + end + +end
\ No newline at end of file |