Skip to content
Browse files

Initial Commit

  • Loading branch information...
0 parents commit a2967b84a01e2fdfb26b7f1f83336c97ff2b3585 @jyurek jyurek committed Sep 30, 2008
Showing with 23,864 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +3 −0 Capfile
  3. +10 −0 Rakefile
  4. +9 −0 app/controllers/application.rb
  5. +5 −0 app/helpers/application_helper.rb
  6. 0 app/models/.keep
  7. +5 −0 app/views/layouts/_flashes.erb
  8. +14 −0 app/views/layouts/application.html.erb
  9. +109 −0 config/boot.rb
  10. +35 −0 config/database.yml
  11. +41 −0 config/deploy.rb
  12. +24 −0 config/deploy/production.rb
  13. +24 −0 config/deploy/staging.rb
  14. +73 −0 config/environment.rb
  15. +18 −0 config/environments/development.rb
  16. +18 −0 config/environments/production.rb
  17. +12 −0 config/environments/staging.rb
  18. +27 −0 config/environments/test.rb
  19. +6 −0 config/initializers/action_mailer_configs.rb
  20. +3 −0 config/initializers/hoptoad.rb
  21. +10 −0 config/initializers/inflections.rb
  22. +5 −0 config/initializers/mime_types.rb
  23. +15 −0 config/initializers/requires.rb
  24. +4 −0 config/initializers/time_formats.rb
  25. +7 −0 config/mongrel_cluster_production.yml
  26. +7 −0 config/mongrel_cluster_staging.yml
  27. +29 −0 config/routes.rb
  28. 0 db/bootstrap/.keep
  29. 0 db/migrate/.keep
  30. +2 −0 doc/README_FOR_APP
  31. +15 −0 doc/README_FOR_TEMPLATE
  32. +16 −0 lib/tasks/bootstrap.rake
  33. +96 −0 lib/tasks/capistrano.rake
  34. +129 −0 lib/tasks/git_tasks.rake
  35. +40 −0 public/.htaccess
  36. +30 −0 public/404.html
  37. +30 −0 public/422.html
  38. +30 −0 public/500.html
  39. +10 −0 public/dispatch.rb
  40. 0 public/favicon.ico
  41. BIN public/images/rails.png
  42. +2 −0 public/javascripts/application.js
  43. +136 −0 public/javascripts/builder.js
  44. +963 −0 public/javascripts/controls.js
  45. +972 −0 public/javascripts/dragdrop.js
  46. +1,120 −0 public/javascripts/effects.js
  47. +4,225 −0 public/javascripts/prototype.js
  48. +58 −0 public/javascripts/scriptaculous.js
  49. +277 −0 public/javascripts/slider.js
  50. +60 −0 public/javascripts/sound.js
  51. +1 −0 public/robots.txt
  52. 0 public/stylesheets/.keep
  53. +3 −0 script/about
  54. +3 −0 script/breakpointer
  55. +3 −0 script/console
  56. +58 −0 script/create_project
  57. +3 −0 script/dbconsole
  58. +3 −0 script/destroy
  59. +3 −0 script/generate
  60. +3 −0 script/performance/benchmarker
  61. +3 −0 script/performance/profiler
  62. +3 −0 script/performance/request
  63. +3 −0 script/plugin
  64. +3 −0 script/process/inspector
  65. +3 −0 script/process/reaper
  66. +3 −0 script/process/spawner
  67. +3 −0 script/runner
  68. +3 −0 script/server
  69. 0 test/functional/.keep
  70. 0 test/integration/.keep
  71. 0 test/mocks/development/.keep
  72. 0 test/mocks/test/.keep
  73. +14 −0 test/test_helper.rb
  74. 0 test/unit/.keep
  75. +3 −0 vendor/gems/RedCloth-3.0.4/bin/redcloth
  76. +160 −0 vendor/gems/RedCloth-3.0.4/doc/CHANGELOG
  77. +25 −0 vendor/gems/RedCloth-3.0.4/doc/COPYING
  78. +106 −0 vendor/gems/RedCloth-3.0.4/doc/README
  79. +216 −0 vendor/gems/RedCloth-3.0.4/doc/REFERENCE
  80. +359 −0 vendor/gems/RedCloth-3.0.4/doc/make.rb
  81. +1,130 −0 vendor/gems/RedCloth-3.0.4/lib/redcloth.rb
  82. +28 −0 vendor/gems/RedCloth-3.0.4/run-tests.rb
  83. +1,376 −0 vendor/gems/RedCloth-3.0.4/setup.rb
  84. +105 −0 vendor/gems/RedCloth-3.0.4/tests/code.yml
  85. +26 −0 vendor/gems/RedCloth-3.0.4/tests/hard_breaks.yml
  86. +171 −0 vendor/gems/RedCloth-3.0.4/tests/images.yml
  87. +39 −0 vendor/gems/RedCloth-3.0.4/tests/instiki.yml
  88. +155 −0 vendor/gems/RedCloth-3.0.4/tests/links.yml
  89. +77 −0 vendor/gems/RedCloth-3.0.4/tests/lists.yml
  90. +218 −0 vendor/gems/RedCloth-3.0.4/tests/markdown.yml
  91. +64 −0 vendor/gems/RedCloth-3.0.4/tests/poignant.yml
  92. +198 −0 vendor/gems/RedCloth-3.0.4/tests/table.yml
  93. +406 −0 vendor/gems/RedCloth-3.0.4/tests/textism.yml
  94. +3 −0 vendor/gems/mocha-0.9.0/COPYING
  95. +7 −0 vendor/gems/mocha-0.9.0/MIT-LICENSE
  96. +35 −0 vendor/gems/mocha-0.9.0/README
  97. +233 −0 vendor/gems/mocha-0.9.0/RELEASE
  98. +171 −0 vendor/gems/mocha-0.9.0/Rakefile
  99. +44 −0 vendor/gems/mocha-0.9.0/examples/misc.rb
  100. +26 −0 vendor/gems/mocha-0.9.0/examples/mocha.rb
  101. +65 −0 vendor/gems/mocha-0.9.0/examples/stubba.rb
  102. +20 −0 vendor/gems/mocha-0.9.0/lib/mocha.rb
  103. +55 −0 vendor/gems/mocha-0.9.0/lib/mocha/any_instance_method.rb
  104. +17 −0 vendor/gems/mocha-0.9.0/lib/mocha/backtrace_filter.rb
  105. +92 −0 vendor/gems/mocha-0.9.0/lib/mocha/cardinality.rb
  106. +27 −0 vendor/gems/mocha-0.9.0/lib/mocha/central.rb
  107. +19 −0 vendor/gems/mocha-0.9.0/lib/mocha/change_state_side_effect.rb
  108. +86 −0 vendor/gems/mocha-0.9.0/lib/mocha/class_method.rb
  109. +60 −0 vendor/gems/mocha-0.9.0/lib/mocha/configuration.rb
  110. +22 −0 vendor/gems/mocha-0.9.0/lib/mocha/deprecation.rb
  111. +17 −0 vendor/gems/mocha-0.9.0/lib/mocha/exception_raiser.rb
  112. +445 −0 vendor/gems/mocha-0.9.0/lib/mocha/expectation.rb
  113. +15 −0 vendor/gems/mocha-0.9.0/lib/mocha/expectation_error.rb
  114. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/expectation_list.rb
  115. +19 −0 vendor/gems/mocha-0.9.0/lib/mocha/in_state_ordering_constraint.rb
  116. +39 −0 vendor/gems/mocha-0.9.0/lib/mocha/inspect.rb
  117. +17 −0 vendor/gems/mocha-0.9.0/lib/mocha/instance_method.rb
  118. +9 −0 vendor/gems/mocha-0.9.0/lib/mocha/is_a.rb
  119. +15 −0 vendor/gems/mocha-0.9.0/lib/mocha/logger.rb
  120. +7 −0 vendor/gems/mocha-0.9.0/lib/mocha/metaclass.rb
  121. +21 −0 vendor/gems/mocha-0.9.0/lib/mocha/method_matcher.rb
  122. +207 −0 vendor/gems/mocha-0.9.0/lib/mocha/mock.rb
  123. +166 −0 vendor/gems/mocha-0.9.0/lib/mocha/mockery.rb
  124. +17 −0 vendor/gems/mocha-0.9.0/lib/mocha/module_method.rb
  125. +20 −0 vendor/gems/mocha-0.9.0/lib/mocha/multiple_yields.rb
  126. +53 −0 vendor/gems/mocha-0.9.0/lib/mocha/names.rb
  127. +11 −0 vendor/gems/mocha-0.9.0/lib/mocha/no_yields.rb
  128. +127 −0 vendor/gems/mocha-0.9.0/lib/mocha/object.rb
  129. +26 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers.rb
  130. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/all_of.rb
  131. +47 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/any_of.rb
  132. +40 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/any_parameters.rb
  133. +33 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/anything.rb
  134. +15 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/base.rb
  135. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/equals.rb
  136. +45 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/has_entries.rb
  137. +56 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/has_entry.rb
  138. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/has_key.rb
  139. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/has_value.rb
  140. +40 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/includes.rb
  141. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/instance_of.rb
  142. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/is_a.rb
  143. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/kind_of.rb
  144. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/not.rb
  145. +9 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/object.rb
  146. +55 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/optionally.rb
  147. +43 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/regexp_matches.rb
  148. +43 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/responds_with.rb
  149. +43 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameter_matchers/yaml_equivalent.rb
  150. +37 −0 vendor/gems/mocha-0.9.0/lib/mocha/parameters_matcher.rb
  151. +28 −0 vendor/gems/mocha-0.9.0/lib/mocha/pretty_parameters.rb
  152. +34 −0 vendor/gems/mocha-0.9.0/lib/mocha/return_values.rb
  153. +42 −0 vendor/gems/mocha-0.9.0/lib/mocha/sequence.rb
  154. +17 −0 vendor/gems/mocha-0.9.0/lib/mocha/single_return_value.rb
  155. +18 −0 vendor/gems/mocha-0.9.0/lib/mocha/single_yield.rb
  156. +166 −0 vendor/gems/mocha-0.9.0/lib/mocha/standalone.rb
  157. +91 −0 vendor/gems/mocha-0.9.0/lib/mocha/state_machine.rb
  158. +16 −0 vendor/gems/mocha-0.9.0/lib/mocha/stubbing_error.rb
  159. +103 −0 vendor/gems/mocha-0.9.0/lib/mocha/test_case_adapter.rb
  160. +31 −0 vendor/gems/mocha-0.9.0/lib/mocha/yield_parameters.rb
  161. +2 −0 vendor/gems/mocha-0.9.0/lib/mocha_standalone.rb
  162. +3 −0 vendor/gems/mocha-0.9.0/lib/stubba.rb
  163. +38 −0 vendor/gems/mocha-0.9.0/test/acceptance/acceptance_test_helper.rb
  164. +43 −0 vendor/gems/mocha-0.9.0/test/acceptance/bug_18914_test.rb
  165. +196 −0 vendor/gems/mocha-0.9.0/test/acceptance/expected_invocation_count_test.rb
  166. +64 −0 vendor/gems/mocha-0.9.0/test/acceptance/failure_messages_test.rb
  167. +98 −0 vendor/gems/mocha-0.9.0/test/acceptance/mocha_example_test.rb
  168. +84 −0 vendor/gems/mocha-0.9.0/test/acceptance/mocha_test_result_test.rb
  169. +100 −0 vendor/gems/mocha-0.9.0/test/acceptance/mock_test.rb
  170. +51 −0 vendor/gems/mocha-0.9.0/test/acceptance/mock_with_initializer_block_test.rb
  171. +78 −0 vendor/gems/mocha-0.9.0/test/acceptance/mocked_methods_dispatch_test.rb
  172. +70 −0 vendor/gems/mocha-0.9.0/test/acceptance/optional_parameters_test.rb
  173. +179 −0 vendor/gems/mocha-0.9.0/test/acceptance/parameter_matcher_test.rb
  174. +47 −0 vendor/gems/mocha-0.9.0/test/acceptance/partial_mocks_test.rb
  175. +52 −0 vendor/gems/mocha-0.9.0/test/acceptance/return_value_test.rb
  176. +186 −0 vendor/gems/mocha-0.9.0/test/acceptance/sequence_test.rb
  177. +139 −0 vendor/gems/mocha-0.9.0/test/acceptance/standalone_test.rb
  178. +70 −0 vendor/gems/mocha-0.9.0/test/acceptance/states_test.rb
  179. +195 −0 vendor/gems/mocha-0.9.0/test/acceptance/stub_any_instance_method_test.rb
  180. +203 −0 vendor/gems/mocha-0.9.0/test/acceptance/stub_class_method_test.rb
  181. +56 −0 vendor/gems/mocha-0.9.0/test/acceptance/stub_everything_test.rb
  182. +165 −0 vendor/gems/mocha-0.9.0/test/acceptance/stub_instance_method_test.rb
  183. +163 −0 vendor/gems/mocha-0.9.0/test/acceptance/stub_module_method_test.rb
  184. +52 −0 vendor/gems/mocha-0.9.0/test/acceptance/stub_test.rb
  185. +102 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubba_example_test.rb
  186. +66 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubba_test_result_test.rb
  187. +64 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_error_backtrace_test.rb
  188. +65 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_method_unnecessarily_test.rb
  189. +130 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_non_existent_any_instance_method_test.rb
  190. +155 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_non_existent_class_method_test.rb
  191. +145 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_non_existent_instance_method_test.rb
  192. +130 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_non_public_any_instance_method_test.rb
  193. +161 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_non_public_class_method_test.rb
  194. +141 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_non_public_instance_method_test.rb
  195. +64 −0 vendor/gems/mocha-0.9.0/test/acceptance/stubbing_on_non_mock_object_test.rb
  196. +36 −0 vendor/gems/mocha-0.9.0/test/active_record_test_case.rb
  197. +15 −0 vendor/gems/mocha-0.9.0/test/deprecation_disabler.rb
  198. +36 −0 vendor/gems/mocha-0.9.0/test/execution_point.rb
  199. +18 −0 vendor/gems/mocha-0.9.0/test/method_definer.rb
  200. +13 −0 vendor/gems/mocha-0.9.0/test/simple_counter.rb
  201. +11 −0 vendor/gems/mocha-0.9.0/test/test_helper.rb
  202. +33 −0 vendor/gems/mocha-0.9.0/test/test_runner.rb
  203. +126 −0 vendor/gems/mocha-0.9.0/test/unit/any_instance_method_test.rb
  204. +16 −0 vendor/gems/mocha-0.9.0/test/unit/array_inspect_test.rb
  205. +19 −0 vendor/gems/mocha-0.9.0/test/unit/backtrace_filter_test.rb
  206. +56 −0 vendor/gems/mocha-0.9.0/test/unit/cardinality_test.rb
  207. +65 −0 vendor/gems/mocha-0.9.0/test/unit/central_test.rb
  208. +41 −0 vendor/gems/mocha-0.9.0/test/unit/change_state_side_effect_test.rb
  209. +237 −0 vendor/gems/mocha-0.9.0/test/unit/class_method_test.rb
  210. +21 −0 vendor/gems/mocha-0.9.0/test/unit/date_time_inspect_test.rb
  211. +42 −0 vendor/gems/mocha-0.9.0/test/unit/exception_raiser_test.rb
  212. +57 −0 vendor/gems/mocha-0.9.0/test/unit/expectation_list_test.rb
  213. +459 −0 vendor/gems/mocha-0.9.0/test/unit/expectation_test.rb
  214. +16 −0 vendor/gems/mocha-0.9.0/test/unit/hash_inspect_test.rb
  215. +43 −0 vendor/gems/mocha-0.9.0/test/unit/in_state_ordering_constraint_test.rb
  216. +22 −0 vendor/gems/mocha-0.9.0/test/unit/metaclass_test.rb
  217. +23 −0 vendor/gems/mocha-0.9.0/test/unit/method_matcher_test.rb
  218. +302 −0 vendor/gems/mocha-0.9.0/test/unit/mock_test.rb
  219. +149 −0 vendor/gems/mocha-0.9.0/test/unit/mockery_test.rb
  220. +18 −0 vendor/gems/mocha-0.9.0/test/unit/multiple_yields_test.rb
  221. +18 −0 vendor/gems/mocha-0.9.0/test/unit/no_yields_test.rb
  222. +37 −0 vendor/gems/mocha-0.9.0/test/unit/object_inspect_test.rb
  223. +82 −0 vendor/gems/mocha-0.9.0/test/unit/object_test.rb
  224. +26 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/all_of_test.rb
  225. +26 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/any_of_test.rb
  226. +21 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/anything_test.rb
  227. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/equals_test.rb
  228. +51 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/has_entries_test.rb
  229. +62 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/has_entry_test.rb
  230. +36 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/has_key_test.rb
  231. +37 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/has_value_test.rb
  232. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/includes_test.rb
  233. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/instance_of_test.rb
  234. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/is_a_test.rb
  235. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/kind_of_test.rb
  236. +26 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/not_test.rb
  237. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/regexp_matches_test.rb
  238. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/responds_with_test.rb
  239. +27 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/stub_matcher.rb
  240. +25 −0 vendor/gems/mocha-0.9.0/test/unit/parameter_matchers/yaml_equivalent_test.rb
  241. +121 −0 vendor/gems/mocha-0.9.0/test/unit/parameters_matcher_test.rb
  242. +63 −0 vendor/gems/mocha-0.9.0/test/unit/return_values_test.rb
  243. +104 −0 vendor/gems/mocha-0.9.0/test/unit/sequence_test.rb
  244. +14 −0 vendor/gems/mocha-0.9.0/test/unit/single_return_value_test.rb
  245. +18 −0 vendor/gems/mocha-0.9.0/test/unit/single_yield_test.rb
  246. +98 −0 vendor/gems/mocha-0.9.0/test/unit/state_machine_test.rb
  247. +11 −0 vendor/gems/mocha-0.9.0/test/unit/string_inspect_test.rb
