Skip to content

Commit

Permalink
Remove one more place where core knows about pages and move it to pag…
Browse files Browse the repository at this point in the history
…es instead.
  • Loading branch information
parndt committed Apr 1, 2011
1 parent 3788269 commit 4562f4d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
22 changes: 4 additions & 18 deletions core/lib/refinery/admin/base_controller.rb
Expand Up @@ -31,24 +31,10 @@ def searching?
end

def error_404(exception=nil)
if (@page = Page.find_by_menu_match("^/404$", :include => [:parts, :slugs])).present?
params[:action] = 'error_404'
# change any links in the copy to the admin_root_path
# and any references to "home page" to "Dashboard"
part_symbol = Page.default_parts.first.to_sym
@page[part_symbol] = @page[part_symbol].to_s.gsub(
/href=(\'|\")\/(\'|\")/, "href='#{admin_root_path}'"
).gsub("home page", "Dashboard")

render :template => "/pages/show",
:layout => layout?,
:status => 404
else
# fallback to the default 404.html page.
render :file => Rails.root.join("public", "404.html").cleanpath.to_s,
:layout => false,
:status => 404
end
# fallback to the default 404.html page.
render :file => Rails.root.join("public", "404.html").cleanpath.to_s,
:layout => false,
:status => 404
end

protected
Expand Down
27 changes: 27 additions & 0 deletions pages/lib/refinery/pages/admin/instance_methods.rb
@@ -0,0 +1,27 @@
module Refinery
module Pages
module Admin
module InstanceMethods

def error_404(exception=nil)
if (@page = Page.find_by_menu_match("^/404$", :include => [:parts, :slugs])).present?
params[:action] = 'error_404'
# change any links in the copy to the admin_root_path
# and any references to "home page" to "Dashboard"
part_symbol = Page.default_parts.first.to_sym
@page[part_symbol] = @page[part_symbol].to_s.gsub(
/href=(\'|\")\/(\'|\")/, "href='#{admin_root_path}'"
).gsub("home page", "Dashboard")

render :template => "/pages/show",
:layout => layout?,
:status => 404
else
super
end
end

end
end
end
end
4 changes: 4 additions & 0 deletions pages/lib/refinerycms-pages.rb
Expand Up @@ -7,6 +7,9 @@ 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__)
end

class << self
attr_accessor :root
Expand All @@ -26,6 +29,7 @@ class Engine < ::Rails::Engine

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

config.after_initialize do
Expand Down
4 changes: 3 additions & 1 deletion pages/refinerycms-pages.gemspec
Expand Up @@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.version = %q{0.9.9.15}
s.summary = %q{Pages engine for Refinery CMS}
s.description = %q{The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.}
s.date = %q{2011-04-01}
s.date = %q{2011-04-02}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
s.rubyforge_project = %q{refinerycms}
Expand Down Expand Up @@ -106,6 +106,8 @@ Gem::Specification.new do |s|
'lib/pages/tabs.rb',
'lib/refinery',
'lib/refinery/pages',
'lib/refinery/pages/admin',
'lib/refinery/pages/admin/instance_methods.rb',
'lib/refinery/pages/instance_methods.rb',
'lib/refinerycms-pages.rb',
'license.md',
Expand Down

0 comments on commit 4562f4d

Please sign in to comment.