Skip to content

Commit 88ce0bd

Browse files
committed
Initial crack at getting Refinery to be module based and only activated when included.
1 parent 30e41eb commit 88ce0bd

File tree

28 files changed

+84
-70
lines changed

28 files changed

+84
-70
lines changed

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
require File.expand_path('../config/application', __FILE__)
55
require 'rake'
66

7-
Refinery::Application.load_tasks
7+
RefineryApp::Application.load_tasks
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Filters added to this controller apply to all controllers in the application.
22
# Likewise, all the methods added will be available for all controllers.
33

4-
# You can extend refinery with your own functions here and they will likely not get overriden in an update.
5-
64
class ApplicationController < ActionController::Base
7-
include Refinery::ApplicationController
85

96
end

app/helpers/application_helper.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Methods added to this helper will be available to all templates in the application.
22

3-
# You can extend refinery with your own functions here and they will likely not get overriden in an update.
43
module ApplicationHelper
5-
include Refinery::ApplicationHelper # leave this line in to include all of Refinery's core helper methods.
64

75
end

config.ru

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# This file is used by Rack-based servers to start the application.
22

33
require ::File.expand_path('../config/environment', __FILE__)
4-
run Refinery::Application
4+
run RefineryApp::Application

config/application.rb

+5-23
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
# you've limited to :test, :development, or :production.
77
Bundler.require(:default, Rails.env) if defined?(Bundler)
88

9-
module Refinery
9+
module RefineryApp
1010
class Application < Rails::Application
11+
# Includes Refinery's application
12+
include ::Refinery::Application
13+
1114
# Settings in config/environments/* take precedence over those specified here.
1215
# Application configuration should go into files in config/initializers
1316
# -- all .rb files in that directory are automatically loaded.
@@ -25,26 +28,5 @@ class Application < Rails::Application
2528
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
2629
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
2730
# config.time_zone = 'Central Time (US & Canada)'
28-
29-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30-
config.i18n.load_path += Dir[Refinery.root.join('vendor', 'refinerycms', '*/config/locales/*.{rb,yml}').to_s]
31-
# config.i18n.default_locale = :de
32-
33-
# JavaScript files you want as :defaults (application.js is always included).
34-
config.action_view.javascript_expansions[:defaults] = %w()
35-
36-
# Configure the default encoding used in templates for Ruby 1.9.
37-
config.encoding = "utf-8"
38-
39-
# Configure sensitive parameters which will be filtered from the log file.
40-
config.filter_parameters += [:password, :password_confirmation]
41-
42-
# Specify a cache store to use
43-
config.cache_store = :memory_store
44-
45-
# load in any settings that the developer wants after the initialization.
46-
config.after_initialize do
47-
require Rails.root.join('config', 'settings.rb')
48-
end if Rails.root.join('config', 'settings.rb').exist?
4931
end
50-
end
32+
end

config/environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
require File.expand_path('../application', __FILE__)
33

44
# Initialize the rails application
5-
Refinery::Application.initialize!
5+
RefineryApp::Application.initialize!

config/environments/development.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.configure do
1+
RefineryApp::Application.configure do
22
# Settings specified here will take precedence over those in config/environment.rb
33

44
# In the development environment your application's code is reloaded on

config/environments/production.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.configure do
1+
RefineryApp::Application.configure do
22
# Settings specified here will take precedence over those in config/environment.rb
33

44
# The production environment is meant for finished, "live" apps.

config/environments/test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.configure do
1+
RefineryApp::Application.configure do
22
# Settings specified here will take precedence over those in config/environment.rb
33

44
# The test environment is used exclusively to run your application's

config/initializers/secret_token.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# If you change this key, all old signed cookies will become invalid!
55
# Make sure the secret is at least 30 characters and all random,
66
# no regular words or you'll be exposed to dictionary attacks.
7-
Refinery::Application.config.secret_token = 'a87f3b2cd301eab5bfd6b21288123b0a76fc604844f73e2eeca7dd6936330d86e2b057ee91304b9b4244eb1aed83eaef882194983abdcfb0b75ba3714708e668'
7+
::Refinery::Application.config.secret_token = 'a87f3b2cd301eab5bfd6b21288123b0a76fc604844f73e2eeca7dd6936330d86e2b057ee91304b9b4244eb1aed83eaef882194983abdcfb0b75ba3714708e668'