Sorry, we could not display the entire diff because too many files (1,831) changed.
8 .gitignore
@@ -0,0 +1,8 @@
+log/*
+tmp/**/*
+db/schema.rb
+db/*.sqlite3
+public/system
+*.DS_Store
+coverage/*
+*.swp
3 Capfile
@@ -0,0 +1,3 @@
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+load 'config/deploy'
10 Rakefile
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
9 app/controllers/application.rb
@@ -0,0 +1,9 @@
+class ApplicationController < ActionController::Base
+
+ helper :all
+
+ protect_from_forgery
+
+ include HoptoadNotifier::Catcher
+
+end
5 app/helpers/application_helper.rb
@@ -0,0 +1,5 @@
+module ApplicationHelper
+ def body_class
+ "#{controller.controller_name} #{controller.controller_name}-#{controller.action_name}"
+ end
+end
0 app/models/.keep
No changes.
5 app/views/layouts/_flashes.erb
@@ -0,0 +1,5 @@
+<div id="flash">
+ <% flash.each do |key, value| -%>
+ <div id="flash_<%= key %>"><%=h value %></div>
+ <% end %>
+</div>
14 app/views/layouts/application.html.erb
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title><%= PROJECT_NAME.humanize %></title>
+ <%= stylesheet_link_tag 'screen', :media => 'all' %>
+ <%= javascript_include_tag :defaults %>
+ </head>
+ <body class="<%= body_class %>">
+ <%= render :partial => 'layouts/flashes' %>
+ <%= yield %>
+ </body>
+</html>
109 config/boot.rb
@@ -0,0 +1,109 @@
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+ class << self
+ def boot!
+ unless booted?
+ preinitialize
+ pick_boot.run
+ end
+ end
+
+ def booted?
+ defined? Rails::Initializer
+ end
+
+ def pick_boot
+ (vendor_rails? ? VendorBoot : GemBoot).new
+ end
+
+ def vendor_rails?
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
+ end
+
+ def preinitialize
+ load(preinitializer_path) if File.exist?(preinitializer_path)
+ end
+
+ def preinitializer_path
+ "#{RAILS_ROOT}/config/preinitializer.rb"
+ end
+ end
+
+ class Boot
+ def run
+ load_initializer
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+
+ class VendorBoot < Boot
+ def load_initializer
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ end
+ end
+
+ class GemBoot < Boot
+ def load_initializer
+ self.class.load_rubygems
+ load_rails_gem
+ require 'initializer'
+ end
+
+ def load_rails_gem
+ if version = self.class.gem_version
+ gem 'rails', version
+ else
+ gem 'rails'
+ end
+ rescue Gem::LoadError => load_error
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ end
+
+ class << self
+ def rubygems_version
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ end
+
+ def gem_version
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ elsif ENV.include?('RAILS_GEM_VERSION')
+ ENV['RAILS_GEM_VERSION']
+ else
+ parse_gem_version(read_environment_rb)
+ end
+ end
+
+ def load_rubygems
+ require 'rubygems'
+ min_version = '1.1.1'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ exit 1
+ end
+
+ def parse_gem_version(text)
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+ end
+
+ private
+ def read_environment_rb
+ File.read("#{RAILS_ROOT}/config/environment.rb")
+ end
+ end
+ end
+end
+
+# All that for this:
+Rails.boot!
35 config/database.yml
@@ -0,0 +1,35 @@
+<% PASSWORD_FILE = File.join(RAILS_ROOT, '..', '..', 'shared', 'config', 'dbpassword') %>
+
+development:
+ adapter: mysql
+ database: <%= PROJECT_NAME %>_development
+ username: root
+ password:
+ host: localhost
+ encoding: utf8
+
+test:
+ adapter: mysql
+ database: <%= PROJECT_NAME %>_test
+ username: root
+ password:
+ host: localhost
+ encoding: utf8
+
+staging:
+ adapter: mysql
+ database: <%= PROJECT_NAME %>_staging
+ username: <%= PROJECT_NAME %>
+ password: <%= File.read(PASSWORD_FILE).chomp if File.readable? PASSWORD_FILE %>
+ host: localhost
+ encoding: utf8
+ socket: /var/lib/mysql/mysql.sock
+
+production:
+ adapter: mysql
+ database: <%= PROJECT_NAME %>_production
+ username: <%= PROJECT_NAME %>
+ password: <%= File.read(PASSWORD_FILE).chomp if File.readable? PASSWORD_FILE %>
+ host: localhost
+ encoding: utf8
+ socket: /var/lib/mysql/mysql.sock
41 config/deploy.rb
@@ -0,0 +1,41 @@
+set :stages, %w(staging production)
+set :default_stage, 'staging'
+require 'capistrano/ext/multistage'
+
+before "deploy:setup", "db:password"
+
+namespace :deploy do
+ desc "Default deploy - updated to run migrations"
+ task :default do
+ set :migrate_target, :latest
+ update_code
+ migrate
+ symlink
+ restart
+ end
+ desc "Start the mongrels"
+ task :start do
+ send(run_method, "cd #{deploy_to}/#{current_dir} && #{mongrel_rails} cluster::start --config #{mongrel_cluster_config}")
+ end
+ desc "Stop the mongrels"
+ task :stop do
+ send(run_method, "cd #{deploy_to}/#{current_dir} && #{mongrel_rails} cluster::stop --config #{mongrel_cluster_config}")
+ end
+ desc "Restart the mongrels"
+ task :restart do
+ send(run_method, "cd #{deploy_to}/#{current_dir} && #{mongrel_rails} cluster::restart --config #{mongrel_cluster_config}")
+ end
+ desc "Run this after every successful deployment"
+ task :after_default do
+ cleanup
+ end
+end
+
+namespace :db do
+ desc "Create database password in shared path"
+ task :password do
+ set :db_password, Proc.new { Capistrano::CLI.password_prompt("Remote database password: ") }
+ run "mkdir -p #{shared_path}/config"
+ put db_password, "#{shared_path}/config/dbpassword"
+ end
+end
24 config/deploy/production.rb
@@ -0,0 +1,24 @@
+# For migrations
+set :rails_env, 'production'
+
+# Who are we?
+set :application, 'CHANGEME'
+set :repository, "git@github.com:thoughtbot/#{application}.git"
+set :scm, "git"
+set :deploy_via, :remote_cache
+set :branch, "production"
+
+# Where to deploy to?
+role :web, "production.example.com"
+role :app, "production.example.com"
+role :db, "production.example.com", :primary => true
+
+# Deploy details
+set :user, "#{application}"
+set :deploy_to, "/home/#{user}/apps/#{application}"
+set :use_sudo, false
+set :checkout, 'export'
+
+# We need to know how to use mongrel
+set :mongrel_rails, '/usr/local/bin/mongrel_rails'
+set :mongrel_cluster_config, "#{deploy_to}/#{current_dir}/config/mongrel_cluster_production.yml"
24 config/deploy/staging.rb
@@ -0,0 +1,24 @@
+# For migrations
+set :rails_env, 'staging'
+
+# Who are we?
+set :application, 'CHANGEME'
+set :repository, "git@github.com:thoughtbot/#{application}.git"
+set :scm, "git"
+set :deploy_via, :remote_cache
+set :branch, "staging"
+
+# Where to deploy to?
+role :web, "staging.example.com"
+role :app, "staging.example.com"
+role :db, "staging.example.com", :primary => true
+
+# Deploy details
+set :user, "#{application}"
+set :deploy_to, "/home/#{user}/apps/#{application}"
+set :use_sudo, false
+set :checkout, 'export'
+
+# We need to know how to use mongrel
+set :mongrel_rails, '/usr/local/bin/mongrel_rails'
+set :mongrel_cluster_config, "#{deploy_to}/#{current_dir}/config/mongrel_cluster_staging.yml"
73 config/environment.rb
@@ -0,0 +1,73 @@
+# Be sure to restart your server when you modify this file
+
+# Change this to the name of your rails project, like carbonrally.
+# Just use the same name as the svn repo.
+PROJECT_NAME = "CHANGEME"
+
+throw "The project's name in environment.rb is blank" if PROJECT_NAME.empty?
+throw "Project name (#{PROJECT_NAME}) must_be_like_this" unless PROJECT_NAME =~ /^[a-z_]*$/
+
+# Specifies gem version of Rails to use when vendor/rails is not present
+RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION
+
+# Bootstrap the Rails environment, frameworks, and default configuration
+require File.join(File.dirname(__FILE__), 'boot')
+
+Rails::Initializer.run do |config|
+ # Settings in config/environments/* take precedence over those specified here.
+
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+ # See Rails::Configuration for more options.
+
+ # Skip frameworks you're not going to use. To use Rails without a database
+ # you must remove the Active Record framework.
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
+
+ # Specify gems that this application depends on.
+ # They can then be installed with "rake gems:install" on new installations.
+ # config.gem "bj"
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
+ # config.gem "aws-s3", :lib => "aws/s3"
+
+ # Only load the plugins named here, in the order given. By default, all plugins
+ # in vendor/plugins are loaded in alphabetical order.
+ # :all can be used as a placeholder for all plugins not explicitly named
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Add the vendor/gems/*/lib directories to the LOAD_PATH
+ config.load_paths += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'gems', '*', 'lib'))
+
+ # Force all environments to use the same logger level
+ # (by default production uses :info, the others :debug)
+ # config.log_level = :debug
+
+ # Make Time.zone default to the specified zone, and make Active Record store time values
+ # in the database in UTC, and return them converted to the specified local zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
+ config.time_zone = 'UTC'
+
+ # Your secret key for verifying cookie session data integrity.
+ # If you change this key, all old sessions will become invalid!
+ # Make sure the secret is at least 30 characters and all random,
+ # no regular words or you'll be exposed to dictionary attacks.
+ SESSION_KEY = "CHANGESESSION"
+ config.action_controller.session = {
+ :session_key => "_#{PROJECT_NAME}_session",
+ :secret => SESSION_KEY
+ }
+
+ # Use the database for sessions instead of the cookie-based default,
+ # which shouldn't be used to store highly confidential information
+ # (create the session table with "rake db:sessions:create")
+ # config.action_controller.session_store = :active_record_store
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Activate observers that should always be running
+ # config.active_record.observers = :cacher, :garbage_collector
+end
+
18 config/environments/development.rb
@@ -0,0 +1,18 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = false
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = false
+config.action_view.cache_template_extensions = false
+config.action_view.debug_rjs = true
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
18 config/environments/production.rb
@@ -0,0 +1,18 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The production environment is meant for finished, "live" apps.
+# Code is not reloaded between requests
+config.cache_classes = true
+
+# Use a different logger for distributed setups
+# config.logger = SyslogLogger.new
+
+# Full error reports are disabled and caching is turned on
+config.action_controller.consider_all_requests_local = false
+config.action_controller.perform_caching = true
+
+# Enable serving of images, stylesheets, and javascripts from an asset server
+# config.action_controller.asset_host = "http://assets.example.com"
+
+# Disable delivery errors, bad email addresses will be ignored
+config.action_mailer.raise_delivery_errors = false
12 config/environments/staging.rb
@@ -0,0 +1,12 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# We'd like to stay as close to prod as possible
+# Code is not reloaded between requests
+config.cache_classes = true
+
+# Full error reports are disabled and caching is turned on
+config.action_controller.consider_all_requests_local = false
+config.action_controller.perform_caching = true
+
+# Disable delivery errors if you bad email addresses should just be ignored
+config.action_mailer.raise_delivery_errors = false
27 config/environments/test.rb
@@ -0,0 +1,27 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+config.cache_classes = true
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = false
+
+# Disable request forgery protection in test environment
+config.action_controller.allow_forgery_protection = false
+
+# Tell ActionMailer not to deliver emails to the real world.
+# The :test delivery method accumulates sent emails in the
+# ActionMailer::Base.deliveries array.
+config.action_mailer.delivery_method = :test
+
+# Comment for testing the rails-template
+
+require 'mocha'
+require 'factory_girl'
6 config/initializers/action_mailer_configs.rb
@@ -0,0 +1,6 @@
+ActionMailer::Base.smtp_settings = {
+ :address => "smtp.thoughtbot.com",
+ :port => 25,
+ :domain => "thoughtbot.com"
+}
+
3 config/initializers/hoptoad.rb
@@ -0,0 +1,3 @@
+HoptoadNotifier.configure do |config|
+ config.api_key = 'HOPTOAD-KEY'
+end
10 config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
15 config/initializers/requires.rb
@@ -0,0 +1,15 @@
+require 'redcloth'
+
+Dir[File.join(RAILS_ROOT, 'lib', 'extensions', '*.rb')].each do |f|
+ require f
+end
+
+Dir[File.join(RAILS_ROOT, 'lib', '*.rb')].each do |f|
+ require f
+end
+
+# Rails 2 doesn't like mocks
+
+Dir[File.join(RAILS_ROOT, 'test', 'mocks', RAILS_ENV, '*.rb')].each do |f|
+ require f
+end
4 config/initializers/time_formats.rb
@@ -0,0 +1,4 @@
+# Example time formats
+{ :short_date => "%x", :long_date => "%a, %b %d, %Y" }.each do |k, v|
+ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(k => v)
+end
7 config/mongrel_cluster_production.yml
@@ -0,0 +1,7 @@
+---
+# cwd: /home/CHANGEME/apps/CHANGEME/current
+# port: "3030"
+environment: production
+address: 127.0.0.1
+pid_file: log/mongrel.pid
+servers: 3
7 config/mongrel_cluster_staging.yml
@@ -0,0 +1,7 @@
+---
+# cwd: /home/CHANGEME/apps/CHANGEME/current
+# port: "3030"
+environment: staging
+address: 127.0.0.1
+pid_file: log/mongrel.pid
+servers: 2
29 config/routes.rb
@@ -0,0 +1,29 @@
+ActionController::Routing::Routes.draw do |map|
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # map.resources :products
+
+ # Sample resource route with options:
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
+
+ # Sample resource route with sub-resources:
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
+
+ # Sample resource route within a namespace:
+ # map.namespace :admin do |admin|
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
+ # admin.resources :products
+ # end
+
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
+ # map.root :controller => "welcome"
+
+ # See how all your routes lay out with "rake routes"
+
+ # map.home '', :controller => 'home', :action => 'dashboard'
+ # map.with_options :controller => 'sessions' do |m|
+ # m.login '/login', :action => 'new'
+ # m.logout '/logout', :action => 'destroy'
+ # end
+
+end
0 db/bootstrap/.keep
No changes.
0 db/migrate/.keep
No changes.
2 doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake appdoc" to generate API documentation for your models and controllers.
15 doc/README_FOR_TEMPLATE
@@ -0,0 +1,15 @@
+This is the Thoughtbot Rails Template. To create a new project, checkout this
+repository and run:
+
+ ./script/create_project.rb projectname
+
+This will create a project in ../projectname. You should then follow the
+instructions on Github to upload that project there. This script creates an
+entirely new git repository, and is not meant to be used against an existing
+repo.
+
+When making a change to a project that was created via this template, consider
+whether it's a change that should be made across all projects. If so, then
+make the change in this template, and pull it into your project via:
+
+ git pull git@github.com:thoughtbot/rails-template.git master
16 lib/tasks/bootstrap.rake
@@ -0,0 +1,16 @@
+namespace :db do
+ desc "Loads a schema.rb file into the database and then loads the initial database fixtures."
+ task :bootstrap => ['db:schema:load', 'db:bootstrap:load']
+
+ namespace :bootstrap do
+ desc "Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
+ task :load => :environment do
+ require 'active_record/fixtures'
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'db', 'bootstrap', '*.{yml,csv}'))).each do |fixture_file|
+ Fixtures.create_fixtures('db/bootstrap', File.basename(fixture_file, '.*'))
+ end
+ end
+ end
+end
+
96 lib/tasks/capistrano.rake
@@ -0,0 +1,96 @@
+# =============================================================================
+# A set of rake tasks for invoking the Capistrano automation utility.
+# =============================================================================
+
+# Invoke the given actions via Capistrano
+def cap(*parameters)
+ begin
+ require 'rubygems'
+ rescue LoadError
+ # no rubygems to load, so we fail silently
+ end
+
+ require 'capistrano/cli'
+
+ Capistrano::CLI.new(parameters.map { |param| param.to_s }).execute!
+end
+
+namespace :remote do
+ desc "Removes unused releases from the releases directory."
+ task(:cleanup) { cap :cleanup }
+
+ desc "Used only for deploying when the spinner isn't running."
+ task(:cold_deploy) { cap :cold_deploy }
+
+ desc "A macro-task that updates the code, fixes the symlink, and restarts the application servers."
+ task(:deploy) { cap :deploy }
+
+ desc "Similar to deploy, but it runs the migrate task on the new release before updating the symlink."
+ task(:deploy_with_migrations) { cap :deploy_with_migrations }
+
+ desc "Displays the diff between HEAD and what was last deployed."
+ task(:diff_from_last_deploy) { cap :diff_from_last_deploy }
+
+ desc "Disable the web server by writing a \"maintenance.html\" file to the web servers."
+ task(:disable_web) { cap :disable_web }
+
+ desc "Re-enable the web server by deleting any \"maintenance.html\" file."
+ task(:enable_web) { cap :enable_web }
+
+ desc "A simple task for performing one-off commands that may not require a full task to be written for them."
+ task(:invoke) { cap :invoke }
+
+ desc "Run the migrate rake task."
+ task(:migrate) { cap :migrate }
+
+ desc "Restart the FCGI processes on the app server."
+ task(:restart) { cap :restart }
+
+ desc "A macro-task that rolls back the code and restarts the application servers."
+ task(:rollback) { cap :rollback }
+
+ desc "Rollback the latest checked-out version to the previous one by fixing the symlinks and deleting the current release from all servers."
+ task(:rollback_code) { cap :rollback_code }
+
+ desc "Set up the expected application directory structure on all boxes"
+ task(:setup) { cap :setup }
+
+ desc "Begin an interactive Capistrano session."
+ task(:shell) { cap :shell }
+
+ desc "Enumerate and describe every available task."
+ task(:show_tasks) { cap :show_tasks, '-q' }
+
+ desc "Start the spinner daemon for the application (requires script/spin)."
+ task(:spinner) { cap :spinner }
+
+ desc "Update the 'current' symlink to point to the latest version of the application's code."
+ task(:symlink) { cap :symlink }
+
+ desc "Updates the code and fixes the symlink under a transaction"
+ task(:update) { cap :update }
+
+ desc "Update all servers with the latest release of the source code."
+ task(:update_code) { cap :update_code }
+
+ desc "Update the currently released version of the software directly via an SCM update operation"
+ task(:update_current) { cap :update_current }
+
+ desc "Execute a specific action using capistrano"
+ task :exec do
+ unless ENV['ACTION']
+ raise "Please specify an action (or comma separated list of actions) via the ACTION environment variable"
+ end
+
+ actions = ENV['ACTION'].split(",")
+ actions.concat(ENV['PARAMS'].split(" ")) if ENV['PARAMS']
+
+ cap(*actions)
+ end
+end
+
+desc "Push the latest revision into production (delegates to remote:deploy)"
+task :deploy => "remote:deploy"
+
+desc "Rollback to the release before the current release in production (delegates to remote:rollback)"
+task :rollback => "remote:rollback"
129 lib/tasks/git_tasks.rake
@@ -0,0 +1,129 @@
+module GitCommands
+ class ShellError < RuntimeError; end
+
+ @logging = ENV['LOGGING'] != "false"
+
+ def self.run cmd, *expected_exitstatuses
+ puts "+ #{cmd}" if @logging
+ output = `#{cmd} 2>&1`
+ puts output.gsub(/^/, "- ") if @logging
+ expected_exitstatuses << 0 if expected_exitstatuses.empty?
+ raise ShellError.new("ERROR: '#{cmd}' failed with exit status #{$?.exitstatus}") unless
+ [expected_exitstatuses].flatten.include?( $?.exitstatus )
+ output
+ end
+
+ def self.current_branch
+ run("git branch --no-color | grep '*' | cut -d ' ' -f 2").chomp
+ end
+
+ def self.remote_branch_exists?(branch)
+ ! run("git branch -r --no-color | grep '#{branch}'").blank?
+ end
+
+ def self.ensure_clean_working_directory!
+ return if run("git status", 0, 1).match(/working directory clean/)
+ raise "Must have clean working directory"
+ end
+
+ def self.diff_staging
+ puts run("git diff HEAD origin/staging")
+ end
+
+ def self.diff_production
+ puts run("git diff origin/staging origin/production")
+ end
+
+ def self.push_staging(branch)
+ raise "Branch must not be blank" if branch.blank?
+ raise "origin/staging branch does not exist" unless remote_branch_exists?("origin/staging")
+ ensure_clean_working_directory!
+ begin
+ run "git fetch"
+ run "git branch -f staging origin/staging"
+ run "git checkout staging"
+ run "git pull . #{branch}"
+ run "git push origin staging"
+ rescue
+ puts "Creating staging tag failed."
+ raise
+ ensure
+ run "git checkout master"
+ run "git branch -D staging"
+ end
+ end
+
+ def self.push_production
+ raise "origin/production branch does not exist" unless remote_branch_exists?("origin/production")
+ ensure_clean_working_directory!
+ begin
+ run "git fetch"
+ run "git branch -f production origin/production"
+ run "git checkout production"
+ run "git pull origin staging"
+ run "git push origin production"
+ rescue
+ puts "Creating production tag failed."
+ raise
+ ensure
+ run "git checkout master"
+ run "git branch -D production"
+ end
+ end
+
+ def self.branch_production(branch)
+ raise "Branch must not be blank" if branch.blank?
+ ensure_clean_working_directory!
+ run "git branch -f #{branch} origin/production"
+ run "git checkout #{branch}"
+ end
+
+ def self.pull_template
+ ensure_clean_working_directory!
+ run "git pull git://github.com/thoughtbot/suspenders.git master"
+ end
+end
+
+namespace :git do
+ namespace :push do
+ desc "Merge a branch into the origin/staging branch."
+ task :staging do
+ branch = ENV['BRANCH'].blank? ? GitCommands.current_branch : ENV['BRANCH']
+ puts "Tagging #{branch} as origin/staging"
+ GitCommands.push_staging(branch)
+ end
+
+ desc "Merge the staging branch into origin/production for launch."
+ task :production do
+ GitCommands.push_production
+ end
+ end
+
+ namespace :diff do
+ desc "Show the difference between current branch and origin/staging."
+ task :staging do
+ GitCommands.diff_staging
+ end
+
+ desc "Show the difference between origin/staging and origin/production."
+ task :production do
+ GitCommands.diff_production
+ end
+ end
+
+ namespace :pull do
+ desc "Pull updates from the thoughtbot rails template"
+ task :template do
+ GitCommands.pull_template
+ end
+ end
+
+ namespace :branch do
+ desc "Branch origin/production into BRANCH locally."
+ task :production do
+ branch = ENV['BRANCH'].blank? ? GitCommands.current_branch : ENV['BRANCH']
+ puts "Branching origin/production into #{branch}"
+ GitCommands.branch_production(branch)
+ end
+ end
+end
40 public/.htaccess
@@ -0,0 +1,40 @@
+# General Apache options
+AddHandler fastcgi-script .fcgi
+AddHandler cgi-script .cgi
+Options +FollowSymLinks +ExecCGI
+
+# If you don't want Rails to look in certain directories,
+# use the following rewrite rules so that Apache won't rewrite certain requests
+#
+# Example:
+# RewriteCond %{REQUEST_URI} ^/notrails.*
+# RewriteRule .* - [L]
+
+# Redirect all requests not available on the filesystem to Rails
+# By default the cgi dispatcher is used which is very slow
+#
+# For better performance replace the dispatcher with the fastcgi one
+#
+# Example:
+# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
+RewriteEngine On
+
+# If your Rails application is accessed via an Alias directive,
+# then you MUST also set the RewriteBase in this htaccess file.
+#
+# Example:
+# Alias /myrailsapp /path/to/myrailsapp/public
+# RewriteBase /myrailsapp
+
+RewriteRule ^$ index.html [QSA]
+RewriteRule ^([^.]+)$ $1.html [QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
+
+# In case Rails experiences terminal errors
+# Instead of displaying this message you can supply a file here which will be rendered instead
+#
+# Example:
+# ErrorDocument 500 /500.html
+
+ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
30 public/404.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
30 public/422.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
30 public/500.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <title>We're sorry, but something went wrong</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+ </div>
+</body>
+</html>
10 public/dispatch.rb
@@ -0,0 +1,10 @@
+#!/opt/local/bin/ruby
+
+require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
+
+# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
+# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
+require "dispatcher"
+
+ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
+Dispatcher.dispatch
0 public/favicon.ico
No changes.
BIN public/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 public/javascripts/application.js
@@ -0,0 +1,2 @@
+// Place your application-specific JavaScript functions and classes here
+// This file is automatically included by javascript_include_tag :defaults
136 public/javascripts/builder.js
@@ -0,0 +1,136 @@
+// script.aculo.us builder.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
+
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+var Builder = {
+ NODEMAP: {
+ AREA: 'map',
+ CAPTION: 'table',
+ COL: 'table',
+ COLGROUP: 'table',
+ LEGEND: 'fieldset',
+ OPTGROUP: 'select',
+ OPTION: 'select',
+ PARAM: 'object',
+ TBODY: 'table',
+ TD: 'table',
+ TFOOT: 'table',
+ TH: 'table',
+ THEAD: 'table',
+ TR: 'table'
+ },
+ // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
+ // due to a Firefox bug
+ node: function(elementName) {
+ elementName = elementName.toUpperCase();
+
+ // try innerHTML approach
+ var parentTag = this.NODEMAP[elementName] || 'div';
+ var parentElement = document.createElement(parentTag);
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+ parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
+ } catch(e) {}
+ var element = parentElement.firstChild || null;
+
+ // see if browser added wrapping tags
+ if(element && (element.tagName.toUpperCase() != elementName))
+ element = element.getElementsByTagName(elementName)[0];
+
+ // fallback to createElement approach
+ if(!element) element = document.createElement(elementName);
+
+ // abort if nothing could be created
+ if(!element) return;
+
+ // attributes (or text)
+ if(arguments[1])
+ if(this._isStringOrNumber(arguments[1]) ||
+ (arguments[1] instanceof Array) ||
+ arguments[1].tagName) {
+ this._children(element, arguments[1]);
+ } else {
+ var attrs = this._attributes(arguments[1]);
+ if(attrs.length) {
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+ parentElement.innerHTML = "<" +elementName + " " +
+ attrs + "></" + elementName + ">";
+ } catch(e) {}
+ element = parentElement.firstChild || null;
+ // workaround firefox 1.0.X bug
+ if(!element) {
+ element = document.createElement(elementName);
+ for(attr in arguments[1])
+ element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
+ }
+ if(element.tagName.toUpperCase() != elementName)
+ element = parentElement.getElementsByTagName(elementName)[0];
+ }
+ }
+
+ // text, or array of children
+ if(arguments[2])
+ this._children(element, arguments[2]);
+
+ return element;
+ },
+ _text: function(text) {
+ return document.createTextNode(text);
+ },
+
+ ATTR_MAP: {
+ 'className': 'class',
+ 'htmlFor': 'for'
+ },
+
+ _attributes: function(attributes) {
+ var attrs = [];
+ for(attribute in attributes)
+ attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
+ return attrs.join(" ");
+ },
+ _children: function(element, children) {
+ if(children.tagName) {
+ element.appendChild(children);
+ return;
+ }
+ if(typeof children=='object') { // array can hold nodes and text
+ children.flatten().each( function(e) {
+ if(typeof e=='object')
+ element.appendChild(e)
+ else
+ if(Builder._isStringOrNumber(e))
+ element.appendChild(Builder._text(e));
+ });
+ } else
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
+ },
+ _isStringOrNumber: function(param) {
+ return(typeof param=='string' || typeof param=='number');
+ },
+ build: function(html) {
+ var element = this.node('div');
+ $(element).update(html.strip());
+ return element.down();
+ },
+ dump: function(scope) {
+ if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
+
+ var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
+ "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
+ "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
+
+ tags.each( function(tag){
+ scope[tag] = function() {
+ return Builder.node.apply(Builder, [tag].concat($A(arguments)));
+ }
+ });
+ }
+}
963 public/javascripts/controls.js
@@ -0,0 +1,963 @@
+// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
+// Contributors:
+// Richard Livsey
+// Rahul Bhargava
+// Rob Wills
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// Autocompleter.Base handles all the autocompletion functionality
+// that's independent of the data source for autocompletion. This
+// includes drawing the autocompletion menu, observing keyboard
+// and mouse events, and similar.
+//
+// Specific autocompleters need to provide, at the very least,
+// a getUpdatedChoices function that will be invoked every time
+// the text inside the monitored textbox changes. This method
+// should get the text for which to provide autocompletion by
+// invoking this.getToken(), NOT by directly accessing
+// this.element.value. This is to allow incremental tokenized
+// autocompletion. Specific auto-completion logic (AJAX, etc)
+// belongs in getUpdatedChoices.
+//
+// Tokenized incremental autocompletion is enabled automatically
+// when an autocompleter is instantiated with the 'tokens' option
+// in the options parameter, e.g.:
+// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
+// will incrementally autocomplete with a comma as the token.
+// Additionally, ',' in the above example can be replaced with
+// a token array, e.g. { tokens: [',', '\n'] } which
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
+// allows smart autocompletion after linebreaks.
+
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = { }
+Autocompleter.Base = Class.create({
+ baseInitialize: function(element, update, options) {
+ element = $(element)
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
+ this.entryCount = 0;
+ this.oldElementValue = this.element.value;
+
+ if(this.setOptions)
+ this.setOptions(options);
+ else
+ this.options = options || { };
+
+ this.options.paramName = this.options.paramName || this.element.name;
+ this.options.tokens = this.options.tokens || [];
+ this.options.frequency = this.options.frequency || 0.4;
+ this.options.minChars = this.options.minChars || 1;
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
+ if(!update.style.position || update.style.position=='absolute') {
+ update.style.position = 'absolute';
+ Position.clone(element, update, {
+ setHeight: false,
+ offsetTop: element.offsetHeight
+ });
+ }
+ Effect.Appear(update,{duration:0.15});
+ };
+ this.options.onHide = this.options.onHide ||
+ function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+ if(typeof(this.options.tokens) == 'string')
+ this.options.tokens = new Array(this.options.tokens);
+ // Force carriage returns as token delimiters anyway
+ if (!this.options.tokens.include('\n'))
+ this.options.tokens.push('\n');
+
+ this.observer = null;
+
+ this.element.setAttribute('autocomplete','off');
+
+ Element.hide(this.update);
+
+ Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
+ },
+
+ show: function() {
+ if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+ if(!this.iefix &&
+ (Prototype.Browser.IE) &&
+ (Element.getStyle(this.update, 'position')=='absolute')) {
+ new Insertion.After(this.update,
+ '<iframe id="' + this.update.id + '_iefix" '+
+ 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
+ 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
+ this.iefix = $(this.update.id+'_iefix');
+ }
+ if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+ },
+
+ fixIEOverlapping: function() {
+ Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
+ this.iefix.style.zIndex = 1;
+ this.update.style.zIndex = 2;
+ Element.show(this.iefix);
+ },
+
+ hide: function() {
+ this.stopIndicator();
+ if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
+ if(this.iefix) Element.hide(this.iefix);
+ },
+
+ startIndicator: function() {
+ if(this.options.indicator) Element.show(this.options.indicator);
+ },
+
+ stopIndicator: function() {
+ if(this.options.indicator) Element.hide(this.options.indicator);
+ },
+
+ onKeyPress: function(event) {
+ if(this.active)
+ switch(event.keyCode) {
+ case Event.KEY_TAB:
+ case Event.KEY_RETURN:
+ this.selectEntry();
+ Event.stop(event);
+ case Event.KEY_ESC:
+ this.hide();
+ this.active = false;
+ Event.stop(event);
+ return;
+ case Event.KEY_LEFT:
+ case Event.KEY_RIGHT:
+ return;
+ case Event.KEY_UP:
+ this.markPrevious();
+ this.render();
+ Event.stop(event);
+ return;
+ case Event.KEY_DOWN:
+ this.markNext();
+ this.render();
+ Event.stop(event);
+ return;
+ }
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
+
+ this.changed = true;
+ this.hasFocus = true;
+
+ if(this.observer) clearTimeout(this.observer);
+ this.observer =
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
+ },
+
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
+ onHover: function(event) {
+ var element = Event.findElement(event, 'LI');
+ if(this.index != element.autocompleteIndex)
+ {
+ this.index = element.autocompleteIndex;
+ this.render();
+ }
+ Event.stop(event);
+ },
+
+ onClick: function(event) {
+ var element = Event.findElement(event, 'LI');
+ this.index = element.autocompleteIndex;
+ this.selectEntry();
+ this.hide();
+ },
+
+ onBlur: function(event) {
+ // needed to make click events working
+ setTimeout(this.hide.bind(this), 250);
+ this.hasFocus = false;
+ this.active = false;
+ },
+
+ render: function() {
+ if(this.entryCount > 0) {
+ for (var i = 0; i < this.entryCount; i++)
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
+ Element.removeClassName(this.getEntry(i),"selected");
+ if(this.hasFocus) {
+ this.show();
+ this.active = true;
+ }
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ markPrevious: function() {
+ if(this.index > 0) this.index--
+ else this.index = this.entryCount-1;
+ this.getEntry(this.index).scrollIntoView(true);
+ },
+
+ markNext: function() {
+ if(this.index < this.entryCount-1) this.index++
+ else this.index = 0;
+ this.getEntry(this.index).scrollIntoView(false);
+ },
+
+ getEntry: function(index) {
+ return this.update.firstChild.childNodes[index];
+ },
+
+ getCurrentEntry: function() {
+ return this.getEntry(this.index);
+ },
+
+ selectEntry: function() {
+ this.active = false;
+ this.updateElement(this.getCurrentEntry());
+ },
+
+ updateElement: function(selectedElement) {
+ if (this.options.updateElement) {
+ this.options.updateElement(selectedElement);
+ return;
+ }
+ var value = '';
+ if (this.options.select) {
+ var nodes = $(selectedElement).select('.' + this.options.select) || [];
+ if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
+ } else
+ value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+
+ var bounds = this.getTokenBounds();
+ if (bounds[0] != -1) {
+ var newValue = this.element.value.substr(0, bounds[0]);
+ var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
+ if (whitespace)
+ newValue += whitespace[0];
+ this.element.value = newValue + value + this.element.value.substr(bounds[1]);
+ } else {
+ this.element.value = value;
+ }
+ this.oldElementValue = this.element.value;
+ this.element.focus();
+
+ if (this.options.afterUpdateElement)
+ this.options.afterUpdateElement(this.element, selectedElement);
+ },
+
+ updateChoices: function(choices) {
+ if(!this.changed && this.hasFocus) {
+ this.update.innerHTML = choices;
+ Element.cleanWhitespace(this.update);
+ Element.cleanWhitespace(this.update.down());
+
+ if(this.update.firstChild && this.update.down().childNodes) {
+ this.entryCount =
+ this.update.down().childNodes.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ } else {
+ this.entryCount = 0;
+ }
+
+ this.stopIndicator();
+ this.index = 0;
+
+ if(this.entryCount==1 && this.options.autoSelect) {
+ this.selectEntry();
+ this.hide();
+ } else {
+ this.render();
+ }
+ }
+ },
+
+ addObservers: function(element) {
+ Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
+ Event.observe(element, "click", this.onClick.bindAsEventListener(this));
+ },
+
+ onObserverEvent: function() {
+ this.changed = false;
+ this.tokenBounds = null;
+ if(this.getToken().length>=this.options.minChars) {
+ this.getUpdatedChoices();
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ this.oldElementValue = this.element.value;
+ },
+
+ getToken: function() {
+ var bounds = this.getTokenBounds();
+ return this.element.value.substring(bounds[0], bounds[1]).strip();
+ },
+
+ getTokenBounds: function() {
+ if (null != this.tokenBounds) return this.tokenBounds;
+ var value = this.element.value;
+ if (value.strip().empty()) return [-1, 0];
+ var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
+ var offset = (diff == this.oldElementValue.length ? 1 : 0);
+ var prevTokenPos = -1, nextTokenPos = value.length;
+ var tp;
+ for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
+ tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
+ if (tp > prevTokenPos) prevTokenPos = tp;
+ tp = value.indexOf(this.options.tokens[index], diff + offset);
+ if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
+ }
+ return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
+ }
+});
+
+Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
+ var boundary = Math.min(newS.length, oldS.length);
+ for (var index = 0; index < boundary; ++index)
+ if (newS[index] != oldS[index])
+ return index;
+ return boundary;
+};
+
+Ajax.Autocompleter = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, url, options) {
+ this.baseInitialize(element, update, options);
+ this.options.asynchronous = true;
+ this.options.onComplete = this.onComplete.bind(this);
+ this.options.defaultParams = this.options.parameters || null;
+ this.url = url;
+ },
+
+ getUpdatedChoices: function() {
+ this.startIndicator();
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
+ encodeURIComponent(this.getToken());
+
+ this.options.parameters = this.options.callback ?
+ this.options.callback(this.element, entry) : entry;
+
+ if(this.options.defaultParams)
+ this.options.parameters += '&' + this.options.defaultParams;
+
+ new Ajax.Request(this.url, this.options);
+ },
+
+ onComplete: function(request) {
+ this.updateChoices(request.responseText);
+ }
+});
+
+// The local array autocompleter. Used when you'd prefer to
+// inject an array of autocompletion options into the page, rather
+// than sending out Ajax queries, which can be quite slow sometimes.
+//
+// The constructor takes four parameters. The first two are, as usual,
+// the id of the monitored textbox, and id of the autocompletion menu.
+// The third is the array you want to autocomplete from, and the fourth
+// is the options block.
+//
+// Extra local autocompletion options:
+// - choices - How many autocompletion choices to offer
+//
+// - partialSearch - If false, the autocompleter will match entered
+// text only at the beginning of strings in the
+// autocomplete array. Defaults to true, which will
+// match text at the beginning of any *word* in the
+// strings in the autocomplete array. If you want to
+// search anywhere in the string, additionally set
+// the option fullSearch to true (default: off).
+//
+// - fullSsearch - Search anywhere in autocomplete array strings.
+//
+// - partialChars - How many characters to enter before triggering
+// a partial match (unlike minChars, which defines
+// how many characters are required to do any match
+// at all). Defaults to 2.
+//
+// - ignoreCase - Whether to ignore case when autocompleting.
+// Defaults to true.
+//
+// It's possible to pass in a custom function as the 'selector'
+// option, if you prefer to write your own autocompletion logic.
+// In that case, the other options above will not apply unless
+// you support them.
+
+Autocompleter.Local = Class.create(Autocompleter.Base, {
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ },
+
+ getUpdatedChoices: function() {
+ this.updateChoices(this.options.selector(this));
+ },
+
+ setOptions: function(options) {
+ this.options = Object.extend({
+ choices: 10,
+ partialSearch: true,
+ partialChars: 2,
+ ignoreCase: true,
+ fullSearch: false,
+ selector: function(instance) {
+ var ret = []; // Beginning matches
+ var partial = []; // Inside matches
+ var entry = instance.getToken();
+ var count = 0;
+
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
+
+ var elem = instance.options.array[i];
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ elem.indexOf(entry);
+
+ while (foundPos != -1) {
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
+ elem.substr(entry.length) + "</li>");
+ break;
+ } else if (entry.length >= instance.options.partialChars &&
+ instance.options.partialSearch && foundPos != -1) {
+ if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
+ partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
+ elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
+ foundPos + entry.length) + "</li>");
+ break;
+ }
+ }
+
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ elem.indexOf(entry, foundPos + 1);
+
+ }
+ }
+ if (partial.length)
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
+ return "<ul>" + ret.join('') + "</ul>";
+ }
+ }, options || { });
+ }
+});
+
+// AJAX in-place editor and collection editor
+// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
+
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+ setTimeout(function() {
+ Field.activate(field);
+ }, 1);
+}
+
+Ajax.InPlaceEditor = Class.create({
+ initialize: function(element, url, options) {
+ this.url = url;
+ this.element = element = $(element);
+ this.prepareOptions();
+ this._controls = { };
+ arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
+ Object.extend(this.options, options || { });
+ if (!this.options.formId && this.element.id) {
+ this.options.formId = this.element.id + '-inplaceeditor';
+ if ($(this.options.formId))
+ this.options.formId = '';
+ }
+ if (this.options.externalControl)
+ this.options.externalControl = $(this.options.externalControl);
+ if (!this.options.externalControl)
+ this.options.externalControlOnly = false;
+ this._originalBackground = this.element.getStyle('background-color') || 'transparent';
+ this.element.title = this.options.clickToEditText;
+ this._boundCancelHandler = this.handleFormCancellation.bind(this);
+ this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
+ this._boundFailureHandler = this.handleAJAXFailure.bind(this);
+ this._boundSubmitHandler = this.handleFormSubmission.bind(this);
+ this._boundWrapperHandler = this.wrapUp.bind(this);
+ this.registerListeners();
+ },
+ checkForEscapeOrReturn: function(e) {
+ if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
+ if (Event.KEY_ESC == e.keyCode)
+ this.handleFormCancellation(e);
+ else if (Event.KEY_RETURN == e.keyCode)
+ this.handleFormSubmission(e);
+ },
+ createControl: function(mode, handler, extraClasses) {
+ var control = this.options[mode + 'Control'];
+ var text = this.options[mode + 'Text'];
+ if ('button' == control) {
+ var btn = document.createElement('input');
+ btn.type = 'submit';
+ btn.value = text;
+ btn.className = 'editor_' + mode + '_button';
+ if ('cancel' == mode)
+ btn.onclick = this._boundCancelHandler;
+ this._form.appendChild(btn);
+ this._controls[mode] = btn;
+ } else if ('link' == control) {
+ var link = document.createElement('a');
+ link.href = '#';
+ link.appendChild(document.createTextNode(text));
+ link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
+ link.className = 'editor_' + mode + '_link';
+ if (extraClasses)
+ link.className += ' ' + extraClasses;
+ this._form.appendChild(link);
+ this._controls[mode] = link;
+ }
+ },
+ createEditField: function() {
+ var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
+ var fld;
+ if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
+ fld = document.createElement('input');
+ fld.type = 'text';
+ var size = this.options.size || this.options.cols || 0;
+ if (0 < size) fld.size = size;
+ } else {
+ fld = document.createElement('textarea');
+ fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
+ fld.cols = this.options.cols || 40;
+ }
+ fld.name = this.options.paramName;
+ fld.value = text; // No HTML breaks conversion anymore
+ fld.className = 'editor_field';
+ if (this.options.submitOnBlur)
+ fld.onblur = this._boundSubmitHandler;
+ this._controls.editor = fld;
+ if (this.options.loadTextURL)
+ this.loadExternalText();
+ this._form.appendChild(this._controls.editor);