parlement 0.3 → 0.4

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.
Files changed (122) hide show
  1. data/CHANGES +16 -0
  2. data/README +36 -3
  3. data/Rakefile +8 -12
  4. data/app/controllers/account_controller.rb +2 -0
  5. data/app/controllers/elt_controller.rb +1 -5
  6. data/app/controllers/subscriber_controller.rb +1 -1
  7. data/app/helpers/elt_helper.rb +30 -10
  8. data/app/models/elt.rb +2 -1
  9. data/app/models/mail.rb +41 -41
  10. data/app/models/mail_notify.rb +27 -10
  11. data/app/views/account/_login.rhtml +9 -7
  12. data/app/views/account/_show.rhtml +4 -4
  13. data/app/views/elt/_elt.rhtml +52 -51
  14. data/app/views/elt/_list.rhtml +22 -14
  15. data/app/views/elt/new.rhtml +1 -1
  16. data/app/views/elt/show.rhtml +15 -16
  17. data/app/views/layouts/top.rhtml +13 -1
  18. data/app/views/person/show.rhtml +1 -7
  19. data/config/boot.rb +32 -7
  20. data/config/database.yml +3 -0
  21. data/config/environment.rb +3 -1
  22. data/config/environments/development.rb +1 -1
  23. data/db/ROOT/parlement/ddRing.txt +14 -0
  24. data/db/ROOT/parlement/top-politics.txt +12 -0
  25. data/db/ROOT/perso.txt +1 -1
  26. data/db/development_structure.sql +30 -16
  27. data/db/schema.rb +18 -10
  28. data/db/schema.sql +34 -34
  29. data/public/javascripts/application.js +2 -0
  30. data/public/javascripts/blank.gif +0 -0
  31. data/public/javascripts/borders.js +687 -0
  32. data/public/javascripts/controls.js +95 -30
  33. data/public/javascripts/dragdrop.js +161 -21
  34. data/public/javascripts/effects.js +310 -211
  35. data/public/javascripts/ie7-load.htc +1 -0
  36. data/public/javascripts/prototype.js +228 -28
  37. data/test/fixtures/attachments.yml +3 -0
  38. data/test/fixtures/mail/mail_ruby +1 -0
  39. data/test/fixtures/people.yml +14 -0
  40. data/test/functional/account_controller_test.rb +3 -2
  41. data/test/unit/mail_notify_test.rb +2 -0
  42. data/test/unit/mail_test.rb +59 -6
  43. data/test/unit/person_test.rb +1 -1
  44. data/vendor/plugins/engines/CHANGELOG +92 -0
  45. data/vendor/plugins/engines/MIT-LICENSE +21 -0
  46. data/vendor/plugins/engines/README +325 -39
  47. data/vendor/plugins/engines/generators/engine/USAGE +26 -0
  48. data/vendor/plugins/engines/generators/engine/engine_generator.rb +199 -0
  49. data/vendor/plugins/engines/generators/engine/templates/README +85 -0
  50. data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +13 -0
  51. data/vendor/plugins/engines/generators/engine/templates/install.erb +4 -0
  52. data/vendor/plugins/engines/generators/engine/templates/lib/engine.erb +6 -0
  53. data/vendor/plugins/engines/generators/engine/templates/licenses/GPL +18 -0
  54. data/vendor/plugins/engines/generators/engine/templates/licenses/LGPL +19 -0
  55. data/vendor/plugins/engines/generators/engine/templates/licenses/MIT +22 -0
  56. data/vendor/plugins/engines/generators/engine/templates/licenses/None +1 -0
  57. data/vendor/plugins/engines/generators/engine/templates/public/javascripts/engine.js +0 -0
  58. data/vendor/plugins/engines/generators/engine/templates/public/stylesheets/engine.css +0 -0
  59. data/vendor/plugins/engines/generators/engine/templates/tasks/engine.rake +0 -0
  60. data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +13 -0
  61. data/vendor/plugins/engines/init.rb +18 -3
  62. data/vendor/plugins/engines/lib/bundles/require_resource.rb +124 -0
  63. data/vendor/plugins/engines/lib/bundles.rb +77 -0
  64. data/vendor/plugins/engines/lib/{action_mailer_extensions.rb → engines/action_mailer_extensions.rb} +15 -36
  65. data/vendor/plugins/engines/lib/{action_view_extensions.rb → engines/action_view_extensions.rb} +40 -33
  66. data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +19 -0
  67. data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +118 -0
  68. data/vendor/plugins/engines/lib/engines/migration_extensions.rb +53 -0
  69. data/vendor/plugins/engines/lib/{ruby_extensions.rb → engines/ruby_extensions.rb} +14 -28
  70. data/vendor/plugins/engines/lib/engines/testing_extensions.rb +323 -0
  71. data/vendor/plugins/engines/lib/engines.rb +258 -148
  72. data/vendor/plugins/engines/tasks/engines.rake +161 -0
  73. data/vendor/plugins/engines/test/action_view_extensions_test.rb +9 -0
  74. data/vendor/plugins/engines/test/ruby_extensions_test.rb +24 -3
  75. data/vendor/plugins/guid/README.TXT +14 -4
  76. data/vendor/plugins/guid/init.rb +9 -2
  77. data/vendor/plugins/guid/lib/uuidtools.rb +22 -15
  78. data/vendor/plugins/login_engine/CHANGELOG +14 -0
  79. data/vendor/plugins/login_engine/README +93 -7
  80. data/vendor/plugins/login_engine/app/controllers/user_controller.rb +30 -20
  81. data/vendor/plugins/login_engine/app/helpers/user_helper.rb +1 -1
  82. data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +2 -2
  83. data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +25 -0
  84. data/vendor/plugins/login_engine/install.rb +4 -0
  85. data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +11 -5
  86. data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +15 -9
  87. data/vendor/plugins/login_engine/lib/login_engine.rb +7 -3
  88. data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +22 -19
  89. data/vendor/plugins/login_engine/test/test_helper.rb +4 -8
  90. data/vendor/plugins/login_engine/test/unit/user_test.rb +31 -11
  91. metadata +60 -57
  92. data/app/models/attachment.rb +0 -6
  93. data/public/attachment/file/architecture.png +0 -0
  94. data/public/attachment/file/architecture.svg +0 -8972
  95. data/public/attachment/file/security.svg +0 -8960
  96. data/public/engine_files/login_engine/stylesheets/login_engine.css +0 -81
  97. data/public/oldREADME +0 -190
  98. data/public/stylesheets/default.css +0 -235
  99. data/public/stylesheets/live_tree.css +0 -62
  100. data/public/stylesheets/scaffold.css +0 -74
  101. data/script/about +0 -3
  102. data/script/benchmarker +0 -19
  103. data/script/breakpointer +0 -3
  104. data/script/console +0 -3
  105. data/script/create_db +0 -7
  106. data/script/destroy +0 -3
  107. data/script/generate +0 -3
  108. data/script/performance/benchmarker +0 -3
  109. data/script/performance/profiler +0 -3
  110. data/script/plugin +0 -3
  111. data/script/process/reaper +0 -3
  112. data/script/process/spawner +0 -3
  113. data/script/process/spinner +0 -3
  114. data/script/profiler +0 -34
  115. data/script/runner +0 -3
  116. data/script/server +0 -3
  117. data/test/unit/user_test.rb +0 -94
  118. data/vendor/plugins/engines/lib/dependencies_extensions.rb +0 -56
  119. data/vendor/plugins/engines/lib/testing_extensions.rb +0 -33
  120. data/vendor/plugins/login_engine/db/schema.rb +0 -25
  121. data/vendor/plugins/login_engine/test/fixtures/templates/users.yml +0 -41
  122. /data/public/images/{eltBackground.png → eltBackground.jng} +0 -0