config/initializers/session_store.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Be sure to restart your server when you modify this file.
22

3-
Refinery::Application.config.session_store :cookie_store, :key => '_rails_Refinery_session'
3+
::Refinery::Application.config.session_store :cookie_store, :key => '_rails_Refinery_session'
44

55
# Use the database for sessions instead of the cookie-based default,
66
# which shouldn't be used to store highly confidential information
77
# (create the session table with "rake db:sessions:create")
8-
# Refinery::Application.config.session_store :active_record_store
8+
# ::Refinery::Application.config.session_store :active_record_store

config/routes.rb

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
Refinery::Application.routes.draw do
2-
3-
# REFINERY CMS ================================================================
4-
5-
filter(:refinery_locales) if defined?(RoutingFilter::RefineryLocales) # optionally use i18n.
6-
7-
root :to => 'pages#home'
8-
9-
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
10-
root :to => 'dashboard#index'
11-
end
12-
13-
# Marketable URLs should be appended to routes by the Pages Engine.
14-
# Catch all routes should be appended to routes by the Core Engine.
15-
16-
# END REFINERY CMS ============================================================
1+
::RefineryApp::Application.routes.draw do
172

183
# The priority is based upon order of creation:
194
# first created -> highest priority.

refinerycms.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ Gem::Specification.new do |s|
268268
'vendor/refinerycms/core/lib/refinery',
269269
'vendor/refinerycms/core/lib/refinery/activity.rb',
270270
'vendor/refinerycms/core/lib/refinery/admin_base_controller.rb',
271+
'vendor/refinerycms/core/lib/refinery/application.rb',
271272
'vendor/refinerycms/core/lib/refinery/application_controller.rb',
272273
'vendor/refinerycms/core/lib/refinery/application_helper.rb',
273274
'vendor/refinerycms/core/lib/refinery/base_presenter.rb',

vendor/refinerycms/authentication/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22

33
resource :session, :only => [:new, :create, :destroy]
44
match '/users/reset/:reset_code', :to => 'users#reset', :as => 'reset_users'

vendor/refinerycms/authentication/features/lost_password.feature

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Feature: Lost Password
3636
When I go to the reset password page
3737
And I fill in "Password" with "cukes"
3838
And I fill in "Password confirmation" with "cukes"
39+
Then show me the page
3940
And I press "Reset password"
41+
Then show me the page
4042
Then I should be on the admin root
4143
And I should see "Password reset successfully for"
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Given /^I have a user with email "(.*)"$/ do |email|
2-
Factory(:user, :email => email)
2+
Factory(:refinery_user, :email => email)
33
end
44

55
Given /^I am (not )?requesting password reset$/ do |action|
6-
@user = Factory(:user, :updated_at => 11.minutes.ago)
6+
@user = Factory(:refinery_user, :updated_at => 11.minutes.ago)
77
@user.reset_perishable_token! if action.nil?
88
end

vendor/refinerycms/core/app/views/admin/_head.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
end
1818
-%>
1919
<head>
20-
<meta charset='<%= Refinery::Application.config.encoding %>' />
20+
<meta charset='<%= ::Refinery::Application.config.encoding %>' />
2121
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
2222
<%= yield :meta %>
2323
<title><%= RefinerySetting.find_or_set(:site_name, 'Company Name') -%> - Refinery</title>

vendor/refinerycms/core/app/views/wymiframe.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>WYMeditor</title>
5-
<meta charset='<%= Refinery::Application.config.encoding %>' />
5+
<meta charset='<%= ::Refinery::Application.config.encoding %>' />
66
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
77
<%= stylesheet_link_tag "wymeditor/skins/refinery/wymiframe", :media => "all" %>
88
<%= stylesheet_link_tag "refinery/formatting", :media => "all" if RefinerySetting.find_or_set(:frontend_refinery_stylesheets_enabled, true) %>
+9-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
2+
filter(:refinery_locales) if defined?(RoutingFilter::RefineryLocales) # optionally use i18n.
3+
4+
root :to => 'pages#home'
25

