Skip to content

Commit

Permalink
refactor pages/engine class into it's own file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Winsor committed Sep 8, 2011
1 parent be92877 commit b24b591
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
42 changes: 42 additions & 0 deletions pages/lib/refinery/pages/engine.rb
@@ -0,0 +1,42 @@
module Refinery
module Pages
class Engine < ::Rails::Engine
isolate_namespace ::Refinery

config.before_initialize do
require 'pages/marketable_urls'
end

config.to_prepare do
require 'pages/tabs'
require 'pages/marketable_urls'
::Refinery::Page.translation_class.send(:is_seo_meta)
# set allowed attributes for mass assignment
::Refinery::Page.translation_class.send(:attr_accessible, :browser_title, :meta_description, :meta_keywords, :locale)
end

refinery.after_inclusion do
::ApplicationController.send :include, ::Refinery::Pages::InstanceMethods
::Refinery::AdminController.send :include, ::Refinery::Pages::Admin::InstanceMethods
end

initializer "init plugin", :after => :set_routes_reloader do |app|
::Refinery::Plugin.register do |plugin|
plugin.pathname = root
plugin.name = 'refinery_pages'
plugin.directory = 'pages'
plugin.version = %q{2.0.0}
plugin.menu_match = /refinery\/page(_part)?s(_dialogs)?$/
plugin.url = app.routes.url_helpers.refinery_admin_pages_path
plugin.activity = {
:class => ::Refinery::Page,
:url_prefix => "edit",
:title => "title",
:created_image => "page_add.png",
:updated_image => "page_edit.png"
}
end
end
end
end
end
49 changes: 5 additions & 44 deletions pages/lib/refinerycms-pages.rb
Expand Up @@ -7,11 +7,11 @@

module Refinery
module Pages

autoload :InstanceMethods, File.expand_path('../refinery/pages/instance_methods', __FILE__)
module Admin
autoload :InstanceMethods, File.expand_path('../refinery/pages/admin/instance_methods', __FILE__)
autoload :InstanceMethods, 'refinery/pages/admin/instance_methods'
end

autoload :InstanceMethods, 'refinery/pages/instance_methods'

class << self
attr_accessor :root
Expand All @@ -24,50 +24,11 @@ def use_marketable_urls?
end

def use_marketable_urls=(value)
::Refinery::Setting.set(:use_marketable_urls, {:value => value, :scoping => 'pages'})
end
end

class Engine < ::Rails::Engine
isolate_namespace ::Refinery

config.before_initialize do
require File.expand_path('../pages/marketable_urls', __FILE__)
end

config.to_prepare do
require File.expand_path('../pages/tabs', __FILE__)
require File.expand_path('../pages/marketable_urls', __FILE__)
::Refinery::Page.translation_class.send(:is_seo_meta)
# set allowed attributes for mass assignment
::Refinery::Page.translation_class.send :attr_accessible, :browser_title, :meta_description, :meta_keywords, :locale
end

refinery.after_inclusion do
::ApplicationController.send :include, ::Refinery::Pages::InstanceMethods
::Refinery::AdminController.send :include, ::Refinery::Pages::Admin::InstanceMethods
::Refinery::Setting.set(:use_marketable_urls, :value => value, :scoping => 'pages')
end

initializer "init plugin", :after => :set_routes_reloader do |app|
::Refinery::Plugin.register do |plugin|
plugin.pathname = root
plugin.name = 'refinery_pages'
plugin.directory = 'pages'
plugin.version = %q{2.0.0}
plugin.menu_match = /refinery\/page(_part)?s(_dialogs)?$/
plugin.url = app.routes.url_helpers.refinery_admin_pages_path
plugin.activity = {
:class => ::Refinery::Page,
:url_prefix => "edit",
:title => "title",
:created_image => "page_add.png",
:updated_image => "page_edit.png"
}
end
end

end
end
end

require 'refinery/pages/engine'
::Refinery.engines << 'pages'

0 comments on commit b24b591

Please sign in to comment.