parlement 0.14 → 0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +41 -1
- data/MEMORY +66 -5
- data/README +10 -5
- data/Rakefile +15 -23
- data/app/controllers/account_controller.rb +48 -43
- data/app/controllers/{application.rb → application_controller.rb} +15 -12
- data/app/controllers/elt_controller.rb +77 -32
- data/app/controllers/subscriber_controller.rb +11 -10
- data/app/helpers/application_helper.rb +14 -1
- data/app/helpers/elt_helper.rb +9 -7
- data/app/models/elt.rb +25 -24
- data/app/models/mail.rb +44 -47
- data/app/models/person_notify.rb +2 -2
- data/app/models/user.rb +128 -2
- data/app/models/user_notify.rb +15 -15
- data/app/views/account/_login.rhtml +39 -39
- data/app/views/account/_show.rhtml +22 -30
- data/app/views/account/signup.rhtml +2 -2
- data/app/views/elt/_choice.rhtml +6 -6
- data/app/views/elt/_elt.rhtml +27 -32
- data/app/views/elt/choices.rhtml +16 -18
- data/app/views/elt/list/_byDate.rhtml +14 -14
- data/app/views/elt/list/_byVote.rhtml +15 -15
- data/app/views/elt/list/_children.rhtml +48 -40
- data/app/views/elt/list/_subscribers.rhtml +1 -1
- data/app/views/elt/new.rhtml +22 -21
- data/app/views/elt/rss.rxml +4 -11
- data/app/views/elt/show.rhtml +65 -61
- data/app/views/elt/vote_rss.rxml +4 -11
- data/app/views/layouts/top.rhtml +39 -50
- data/app/views/person/_listElts.rhtml +1 -1
- data/app/views/person/show.rhtml +1 -1
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/change_password.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/delete.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/forgot_password.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/pending_delete.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/signup.rhtml +0 -0
- data/config/boot.rb +97 -32
- data/config/environment.rb +37 -35
- data/config/environments/development.rb +2 -3
- data/config/environments/production.rb +3 -0
- data/config/initializers/string_ruby_1.8.rb +10 -0
- data/config/routes.rb +17 -22
- data/db/schema.rb +102 -74
- data/lib/tasks/rspec.rake +167 -0
- data/public/404.html +25 -7
- data/public/500.html +26 -7
- data/public/dispatch.cgi +0 -0
- data/public/dispatch.fcgi +0 -0
- data/public/dispatch.rb +0 -0
- data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
- data/public/images/live_tree_branch_expanded_icon.gif +0 -0
- data/public/images/live_tree_leaf_icon.gif +0 -0
- data/public/javascripts/application.js +258 -0
- data/public/javascripts/controls.js +544 -414
- data/public/javascripts/dragdrop.js +229 -198
- data/public/javascripts/effects.js +499 -459
- data/public/javascripts/prototype.js +2926 -1121
- data/public/javascripts/shadedborder.js +68 -50
- data/public/stylesheets/default.css +34 -34
- data/public/stylesheets/live_tree.css +0 -0
- data/public/stylesheets/scaffold.css +6 -6
- data/script/about +0 -0
- data/script/autospec +6 -0
- data/script/benchmarker +0 -0
- data/script/breakpointer +0 -0
- data/script/console +0 -0
- data/script/dbconsole +3 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/plugin +0 -0
- data/script/profiler +0 -0
- data/script/runner +0 -0
- data/script/server +0 -0
- data/script/spec +10 -0
- data/script/spec_server +9 -0
- data/test/unit/attachment_test.rb +4 -4
- data/test/unit/choice_test.rb +1 -1
- data/test/unit/elt_test.rb +9 -9
- data/test/unit/mail_notify_test.rb +2 -2
- data/test/unit/mail_test.rb +18 -11
- data/test/unit/person_notify_test.rb +1 -1
- data/test/unit/person_test.rb +1 -1
- data/test/unit/subscriber_test.rb +1 -1
- data/test/unit/user_test.rb +81 -0
- data/test/unit/visit_test.rb +6 -6
- data/vendor/plugins/activerecord_foreign_key_extensions/init.rb +2 -0
- data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +182 -0
- data/vendor/plugins/activerecord_text_id_extensions/init.rb +2 -0
- data/vendor/plugins/activerecord_text_id_extensions/lib/active_record_extensions.rb +24 -0
- data/vendor/plugins/acts_as_nested_set/README +15 -0
- data/vendor/plugins/acts_as_nested_set/init.rb +1 -0
- data/vendor/plugins/acts_as_nested_set/lib/active_record/acts/nested_set.rb +210 -0
- data/vendor/plugins/acts_as_nested_set/test/nested_set_test.rb +269 -0
- data/vendor/plugins/acts_as_tree/README +26 -0
- data/vendor/plugins/acts_as_tree/Rakefile +22 -0
- data/vendor/plugins/acts_as_tree/init.rb +1 -0
- data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
- data/vendor/plugins/{output_compression/CHANGELOG → acts_as_tree/test/abstract_unit.rb} +0 -0
- data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
- data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
- data/vendor/plugins/classic_pagination/CHANGELOG +152 -0
- data/vendor/plugins/classic_pagination/README +18 -0
- data/vendor/plugins/{output_compression/rakefile → classic_pagination/Rakefile} +22 -22
- data/vendor/plugins/classic_pagination/init.rb +33 -0
- data/vendor/plugins/classic_pagination/install.rb +1 -0
- data/vendor/plugins/classic_pagination/lib/pagination.rb +405 -0
- data/vendor/plugins/classic_pagination/lib/pagination_helper.rb +135 -0
- data/vendor/plugins/classic_pagination/test/fixtures/companies.yml +24 -0
- data/vendor/plugins/classic_pagination/test/fixtures/company.rb +9 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developer.rb +7 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developers.yml +21 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml +13 -0
- data/vendor/plugins/classic_pagination/test/fixtures/project.rb +3 -0
- data/vendor/plugins/classic_pagination/test/fixtures/projects.yml +7 -0
- data/vendor/plugins/classic_pagination/test/fixtures/replies.yml +13 -0
- data/vendor/plugins/classic_pagination/test/fixtures/reply.rb +5 -0
- data/vendor/plugins/classic_pagination/test/fixtures/schema.sql +42 -0
- data/vendor/plugins/classic_pagination/test/fixtures/topic.rb +3 -0
- data/vendor/plugins/classic_pagination/test/fixtures/topics.yml +22 -0
- data/vendor/plugins/classic_pagination/test/helper.rb +117 -0
- data/vendor/plugins/classic_pagination/test/pagination_helper_test.rb +38 -0
- data/vendor/plugins/classic_pagination/test/pagination_test.rb +177 -0
- data/vendor/plugins/file_column/lib/file_column.rb +1 -1
- data/vendor/plugins/file_column/test/file_column_test.rb +0 -0
- metadata +151 -197
- data/app/helpers/live_tree.rb +0 -238
- data/app/views/elt/_form.rhtml +0 -31
- data/app/views/elt/show_tree.rhtml +0 -8
- data/config/environments/user_environment.rb +0 -1
- data/db/ROOT/Titemagli.txt +0 -3
- data/db/ROOT/titemagli.txt +0 -9
- data/public/javascripts/behaviour.js +0 -254
- data/public/javascripts/ie7-load.htc +0 -1
- data/public/javascripts/ie7.js +0 -6
- data/public/javascripts/live_tree.js +0 -749
- data/public/javascripts/mybehaviour.js +0 -225
- data/public/javascripts/scriptaculous.js +0 -47
- data/public/javascripts/slider.js +0 -283
- data/public/stylesheets/blue.css +0 -471
- data/vendor/plugins/engines/CHANGELOG +0 -241
- data/vendor/plugins/engines/MIT-LICENSE +0 -21
- data/vendor/plugins/engines/README +0 -64
- data/vendor/plugins/engines/Rakefile +0 -32
- data/vendor/plugins/engines/UPGRADING +0 -93
- data/vendor/plugins/engines/about.yml +0 -7
- data/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
- data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
- data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
- data/vendor/plugins/engines/init.rb +0 -40
- data/vendor/plugins/engines/install.rb +0 -32
- data/vendor/plugins/engines/lib/engines.rb +0 -323
- data/vendor/plugins/engines/lib/engines/deprecated_config_support.rb +0 -135
- data/vendor/plugins/engines/lib/engines/plugin.rb +0 -214
- data/vendor/plugins/engines/lib/engines/plugin_list.rb +0 -31
- data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +0 -60
- data/vendor/plugins/engines/lib/engines/rails_extensions.rb +0 -6
- data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -19
- data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -143
- data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -155
- data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +0 -116
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -20
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +0 -86
- data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -77
- data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +0 -140
- data/vendor/plugins/engines/lib/engines/testing.rb +0 -87
- data/vendor/plugins/engines/tasks/engines.rake +0 -149
- data/vendor/plugins/login_engine/CHANGELOG +0 -22
- data/vendor/plugins/login_engine/README +0 -344
- data/vendor/plugins/login_engine/app/controllers/user_controller.rb +0 -262
- data/vendor/plugins/login_engine/app/helpers/user_helper.rb +0 -88
- data/vendor/plugins/login_engine/app/models/user.rb +0 -7
- data/vendor/plugins/login_engine/app/models/user_notify.rb +0 -75
- data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +0 -11
- data/vendor/plugins/login_engine/app/views/user/_password.rhtml +0 -9
- data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +0 -17
- data/vendor/plugins/login_engine/app/views/user/edit.rhtml +0 -23
- data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +0 -18
- data/vendor/plugins/login_engine/app/views/user/home.rhtml +0 -7
- data/vendor/plugins/login_engine/app/views/user/login.rhtml +0 -17
- data/vendor/plugins/login_engine/app/views/user/logout.rhtml +0 -8
- data/vendor/plugins/login_engine/app/views/user/signup.rhtml +0 -17
- data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +0 -25
- data/vendor/plugins/login_engine/init_engine.rb +0 -11
- data/vendor/plugins/login_engine/install.rb +0 -4
- data/vendor/plugins/login_engine/lib/login_engine.rb +0 -62
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +0 -113
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +0 -155
- data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +0 -81
- data/vendor/plugins/login_engine/test/fixtures/users.yml +0 -41
- data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +0 -536
- data/vendor/plugins/login_engine/test/mocks/mail.rb +0 -14
- data/vendor/plugins/login_engine/test/mocks/time.rb +0 -19
- data/vendor/plugins/login_engine/test/test_helper.rb +0 -11
- data/vendor/plugins/login_engine/test/unit/user_test.rb +0 -114
- data/vendor/plugins/output_compression/MIT-LICENSE +0 -20
- data/vendor/plugins/output_compression/README +0 -4
- data/vendor/plugins/output_compression/init.rb +0 -1
- data/vendor/plugins/output_compression/lib/output_compression.rb +0 -84
- data/vendor/plugins/output_compression/test/output_test.rb +0 -11
- data/vendor/plugins/output_compression/test/test_controller.rb +0 -3
- data/vendor/plugins/output_compression/test/test_helper.rb +0 -14
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
author: James Adam
|
|
2
|
-
email: james.adam@gmail.com
|
|
3
|
-
homepage: http://www.rails-engines.org
|
|
4
|
-
summary: Enhances the plugin mechanism to perform more flexible sharing
|
|
5
|
-
description: The Rails Engines plugin allows the sharing of almost any type of code or asset that you could use in a Rails application, including controllers, models, stylesheets, and views.
|
|
6
|
-
license: MIT
|
|
7
|
-
version: 1.2.0
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
The plugin migration generator assists in working with schema additions
|
|
3
|
-
required by plugins. Instead of running migrations from plugins directly,
|
|
4
|
-
the generator creates a regular Rails migration which will be responsible
|
|
5
|
-
for migrating the plugins from their current version to the latest version
|
|
6
|
-
installed.
|
|
7
|
-
|
|
8
|
-
This is important because the set of application migrations remains an
|
|
9
|
-
accurate record of the state of the database, even as plugins are installed
|
|
10
|
-
and removed during the development process.
|
|
11
|
-
|
|
12
|
-
Example:
|
|
13
|
-
./script/generate plugin_migration [<plugin_name> <another_plugin_name> ...]
|
|
14
|
-
|
|
15
|
-
This will generate:
|
|
16
|
-
|
|
17
|
-
RAILS_ROOT
|
|
18
|
-
|- db
|
|
19
|
-
|-migrate
|
|
20
|
-
|- xxx_plugin_migrations.rb
|
|
21
|
-
|
|
22
|
-
which contains the migrations for the given plugin(s).
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Advanced Usage:
|
|
26
|
-
|
|
27
|
-
There may be situations where you need *complete* control over the migrations
|
|
28
|
-
of plugins in your application, migrating a certainly plugin down to X, and
|
|
29
|
-
another plugin up to Y, where neither X or Y are the latest migrations for those
|
|
30
|
-
plugins.
|
|
31
|
-
|
|
32
|
-
For those unfortunate few, I have two pieces of advice:
|
|
33
|
-
|
|
34
|
-
1. Why? This is a code smell [http://c2.com/xp/CodeSmell.html].
|
|
35
|
-
|
|
36
|
-
2. Well, OK. Don't panic. You can completely control plugin migrations by
|
|
37
|
-
creating your own migrations. To manually migrate a plugin to a specific
|
|
38
|
-
version, simply use
|
|
39
|
-
|
|
40
|
-
Rails.plugins[:your_plugin_name].migrate(version)
|
|
41
|
-
|
|
42
|
-
where version is the integer of the migration this plugin should end
|
|
43
|
-
up at.
|
|
44
|
-
|
|
45
|
-
With great power comes great responsibility. Use this wisely.
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# Generates a migration which migrates all plugins to their latest versions
|
|
2
|
-
# within the database.
|
|
3
|
-
class PluginMigrationGenerator < Rails::Generator::Base
|
|
4
|
-
|
|
5
|
-
def initialize(runtime_args, runtime_options={})
|
|
6
|
-
super
|
|
7
|
-
@options = {:assigns => {}}
|
|
8
|
-
|
|
9
|
-
ensure_plugin_schema_table_exists
|
|
10
|
-
get_plugins_to_migrate(runtime_args)
|
|
11
|
-
|
|
12
|
-
if @plugins_to_migrate.empty?
|
|
13
|
-
puts "All plugins are migrated to their latest versions"
|
|
14
|
-
exit(0)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
@options[:migration_file_name] = build_migration_name
|
|
18
|
-
@options[:assigns][:class_name] = build_migration_name.classify
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def manifest
|
|
22
|
-
record do |m|
|
|
23
|
-
m.migration_template 'plugin_migration.erb', 'db/migrate', @options
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
protected
|
|
28
|
-
|
|
29
|
-
# Create the plugin schema table if it doesn't already exist. See
|
|
30
|
-
# Engines::RailsExtensions::Migrations#initialize_schema_information_with_engine_additions
|
|
31
|
-
def ensure_plugin_schema_table_exists
|
|
32
|
-
ActiveRecord::Base.connection.initialize_schema_information
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Determine all the plugins which have migrations that aren't present
|
|
36
|
-
# according to the plugin schema information from the database.
|
|
37
|
-
def get_plugins_to_migrate(plugin_names)
|
|
38
|
-
|
|
39
|
-
# First, grab all the plugins which exist and have migrations
|
|
40
|
-
@plugins_to_migrate = if plugin_names.empty?
|
|
41
|
-
Rails.plugins
|
|
42
|
-
else
|
|
43
|
-
plugin_names.map do |name|
|
|
44
|
-
Rails.plugins[name] ? Rails.plugins[name] : raise("Cannot find the plugin '#{name}'")
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
@plugins_to_migrate.reject! { |p| p.latest_migration.nil? }
|
|
49
|
-
|
|
50
|
-
# Then find the current versions from the database
|
|
51
|
-
@current_versions = {}
|
|
52
|
-
@plugins_to_migrate.each do |plugin|
|
|
53
|
-
@current_versions[plugin.name] = Engines::PluginMigrator.current_version(plugin)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Then find the latest versions from their migration directories
|
|
57
|
-
@new_versions = {}
|
|
58
|
-
@plugins_to_migrate.each do |plugin|
|
|
59
|
-
@new_versions[plugin.name] = plugin.latest_migration
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Remove any plugins that don't need migration
|
|
63
|
-
@plugins_to_migrate.map { |p| p.name }.each do |name|
|
|
64
|
-
@plugins_to_migrate.delete(Rails.plugins[name]) if @current_versions[name] == @new_versions[name]
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
@options[:assigns][:plugins] = @plugins_to_migrate
|
|
68
|
-
@options[:assigns][:new_versions] = @new_versions
|
|
69
|
-
@options[:assigns][:current_versions] = @current_versions
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Construct a unique migration name based on the plugins involved and the
|
|
73
|
-
# versions they should reach after this migration is run.
|
|
74
|
-
def build_migration_name
|
|
75
|
-
@plugins_to_migrate.map do |plugin|
|
|
76
|
-
"#{plugin.name}_to_version_#{@new_versions[plugin.name]}"
|
|
77
|
-
end.join("_and_")
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class <%= class_name %> < ActiveRecord::Migration
|
|
2
|
-
def self.up
|
|
3
|
-
<%- plugins.each do |plugin| -%>
|
|
4
|
-
Rails.plugins["<%= plugin.name %>"].migrate(<%= new_versions[plugin.name] %>)
|
|
5
|
-
<%- end -%>
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.down
|
|
9
|
-
<%- plugins.each do |plugin| -%>
|
|
10
|
-
Rails.plugins["<%= plugin.name %>"].migrate(<%= current_versions[plugin.name] %>)
|
|
11
|
-
<%- end -%>
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
silence_warnings { require 'rails/version' } # it may already be loaded
|
|
3
|
-
unless Rails::VERSION::MAJOR >= 1 && Rails::VERSION::MINOR >= 2
|
|
4
|
-
raise "This version of the engines plugin requires Rails 1.2 or later!"
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# First, require the engines module & core methods
|
|
9
|
-
require "engines"
|
|
10
|
-
|
|
11
|
-
# Load this before we get actually start engines
|
|
12
|
-
require "engines/rails_extensions/rails_initializer"
|
|
13
|
-
|
|
14
|
-
# Start the engines mechanism.
|
|
15
|
-
Engines.init(config, self)
|
|
16
|
-
|
|
17
|
-
# Now that we've defined the engines module, load up any extensions
|
|
18
|
-
[:rails,
|
|
19
|
-
:rails_initializer,
|
|
20
|
-
:dependencies,
|
|
21
|
-
:active_record,
|
|
22
|
-
:migrations,
|
|
23
|
-
:templates,
|
|
24
|
-
:public_asset_helpers,
|
|
25
|
-
:routing
|
|
26
|
-
].each do |f|
|
|
27
|
-
require "engines/rails_extensions/#{f}"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Load the testing extensions, if we are in the test environment.
|
|
31
|
-
require "engines/testing" if RAILS_ENV == "test"
|
|
32
|
-
|
|
33
|
-
# Load the Rails::Info module so that plugins can insert information into it.
|
|
34
|
-
begin
|
|
35
|
-
require 'rails/info'
|
|
36
|
-
rescue Exception
|
|
37
|
-
# If this file can't be loaded, it's probably because we're running in an
|
|
38
|
-
# environment where Rails' builtins aren't yet in the load path.
|
|
39
|
-
# For the moment, just ignore this. See Ticket #261
|
|
40
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "..", "rails", "railties", "lib")
|
|
2
|
-
silence_warnings { require 'rails/version' } # it may already be loaded.
|
|
3
|
-
|
|
4
|
-
unless Rails::VERSION::MAJOR >= 1 && Rails::VERSION::MINOR >= 2
|
|
5
|
-
puts <<-end_of_warning
|
|
6
|
-
|
|
7
|
-
!!!=== IMPORTANT NOTE ===!!!
|
|
8
|
-
|
|
9
|
-
Support for Rails < 1.2 has been dropped; if you are using
|
|
10
|
-
Rails =< 1.1.6, please use Engines 1.1.6, available from:
|
|
11
|
-
|
|
12
|
-
>> http://svn.rails-engines.org/engines/tags/rel_1.1.6
|
|
13
|
-
|
|
14
|
-
For more details about changes in Engines 1.2, please see
|
|
15
|
-
the changelog or the website:
|
|
16
|
-
|
|
17
|
-
>> http://www.rails-engines.org
|
|
18
|
-
|
|
19
|
-
end_of_warning
|
|
20
|
-
else
|
|
21
|
-
puts <<-end_of_message
|
|
22
|
-
|
|
23
|
-
The engines plugin is now installed. Feels good, right? Yeah.
|
|
24
|
-
You knew it would.
|
|
25
|
-
|
|
26
|
-
Once the warm, fuzzy glow has subsided, be sure to read the contents
|
|
27
|
-
of the README and UPGRADING files if you're migrating this application
|
|
28
|
-
from Rails 1.1.x to 1.2.x.
|
|
29
|
-
|
|
30
|
-
Have a great day!
|
|
31
|
-
end_of_message
|
|
32
|
-
end
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
# This file contains the Engines module, which holds most of the logic regarding
|
|
2
|
-
# the startup and management of plugins. See Engines for more details.
|
|
3
|
-
#
|
|
4
|
-
# The engines plugin adds to Rails' existing behaviour by producing the +Rails.plugins+
|
|
5
|
-
# PluginList, a list of all loaded plugins in a form which can be easily queried
|
|
6
|
-
# and manipulated. Each instance of Plugin has methods which are used to enhance
|
|
7
|
-
# their behaviour, including mirroring public assets, add controllers, helpers
|
|
8
|
-
# and views and even migration.
|
|
9
|
-
#
|
|
10
|
-
# = init.rb
|
|
11
|
-
#
|
|
12
|
-
# When the engines plugin loads, it first includes the
|
|
13
|
-
# Engines::RailsExtensions::RailsInitializer module into Rails::Initializer,
|
|
14
|
-
# overriding a number of the methods used to load plugins.
|
|
15
|
-
#
|
|
16
|
-
# Once this is loaded, Engines.init is called to prepare the application
|
|
17
|
-
# and create the relevant new datastructures (including <tt>Rails.plugins</tt>).
|
|
18
|
-
#
|
|
19
|
-
# Finally, each of the extension modules from Engines::RailsExtensionsis
|
|
20
|
-
# loaded and included into the relevant Rails classes and modules, enhancing
|
|
21
|
-
# their behaviour to work better with files from plugins.
|
|
22
|
-
|
|
23
|
-
require "engines/plugin_list"
|
|
24
|
-
require "engines/plugin"
|
|
25
|
-
|
|
26
|
-
# TODO: define a better logger.
|
|
27
|
-
def logger
|
|
28
|
-
RAILS_DEFAULT_LOGGER
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# The Engines module contains most of the methods used during the enhanced
|
|
32
|
-
# startup of Rails plugins.
|
|
33
|
-
#
|
|
34
|
-
# When the Engines plugin loads (its <tt>init.rb</tt> file is evaluated), the
|
|
35
|
-
# Engines.init method is called. This kickstarts the plugins hooks into
|
|
36
|
-
# the initialization process.
|
|
37
|
-
#
|
|
38
|
-
# == Parameters
|
|
39
|
-
#
|
|
40
|
-
# The Engines module has a number of public configuration parameters:
|
|
41
|
-
#
|
|
42
|
-
# [+public_directory+] The directory into which plugin assets should be
|
|
43
|
-
# mirrored. Defaults to <tt>RAILS_ROOT/public/plugin_assets</tt>.
|
|
44
|
-
# [+schema_info_table+] The table to use when storing plugin migration
|
|
45
|
-
# version information. Defaults to +plugin_schema_info+.
|
|
46
|
-
# [+rails_initializer+] A reference of the Rails initializer instance that
|
|
47
|
-
# was used to startup Rails. This is often useful
|
|
48
|
-
# when working with the startup process; see
|
|
49
|
-
# Engines::RailsExtensions::RailsInitializer for more
|
|
50
|
-
# information
|
|
51
|
-
#
|
|
52
|
-
# Additionally, there are a few flags which control the behaviour of
|
|
53
|
-
# some of the features the engines plugin adds to Rails:
|
|
54
|
-
#
|
|
55
|
-
# [+disable_application_view_loading+] A boolean flag determining whether
|
|
56
|
-
# or not views should be loaded from
|
|
57
|
-
# the main <tt>app/views</tt> directory.
|
|
58
|
-
# Defaults to false; probably only
|
|
59
|
-
# useful when testing your plugin.
|
|
60
|
-
# [+disable_application_code_loading+] A boolean flag determining whether
|
|
61
|
-
# or not to load controllers/helpers
|
|
62
|
-
# from the main +app+ directory,
|
|
63
|
-
# if corresponding code exists within
|
|
64
|
-
# a plugin. Defaults to false; again,
|
|
65
|
-
# probably only useful when testing
|
|
66
|
-
# your plugin.
|
|
67
|
-
# [+disable_code_mixing+] A boolean flag indicating whether all plugin
|
|
68
|
-
# copies of a particular controller/helper should
|
|
69
|
-
# be loaded and allowed to override each other,
|
|
70
|
-
# or if the first matching file should be loaded
|
|
71
|
-
# instead. Defaults to false.
|
|
72
|
-
#
|
|
73
|
-
module Engines
|
|
74
|
-
# The name of the public directory to mirror public engine assets into.
|
|
75
|
-
# Defaults to <tt>RAILS_ROOT/public/plugin_assets</tt>.
|
|
76
|
-
mattr_accessor :public_directory
|
|
77
|
-
self.public_directory = File.join(RAILS_ROOT, 'public', 'plugin_assets')
|
|
78
|
-
|
|
79
|
-
# The table in which to store plugin schema information. Defaults to
|
|
80
|
-
# "plugin_schema_info".
|
|
81
|
-
mattr_accessor :schema_info_table
|
|
82
|
-
self.schema_info_table = "plugin_schema_info"
|
|
83
|
-
|
|
84
|
-
# A reference to the current Rails::Initializer instance
|
|
85
|
-
mattr_accessor :rails_initializer
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
#--
|
|
89
|
-
# These attributes control the behaviour of the engines extensions
|
|
90
|
-
#++
|
|
91
|
-
|
|
92
|
-
# Set this to true if views should *only* be loaded from plugins
|
|
93
|
-
mattr_accessor :disable_application_view_loading
|
|
94
|
-
self.disable_application_view_loading = false
|
|
95
|
-
|
|
96
|
-
# Set this to true if controller/helper code shouldn't be loaded
|
|
97
|
-
# from the application
|
|
98
|
-
mattr_accessor :disable_application_code_loading
|
|
99
|
-
self.disable_application_code_loading = false
|
|
100
|
-
|
|
101
|
-
# Set this ti true if code should not be mixed (i.e. it will be loaded
|
|
102
|
-
# from the first valid path on $LOAD_PATH)
|
|
103
|
-
mattr_accessor :disable_code_mixing
|
|
104
|
-
self.disable_code_mixing = false
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
private
|
|
108
|
-
|
|
109
|
-
# A memo of the bottom of Rails' default load path
|
|
110
|
-
mattr_accessor :rails_final_load_path
|
|
111
|
-
# A memo of the bottom of Rails Dependencies load path
|
|
112
|
-
mattr_accessor :rails_final_dependency_load_path
|
|
113
|
-
|
|
114
|
-
public
|
|
115
|
-
|
|
116
|
-
# Initializes the engines plugin and prepares Rails to start loading
|
|
117
|
-
# plugins using engines extensions. Within this method:
|
|
118
|
-
#
|
|
119
|
-
# 1. Copies of the Rails configuration and initializer are stored;
|
|
120
|
-
# 2. The Rails.plugins PluginList instance is created;
|
|
121
|
-
# 3. Any plugins which were loaded before the engines plugin are given
|
|
122
|
-
# the engines treatment via #enhance_loaded_plugins.
|
|
123
|
-
# 4. The base public directory (into which plugin assets are mirrored)
|
|
124
|
-
# is created, if necessary - #initialize_base_public_directory
|
|
125
|
-
# 5. <tt>config.plugins</tt> is checked to see if a wildcard was present -
|
|
126
|
-
# #check_for_star_wildcard
|
|
127
|
-
#
|
|
128
|
-
def self.init(rails_configuration, rails_initializer)
|
|
129
|
-
# First, determine if we're running in legacy mode
|
|
130
|
-
@legacy_support = self.const_defined?(:LegacySupport) && LegacySupport
|
|
131
|
-
|
|
132
|
-
# Store some information about the plugin subsystem
|
|
133
|
-
Rails.configuration = rails_configuration
|
|
134
|
-
|
|
135
|
-
# We need a hook into this so we can get freaky with the plugin loading itself
|
|
136
|
-
self.rails_initializer = rails_initializer
|
|
137
|
-
|
|
138
|
-
@load_all_plugins = false
|
|
139
|
-
|
|
140
|
-
store_load_path_markers
|
|
141
|
-
|
|
142
|
-
Rails.plugins ||= PluginList.new
|
|
143
|
-
enhance_loaded_plugins # including this one, as it happens.
|
|
144
|
-
|
|
145
|
-
initialize_base_public_directory
|
|
146
|
-
|
|
147
|
-
check_for_star_wildcard
|
|
148
|
-
|
|
149
|
-
logger.debug "engines has started."
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# You can enable legacy support by defining the LegacySupport constant
|
|
153
|
-
# in the Engines module before Rails loads, i.e. at the *top* of environment.rb,
|
|
154
|
-
# add:
|
|
155
|
-
#
|
|
156
|
-
# module Engines
|
|
157
|
-
# LegacySupport = true
|
|
158
|
-
# end
|
|
159
|
-
#
|
|
160
|
-
# Legacy Support doesn't actually do anything at the moment. If necessary
|
|
161
|
-
# we may support older-style 'engines' using this flag.
|
|
162
|
-
def self.legacy_support?
|
|
163
|
-
@legacy_support
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
# A reference to the currently-loading/loaded plugin. This is present to support
|
|
167
|
-
# legacy engines; it's preferred to use Rails.plugins[name] in your plugin's
|
|
168
|
-
# init.rb file in order to get your Plugin instance.
|
|
169
|
-
def self.current
|
|
170
|
-
Rails.plugins.last
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# This is set to true if a "*" widlcard is present at the end of
|
|
174
|
-
# the config.plugins array.
|
|
175
|
-
def self.load_all_plugins?
|
|
176
|
-
@load_all_plugins
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
# Stores a record of the last paths which Rails added to each of the load path
|
|
180
|
-
# attributes ($LOAD_PATH, Dependencies.load_paths and
|
|
181
|
-
# ActionController::Routing.controller_paths) that influence how code is loaded
|
|
182
|
-
# We need this to ensure that we place our additions to the load path *after*
|
|
183
|
-
# all Rails' defaults
|
|
184
|
-
def self.store_load_path_markers
|
|
185
|
-
self.rails_final_load_path = $LOAD_PATH.last
|
|
186
|
-
logger.debug "Rails final load path: #{self.rails_final_load_path}"
|
|
187
|
-
self.rails_final_dependency_load_path = ::Dependencies.load_paths.last
|
|
188
|
-
logger.debug "Rails final dependency load path: #{self.rails_final_dependency_load_path}"
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# Create Plugin instances for plugins loaded before the engines plugin was.
|
|
192
|
-
# Once a Plugin instance is created, the Plugin#load method is then called
|
|
193
|
-
# to fully load the plugin. See Plugin#load for more details about how a
|
|
194
|
-
# plugin is started once engines is involved.
|
|
195
|
-
def self.enhance_loaded_plugins
|
|
196
|
-
Engines.rails_initializer.loaded_plugins.each do |name|
|
|
197
|
-
plugin_path = File.join(self.find_plugin_path(name), name)
|
|
198
|
-
unless Rails.plugins[name]
|
|
199
|
-
plugin = Plugin.new(name, plugin_path)
|
|
200
|
-
logger.debug "enginizing plugin: #{plugin.name} from #{plugin_path}"
|
|
201
|
-
plugin.load # injects the extra directories into the load path, and mirrors public files
|
|
202
|
-
Rails.plugins << plugin
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
logger.debug "plugins is now: #{Rails.plugins.map { |p| p.name }.join(", ")}"
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
# Ensure that the plugin asset subdirectory of RAILS_ROOT/public exists, and
|
|
209
|
-
# that we've added a little warning message to instruct developers not to mess with
|
|
210
|
-
# the files inside, since they're automatically generated.
|
|
211
|
-
def self.initialize_base_public_directory
|
|
212
|
-
if !File.exist?(self.public_directory)
|
|
213
|
-
# create the public/engines directory, with a warning message in it.
|
|
214
|
-
logger.debug "Creating public engine files directory '#{self.public_directory}'"
|
|
215
|
-
FileUtils.mkdir(self.public_directory)
|
|
216
|
-
message = %{Files in this directory are automatically generated from your Rails Engines.
|
|
217
|
-
They are copied from the 'public' directories of each engine into this directory
|
|
218
|
-
each time Rails starts (server, console... any time 'start_engine' is called).
|
|
219
|
-
Any edits you make will NOT persist across the next server restart; instead you
|
|
220
|
-
should edit the files within the <plugin_name>/assets/ directory itself.}
|
|
221
|
-
target = File.join(public_directory, "README")
|
|
222
|
-
File.open(target, 'w') { |f| f.puts(message) } unless File.exist?(target)
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
# Check for a "*" at the end of the plugins list; if one is found, note that
|
|
227
|
-
# we should load all other plugins once Rails has finished initializing, and
|
|
228
|
-
# remove the "*".
|
|
229
|
-
def self.check_for_star_wildcard
|
|
230
|
-
if Rails.configuration.plugins && Rails.configuration.plugins.last == "*"
|
|
231
|
-
Rails.configuration.plugins.pop
|
|
232
|
-
@load_all_plugins = true
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
#-
|
|
238
|
-
# The following code is called once all plugins are loaded, and Rails is almost
|
|
239
|
-
# finished initialization
|
|
240
|
-
#+
|
|
241
|
-
|
|
242
|
-
# Once the Rails Initializer has finished, the engines plugin takes over
|
|
243
|
-
# and performs any post-processing tasks it may have, including:
|
|
244
|
-
#
|
|
245
|
-
# * Loading any remaining plugins if config.plugins ended with a '*'.
|
|
246
|
-
# * Updating Rails::Info with version information, if possible.
|
|
247
|
-
#
|
|
248
|
-
def self.after_initialize
|
|
249
|
-
if self.load_all_plugins?
|
|
250
|
-
logger.debug "loading remaining plugins from #{Rails.configuration.plugin_paths.inspect}"
|
|
251
|
-
# this will actually try to load ALL plugins again, but any that have already
|
|
252
|
-
# been loaded will be ignored.
|
|
253
|
-
rails_initializer.load_all_plugins
|
|
254
|
-
update_rails_info_with_loaded_plugins
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
# Updates Rails::Info with the list of loaded plugins, and version information for
|
|
259
|
-
# each plugin. This information is then available via script/about, or through
|
|
260
|
-
# the builtin rails_info controller.
|
|
261
|
-
def self.update_rails_info_with_loaded_plugins
|
|
262
|
-
if defined?(Rails::Info) # since it may not be available by default in some environments...
|
|
263
|
-
# don't do anything if it's not there.
|
|
264
|
-
Rails::Info.property("Loaded plugins") { Rails.plugins.map { |p| p.name }.join(", ") }
|
|
265
|
-
Rails.plugins.each do |plugin|
|
|
266
|
-
Rails::Info.property("#{plugin.name} version") { plugin.version.blank? ? "(unknown)" : plugin.version }
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
#-
|
|
272
|
-
# helper methods to find and deal with plugin paths and names
|
|
273
|
-
#+
|
|
274
|
-
|
|
275
|
-
# Returns the path within +Rails.configuration.plugin_paths+ which includes
|
|
276
|
-
# a plugin with the given name.
|
|
277
|
-
def self.find_plugin_path(name)
|
|
278
|
-
Rails.configuration.plugin_paths.find do |path|
|
|
279
|
-
File.exist?(File.join(path, name.to_s))
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
# Returns the name for the plugin at the given path.
|
|
284
|
-
# (Note this method also appears in Rails::Initializer extensions)
|
|
285
|
-
def self.plugin_name(path)
|
|
286
|
-
File.basename(path)
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
# A general purpose method to mirror a directory (+source+) into a destination
|
|
290
|
-
# directory, including all files and subdirectories. Files will not be mirrored
|
|
291
|
-
# if they are identical already (checked via FileUtils#identical?).
|
|
292
|
-
def self.mirror_files_from(source, destination)
|
|
293
|
-
return unless File.directory?(source)
|
|
294
|
-
|
|
295
|
-
# TODO: use Rake::FileList#pathmap?
|
|
296
|
-
|
|
297
|
-
source_files = Dir[source + "/**/*"]
|
|
298
|
-
source_dirs = source_files.select { |d| File.directory?(d) }
|
|
299
|
-
source_files -= source_dirs
|
|
300
|
-
|
|
301
|
-
source_dirs.each do |dir|
|
|
302
|
-
# strip down these paths so we have simple, relative paths we can
|
|
303
|
-
# add to the destination
|
|
304
|
-
target_dir = File.join(destination, dir.gsub(source, ''))
|
|
305
|
-
begin
|
|
306
|
-
FileUtils.mkdir_p(target_dir)
|
|
307
|
-
rescue Exception => e
|
|
308
|
-
raise "Could not create directory #{target_dir}: \n" + e
|
|
309
|
-
end
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
source_files.each do |file|
|
|
313
|
-
begin
|
|
314
|
-
target = File.join(destination, file.gsub(source, ''))
|
|
315
|
-
unless File.exist?(target) && FileUtils.identical?(file, target)
|
|
316
|
-
FileUtils.cp(file, target)
|
|
317
|
-
end
|
|
318
|
-
rescue Exception => e
|
|
319
|
-
raise "Could not copy #{file} to #{target}: \n" + e
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
end
|