36
match 'wymiframe(/:id)', :to => 'refinery/fast#wymiframe', :as => :wymiframe
47

58
# TODO: is this needed or it can be removed?
69
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
710
resources :refinery_core
11+
root :to => 'dashboard#index'
12+
resources :dialogs, :only => :show
813
end
914

1015
match '/refinery/update_menu_positions', :to => 'admin/refinery_core#update_plugin_positions'
11-
12-
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
13-
resources :dialogs, :only => :show
14-
end
16+
17+
# Marketable URLs should be appended to routes by the Pages Engine.
18+
# Catch all routes should be appended to routes by the Core Engine.
1519
end

vendor/refinerycms/core/lib/core.rb

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
require 'rails/generators/migration'
1212

1313
module Refinery
14+
15+
autoload :Application, File.expand_path('../refinery/application', __FILE__)
1416
autoload :Plugin, File.expand_path('../refinery/plugin', __FILE__)
1517
autoload :Plugins, File.expand_path('../refinery/plugins', __FILE__)
1618
autoload :Activity, File.expand_path('../refinery/activity', __FILE__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module Refinery
2+
module Application
3+
def self.included(base)
4+
self.instance_eval %(
5+
def self.method_missing(method_sym, *arguments, &block)
6+
#{base}.send(method_sym)
7+
end
8+
)
9+
10+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
11+
base.config.i18n.load_path += Dir[Refinery.root.join('vendor', 'refinerycms', '*/config/locales/*.{rb,yml}').to_s]
12+
# config.i18n.default_locale = :de
13+
14+
# JavaScript files you want as :defaults (application.js is always included).
15+
base.config.action_view.javascript_expansions[:defaults] = %w()
16+
17+
# Configure the default encoding used in templates for Ruby 1.9.
18+
base.config.encoding = "utf-8"
19+
20+
# Configure sensitive parameters which will be filtered from the log file.
21+
base.config.filter_parameters += [:password, :password_confirmation]
22+
23+
# Specify a cache store to use
24+
base.config.cache_store = :memory_store
25+
26+
# Extend the application controller
27+
base.config.to_prepare do
28+
::ApplicationController.instance_eval do
29+
include ::Refinery::ApplicationController
30+
end if defined?(::ApplicationController)
31+
32+
::ApplicationHelper.instance_eval do
33+
include ::Refinery::ApplicationHelper
34+
end if defined?(::ApplicationHelper)
35+
end
36+
37+
# load in any settings that the developer wants after the initialization.
38+
base.config.after_initialize do
39+
require Rails.root.join('config', 'settings.rb')
40+
end if Rails.root.join('config', 'settings.rb').exist?
41+
end
42+
end
43+
end

vendor/refinerycms/core/lib/refinery/catch_all_routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22
match '/admin(/*path)', :to => redirect {|params, request|
33
request.flash[:message] = "<p>
44
The URL '/<strong>admin</strong>#{"/#{params[:path]}" unless params[:path].blank?}' will be removed in Refinery CMS version 1.0

vendor/refinerycms/dashboard/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
33
match 'dashboard',
44
:to => 'dashboard#index',

vendor/refinerycms/images/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
33
resources :images, :except => :show do
44
collection do

vendor/refinerycms/pages/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22
get '/pages/:id', :to => 'pages#show', :as => :page
33

44
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22
match '*path' => 'pages#show'
33
end

vendor/refinerycms/resources/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22

33
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
44
resources :resources, :except => :show do

vendor/refinerycms/settings/config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Refinery::Application.routes.draw do
1+
::Refinery::Application.routes.draw do
22
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
33
resources :settings,
44
:except => :show,

0 commit comments

Comments
 (0)