parlement 0.10 → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +11 -0
- data/MEMORY +9 -1
- data/README +5 -4
- data/app/controllers/account_controller.rb +10 -13
- data/app/controllers/application.rb +4 -5
- data/app/controllers/elt_controller.rb +9 -7
- data/app/controllers/person_controller.rb +1 -3
- data/app/controllers/subscriber_controller.rb +10 -10
- data/app/helpers/elt_helper.rb +2 -0
- data/app/models/elt.rb +28 -19
- data/app/models/mail.rb +26 -14
- data/app/models/mail_notify.rb +5 -4
- data/app/models/person.rb +11 -2
- data/app/views/account/_login.rhtml +3 -3
- data/app/views/account/_show.rhtml +12 -14
- data/app/views/elt/_choice.rhtml +3 -3
- data/app/views/elt/_elt.rhtml +4 -4
- data/app/views/elt/_list.rhtml +2 -2
- data/app/views/elt/_listByDate.rhtml +1 -1
- data/app/views/elt/_listByVote.rhtml +1 -1
- data/app/views/elt/new.rhtml +3 -3
- data/app/views/elt/show.rhtml +2 -2
- data/app/views/layouts/top.rhtml +6 -0
- data/app/views/mail_notify/publish.text.html.rhtml +1 -1
- data/app/views/person/_listElts.rhtml +5 -3
- data/app/views/person/show.rhtml +1 -2
- data/config/boot.rb +5 -4
- data/config/environment.rb +6 -4
- data/config/routes.rb +3 -2
- data/db/development_structure.sql +15 -4
- data/db/migrate/006_last_activity.rb +10 -0
- data/db/schema.rb +67 -49
- data/public/dispatch.fcgi +1 -0
- data/public/javascripts/controls.js +41 -23
- data/public/javascripts/dragdrop.js +317 -99
- data/public/javascripts/effects.js +301 -166
- data/public/javascripts/prototype.js +932 -402
- data/public/stylesheets/default.css +3 -2
- data/test/unit/elt_test.rb +13 -0
- data/test/unit/mail_test.rb +3 -1
- data/vendor/plugins/engines/CHANGELOG +203 -99
- data/vendor/plugins/engines/MIT-LICENSE +1 -1
- data/vendor/plugins/engines/README +32 -384
- data/vendor/plugins/engines/Rakefile +14 -0
- data/vendor/plugins/engines/UPGRADING +93 -0
- data/vendor/plugins/engines/about.yml +7 -0
- data/vendor/plugins/engines/generators/plugin_migration/USAGE +45 -0
- data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +79 -0
- data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +13 -0
- data/vendor/plugins/engines/init.rb +34 -47
- data/vendor/plugins/engines/install.rb +32 -0
- data/vendor/plugins/engines/lib/engines/{ruby_extensions.rb → deprecated_config_support.rb} +135 -113
- data/vendor/plugins/engines/lib/engines/plugin.rb +214 -0
- data/vendor/plugins/engines/lib/engines/plugin_list.rb +31 -0
- data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +60 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +19 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +143 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +155 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +116 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +20 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +86 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +77 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +140 -0
- data/vendor/plugins/engines/lib/engines/rails_extensions.rb +6 -0
- data/vendor/plugins/engines/lib/engines/testing.rb +88 -0
- data/vendor/plugins/engines/lib/engines.rb +281 -425
- data/vendor/plugins/engines/tasks/engines.rake +108 -137
- metadata +218 -250
- data/db/ROOT/perso.txt +0 -214
- data/public/images/indicator.gif +0 -0
- data/public/images/orange_by_darren_Hester_350o.jpg +0 -0
- data/public/images/smile.png +0 -0
- data/vendor/plugins/engines/generators/engine/USAGE +0 -26
- data/vendor/plugins/engines/generators/engine/engine_generator.rb +0 -199
- data/vendor/plugins/engines/generators/engine/templates/README +0 -85
- data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +0 -15
- data/vendor/plugins/engines/generators/engine/templates/install.erb +0 -4
- data/vendor/plugins/engines/generators/engine/templates/lib/engine.erb +0 -6
- data/vendor/plugins/engines/generators/engine/templates/licenses/GPL +0 -18
- data/vendor/plugins/engines/generators/engine/templates/licenses/LGPL +0 -19
- data/vendor/plugins/engines/generators/engine/templates/licenses/MIT +0 -22
- data/vendor/plugins/engines/generators/engine/templates/licenses/None +0 -1
- data/vendor/plugins/engines/generators/engine/templates/public/javascripts/engine.js +0 -0
- data/vendor/plugins/engines/generators/engine/templates/public/stylesheets/engine.css +0 -0
- data/vendor/plugins/engines/generators/engine/templates/tasks/engine.rake +0 -0
- data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +0 -17
- data/vendor/plugins/engines/lib/bundles/require_resource.rb +0 -124
- data/vendor/plugins/engines/lib/bundles.rb +0 -77
- data/vendor/plugins/engines/lib/engines/action_mailer_extensions.rb +0 -140
- data/vendor/plugins/engines/lib/engines/action_view_extensions.rb +0 -141
- data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +0 -21
- data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +0 -129
- data/vendor/plugins/engines/lib/engines/migration_extensions.rb +0 -53
- data/vendor/plugins/engines/lib/engines/routing_extensions.rb +0 -28
- data/vendor/plugins/engines/lib/engines/testing_extensions.rb +0 -327
- data/vendor/plugins/engines/tasks/deprecated_engines.rake +0 -7
- data/vendor/plugins/engines/test/action_view_extensions_test.rb +0 -9
- data/vendor/plugins/engines/test/ruby_extensions_test.rb +0 -115
- data/vendor/plugins/guid/README.TXT +0 -29
- data/vendor/plugins/guid/init.rb +0 -30
- data/vendor/plugins/guid/lib/usesguid.rb +0 -37
- data/vendor/plugins/guid/lib/uuid22.rb +0 -43
- data/vendor/plugins/guid/lib/uuidtools.rb +0 -572
- data/vendor/plugins/responds_to_parent/MIT-LICENSE +0 -20
- data/vendor/plugins/responds_to_parent/README +0 -42
- data/vendor/plugins/responds_to_parent/Rakefile +0 -22
- data/vendor/plugins/responds_to_parent/init.rb +0 -1
- data/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb +0 -46
- data/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb +0 -115
@@ -1,124 +0,0 @@
|
|
1
|
-
# RequireResource v.1.4 by Duane Johnson
|
2
|
-
#
|
3
|
-
# Makes inclusion of javascript and stylesheet resources easier via automatic or explicit
|
4
|
-
# calls. e.g. require_javascript 'popup' is an explicit call.
|
5
|
-
#
|
6
|
-
# The simplest way to make use of this functionality is to add
|
7
|
-
# <%= resource_tags %>
|
8
|
-
# to your layout (usually in the <head></head> section). This will automatically add
|
9
|
-
# bundle support to your application, as well as enable simple javascript and stylesheet
|
10
|
-
# dependencies for your views.
|
11
|
-
#
|
12
|
-
# Note that this can easily be turned in to a helper on its own.
|
13
|
-
module RequireResource
|
14
|
-
mattr_accessor :path_prefix
|
15
|
-
|
16
|
-
# Write out all javascripts & stylesheets, including default javascripts (unless :defaults => false)
|
17
|
-
def resource_tags(options = {})
|
18
|
-
options = {:auto => true, :defaults => true}.update(options)
|
19
|
-
require_defaults if options[:defaults]
|
20
|
-
stylesheet_auto_link_tags(:auto => options[:auto]) +
|
21
|
-
javascript_auto_include_tags(:auto => options[:auto])
|
22
|
-
end
|
23
|
-
|
24
|
-
# Write out the <link> tags themselves based on the array of stylesheets to be included
|
25
|
-
def stylesheet_auto_link_tags(options = {})
|
26
|
-
options = {:auto => true}.update(options)
|
27
|
-
ensure_resource_is_initialized(:stylesheet)
|
28
|
-
autorequire(:stylesheet) if options[:auto]
|
29
|
-
@stylesheets.uniq.inject("") do |buffer, css|
|
30
|
-
buffer << stylesheet_link_tag(css) + "\n "
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Write out the <script> tags themselves based on the array of javascripts to be included
|
35
|
-
def javascript_auto_include_tags(options = {})
|
36
|
-
options = {:auto => true}.update(options)
|
37
|
-
ensure_resource_is_initialized(:javascript)
|
38
|
-
autorequire(:javascript) if options[:auto]
|
39
|
-
@javascripts.uniq.inject("") do |buffer, js|
|
40
|
-
buffer << javascript_include_tag(js) + "\n "
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Bundle the defaults together for easy inclusion
|
45
|
-
def require_defaults
|
46
|
-
require_javascript(:prototype)
|
47
|
-
require_javascript(:controls)
|
48
|
-
require_javascript(:effects)
|
49
|
-
require_javascript(:dragdrop)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Adds a javascript to the array of javascripts that will be included in the layout by
|
53
|
-
# either your call to 'javascript_auto_include_tags' or 'resource_tags'.
|
54
|
-
def require_javascript(*scripts)
|
55
|
-
scripts.each do |script|
|
56
|
-
require_resource(:javascript, RequireResource.path_prefix.to_s + script.to_s)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Adds a stylesheet to the array of stylesheets that will be included in the layout by
|
61
|
-
# either your call to 'stylesheet_auto_link_tags' or 'resource_tags'.
|
62
|
-
def require_stylesheet(*sheets)
|
63
|
-
sheets.each do |sheet|
|
64
|
-
require_resource(:stylesheet, RequireResource.path_prefix.to_s + sheet.to_s)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Changes the RequireResource.path_prefix within the scope of a block. This is
|
69
|
-
# particularly useful when requiring several resources within a directory. For example,
|
70
|
-
# bundles can take advantage of this by calling
|
71
|
-
# require_relative_to Engines.current.public_dir do
|
72
|
-
# require_javascript '...'
|
73
|
-
# require_stylesheet '...'
|
74
|
-
# # ...
|
75
|
-
# end
|
76
|
-
def require_relative_to(path)
|
77
|
-
former_prefix = RequireResource.path_prefix
|
78
|
-
RequireResource.path_prefix = path
|
79
|
-
yield
|
80
|
-
RequireResource.path_prefix = former_prefix
|
81
|
-
end
|
82
|
-
|
83
|
-
protected
|
84
|
-
# Adds resources such as stylesheet or javascript files to the corresponding array of
|
85
|
-
# resources that will be 'required' by the layout. The +resource_type+ is either
|
86
|
-
# :javascript or :stylesheet. The +extension+ is optional, and should normally correspond
|
87
|
-
# with the resource type, e.g. 'css' for :stylesheet and 'js' for :javascript.
|
88
|
-
def autorequire(resource_type, extension = nil)
|
89
|
-
extensions = {:stylesheet => 'css', :javascript => 'js'}
|
90
|
-
extension ||= extensions[resource_type]
|
91
|
-
candidates = []
|
92
|
-
class_iterator = controller.class
|
93
|
-
resource_path = "#{RAILS_ROOT}/public/#{resource_type.to_s.pluralize}/"
|
94
|
-
|
95
|
-
while ![ActionController::Base].include? class_iterator
|
96
|
-
controller_path = class_iterator.to_s.underscore.sub('controllers/', '').sub('_controller', '')
|
97
|
-
candidates |= [ "#{controller_path}", "#{controller_path}/#{controller.action_name}" ]
|
98
|
-
class_iterator = class_iterator.superclass
|
99
|
-
end
|
100
|
-
|
101
|
-
for candidate in candidates
|
102
|
-
if FileTest.exist?("#{resource_path}/#{candidate}.#{extension}")
|
103
|
-
require_resource(resource_type, candidate)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Adds a resource (e.g. a javascript) to the appropriate array (e.g. @javascripts)
|
109
|
-
# ONLY if the resource is not already included.
|
110
|
-
def require_resource(type, name)
|
111
|
-
variable = type.to_s.pluralize
|
112
|
-
new_resource_array = (instance_variable_get("@#{variable}") || []) | [name.to_s]
|
113
|
-
instance_variable_set("@#{variable}", new_resource_array)
|
114
|
-
end
|
115
|
-
|
116
|
-
# Ensures that a resource array (e.g. @javascripts) is not nil--uses [] if so
|
117
|
-
def ensure_resource_is_initialized(type)
|
118
|
-
variable = type.to_s.pluralize
|
119
|
-
new_resource_array = (instance_variable_get("@#{variable}") || [])
|
120
|
-
instance_variable_set("@#{variable}", new_resource_array)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
ActionView::Base.send(:include, RequireResource)
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'bundles/require_resource'
|
2
|
-
|
3
|
-
# The 'require_bundle' method is used in views to declare that certain stylesheets and javascripts should
|
4
|
-
# be included by the 'resource_tags' (used in the layout) for the view to function properly.
|
5
|
-
module Bundles
|
6
|
-
def require_bundle(name, *args)
|
7
|
-
method = "bundle_#{name}"
|
8
|
-
send(method, *args)
|
9
|
-
end
|
10
|
-
|
11
|
-
def require_bundles(*names)
|
12
|
-
names.each { |name| require_bundle(name) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
ActionView::Base.send(:include, Bundles)
|
17
|
-
|
18
|
-
# Registers a module within the Bundles module by renaming the module's 'bundle' method (so it doesn't
|
19
|
-
# clash with other methods named 'bundle') and by including any Controller or Helper modules within
|
20
|
-
# their respective Rails base classes.
|
21
|
-
#
|
22
|
-
# For example, if you have a module such as
|
23
|
-
# module Bundles::Calendar; end
|
24
|
-
#
|
25
|
-
# then within that Calendar module there *must* be a method named "bundle" which groups the
|
26
|
-
# bundle's resources together. Example:
|
27
|
-
# module Bundles::Calendar
|
28
|
-
# def bundle
|
29
|
-
# require_relative_to Engines.current.public_dir do
|
30
|
-
# require_stylesheet "/stylesheets/calendar.css"
|
31
|
-
# require_javascript "/javascripts/calendar.js"
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# You may optionally define a Controller or Helper sub-module if you need any methods available to
|
37
|
-
# the applications controllers or views. Example:
|
38
|
-
#
|
39
|
-
# module Bundles::Calendar
|
40
|
-
# module Helper
|
41
|
-
# def calendar_date_select(*args
|
42
|
-
# # ... output some HTML
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# The calendar_date_select method will now be available within the scope of the app's views because the
|
48
|
-
# register_bundle method will inject the Helper module's methods in to ActionView::Base for you.
|
49
|
-
#
|
50
|
-
# Similarly, you can make methods available to controllers by adding a Controller module.
|
51
|
-
def register_bundle(name)
|
52
|
-
require "bundles/#{name}"
|
53
|
-
|
54
|
-
# Rename the generic 'bundle' method in to something that doesn't conflict with
|
55
|
-
# the other module method names.
|
56
|
-
bundle_module = Bundles.const_get(name.to_s.camelize)
|
57
|
-
bundle_module.module_eval "alias bundle_#{name} bundle"
|
58
|
-
bundle_module.send :undef_method, :bundle
|
59
|
-
|
60
|
-
# Then include the bundle module in to the base module, so that the methods will
|
61
|
-
# be available inside ActionView::Base
|
62
|
-
ActionView::Base.send(:include, bundle_module)
|
63
|
-
|
64
|
-
# Check for optional Controller module
|
65
|
-
if bundle_module.const_defined? 'Controller'
|
66
|
-
controller_addon = bundle_module.const_get('Controller')
|
67
|
-
RAILS_DEFAULT_LOGGER.debug "Including #{name} bundle's Controller module"
|
68
|
-
ActionController::Base.send(:include, controller_addon)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Check for optional Helper module
|
72
|
-
if bundle_module.const_defined? 'Helper'
|
73
|
-
helper_addon = bundle_module.const_get('Helper')
|
74
|
-
RAILS_DEFAULT_LOGGER.debug "Including #{name} bundle's Helper module"
|
75
|
-
ActionView::Base.send(:include, helper_addon)
|
76
|
-
end
|
77
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
# Overriding ActionMailer to teach it about Engines...
|
2
|
-
module ActionMailer
|
3
|
-
class Base
|
4
|
-
|
5
|
-
# Initialize the mailer via the given +method_name+. The body will be
|
6
|
-
# rendered and a new TMail::Mail object created.
|
7
|
-
def old_create!(method_name, *parameters) #:nodoc:
|
8
|
-
initialize_defaults(method_name)
|
9
|
-
send(method_name, *parameters)
|
10
|
-
|
11
|
-
|
12
|
-
# If an explicit, textual body has not been set, we check assumptions.
|
13
|
-
unless String === @body
|
14
|
-
# First, we look to see if there are any likely templates that match,
|
15
|
-
# which include the content-type in their file name (i.e.,
|
16
|
-
# "the_template_file.text.html.rhtml", etc.). Only do this if parts
|
17
|
-
# have not already been specified manually.
|
18
|
-
|
19
|
-
templates = get_all_templates_for_action(@template)
|
20
|
-
|
21
|
-
#RAILS_DEFAULT_LOGGER.debug "template: #{@template}; templates: #{templates.inspect}"
|
22
|
-
|
23
|
-
if @parts.empty?
|
24
|
-
|
25
|
-
# /app/views/<mailer object name> / <action>.something.rhtml
|
26
|
-
|
27
|
-
#templates = Dir.glob("#{template_path}/#{@template}.*")
|
28
|
-
|
29
|
-
# this loop expects an array of paths to actual template files which match
|
30
|
-
# the given action name
|
31
|
-
templates.each do |path|
|
32
|
-
# TODO: don't hardcode rhtml|rxml
|
33
|
-
basename = File.basename(path)
|
34
|
-
next unless md = /^([^\.]+)\.([^\.]+\.[^\+]+)\.(rhtml|rxml)$/.match(basename)
|
35
|
-
|
36
|
-
template_name = basename
|
37
|
-
content_type = md.captures[1].gsub('.', '/')
|
38
|
-
|
39
|
-
@parts << Part.new(:content_type => content_type,
|
40
|
-
:disposition => "inline", :charset => charset,
|
41
|
-
:body => render_message(template_name, @body))
|
42
|
-
end
|
43
|
-
unless @parts.empty?
|
44
|
-
@content_type = "multipart/alternative"
|
45
|
-
@parts = sort_parts(@parts, @implicit_parts_order)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Then, if there were such templates, we check to see if we ought to
|
50
|
-
# also render a "normal" template (without the content type). If a
|
51
|
-
# normal template exists (or if there were no implicit parts) we render
|
52
|
-
# it.
|
53
|
-
template_exists = @parts.empty?
|
54
|
-
# template_exists ||= Dir.glob("#{template_path}/#{@template}.*").any? { |i| i.split(".").length == 2 }
|
55
|
-
template_exists ||= templates.any? do |i|
|
56
|
-
arr = File.basename(i).split(".")
|
57
|
-
(arr.length == 2) && (arr[0] == @template)
|
58
|
-
end
|
59
|
-
@body = render_message(@template, @body) if template_exists
|
60
|
-
|
61
|
-
# Finally, if there are other message parts and a textual body exists,
|
62
|
-
# we shift it onto the front of the parts and set the body to nil (so
|
63
|
-
# that create_mail doesn't try to render it in addition to the parts).
|
64
|
-
if !@parts.empty? && String === @body
|
65
|
-
@parts.unshift Part.new(:charset => charset, :body => @body)
|
66
|
-
@body = nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# If this is a multipart e-mail add the mime_version if it is not
|
71
|
-
# already set.
|
72
|
-
@mime_version ||= "1.0" if !@parts.empty?
|
73
|
-
|
74
|
-
# build the mail object itself
|
75
|
-
@mail = create_mail
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
|
81
|
-
# JGA - Modified to pass the method name to initialize_template_class
|
82
|
-
def render(opts)
|
83
|
-
body = opts.delete(:body)
|
84
|
-
initialize_template_class(body, opts[:file]).render(opts)
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
# Return all ActionView template paths from the app and all Engines
|
89
|
-
def template_paths
|
90
|
-
paths = [template_path]
|
91
|
-
Engines.each { |engine|
|
92
|
-
# add a path for every engine if one exists.
|
93
|
-
engine_template_path = File.join(engine.root, "app", "views", mailer_name)
|
94
|
-
paths << engine_template_path if File.exists?(engine_template_path)
|
95
|
-
}
|
96
|
-
paths
|
97
|
-
end
|
98
|
-
|
99
|
-
# Returns a list of all template paths in the app and Engines
|
100
|
-
# which contain templates that might be used for the given action
|
101
|
-
def get_all_templates_for_action(action)
|
102
|
-
# can we trust uniq! to do this? i'm not sure...
|
103
|
-
templates = []
|
104
|
-
seen_names = []
|
105
|
-
template_paths.each { |path|
|
106
|
-
all_templates_for_path = Dir.glob(File.join(path, "#{action}*"))
|
107
|
-
all_templates_for_path.each { |template|
|
108
|
-
name = File.basename(template)
|
109
|
-
if !seen_names.include?(name)
|
110
|
-
seen_names << name
|
111
|
-
templates << template
|
112
|
-
end
|
113
|
-
}
|
114
|
-
}
|
115
|
-
templates
|
116
|
-
end
|
117
|
-
|
118
|
-
# Returns the first path to the given template in our
|
119
|
-
# app/Engine 'chain'.
|
120
|
-
def find_template_root_for(template)
|
121
|
-
all_paths = get_all_templates_for_action(template)
|
122
|
-
if all_paths.empty?
|
123
|
-
return template_path
|
124
|
-
else
|
125
|
-
return File.dirname(all_paths[0])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
# JGA - changed here to include the method name that we
|
130
|
-
# are interested in, so that we can re-locate the proper
|
131
|
-
# template root
|
132
|
-
def initialize_template_class(assigns, method_name)
|
133
|
-
engine_template = find_template_root_for(method_name)
|
134
|
-
action_view_class = Class.new(ActionView::Base).send(:include, master_helper_module)
|
135
|
-
action_view_class.new(engine_template, assigns, self)
|
136
|
-
end
|
137
|
-
|
138
|
-
|
139
|
-
end
|
140
|
-
end
|
@@ -1,141 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module ::ActionView
|
4
|
-
class Base
|
5
|
-
|
6
|
-
private
|
7
|
-
def full_template_path(template_path, extension)
|
8
|
-
|
9
|
-
unless Engines.disable_app_views_loading
|
10
|
-
# If the template exists in the normal application directory,
|
11
|
-
# return that path
|
12
|
-
default_template = "#{@base_path}/#{template_path}.#{extension}"
|
13
|
-
return default_template if File.exist?(default_template)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Otherwise, check in the engines to see if the template can be found there.
|
17
|
-
# Load this in order so that more recently started Engines will take priority.
|
18
|
-
Engines.each(:precidence_order) do |engine|
|
19
|
-
site_specific_path = File.join(engine.root, 'app', 'views',
|
20
|
-
template_path.to_s + '.' + extension.to_s)
|
21
|
-
return site_specific_path if File.exist?(site_specific_path)
|
22
|
-
end
|
23
|
-
|
24
|
-
# If it cannot be found anywhere, return the default path, where the
|
25
|
-
# user *should* have put it.
|
26
|
-
return "#{@base_path}/#{template_path}.#{extension}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
# add methods to handle including javascripts and stylesheets
|
32
|
-
module Helpers
|
33
|
-
module AssetTagHelper
|
34
|
-
# Returns a stylesheet link tag to the named stylesheet(s) for the given
|
35
|
-
# engine. A stylesheet with the same name as the engine is included automatically.
|
36
|
-
# If other names are supplied, those stylesheets from within the same engine
|
37
|
-
# will be linked too.
|
38
|
-
#
|
39
|
-
# engine_stylesheet "my_engine" =>
|
40
|
-
# <link href="/engine_files/my_engine/stylesheets/my_engine.css" media="screen" rel="Stylesheet" type="text/css" />
|
41
|
-
#
|
42
|
-
# engine_stylesheet "my_engine", "another_file", "one_more" =>
|
43
|
-
# <link href="/engine_files/my_engine/stylesheets/my_engine.css" media="screen" rel="Stylesheet" type="text/css" />
|
44
|
-
# <link href="/engine_files/my_engine/stylesheets/another_file.css" media="screen" rel="Stylesheet" type="text/css" />
|
45
|
-
# <link href="/engine_files/my_engine/stylesheets/one_more.css" media="screen" rel="Stylesheet" type="text/css" />
|
46
|
-
#
|
47
|
-
# Any options supplied as a Hash as the last argument will be processed as in
|
48
|
-
# stylesheet_link_tag.
|
49
|
-
#
|
50
|
-
def engine_stylesheet(engine_name, *sources)
|
51
|
-
stylesheet_link_tag(*convert_public_sources(engine_name, :stylesheet, sources))
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns a javascript link tag to the named stylesheet(s) for the given
|
55
|
-
# engine. A javascript file with the same name as the engine is included automatically.
|
56
|
-
# If other names are supplied, those javascript from within the same engine
|
57
|
-
# will be linked too.
|
58
|
-
#
|
59
|
-
# engine_javascript "my_engine" =>
|
60
|
-
# <script type="text/javascript" src="/engine_files/my_engine/javascripts/my_engine.js"></script>
|
61
|
-
#
|
62
|
-
# engine_javascript "my_engine", "another_file", "one_more" =>
|
63
|
-
# <script type="text/javascript" src="/engine_files/my_engine/javascripts/my_engine.js"></script>
|
64
|
-
# <script type="text/javascript" src="/engine_files/my_engine/javascripts/another_file.js"></script>
|
65
|
-
# <script type="text/javascript" src="/engine_files/my_engine/javascripts/one_more.js"></script>
|
66
|
-
#
|
67
|
-
# Any options supplied as a Hash as the last argument will be processed as in
|
68
|
-
# javascript_include_tag.
|
69
|
-
#
|
70
|
-
def engine_javascript(engine_name, *sources)
|
71
|
-
javascript_include_tag(*convert_public_sources(engine_name, :javascript, sources))
|
72
|
-
end
|
73
|
-
|
74
|
-
# Returns a image tag based on the parameters passed to it
|
75
|
-
# Required option is option[:engine] in order to correctly idenfity the correct engine location
|
76
|
-
#
|
77
|
-
# engine_image 'rails-engines.png', :engine => 'my_engine', :alt => 'My Engine' =>
|
78
|
-
# <img src="/engine_files/my_engine/images/rails-engines.png" alt="My Engine />
|
79
|
-
#
|
80
|
-
# Any options supplied as a Hash as the last argument will be processed as in
|
81
|
-
# image_tag.
|
82
|
-
#
|
83
|
-
def engine_image(src, options = {})
|
84
|
-
return if !src
|
85
|
-
|
86
|
-
image_src = engine_image_src(src, options)
|
87
|
-
|
88
|
-
options.delete(:engine)
|
89
|
-
|
90
|
-
image_tag(image_src, options)
|
91
|
-
end
|
92
|
-
|
93
|
-
# Alias for engine_image
|
94
|
-
def engine_image_tag(src, options = {})
|
95
|
-
engine_image(src, options)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Returns a path to the image stored within the engine_files
|
99
|
-
# Required option is option[:engine] in order to correctly idenfity the correct engine location
|
100
|
-
#
|
101
|
-
# engine_image_src 'rails-engines.png', :engine => 'my_engine' =>
|
102
|
-
# "/engine_files/my_engine/images/rails-engines.png"
|
103
|
-
#
|
104
|
-
def engine_image_src(src, options = {})
|
105
|
-
File.join(Engines.get(options[:engine].to_sym).public_dir, 'images', src)
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
# convert the engine public file sources into actual public paths
|
110
|
-
# type:
|
111
|
-
# :stylesheet
|
112
|
-
# :javascript
|
113
|
-
def convert_public_sources(engine_name, type, sources)
|
114
|
-
options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
|
115
|
-
new_sources = []
|
116
|
-
|
117
|
-
case type
|
118
|
-
when :javascript
|
119
|
-
type_dir = "javascripts"
|
120
|
-
ext = "js"
|
121
|
-
when :stylesheet
|
122
|
-
type_dir = "stylesheets"
|
123
|
-
ext = "css"
|
124
|
-
end
|
125
|
-
|
126
|
-
engine = Engines.get(engine_name)
|
127
|
-
|
128
|
-
default = "#{engine.public_dir}/#{type_dir}/#{engine_name}"
|
129
|
-
if defined?(RAILS_ROOT) && File.exists?(File.join(RAILS_ROOT, "public", "#{default}.#{ext}"))
|
130
|
-
new_sources << default
|
131
|
-
end
|
132
|
-
|
133
|
-
sources.each { |name|
|
134
|
-
new_sources << "#{engine.public_dir}/#{type_dir}/#{name}"
|
135
|
-
}
|
136
|
-
|
137
|
-
new_sources << options
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ::ActiveRecord
|
2
|
-
class Base
|
3
|
-
class << self
|
4
|
-
|
5
|
-
# NOTE: Currently the Migrations system will ALWAYS wrap given table names
|
6
|
-
# in the prefix/suffix, so any table name set via config(:table_name), for instnace
|
7
|
-
# will always get wrapped in the process of migration. For this reason, whatever
|
8
|
-
# value you give to the config will be wrapped when set_table_name is used in the
|
9
|
-
# model.
|
10
|
-
|
11
|
-
def wrapped_table_name(name)
|
12
|
-
table_name_prefix + name + table_name_suffix
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Set ActiveRecord to ignore the engine_schema_info table by default
|
19
|
-
unless Rails::VERSION::STRING =~ /^1\.0\./
|
20
|
-
::ActiveRecord::SchemaDumper.ignore_tables << 'engine_schema_info'
|
21
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
module ::Dependencies
|
2
|
-
|
3
|
-
# we're going to intercept the require_or_load method; lets
|
4
|
-
# make an alias for the current method so we can use it as the basis
|
5
|
-
# for loading from engines.
|
6
|
-
alias :rails_pre_engines_require_or_load :require_or_load
|
7
|
-
|
8
|
-
def require_or_load(file_name)
|
9
|
-
if Engines.config(:edge)
|
10
|
-
rails_edge_require_or_load(file_name)
|
11
|
-
|
12
|
-
elsif Rails::VERSION::STRING =~ /^1.1/
|
13
|
-
# otherwise, assume we're on trunk (1.1 at the moment)
|
14
|
-
rails_1_1_require_or_load(file_name)
|
15
|
-
|
16
|
-
elsif Rails::VERSION::STRING =~ /^1.0/
|
17
|
-
# use the old dependency load method
|
18
|
-
rails_1_0_require_or_load(file_name)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def rails_edge_require_or_load(file_name)
|
23
|
-
rails_1_1_require_or_load(file_name)
|
24
|
-
end
|
25
|
-
|
26
|
-
def rails_1_1_require_or_load(file_name)
|
27
|
-
Engines.log.debug("Engines 1.1 require_or_load: #{file_name}")
|
28
|
-
|
29
|
-
found = false
|
30
|
-
|
31
|
-
# try and load the engine code first
|
32
|
-
# can't use model, as there's nothing in the name to indicate that the file is a 'model' file
|
33
|
-
# rather than a library or anything else.
|
34
|
-
['controller', 'helper'].each do |type|
|
35
|
-
# if we recognise this type
|
36
|
-
# (this regexp splits out the module/filename from any instances of app/#{type}, so that
|
37
|
-
# modules are still respected.)
|
38
|
-
if file_name =~ /^(.*app\/#{type}s\/)?(.*_#{type})(\.rb)?$/
|
39
|
-
|
40
|
-
# ... go through the active engines from first started to last, so that
|
41
|
-
# code with a high precidence (started later) will override lower precidence
|
42
|
-
# implementations
|
43
|
-
Engines.each(:load_order) do |engine|
|
44
|
-
|
45
|
-
engine_file_name = File.expand_path(File.join(engine.root, 'app', "#{type}s", $2))
|
46
|
-
#engine_file_name = $1 if engine_file_name =~ /^(.*)\.rb$/
|
47
|
-
Engines.log.debug("checking engine '#{engine.name}' for '#{engine_file_name}'")
|
48
|
-
if File.exist?("#{engine_file_name}.rb")
|
49
|
-
Engines.log.debug("==> loading from engine '#{engine.name}'")
|
50
|
-
rails_pre_engines_require_or_load(engine_file_name)
|
51
|
-
found = true
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# finally, load any application-specific controller classes using the 'proper'
|
58
|
-
# rails load mechanism, EXCEPT when we're testing engines and could load this file
|
59
|
-
# from an engine
|
60
|
-
rails_pre_engines_require_or_load(file_name) unless Engines.disable_app_code_mixing && found
|
61
|
-
end
|
62
|
-
|
63
|
-
def rails_1_0_require_or_load(file_name)
|
64
|
-
file_name = $1 if file_name =~ /^(.*)\.rb$/
|
65
|
-
|
66
|
-
Engines.log.debug "Engines 1.0.0 require_or_load '#{file_name}'"
|
67
|
-
|
68
|
-
# if the file_name ends in "_controller" or "_controller.rb", strip all
|
69
|
-
# path information out of it except for module context, and load it. Ditto
|
70
|
-
# for helpers.
|
71
|
-
found = if file_name =~ /_controller(.rb)?$/
|
72
|
-
require_engine_files(file_name, 'controller')
|
73
|
-
elsif file_name =~ /_helper(.rb)?$/ # any other files we can do this with?
|
74
|
-
require_engine_files(file_name, 'helper')
|
75
|
-
end
|
76
|
-
|
77
|
-
# finally, load any application-specific controller classes using the 'proper'
|
78
|
-
# rails load mechanism, EXCEPT when we're testing engines and could load this file
|
79
|
-
# from an engine
|
80
|
-
Engines.log.debug("--> loading from application: '#{file_name}'")
|
81
|
-
rails_pre_engines_require_or_load(file_name) unless Engines.disable_app_code_mixing && found
|
82
|
-
Engines.log.debug("--> Done loading.")
|
83
|
-
end
|
84
|
-
|
85
|
-
# Load the given file (which should be a path to be matched from the root of each
|
86
|
-
# engine) from all active engines which have that file.
|
87
|
-
# NOTE! this method automagically strips file_name up to and including the first
|
88
|
-
# instance of '/app/controller'. This should correspond to the app/controller folder
|
89
|
-
# under RAILS_ROOT. However, if you have your Rails application residing under a
|
90
|
-
# path which includes /app/controller anyway, such as:
|
91
|
-
#
|
92
|
-
# /home/username/app/controller/my_web_application # == RAILS_ROOT
|
93
|
-
#
|
94
|
-
# then you might have trouble. Sorry, just please don't have your web application
|
95
|
-
# running under a path like that.
|
96
|
-
def require_engine_files(file_name, type='')
|
97
|
-
found = false
|
98
|
-
Engines.log.debug "requiring #{type} file '#{file_name}'"
|
99
|
-
processed_file_name = file_name.gsub(/[\w\W\/\.]*app\/#{type}s\//, '')
|
100
|
-
Engines.log.debug "--> rewrote to '#{processed_file_name}'"
|
101
|
-
Engines.each(:load_order) do |engine|
|
102
|
-
engine_file_name = File.join(engine.root, 'app', "#{type}s", processed_file_name)
|
103
|
-
engine_file_name += '.rb' unless ! load? || engine_file_name[-3..-1] == '.rb'
|
104
|
-
Engines.log.debug "--> checking '#{engine.name}' for #{engine_file_name}"
|
105
|
-
if File.exist?(engine_file_name) ||
|
106
|
-
(engine_file_name[-3..-1] != '.rb' && File.exist?(engine_file_name + '.rb'))
|
107
|
-
Engines.log.debug "--> found, loading from engine '#{engine.name}'"
|
108
|
-
rails_pre_engines_require_or_load(engine_file_name)
|
109
|
-
found = true
|
110
|
-
end
|
111
|
-
end
|
112
|
-
found
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
# We only need to deal with LoadingModules in Rails 1.0.0
|
118
|
-
if Rails::VERSION::STRING =~ /^1.0/ && !Engines.config(:edge)
|
119
|
-
module ::Dependencies
|
120
|
-
class RootLoadingModule < LoadingModule
|
121
|
-
# hack to allow adding to the load paths within the Rails Dependencies mechanism.
|
122
|
-
# this allows Engine classes to be unloaded and loaded along with standard
|
123
|
-
# Rails application classes.
|
124
|
-
def add_path(path)
|
125
|
-
@load_paths << (path.kind_of?(ConstantLoadPath) ? path : ConstantLoadPath.new(path))
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
#require 'active_record/connection_adapters/abstract/schema_statements'
|
2
|
-
|
3
|
-
module ::ActiveRecord::ConnectionAdapters::SchemaStatements
|
4
|
-
alias :old_initialize_schema_information :initialize_schema_information
|
5
|
-
def initialize_schema_information
|
6
|
-
# create the normal schema stuff
|
7
|
-
old_initialize_schema_information
|
8
|
-
|
9
|
-
# create the engines schema stuff.
|
10
|
-
begin
|
11
|
-
execute "CREATE TABLE #{engine_schema_info_table_name} (engine_name #{type_to_sql(:string)}, version #{type_to_sql(:integer)})"
|
12
|
-
rescue ActiveRecord::StatementInvalid
|
13
|
-
# Schema has been initialized
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def engine_schema_info_table_name
|
18
|
-
ActiveRecord::Base.wrapped_table_name "engine_schema_info"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
require 'breakpoint'
|
24
|
-
module ::Engines
|
25
|
-
class EngineMigrator < ActiveRecord::Migrator
|
26
|
-
|
27
|
-
# We need to be able to set the 'current' engine being migrated.
|
28
|
-
cattr_accessor :current_engine
|
29
|
-
|
30
|
-
class << self
|
31
|
-
|
32
|
-
def schema_info_table_name
|
33
|
-
ActiveRecord::Base.wrapped_table_name "engine_schema_info"
|
34
|
-
end
|
35
|
-
|
36
|
-
def current_version
|
37
|
-
result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_info_table_name} WHERE engine_name = '#{current_engine.name}'")
|
38
|
-
if result
|
39
|
-
result["version"].to_i
|
40
|
-
else
|
41
|
-
# There probably isn't an entry for this engine in the migration info table.
|
42
|
-
# We need to create that entry, and set the version to 0
|
43
|
-
ActiveRecord::Base.connection.execute("INSERT INTO #{schema_info_table_name} (version, engine_name) VALUES (0,'#{current_engine.name}')")
|
44
|
-
0
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def set_schema_version(version)
|
50
|
-
ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{down? ? version.to_i - 1 : version.to_i} WHERE engine_name = '#{self.current_engine.name}'")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|