@@ -0,0 +1,199 @@
1
+ # Copyright (c) 2005 Jonathan Lim <snowblink@gmail.com>
2
+ #
3
+ # The MIT License
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+
24
+ module Rails
25
+ module Generator
26
+ module Commands
27
+
28
+ class Create < Base
29
+ def complex_template(relative_source, relative_destination, template_options = {})
30
+ options = template_options.dup
31
+ options[:assigns] ||= {}
32
+ options[:assigns]['template_for_inclusion'] = render_template_part(template_options) if template_options[:mark_id]
33
+ options[:assigns]['license'] = render_license(template_options)
34
+ template(relative_source, relative_destination, options)
35
+ end
36
+
37
+ def render_license(template_options)
38
+ # Getting Sandbox to evaluate part template in it
39
+ part_binding = template_options[:sandbox].call.sandbox_binding
40
+ part_rel_path = template_options[:insert]
41
+ part_path = source_path(part_rel_path)
42
+
43
+ # Render inner template within Sandbox binding
44
+ template_file = File.readlines(part_path)
45
+ case template_options[:comment_style]
46
+ when :rb
47
+ template_file.map! {|x| x.sub(/^/, '# ')}
48
+ end
49
+ rendered_part = ERB.new(template_file.join, nil, '-').result(part_binding)
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+
58
+ class LicensingSandbox
59
+ include ActionView::Helpers::ActiveRecordHelper
60
+ attr_accessor :author
61
+
62
+ def sandbox_binding
63
+ binding
64
+ end
65
+
66
+ end
67
+
68
+ class Author
69
+ def initialize
70
+ set_name
71
+ set_email
72
+ end
73
+
74
+ def set_name
75
+ print "Please enter the author's name: "
76
+ @name = gets.chomp
77
+ end
78
+
79
+ def set_email
80
+ print "Please enter the author's email: "
81
+ @email = gets.chomp
82
+ end
83
+
84
+ def to_s
85
+ "#{@name} <#{@email}>"
86
+ end
87
+ end
88
+
89
+ class License
90
+ def initialize(source_root)
91
+ @source_root = source_root
92
+ select_license
93
+ end
94
+
95
+ def select_license
96
+ # list all the licenses in the licenses directory
97
+ licenses = Dir.entries(File.join(@source_root, 'licenses')).select { |name| name !~ /^\./ }
98
+ puts "We can generate the following licenses automatically for you:"
99
+ licenses.sort.each_with_index do |license, index|
100
+ puts "#{index}) #{licenses[index]}"
101
+ end
102
+ print "Please select a license: "
103
+ while choice = gets.chomp
104
+ if (choice !~ /^[0-9]+$/)
105
+ print "Hint - you want to be typing a number.\nPlease select a license: "
106
+ next
107
+ end
108
+ break if choice.to_i >=0 && choice.to_i <= licenses.length
109
+ end
110
+
111
+ @license = licenses[choice.to_i]
112
+ puts "'#{@license}' selected"
113
+ end
114
+
115
+ def to_s
116
+ File.join('licenses', @license)
117
+ end
118
+
119
+ end
120
+
121
+ class EngineGenerator < Rails::Generator::NamedBase
122
+
123
+ attr_reader :engine_class_name, :engine_underscored_name, :engine_start_name, :author
124
+
125
+
126
+ def initialize(runtime_args, runtime_options = {})
127
+ super
128
+ @engine_class_name = runtime_args.shift
129
+
130
+ # ensure that they've given us a valid class name
131
+ if @engine_class_name =~ /^[a-z]/
132
+ raise "'#{@engine_class_name}' should be a valid Ruby constant, e.g. 'MyEngine'; aborting generation..."
133
+ end
134
+
135
+ @engine_underscored_name = @engine_class_name.underscore
136
+ @engine_start_name = @engine_underscored_name.sub(/_engine$/, '')
137
+ @author = Author.new
138
+ @license = License.new(source_root)
139
+ end
140
+
141
+ def manifest
142
+ record do |m|
143
+ m.directory File.join('vendor', 'plugins')
144
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name)
145
+ m.complex_template 'README',
146
+ File.join('vendor', 'plugins', @engine_underscored_name, 'README'),
147
+ :sandbox => lambda {create_sandbox},
148
+ :insert => @license.to_s
149
+
150
+ m.file 'install.erb', File.join('vendor', 'plugins', @engine_underscored_name, 'install.rb')
151
+
152
+ m.complex_template 'init_engine.erb',
153
+ File.join('vendor', 'plugins', @engine_underscored_name, 'init_engine.rb'),
154
+ :sandbox => lambda {create_sandbox},
155
+ :insert => @license.to_s,
156
+ :comment_style => :rb
157
+
158
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'app')
159
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'app', 'models')
160
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'app', 'controllers')
161
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'app', 'helpers')
162
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'app', 'views')
163
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'db')
164
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'db', 'migrate')
165
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'lib')
166
+ m.complex_template File.join('lib', 'engine.erb'),
167
+ File.join('vendor', 'plugins', @engine_underscored_name, 'lib', "#{@engine_underscored_name}.rb"),
168
+ :sandbox => lambda {create_sandbox},
169
+ :insert => @license.to_s,
170
+ :comment_style => :rb
171
+
172
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'lib', @engine_underscored_name)
173
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'public')
174
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'public', 'javascripts')
175
+ m.template File.join('public', 'javascripts', 'engine.js'), File.join('vendor', 'plugins', @engine_underscored_name, 'public', 'javascripts', "#{@engine_underscored_name}.js")
176
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'public', 'stylesheets')
177
+ m.template File.join('public', 'stylesheets', 'engine.css'), File.join('vendor', 'plugins', @engine_underscored_name, 'public', 'stylesheets', "#{@engine_underscored_name}.css")
178
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'tasks')
179
+ m.template File.join('tasks', 'engine.rake'), File.join('vendor', 'plugins', @engine_underscored_name, 'tasks', "#{@engine_underscored_name}.rake")
180
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'test')
181
+ m.template File.join('test', 'test_helper.erb'), File.join('vendor', 'plugins', @engine_underscored_name, 'test', 'test_helper.rb')
182
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'test', 'fixtures')
183
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'test', 'functional')
184
+ m.directory File.join('vendor', 'plugins', @engine_underscored_name, 'test', 'unit')
185
+ end
186
+ end
187
+
188
+ protected
189
+ def banner
190
+ "Usage: #{$0} #{spec.name} MyEngine [general options]"
191
+ end
192
+
193
+ def create_sandbox
194
+ sandbox = LicensingSandbox.new
195
+ sandbox.author = @author
196
+ sandbox
197
+ end
198
+
199
+ end
@@ -0,0 +1,85 @@
1
+ ------------------[ once you've read this, delete it ]---------------------
2
+
3
+ ENGINE DEVELOPERS - HEED THIS!
4
+
5
+ This is a sample README file to guide your users when they are installing what is undoubtedly going to be the finest piece of code they ever got their hands on. Lucky them, but alas they are often foolish, and so this is where you can guide them with the metaphorical beating of twigs. Or just a numbered series of instructions.
6
+
7
+ ANYWAY - you will almost certainly need to tailor this to your specific engine. For instance, your users will probably only need to include modules into the ApplicationController and ApplicationHelper if your engine defines methods to be usable by controllers and views external to your engine.
8
+
9
+ If you engine does not rely on any database tables, you will probably not need migrations either.
10
+
11
+ You are also under no obligation to use the 'config' method for setting options within your modules. Documentation which explains the purpose of the 'config' method is available as part of the Engines plugin itself.
12
+
13
+ Please check the engine development information on the Rails Engines wiki for more information about what to do now:
14
+
15
+ http://rails-engines.rubyforge.org/wiki/wiki.pl?DevelopingAnEngine
16
+
17
+ -----------------------[ remember to delete me! ]--------------------------
18
+
19
+ = <%= engine_class_name %>
20
+
21
+ <%= engine_class_name %> is a ...
22
+
23
+ This software package is developed using the Engines plugin. To find out more about how to use engines in general, go to http://rails-engines.rubyforge.org for general documentation about the Engines mechanism.
24
+
25
+ == Installation
26
+
27
+ 1. Create your Rails application, set up your databases, grab the Engines plugin and the <%= engine_class_name %>, and install them.
28
+
29
+ 2. Install the <%= engine_class_name %> into your vendor/plugins directory
30
+
31
+ 3. Modify your Engines.start call in config/environment.rb
32
+
33
+ Engines.start :<%= engine_start_name %> # or :<%= engine_underscored_name %>
34
+
35
+ 4. Edit your application.rb file so it looks something like the following:
36
+
37
+ class ApplicationController < ActionController::Base
38
+ include <%= engine_class_name %>
39
+ end
40
+
41
+ 5. Edit your application_helper.rb file:
42
+
43
+ module ApplicationHelper
44
+ include <%= engine_class_name %>
45
+ end
46
+
47
+ 6. Perform any configuration you might need. You'll probably want to set these values in environment.rb (before the call to Engines.start):
48
+
49
+ module <%= engine_class_name %>
50
+ config :some_option, "some_value"
51
+ end
52
+
53
+ 7. Initialize the database tables. You can either use the engine migrations by calling:
54
+
55
+ rake engine_migrate
56
+
57
+ to move all engines to their latest versions, or
58
+
59
+ rake engine_migrate ENGINE=<%= engine_start_name %>
60
+
61
+ to migrate only this engine.
62
+
63
+ 8. The <%= engine_class_name %> provides a default stylesheet and a small javascript helper file, so you'll probably want to include the former and almost certainly the latter in your application's layout. Add the following lines:
64
+
65
+ <%%= engine_stylesheet "<%=engine_start_name%>_engine" %>
66
+ <%%= engine_javascript "<%=engine_start_name%>_engine" %>
67
+
68
+ == Configuration
69
+
70
+ A number of configuration parameters are available to allow to you control
71
+ how the data is stored, should you be unhappy with the defaults. These are
72
+ outlined below.
73
+
74
+ module <%= engine_class_name %>
75
+ config :some_option, "some_value"
76
+ end
77
+
78
+ === Configuration Options
79
+ +some_option+:: This option will set some_value
80
+
81
+ == Usage
82
+ How to use this engine
83
+
84
+ == License
85
+ <%= license %>
@@ -0,0 +1,13 @@
1
+ <%= license %>
2
+
3
+ module <%= engine_class_name %>::VERSION
4
+ Major = 0 # change implies compatibility breaking with previous versions
5
+ Minor = 1 # change implies backwards-compatible change to API
6
+ Release = 0 # incremented with bug-fixes, updates, etc.
7
+ end
8
+
9
+ Engines.current.version = <%= engine_class_name %>::VERSION
10
+
11
+ # load up all the required files we need...
12
+ require '<%= engine_underscored_name %>'
13
+
@@ -0,0 +1,4 @@
1
+ # Install the engines plugin if it has been already
2
+ unless File.exist?(File.dirname(__FILE__) + "/../engines")
3
+ Commands::Plugin.parse!(['install', 'http://svn.rails-engines.org/plugins/engines'])
4
+ end
@@ -0,0 +1,6 @@
1
+ <%= license %>
2
+
3
+ #require '<%= engine_underscored_name %>/additional_files'
4
+
5
+ module <%= engine_class_name %>
6
+ end
@@ -0,0 +1,18 @@
1
+ Copyright (c) <%= Time.now.strftime("%Y") %> <%= author %>
2
+
3
+ The GNU General Public License (GPL)
4
+ Version 2, June 1991
5
+
6
+ This program is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation; either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -0,0 +1,19 @@
1
+ Copyright (c) <%= Time.now.strftime("%Y") %> <%= author %>
2
+
3
+ GNU Lesser General Public License
4
+ Version 2.1, February 1999
5
+
6
+ This library is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU Lesser General Public
8
+ License as published by the Free Software Foundation; either
9
+ version 2.1 of the License, or (at your option) any later version.
10
+
11
+ This library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public
17
+ License along with this library; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) <%= Time.now.strftime("%Y") %> <%= author %>
2
+
3
+ The MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
@@ -0,0 +1 @@
1
+ Copyright (c) <%= Time.now.strftime("%Y") %> <%= author %>
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') # the default rails helper
2
+
3
+ # ensure that the Engines testing enhancements are loaded.
4
+ require File.join(Engines.config(:root), "engines", "lib", "engines", "testing_extensions")
5
+
6
+ # force these config values
7
+ module <%= engine_class_name %>
8
+ # config :some_option, "some_value"
9
+ end
10
+
11
+ # set up the fixtures location
12
+ Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
13
+ $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005 James Adam
2
+ # Copyright (c) 2006 James Adam
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -19,15 +19,30 @@
19
19
  # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
20
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+ #
24
+ #
25
+ # = IN OTHER WORDS:
26
+ #
27
+ # You are free to use this software as you please, but if it breaks you'd
28
+ # come a'cryin...
22
29
  #++
23
30
 
24
31
 
25
32
  require 'engines'
33
+ require 'bundles'
34
+
35
+ module ::Engines::Version
36
+ Major = 1 # change implies compatibility breaking with previous versions
37
+ Minor = 1 # change implies backwards-compatible change to API
38
+ Release = 1 # incremented with bug-fixes, updates, etc.
39
+ end
26
40
 
27
41
  #--
28
42
  # Create the Engines directory if it isn't present
29
43
  #++
30
44
  if !File.exist?(Engines.config(:root))
31
- RAILS_DEFAULT_LOGGER.debug "Creating engines directory in /vendor"
45
+ Engines.log.debug "Creating engines directory in /vendor"
32
46
  FileUtils.mkdir_p(Engines.config(:root))
33
- end
47
+ end
48
+
@@ -0,0 +1,124 @@
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)
@@ -0,0 +1,77 @@
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