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,135 +0,0 @@
|
|
|
1
|
-
# This file contains support for the now-deprecated +config+ method that the engines
|
|
2
|
-
# plugin provided before version 1.2. Instead of using this, plugin authors are
|
|
3
|
-
# now encouraged to create their own Module configuration mechanisms; the
|
|
4
|
-
# +mattr_accessor+ mechanism provided by ActiveSupport is ideal for this:
|
|
5
|
-
#
|
|
6
|
-
# module MyPlugin
|
|
7
|
-
# mattr_accessor :config_value
|
|
8
|
-
# self.config_value = "default"
|
|
9
|
-
# end
|
|
10
|
-
#
|
|
11
|
-
# == Using the deprecated config method
|
|
12
|
-
#
|
|
13
|
-
# If you require the config method to be present, change your <tt>environment.rb</tt>
|
|
14
|
-
# file such that the very top of the file looks like this:
|
|
15
|
-
#
|
|
16
|
-
# require File.join(File.dirname(__FILE__), 'boot')
|
|
17
|
-
# require File.join(RAILS_ROOT, "vendor", "plugins", "engines",
|
|
18
|
-
# "lib", "engines", "deprecated_config_support")
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# Adds the +config+ and +default_constant+ methods to Module.
|
|
23
|
-
#
|
|
24
|
-
# *IMPORTANT NOTE* - these methods are deprecated. Only use them when you have no
|
|
25
|
-
# other choice. See link:files/lib/engines/deprecated_config_support_rb.html for more
|
|
26
|
-
# information.
|
|
27
|
-
class Module
|
|
28
|
-
# Defines a constant within a module/class ONLY if that constant does
|
|
29
|
-
# not already exist.
|
|
30
|
-
#
|
|
31
|
-
# This can be used to implement defaults in plugins/engines/libraries, e.g.
|
|
32
|
-
# if a plugin module exists:
|
|
33
|
-
# module MyPlugin
|
|
34
|
-
# default_constant :MyDefault, "the_default_value"
|
|
35
|
-
# end
|
|
36
|
-
#
|
|
37
|
-
# then developers can override this default by defining that constant at
|
|
38
|
-
# some point *before* the module/plugin gets loaded (such as environment.rb)
|
|
39
|
-
def default_constant(name, value)
|
|
40
|
-
if !(name.is_a?(String) or name.is_a?(Symbol))
|
|
41
|
-
raise "Cannot use a #{name.class.name} ['#{name}'] object as a constant name"
|
|
42
|
-
end
|
|
43
|
-
if !self.const_defined?(name)
|
|
44
|
-
self.class_eval("#{name} = #{value.inspect}")
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# A mechanism for defining configuration of Modules. With this
|
|
49
|
-
# mechanism, default values for configuration can be provided within shareable
|
|
50
|
-
# code, and the end user can customise the configuration without having to
|
|
51
|
-
# provide all values.
|
|
52
|
-
#
|
|
53
|
-
# Example:
|
|
54
|
-
#
|
|
55
|
-
# module MyModule
|
|
56
|
-
# config :param_one, "some value"
|
|
57
|
-
# config :param_two, 12345
|
|
58
|
-
# end
|
|
59
|
-
#
|
|
60
|
-
# Those values can now be accessed by the following method
|
|
61
|
-
#
|
|
62
|
-
# MyModule.config :param_one
|
|
63
|
-
# => "some value"
|
|
64
|
-
# MyModule.config :param_two
|
|
65
|
-
# => 12345
|
|
66
|
-
#
|
|
67
|
-
# ... or, if you have overrriden the method 'config'
|
|
68
|
-
#
|
|
69
|
-
# MyModule::CONFIG[:param_one]
|
|
70
|
-
# => "some value"
|
|
71
|
-
# MyModule::CONFIG[:param_two]
|
|
72
|
-
# => 12345
|
|
73
|
-
#
|
|
74
|
-
# Once a value is stored in the configuration, it will not be altered
|
|
75
|
-
# by subsequent assignments, unless a special flag is given:
|
|
76
|
-
#
|
|
77
|
-
# (later on in your code, most likely in another file)
|
|
78
|
-
# module MyModule
|
|
79
|
-
# config :param_one, "another value"
|
|
80
|
-
# config :param_two, 98765, :force
|
|
81
|
-
# end
|
|
82
|
-
#
|
|
83
|
-
# The configuration is now:
|
|
84
|
-
#
|
|
85
|
-
# MyModule.config :param_one
|
|
86
|
-
# => "some value" # not changed
|
|
87
|
-
# MyModule.config :param_two
|
|
88
|
-
# => 98765
|
|
89
|
-
#
|
|
90
|
-
# Configuration values can also be given as a Hash:
|
|
91
|
-
#
|
|
92
|
-
# MyModule.config :param1 => 'value1', :param2 => 'value2'
|
|
93
|
-
#
|
|
94
|
-
# Setting of these values can also be forced:
|
|
95
|
-
#
|
|
96
|
-
# MyModule.config :param1 => 'value3', :param2 => 'value4', :force => true
|
|
97
|
-
#
|
|
98
|
-
# A value of anything other than false or nil given for the :force key will
|
|
99
|
-
# result in the new values *always* being set.
|
|
100
|
-
def config(*args)
|
|
101
|
-
|
|
102
|
-
raise "config expects at least one argument" if args.empty?
|
|
103
|
-
|
|
104
|
-
# extract the arguments
|
|
105
|
-
if args[0].is_a?(Hash)
|
|
106
|
-
override = args[0][:force]
|
|
107
|
-
args[0].delete(:force)
|
|
108
|
-
args[0].each { |key, value| _handle_config(key, value, override)}
|
|
109
|
-
else
|
|
110
|
-
_handle_config(*args)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
private
|
|
115
|
-
# Actually set the config values
|
|
116
|
-
def _handle_config(name, value=nil, override=false)
|
|
117
|
-
if !self.const_defined?("CONFIG")
|
|
118
|
-
self.class_eval("CONFIG = {}")
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
if value != nil
|
|
122
|
-
if override or self::CONFIG[name] == nil
|
|
123
|
-
self::CONFIG[name] = value
|
|
124
|
-
end
|
|
125
|
-
else
|
|
126
|
-
# if we pass an array of config keys to config(),
|
|
127
|
-
# get the array of values back
|
|
128
|
-
if name.is_a? Array
|
|
129
|
-
name.map { |c| self::CONFIG[c] }
|
|
130
|
-
else
|
|
131
|
-
self::CONFIG[name]
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
# An instance of Plugin is created for each plugin loaded by Rails, and
|
|
2
|
-
# stored in the <tt>Rails.plugins</tt> PluginList
|
|
3
|
-
# (see Engines::RailsExtensions::RailsInitializer for more details).
|
|
4
|
-
#
|
|
5
|
-
# Once the engines plugin is loaded, other plugins can take advantage of
|
|
6
|
-
# their own instances by accessing either Engines.current, or the preferred mechanism
|
|
7
|
-
#
|
|
8
|
-
# Rails.plugins[:plugin_name]
|
|
9
|
-
#
|
|
10
|
-
# Useful properties of this object include Plugin#version, which plugin developers
|
|
11
|
-
# can set in their <tt>init.rb</tt> scripts:
|
|
12
|
-
#
|
|
13
|
-
# Rails.plugins[:my_plugin].version = "1.4.2"
|
|
14
|
-
#
|
|
15
|
-
# Plugin developers can also access the contents of their <tt>about.yml</tt> files
|
|
16
|
-
# via Plugin#about, which returns a Hash if the <tt>about.yml</tt> file exists for
|
|
17
|
-
# this plugin. Note that if <tt>about.yml</tt> contains a "version" key, it will
|
|
18
|
-
# automatically be loaded into the <tt>version</tt> attribute described above.
|
|
19
|
-
#
|
|
20
|
-
# If this plugin contains paths in directories other than <tt>app/controllers</tt>,
|
|
21
|
-
# <tt>app/helpers</tt>, <tt>app/models</tt> and <tt>components</tt>, authors can
|
|
22
|
-
# declare this by adding extra paths to #code_paths:
|
|
23
|
-
#
|
|
24
|
-
# Rails.plugin[:my_plugin].code_paths << "app/sweepers" << "vendor/my_lib"
|
|
25
|
-
#
|
|
26
|
-
# Other properties of the Plugin instance can also be set.
|
|
27
|
-
class Plugin
|
|
28
|
-
|
|
29
|
-
# The name of this plugin
|
|
30
|
-
attr_accessor :name
|
|
31
|
-
|
|
32
|
-
# The directory in which this plugin is located
|
|
33
|
-
attr_accessor :root
|
|
34
|
-
|
|
35
|
-
# The version of this plugin
|
|
36
|
-
attr_accessor :version
|
|
37
|
-
|
|
38
|
-
# The about.yml information as a Hash, if it exists
|
|
39
|
-
attr_accessor :about
|
|
40
|
-
|
|
41
|
-
# Plugins can add code paths to this attribute in init.rb if they
|
|
42
|
-
# need plugin directories to be added to the load path, i.e.
|
|
43
|
-
#
|
|
44
|
-
# plugin.code_paths << 'app/other_classes'
|
|
45
|
-
#
|
|
46
|
-
# Defaults to ["app/controllers", "app/helpers", "app/models", "components"]
|
|
47
|
-
# (see #default_code_paths). NOTE: if you want to set this, you must
|
|
48
|
-
# ensure that the engines plugin is loaded before any plugins which
|
|
49
|
-
# reference this since it's not available before the engines plugin has worked
|
|
50
|
-
# its magic.
|
|
51
|
-
attr_accessor :code_paths
|
|
52
|
-
|
|
53
|
-
# Plugins can add paths to this attribute in init.rb if they need
|
|
54
|
-
# controllers loaded from additional locations. See also #default_controller_paths, and
|
|
55
|
-
# the caveat surrounding the #code_paths accessor.
|
|
56
|
-
attr_accessor :controller_paths
|
|
57
|
-
|
|
58
|
-
# The directory in this plugin to mirror into the shared directory
|
|
59
|
-
# under +public+. See Engines.initialize_base_public_directory
|
|
60
|
-
# for more information.
|
|
61
|
-
#
|
|
62
|
-
# Defaults to "assets" (see default_public_directory).
|
|
63
|
-
attr_accessor :public_directory
|
|
64
|
-
|
|
65
|
-
protected
|
|
66
|
-
|
|
67
|
-
# The default set of code paths which will be added to $LOAD_PATH
|
|
68
|
-
# and Dependencies.load_paths
|
|
69
|
-
def default_code_paths
|
|
70
|
-
# lib will actually be removed from the load paths when we call
|
|
71
|
-
# uniq! in #inject_into_load_paths, but it's important to keep it
|
|
72
|
-
# around (for the documentation tasks, for instance).
|
|
73
|
-
%w(app/controllers app/helpers app/models components lib)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# The default set of code paths which will be added to the routing system
|
|
77
|
-
def default_controller_paths
|
|
78
|
-
%w(app/controllers components)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Attempts to detect the directory to use for public files.
|
|
82
|
-
# If +assets+ exists in the plugin, this will be used. If +assets+ is missing
|
|
83
|
-
# but +public+ is found, +public+ will be used.
|
|
84
|
-
def default_public_directory
|
|
85
|
-
%w(assets public).select { |dir| File.directory?(File.join(root, dir)) }.first || "assets"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
public
|
|
89
|
-
|
|
90
|
-
# Creates a new Plugin instance, and loads any other data from <tt>about.yml</tt>
|
|
91
|
-
def initialize(name, path)
|
|
92
|
-
@name = name
|
|
93
|
-
@root = path
|
|
94
|
-
|
|
95
|
-
@code_paths = default_code_paths
|
|
96
|
-
@controller_paths = default_controller_paths
|
|
97
|
-
@public_directory = default_public_directory
|
|
98
|
-
|
|
99
|
-
load_about_information
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# Load the information from <tt>about.yml</tt>. This Hash is then accessible
|
|
103
|
-
# from #about.
|
|
104
|
-
#
|
|
105
|
-
# If <tt>about.yml</tt> includes a "version", this will be assigned
|
|
106
|
-
# automatically into #version.
|
|
107
|
-
def load_about_information
|
|
108
|
-
about_path = File.join(self.root, 'about.yml')
|
|
109
|
-
if File.exist?(about_path)
|
|
110
|
-
@about = YAML.load(File.open(about_path).read)
|
|
111
|
-
@about.stringify_keys!
|
|
112
|
-
@version = @about["version"]
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
# Load the plugin. Since Rails takes care of evaluating <tt>init.rb</tt> and
|
|
117
|
-
# adding +lib+ to the <tt>$LOAD_PATH</tt>, we don't need to do that here (see
|
|
118
|
-
# Engines::RailsExtensions::RailsInitializer.load_plugins_with_engine_additions).
|
|
119
|
-
#
|
|
120
|
-
# Here we add controller/helper code to the appropriate load paths (see
|
|
121
|
-
# #inject_into_load_path) and mirror the plugin assets into the shared public
|
|
122
|
-
# directory (#mirror_public_assets).
|
|
123
|
-
def load
|
|
124
|
-
logger.debug "Plugin '#{name}': starting load."
|
|
125
|
-
|
|
126
|
-
inject_into_load_path
|
|
127
|
-
mirror_public_assets
|
|
128
|
-
|
|
129
|
-
logger.debug "Plugin '#{name}': loaded."
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Adds all directories in the +app+ and +lib+ directories within the engine
|
|
133
|
-
# to the three relevant load paths mechanism that Rails might use:
|
|
134
|
-
#
|
|
135
|
-
# * <tt>$LOAD_PATH</tt>
|
|
136
|
-
# * <tt>Dependencies.load_paths</tt>
|
|
137
|
-
# * <tt>ActionController::Routing.controller_paths</tt>
|
|
138
|
-
#
|
|
139
|
-
def inject_into_load_path
|
|
140
|
-
|
|
141
|
-
load_path_index = $LOAD_PATH.index(Engines.rails_final_load_path)
|
|
142
|
-
dependency_index = ::Dependencies.load_paths.index(Engines.rails_final_dependency_load_path)
|
|
143
|
-
|
|
144
|
-
# Add relevant paths under the engine root to the load path
|
|
145
|
-
code_paths.map { |p| File.join(root, p) }.each do |path|
|
|
146
|
-
if File.directory?(path)
|
|
147
|
-
# Add to the load paths
|
|
148
|
-
$LOAD_PATH.insert(load_path_index + 1, path)
|
|
149
|
-
# Add to the dependency system, for autoloading.
|
|
150
|
-
::Dependencies.load_paths.insert(dependency_index + 1, path)
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# Add controllers to the Routing system specifically. We actually add our paths
|
|
155
|
-
# to the configuration too, since routing is started AFTER plugins are. Plugins
|
|
156
|
-
# which are loaded by engines specifically (i.e. because of the '*' in
|
|
157
|
-
# +config.plugins+) will need their paths added directly to the routing system,
|
|
158
|
-
# since at that point it has already been configured.
|
|
159
|
-
controller_paths.map { |p| File.join(root, p) }.each do |path|
|
|
160
|
-
if File.directory?(path)
|
|
161
|
-
ActionController::Routing.controller_paths << path
|
|
162
|
-
Rails.configuration.controller_paths << path
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
$LOAD_PATH.uniq!
|
|
167
|
-
::Dependencies.load_paths.uniq!
|
|
168
|
-
ActionController::Routing.controller_paths.uniq!
|
|
169
|
-
Rails.configuration.controller_paths.uniq!
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
# Replicates the subdirectories under the plugins's +assets+ (or +public+) directory into
|
|
173
|
-
# the corresponding public directory. See also Plugin#public_directory for more.
|
|
174
|
-
def mirror_public_assets
|
|
175
|
-
|
|
176
|
-
begin
|
|
177
|
-
source = File.join(root, self.public_directory)
|
|
178
|
-
# if there is no public directory, just return after this file
|
|
179
|
-
return if !File.exist?(source)
|
|
180
|
-
|
|
181
|
-
logger.debug "Attempting to copy plugin plugin asset files from '#{source}' to '#{Engines.public_directory}'"
|
|
182
|
-
|
|
183
|
-
Engines.mirror_files_from(source, File.join(Engines.public_directory, name))
|
|
184
|
-
|
|
185
|
-
rescue Exception => e
|
|
186
|
-
logger.warn "WARNING: Couldn't create the public file structure for plugin '#{name}'; Error follows:"
|
|
187
|
-
logger.warn e
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# The path to this plugin's public files
|
|
192
|
-
def public_asset_directory
|
|
193
|
-
"#{File.basename(Engines.public_directory)}/#{name}"
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
# The directory containing this plugin's migrations (<tt>plugin/db/migrate</tt>)
|
|
197
|
-
def migration_directory
|
|
198
|
-
File.join(self.root, 'db', 'migrate')
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
# Returns the version number of the latest migration for this plugin. Returns
|
|
202
|
-
# nil if this plugin has no migrations.
|
|
203
|
-
def latest_migration
|
|
204
|
-
migrations = Dir[migration_directory+"/*.rb"]
|
|
205
|
-
return nil if migrations.empty?
|
|
206
|
-
migrations.map { |p| File.basename(p) }.sort.last.match(/0*(\d+)\_/)[1].to_i
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
# Migrate this plugin to the given version. See Engines::PluginMigrator for more
|
|
210
|
-
# information.
|
|
211
|
-
def migrate(version = nil)
|
|
212
|
-
Engines::PluginMigrator.migrate_plugin(self, version)
|
|
213
|
-
end
|
|
214
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# The PluginList class is an array, enhanced to allow access to loaded plugins
|
|
2
|
-
# by name, and iteration over loaded plugins in order of priority. This array is used
|
|
3
|
-
# by Engines::RailsExtensions::RailsInitializer to create the Rails.plugins array.
|
|
4
|
-
#
|
|
5
|
-
# Each loaded plugin has a corresponding Plugin instance within this array, and
|
|
6
|
-
# the order the plugins were loaded is reflected in the entries in this array.
|
|
7
|
-
#
|
|
8
|
-
# For more information, see the Rails module.
|
|
9
|
-
class PluginList < Array
|
|
10
|
-
# Finds plugins with the set with the given name (accepts Strings or Symbols), or
|
|
11
|
-
# index. So, Rails.plugins[0] returns the first-loaded Plugin, and Rails.plugins[:engines]
|
|
12
|
-
# returns the Plugin instance for the engines plugin itself.
|
|
13
|
-
def [](name_or_index)
|
|
14
|
-
if name_or_index.is_a?(Fixnum)
|
|
15
|
-
super
|
|
16
|
-
else
|
|
17
|
-
self.find { |plugin| plugin.name.to_s == name_or_index.to_s }
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Go through each plugin, highest priority first (last loaded first). Effectively,
|
|
22
|
-
# this is like <tt>Rails.plugins.reverse</tt>, except when given a block, when it behaves
|
|
23
|
-
# like <tt>Rails.plugins.reverse.each</tt>.
|
|
24
|
-
def by_precedence(&block)
|
|
25
|
-
if block_given?
|
|
26
|
-
reverse.each { |x| yield x }
|
|
27
|
-
else
|
|
28
|
-
reverse
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# The PluginMigrator class contains the logic to run migrations from
|
|
2
|
-
# within plugin directories. The directory in which a plugin's migrations
|
|
3
|
-
# should be is determined by the Plugin#migration_directory method.
|
|
4
|
-
#
|
|
5
|
-
# To migrate a plugin, you can simple call the migrate method (Plugin#migrate)
|
|
6
|
-
# with the version number that plugin should be at. The plugin's migrations
|
|
7
|
-
# will then be used to migrate up (or down) to the given version.
|
|
8
|
-
#
|
|
9
|
-
# For more information, see Engines::RailsExtensions::Migrations
|
|
10
|
-
class Engines::PluginMigrator < ActiveRecord::Migrator
|
|
11
|
-
|
|
12
|
-
# We need to be able to set the 'current' engine being migrated.
|
|
13
|
-
cattr_accessor :current_plugin
|
|
14
|
-
|
|
15
|
-
# Runs the migrations from a plugin, up (or down) to the version given
|
|
16
|
-
def self.migrate_plugin(plugin, version)
|
|
17
|
-
self.current_plugin = plugin
|
|
18
|
-
migrate(plugin.migration_directory, version)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Returns the name of the table used to store schema information about
|
|
22
|
-
# installed plugins.
|
|
23
|
-
#
|
|
24
|
-
# See Engines.schema_info_table for more details.
|
|
25
|
-
def self.schema_info_table_name
|
|
26
|
-
ActiveRecord::Base.wrapped_table_name Engines.schema_info_table
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Returns the current version of the given plugin
|
|
30
|
-
def self.current_version(plugin=current_plugin)
|
|
31
|
-
result = ActiveRecord::Base.connection.select_one(<<-ESQL
|
|
32
|
-
SELECT version FROM #{schema_info_table_name}
|
|
33
|
-
WHERE plugin_name = '#{plugin.name}'
|
|
34
|
-
ESQL
|
|
35
|
-
)
|
|
36
|
-
if result
|
|
37
|
-
result["version"].to_i
|
|
38
|
-
else
|
|
39
|
-
# There probably isn't an entry for this engine in the migration info table.
|
|
40
|
-
# We need to create that entry, and set the version to 0
|
|
41
|
-
ActiveRecord::Base.connection.execute(<<-ESQL
|
|
42
|
-
INSERT INTO #{schema_info_table_name} (version, plugin_name)
|
|
43
|
-
VALUES (0,'#{plugin.name}')
|
|
44
|
-
ESQL
|
|
45
|
-
)
|
|
46
|
-
0
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Sets the version of the plugin in Engines::PluginMigrator.current_plugin to
|
|
51
|
-
# the given version.
|
|
52
|
-
def set_schema_version(version)
|
|
53
|
-
ActiveRecord::Base.connection.update(<<-ESQL
|
|
54
|
-
UPDATE #{self.class.schema_info_table_name}
|
|
55
|
-
SET version = #{down? ? version.to_i - 1 : version.to_i}
|
|
56
|
-
WHERE plugin_name = '#{self.current_plugin.name}'
|
|
57
|
-
ESQL
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# This module contains all the extensions that the engines plugin makes to
|
|
2
|
-
# Rails core. Explanations of how each extension works are included as RDoc
|
|
3
|
-
# documentation for each of the modules listed.
|
|
4
|
-
module Engines::RailsExtensions
|
|
5
|
-
# let's not rely *entirely* on Rails' magic modules. Not just yet.
|
|
6
|
-
end
|