Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

boilerplate

  • Loading branch information...
commit 1b9a4fbaa89304bba5e983315418c1cfc756c202 1 parent 81e26b4
@l4rk l4rk authored
Showing with 28,344 additions and 0 deletions.
  1. +2 −0  .gitignore
  2. +3 −0  Capfile
  3. +22 −0 Rakefile
  4. +10 −0 app/controllers/application.rb
  5. +31 −0 app/controllers/sessions_controller.rb
  6. +27 −0 app/controllers/users_controller.rb
  7. +3 −0  app/helpers/application_helper.rb
  8. +2 −0  app/helpers/sessions_helper.rb
  9. +2 −0  app/helpers/users_helper.rb
  10. +83 −0 app/models/user.rb
  11. +14 −0 app/views/sessions/new.html.erb
  12. +16 −0 app/views/users/new.html.erb
  13. +109 −0 config/boot.rb
  14. +12 −0 config/database.example.yml
  15. +14 −0 config/environment.rb
  16. +17 −0 config/environments/development.rb
  17. +22 −0 config/environments/production.rb
  18. +22 −0 config/environments/staging.rb
  19. +22 −0 config/environments/test.rb
  20. +10 −0 config/initializers/inflections.rb
  21. +5 −0 config/initializers/mime_types.rb
  22. +12 −0 config/routes.rb
  23. BIN  db/dev.db
  24. +20 −0 db/migrate/001_create_users.rb
  25. +25 −0 db/schema.rb
  26. +2 −0  doc/README_FOR_APP
  27. +115 −0 lib/authenticated_system.rb
  28. +10 −0 lib/authenticated_test_helper.rb
  29. +17 −0 lib/tasks/cruise.rake
  30. +4 −0 lib/tasks/db.rake
  31. +7 −0 lib/tasks/populate.rake
  32. +40 −0 public/.htaccess
  33. +30 −0 public/404.html
  34. +30 −0 public/422.html
  35. +30 −0 public/500.html
  36. +10 −0 public/dispatch.cgi
  37. +24 −0 public/dispatch.fcgi
  38. +10 −0 public/dispatch.rb
  39. 0  public/favicon.ico
  40. BIN  public/images/rails.png
  41. +277 −0 public/index.html
  42. +2 −0  public/javascripts/application.js
  43. +963 −0 public/javascripts/controls.js
  44. +972 −0 public/javascripts/dragdrop.js
  45. +1,120 −0 public/javascripts/effects.js
  46. +4,225 −0 public/javascripts/prototype.js
  47. +5 −0 public/robots.txt
  48. +3 −0  script/about
  49. +3 −0  script/console
  50. +3 −0  script/dbconsole
  51. +3 −0  script/destroy
  52. +3 −0  script/generate
  53. +3 −0  script/performance/benchmarker
  54. +3 −0  script/performance/profiler
  55. +3 −0  script/performance/request
  56. +3 −0  script/plugin
  57. +3 −0  script/process/inspector
  58. +3 −0  script/process/reaper
  59. +3 −0  script/process/spawner
  60. +3 −0  script/runner
  61. +3 −0  script/server
  62. +4 −0 script/spec
  63. +102 −0 script/spec_server
  64. +74 −0 spec/controllers/sessions_controller_spec.rb
  65. +59 −0 spec/controllers/users_controller_spec.rb
  66. +19 −0 spec/fixtures/users.yml
  67. +111 −0 spec/models/user_spec.rb
  68. +2 −0  spec/rcov.opts
  69. +6 −0 spec/spec.opts
  70. +26 −0 spec/spec_helper.rb
  71. +4 −0 stories/all.rb
  72. +3 −0  stories/helper.rb
  73. +2 −0  tmp/.gitignore
  74. +20 −0 vendor/plugins/footnotes-edge/init.rb
  75. +42 −0 vendor/plugins/footnotes-edge/lib/textmate_backtracer.rb
  76. +257 −0 vendor/plugins/footnotes-edge/lib/textmate_footnotes.rb
  77. +14 −0 vendor/plugins/footnotes-edge/lib/textmate_initialize.rb
  78. +21 −0 vendor/plugins/footnotes-edge/templates/rescues/template_error.erb
  79. +65 −0 vendor/plugins/footnotes-edge/test/mock_controller.rb
  80. +85 −0 vendor/plugins/footnotes-edge/test/textmate_footnotes_test.rb
  81. +7 −0 vendor/plugins/haml/init.rb
  82. +3 −0  vendor/plugins/resources_controller/.gitignore
  83. +280 −0 vendor/plugins/resources_controller/CHANGELOG
  84. +20 −0 vendor/plugins/resources_controller/MIT-LICENSE
  85. +24 −0 vendor/plugins/resources_controller/README.rdoc
  86. +81 −0 vendor/plugins/resources_controller/Rakefile
  87. +875 −0 vendor/plugins/resources_controller/SPECDOC
  88. +5 −0 vendor/plugins/resources_controller/TODO
  89. +36 −0 vendor/plugins/resources_controller/garlic_example.rb
  90. +3 −0  vendor/plugins/resources_controller/init.rb
  91. +927 −0 vendor/plugins/resources_controller/lib/ardes/resources_controller.rb
  92. +151 −0 vendor/plugins/resources_controller/lib/ardes/resources_controller/actions.rb
  93. +123 −0 vendor/plugins/resources_controller/lib/ardes/resources_controller/helper.rb
  94. +156 −0 vendor/plugins/resources_controller/lib/ardes/resources_controller/named_route_helper.rb
  95. +24 −0 vendor/plugins/resources_controller/lib/ardes/resources_controller/singleton_actions.rb
  96. +104 −0 vendor/plugins/resources_controller/lib/ardes/resources_controller/specification.rb
  97. +301 −0 vendor/plugins/resources_controller/spec/app.rb
  98. +71 −0 vendor/plugins/resources_controller/spec/controllers/accounts_controller_spec.rb
  99. +357 −0 vendor/plugins/resources_controller/spec/controllers/addresses_controller_spec.rb
  100. +653 −0 vendor/plugins/resources_controller/spec/controllers/admin_forums_controller_spec.rb
  101. +390 −0 vendor/plugins/resources_controller/spec/controllers/comments_controller_spec.rb
  102. +443 −0 vendor/plugins/resources_controller/spec/controllers/forum_posts_controller_spec.rb
  103. +730 −0 vendor/plugins/resources_controller/spec/controllers/forums_controller_spec.rb
  104. +72 −0 vendor/plugins/resources_controller/spec/controllers/infos_controller_spec.rb
  105. +116 −0 vendor/plugins/resources_controller/spec/controllers/interests_controller_via_forum_spec.rb
  106. +116 −0 vendor/plugins/resources_controller/spec/controllers/interests_controller_via_user_spec.rb
  107. +286 −0 vendor/plugins/resources_controller/spec/controllers/owners_controller_spec.rb
  108. +85 −0 vendor/plugins/resources_controller/spec/controllers/tags_controller_spec.rb
  109. +133 −0 vendor/plugins/resources_controller/spec/controllers/tags_controller_via_account_info_spec.rb
  110. +146 −0 vendor/plugins/resources_controller/spec/controllers/tags_controller_via_forum_post_comment_spec.rb
  111. +132 −0 vendor/plugins/resources_controller/spec/controllers/tags_controller_via_forum_post_spec.rb
  112. +176 −0 vendor/plugins/resources_controller/spec/controllers/tags_controller_via_forum_spec.rb
  113. +132 −0 vendor/plugins/resources_controller/spec/controllers/tags_controller_via_user_address_spec.rb
  114. +279 −0 vendor/plugins/resources_controller/spec/controllers/users_controller_spec.rb
  115. +23 −0 vendor/plugins/resources_controller/spec/spec_helper.rb
  116. +144 −0 vendor/plugins/resources_controller/spec/specs/action_view_helper_spec.rb
  117. +264 −0 vendor/plugins/resources_controller/spec/specs/load_enclosing_resources_spec.rb
  118. +43 −0 vendor/plugins/resources_controller/spec/specs/resources_controller_spec.rb
  119. +95 −0 vendor/plugins/resources_controller/spec/specs/route_enclosing_names_spec.rb
  120. +20 −0 vendor/plugins/restful-authentication/.gitignore
  121. +68 −0 vendor/plugins/restful-authentication/CHANGELOG
  122. +174 −0 vendor/plugins/restful-authentication/README
  123. +22 −0 vendor/plugins/restful-authentication/Rakefile
  124. +15 −0 vendor/plugins/restful-authentication/TODO
  125. +1 −0  vendor/plugins/restful-authentication/generators/authenticated/USAGE
  126. +472 −0 vendor/plugins/restful-authentication/generators/authenticated/authenticated_generator.rb
  127. +50 −0 vendor/plugins/restful-authentication/generators/authenticated/lib/insert_routes.rb
  128. +8 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/_model_partial.html.erb
  129. +3 −0  vendor/plugins/restful-authentication/generators/authenticated/templates/activation.html.erb
  130. +187 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_system.rb
  131. +22 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
  132. +43 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
  133. +2 −0  vendor/plugins/restful-authentication/generators/authenticated/templates/helper.rb
  134. +16 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/login.html.erb
  135. +25 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/mailer.rb
  136. +26 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/migration.rb
  137. +68 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model.rb
  138. +86 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model_controller.rb
  139. +93 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model_helper.rb
  140. +158 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/model_helper_spec.rb
  141. +11 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/observer.rb
  142. +19 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/signup.html.erb
  143. +8 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/signup_notification.html.erb
  144. +38 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/site_keys.rb
  145. +90 −0 ...r/plugins/restful-authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb
  146. +101 −0 ...ins/restful-authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb
  147. +139 −0 ...gins/restful-authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb
  148. +198 −0 ...plugins/restful-authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb
  149. +60 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/spec/fixtures/users.yml
  150. +141 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb
  151. +290 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/spec/models/user_spec.rb
  152. +22 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/rest_auth_stories.rb
  153. +81 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb
  154. +49 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
  155. +179 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb
  156. +171 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb
  157. +153 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/steps/user_steps.rb
  158. +186 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/users/accounts.story
  159. +134 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/stories/users/sessions.story
  160. +88 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/functional_test.rb
  161. +31 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/mailer_test.rb
  162. +99 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/model_functional_test.rb
  163. +164 −0 vendor/plugins/restful-authentication/generators/authenticated/templates/test/unit_test.rb
  164. +3 −0  vendor/plugins/restful-authentication/init.rb
  165. +1 −0  vendor/plugins/restful-authentication/install.rb
  166. +43 −0 vendor/plugins/restful-authentication/lib/authentication.rb
  167. +85 −0 vendor/plugins/restful-authentication/lib/authentication/by_cookie_token.rb
  168. +65 −0 vendor/plugins/restful-authentication/lib/authentication/by_password.rb
  169. +15 −0 vendor/plugins/restful-authentication/lib/authorization.rb
  170. +63 −0 vendor/plugins/restful-authentication/lib/authorization/stateful_roles.rb
  171. +15 −0 vendor/plugins/restful-authentication/lib/trustification.rb
  172. +20 −0 vendor/plugins/restful-authentication/lib/trustification/email_validation.rb
  173. +2 −0  vendor/plugins/restful-authentication/notes/AccessControl.txt
  174. +5 −0 vendor/plugins/restful-authentication/notes/Authentication.txt
  175. +154 −0 vendor/plugins/restful-authentication/notes/Authorization.txt
  176. +78 −0 vendor/plugins/restful-authentication/notes/RailsPlugins.txt
  177. BIN  vendor/plugins/restful-authentication/notes/SecurityFramework.graffle
  178. BIN  vendor/plugins/restful-authentication/notes/SecurityFramework.png
  179. +163 −0 vendor/plugins/restful-authentication/notes/SecurityPatterns.txt
  180. +126 −0 vendor/plugins/restful-authentication/notes/Tradeoffs.txt
  181. +49 −0 vendor/plugins/restful-authentication/notes/Trustification.txt
  182. +4 −0 vendor/plugins/rspec-rails/.gitignore
  183. +21 −0 vendor/plugins/rspec-rails/CHANGES
  184. +31 −0 vendor/plugins/rspec-rails/MIT-LICENSE
  185. +3 −0  vendor/plugins/rspec-rails/README
  186. +9 −0 vendor/plugins/rspec-rails/Rakefile
  187. +1 −0  vendor/plugins/rspec-rails/generators/rspec/CHANGES
  188. +35 −0 vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb
  189. +4 −0 vendor/plugins/rspec-rails/generators/rspec/templates/all_stories.rb
  190. 0  vendor/plugins/rspec-rails/generators/rspec/templates/previous_failures.txt
  191. +2 −0  vendor/plugins/rspec-rails/generators/rspec/templates/rcov.opts
  192. +4 −0 vendor/plugins/rspec-rails/generators/rspec/templates/script/spec
  193. +116 −0 vendor/plugins/rspec-rails/generators/rspec/templates/script/spec_server
  194. +4 −0 vendor/plugins/rspec-rails/generators/rspec/templates/spec.opts
  195. +47 −0 vendor/plugins/rspec-rails/generators/rspec/templates/spec_helper.rb
  196. +3 −0  vendor/plugins/rspec-rails/generators/rspec/templates/stories_helper.rb
  197. +33 −0 vendor/plugins/rspec-rails/generators/rspec_controller/USAGE
  198. +49 −0 vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
  199. +25 −0 vendor/plugins/rspec-rails/generators/rspec_controller/templates/controller_spec.rb
  200. +11 −0 vendor/plugins/rspec-rails/generators/rspec_controller/templates/helper_spec.rb
  201. +12 −0 vendor/plugins/rspec-rails/generators/rspec_controller/templates/view_spec.rb
  202. +18 −0 vendor/plugins/rspec-rails/generators/rspec_model/USAGE
  203. +30 −0 vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb
  204. +11 −0 vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb
  205. +167 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
  206. +313 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb
  207. +25 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
  208. +11 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb
  209. +22 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb
  210. +26 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb
  211. +61 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb
  212. +22 −0 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb
  213. +9 −0 vendor/plugins/rspec-rails/init.rb
  214. +1 −0  vendor/plugins/rspec-rails/lib/autotest/discover.rb
  215. +81 −0 vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb
  216. +52 −0 vendor/plugins/rspec-rails/lib/spec/rails.rb
  217. +46 −0 vendor/plugins/rspec-rails/lib/spec/rails/example.rb
  218. +43 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
  219. +271 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb
  220. +59 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb
  221. +130 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb
  222. +14 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/model_example_group.rb
  223. +27 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/rails_example_group.rb
  224. +90 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/render_observer.rb
  225. +178 −0 vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb
  226. +12 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions.rb
  227. +14 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/base.rb
  228. +21 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/rescue.rb
  229. +11 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/test_response.rb
  230. +27 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb
  231. +30 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/active_record/base.rb
  232. +5 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/object.rb
  233. +71 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/example/configuration.rb
  234. +21 −0 vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/matchers/have.rb
  235. +30 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers.rb
  236. +130 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/assert_select.rb
  237. +57 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/have_text.rb
  238. +54 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/include_text.rb
  239. +113 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/redirect_to.rb
  240. +70 −0 vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb
  241. +115 −0 vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb
  242. +71 −0 vendor/plugins/rspec-rails/lib/spec/rails/story_adapter.rb
  243. +23 −0 vendor/plugins/rspec-rails/lib/spec/rails/version.rb
  244. +36 −0 vendor/plugins/rspec-rails/spec/rails/autotest/mappings_spec.rb
  245. +8 −0 vendor/plugins/rspec-rails/spec/rails/autotest/rails_rspec_spec.rb
  246. +60 −0 vendor/plugins/rspec-rails/spec/rails/example/assigns_hash_proxy_spec.rb
  247. +83 −0 vendor/plugins/rspec-rails/spec/rails/example/configuration_spec.rb
  248. +62 −0 vendor/plugins/rspec-rails/spec/rails/example/controller_isolation_spec.rb
  249. +206 −0 vendor/plugins/rspec-rails/spec/rails/example/controller_spec_spec.rb
  250. +112 −0 vendor/plugins/rspec-rails/spec/rails/example/example_group_factory_spec.rb
  251. +135 −0 vendor/plugins/rspec-rails/spec/rails/example/helper_spec_spec.rb
  252. +18 −0 vendor/plugins/rspec-rails/spec/rails/example/model_spec_spec.rb
  253. +16 −0 vendor/plugins/rspec-rails/spec/rails/example/shared_behaviour_spec.rb
  254. +33 −0 vendor/plugins/rspec-rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb
  255. +272 −0 vendor/plugins/rspec-rails/spec/rails/example/view_spec_spec.rb
  256. +54 −0 vendor/plugins/rspec-rails/spec/rails/extensions/action_controller_rescue_action_spec.rb
  257. +48 −0 vendor/plugins/rspec-rails/spec/rails/extensions/action_view_base_spec.rb
  258. +14 −0 vendor/plugins/rspec-rails/spec/rails/extensions/active_record_spec.rb
  259. +783 −0 vendor/plugins/rspec-rails/spec/rails/matchers/assert_select_spec.rb
  260. +37 −0 vendor/plugins/rspec-rails/spec/rails/matchers/description_generation_spec.rb
  261. +13 −0 vendor/plugins/rspec-rails/spec/rails/matchers/errors_on_spec.rb
  262. +62 −0 vendor/plugins/rspec-rails/spec/rails/matchers/have_text_spec.rb
  263. +70 −0 vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
  264. +209 −0 vendor/plugins/rspec-rails/spec/rails/matchers/redirect_to_spec.rb
  265. +169 −0 vendor/plugins/rspec-rails/spec/rails/matchers/render_spec.rb
  266. +10 −0 vendor/plugins/rspec-rails/spec/rails/mocks/ar_classes.rb
  267. +64 −0 vendor/plugins/rspec-rails/spec/rails/mocks/mock_model_spec.rb
  268. +78 −0 vendor/plugins/rspec-rails/spec/rails/mocks/stub_model_spec.rb
  269. +8 −0 vendor/plugins/rspec-rails/spec/rails/sample_modified_fixture.rb
  270. +8 −0 vendor/plugins/rspec-rails/spec/rails/sample_spec.rb
  271. +96 −0 vendor/plugins/rspec-rails/spec/rails/spec_server_spec.rb
  272. +11 −0 vendor/plugins/rspec-rails/spec/rails/spec_spec.rb
  273. +7 −0 vendor/plugins/rspec-rails/spec/rails_suite.rb
  274. +46 −0 vendor/plugins/rspec-rails/spec/spec_helper.rb
  275. +2 −0  vendor/plugins/rspec-rails/spec_resources/controllers/action_view_base_spec_controller.rb
  276. +68 −0 vendor/plugins/rspec-rails/spec_resources/controllers/controller_spec_controller.rb
  277. +59 −0 vendor/plugins/rspec-rails/spec_resources/controllers/redirect_spec_controller.rb
  278. +26 −0 vendor/plugins/rspec-rails/spec_resources/controllers/render_spec_controller.rb
  279. +58 −0 vendor/plugins/rspec-rails/spec_resources/controllers/rjs_spec_controller.rb
  280. +10 −0 vendor/plugins/rspec-rails/spec_resources/helpers/explicit_helper.rb
  281. +5 −0 vendor/plugins/rspec-rails/spec_resources/helpers/more_explicit_helper.rb
  282. +6 −0 vendor/plugins/rspec-rails/spec_resources/helpers/plugin_application_helper.rb
  283. +13 −0 vendor/plugins/rspec-rails/spec_resources/helpers/view_spec_helper.rb
  284. 0  vendor/plugins/rspec-rails/spec_resources/views/controller_spec/_partial.rhtml
  285. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml
  286. +1 −0  ...or/plugins/rspec-rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml
  287. 0  vendor/plugins/rspec-rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
  288. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml
  289. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/controller_spec/action_with_template.rhtml
  290. 0  vendor/plugins/rspec-rails/spec_resources/views/render_spec/_a_partial.rhtml
  291. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/render_spec/some_action.js.rjs
  292. 0  vendor/plugins/rspec-rails/spec_resources/views/render_spec/some_action.rhtml
  293. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/render_spec/some_action.rjs
  294. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml
  295. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/hide_div.rjs
  296. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/hide_page_element.rjs
  297. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/insert_html.rjs
  298. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/replace.rjs
  299. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/replace_html.rjs
  300. +1 −0  vendor/plugins/rspec-rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs
Sorry, we could not display the entire diff because too many files (736) changed.
View
2  .gitignore
@@ -0,0 +1,2 @@
+config/database.yml
+log/*.log
View
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'
View
22 Rakefile
@@ -0,0 +1,22 @@
+# 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'
+
+def timestamp(label)
+ puts "*** #{label} @ #{DateTime.now.to_formatted_s :db} ***"
+end
+
+task :show_success do
+ timestamp "SUCCESSFUL BUILD"
+end
+
+task :show_start => :environment do
+ timestamp "BUILD"
+end
View
10 app/controllers/application.rb
@@ -0,0 +1,10 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => '5e89a8607a729450f876d58cf6d92b8b'
+end
View
31 app/controllers/sessions_controller.rb
@@ -0,0 +1,31 @@
+# This controller handles the login/logout function of the site.
+class SessionsController < ApplicationController
+ # Be sure to include AuthenticationSystem in Application Controller instead
+ include AuthenticatedSystem
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ self.current_user = User.authenticate(params[:login], params[:password])
+ if logged_in?
+ if params[:remember_me] == "1"
+ current_user.remember_me unless current_user.remember_token?
+ cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
+ end
+ redirect_back_or_default('/')
+ flash[:notice] = "Logged in successfully"
+ else
+ render :action => 'new'
+ end
+ end
+
+ def destroy
+ self.current_user.forget_me if logged_in?
+ cookies.delete :auth_token
+ reset_session
+ flash[:notice] = "You have been logged out."
+ redirect_back_or_default('/')
+ end
+end
View
27 app/controllers/users_controller.rb
@@ -0,0 +1,27 @@
+class UsersController < ApplicationController
+ # Be sure to include AuthenticationSystem in Application Controller instead
+ include AuthenticatedSystem
+
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ cookies.delete :auth_token
+ # protects against session fixation attacks, wreaks havoc with
+ # request forgery protection.
+ # uncomment at your own risk
+ # reset_session
+ @user = User.new(params[:user])
+ @user.save
+ if @user.errors.empty?
+ self.current_user = @user
+ redirect_back_or_default('/')
+ flash[:notice] = "Thanks for signing up!"
+ else
+ render :action => 'new'
+ end
+ end
+
+end
View
3  app/helpers/application_helper.rb
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
View
2  app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
View
2  app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
View
83 app/models/user.rb
@@ -0,0 +1,83 @@
+require 'digest/sha1'
+class User < ActiveRecord::Base
+ # Virtual attribute for the unencrypted password
+ attr_accessor :password
+
+ validates_presence_of :login, :email
+ validates_presence_of :password, :if => :password_required?
+ validates_presence_of :password_confirmation, :if => :password_required?
+ validates_length_of :password, :within => 4..40, :if => :password_required?
+ validates_confirmation_of :password, :if => :password_required?
+ validates_length_of :login, :within => 3..40
+ validates_length_of :email, :within => 3..100
+ validates_uniqueness_of :login, :email, :case_sensitive => false
+ before_save :encrypt_password
+
+ # prevents a user from submitting a crafted form that bypasses activation
+ # anything else you want your user to change should be added here.
+ attr_accessible :login, :email, :password, :password_confirmation
+
+ # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
+ def self.authenticate(login, password)
+ u = find_by_login(login) # need to get the salt
+ u && u.authenticated?(password) ? u : nil
+ end
+
+ # Encrypts some data with the salt.
+ def self.encrypt(password, salt)
+ Digest::SHA1.hexdigest("--#{salt}--#{password}--")
+ end
+
+ # Encrypts the password with the user salt
+ def encrypt(password)
+ self.class.encrypt(password, salt)
+ end
+
+ def authenticated?(password)
+ crypted_password == encrypt(password)
+ end
+
+ def remember_token?
+ remember_token_expires_at && Time.now.utc < remember_token_expires_at
+ end
+
+ # These create and unset the fields required for remembering users between browser closes
+ def remember_me
+ remember_me_for 2.weeks
+ end
+
+ def remember_me_for(time)
+ remember_me_until time.from_now.utc
+ end
+
+ def remember_me_until(time)
+ self.remember_token_expires_at = time
+ self.remember_token = encrypt("#{email}--#{remember_token_expires_at}")
+ save(false)
+ end
+
+ def forget_me
+ self.remember_token_expires_at = nil
+ self.remember_token = nil
+ save(false)
+ end
+
+ # Returns true if the user has just been activated.
+ def recently_activated?
+ @activated
+ end
+
+ protected
+ # before filter
+ def encrypt_password
+ return if password.blank?
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
+ self.crypted_password = encrypt(password)
+ end
+
+ def password_required?
+ crypted_password.blank? || !password.blank?
+ end
+
+
+end
View
14 app/views/sessions/new.html.erb
@@ -0,0 +1,14 @@
+<% form_tag session_path do -%>
+<p><label for="login">Login</label><br/>
+<%= text_field_tag 'login' %></p>
+
+<p><label for="password">Password</label><br/>
+<%= password_field_tag 'password' %></p>
+
+<!-- Uncomment this if you want this functionality
+<p><label for="remember_me">Remember me:</label>
+<%= check_box_tag 'remember_me' %></p>
+-->
+
+<p><%= submit_tag 'Log in' %></p>
+<% end -%>
View
16 app/views/users/new.html.erb
@@ -0,0 +1,16 @@
+<%= error_messages_for :user %>
+<% form_for :user, :url => users_path do |f| -%>
+<p><label for="login">Login</label><br/>
+<%= f.text_field :login %></p>
+
+<p><label for="email">Email</label><br/>
+<%= f.text_field :email %></p>
+
+<p><label for="password">Password</label><br/>
+<%= f.password_field :password %></p>
+
+<p><label for="password_confirmation">Confirm Password</label><br/>
+<%= f.password_field :password_confirmation %></p>
+
+<p><%= submit_tag 'Sign up' %></p>
+<% end -%>
View
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'
+
+ unless rubygems_version >= '0.9.4'
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. 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!
View
12 config/database.example.yml
@@ -0,0 +1,12 @@
+development:
+ adapter: mysql
+ database: spotus_development
+ username: root
+ password:
+
+test:
+ adapter: mysql
+ database: spotus_test
+ username: root
+ password:
+
View
14 config/environment.rb
@@ -0,0 +1,14 @@
+RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION
+
+require File.join(File.dirname(__FILE__), 'boot')
+
+Rails::Initializer.run do |config|
+ config.gem "haml", :version => "2.0.3"
+
+ config.time_zone = 'UTC'
+
+ config.action_controller.session = {
+ :session_key => '_spotus_session',
+ :secret => '5364db1b81e0c120704c572a45f1c6929d10c54ea5b4069680f396e898d8af69920ad7ec1524c5a8f32340624c61f4232204d299b484108bbcdefed1a26f7e7a'
+ }
+end
View
17 config/environments/development.rb
@@ -0,0 +1,17 @@
+# 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_view.debug_rjs = true
+config.action_controller.perform_caching = false
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
View
22 config/environments/production.rb
@@ -0,0 +1,22 @@
+# 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
+config.action_view.cache_template_loading = true
+
+# Use a different cache store in production
+# config.cache_store = :mem_cache_store
+
+# 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
View
22 config/environments/staging.rb
@@ -0,0 +1,22 @@
+# 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
+config.action_view.cache_template_loading = true
+
+# Use a different cache store in production
+# config.cache_store = :mem_cache_store
+
+# 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
View
22 config/environments/test.rb
@@ -0,0 +1,22 @@
+# 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
View
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
View
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
View
12 config/routes.rb
@@ -0,0 +1,12 @@
+ActionController::Routing::Routes.draw do |map|
+ map.resources :users
+ map.signup '/signup', :controller => 'users', :action => 'new'
+
+ map.resource :session
+ map.login '/login', :controller => 'sessions', :action => 'new'
+ map.logout '/logout', :controller => 'sessions', :action => 'destroy'
+
+ # Install the default routes as the lowest priority.
+ map.connect ':controller/:action/:id'
+ map.connect ':controller/:action/:id.:format'
+end
View
BIN  db/dev.db
Binary file not shown
View
20 db/migrate/001_create_users.rb
@@ -0,0 +1,20 @@
+class CreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table "users", :force => true do |t|
+ t.column :login, :string
+ t.column :email, :string
+ t.column :crypted_password, :string, :limit => 40
+ t.column :salt, :string, :limit => 40
+ t.column :created_at, :datetime
+ t.column :updated_at, :datetime
+ t.column :remember_token, :string
+ t.column :remember_token_expires_at, :datetime
+
+
+ end
+ end
+
+ def self.down
+ drop_table "users"
+ end
+end
View
25 db/schema.rb
@@ -0,0 +1,25 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 1) do
+
+ create_table "users", :force => true do |t|
+ t.string "login"
+ t.string "email"
+ t.string "crypted_password", :limit => 40
+ t.string "salt", :limit => 40
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "remember_token"
+ t.datetime "remember_token_expires_at"
+ end
+
+end
View
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 doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
View
115 lib/authenticated_system.rb
@@ -0,0 +1,115 @@
+module AuthenticatedSystem
+ protected
+ # Returns true or false if the user is logged in.
+ # Preloads @current_user with the user model if they're logged in.
+ def logged_in?
+ !!current_user
+ end
+
+ # Accesses the current user from the session.
+ # Future calls avoid the database because nil is not equal to false.
+ def current_user
+ @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_user == false
+ end
+
+ # Store the given user id in the session.
+ def current_user=(new_user)
+ session[:user_id] = new_user ? new_user.id : nil
+ @current_user = new_user || false
+ end
+
+ # Check if the user is authorized
+ #
+ # Override this method in your controllers if you want to restrict access
+ # to only a few actions or if you want to check if the user
+ # has the correct rights.
+ #
+ # Example:
+ #
+ # # only allow nonbobs
+ # def authorized?
+ # current_user.login != "bob"
+ # end
+ def authorized?
+ logged_in?
+ end
+
+ # Filter method to enforce a login requirement.
+ #
+ # To require logins for all actions, use this in your controllers:
+ #
+ # before_filter :login_required
+ #
+ # To require logins for specific actions, use this in your controllers:
+ #
+ # before_filter :login_required, :only => [ :edit, :update ]
+ #
+ # To skip this in a subclassed controller:
+ #
+ # skip_before_filter :login_required
+ #
+ def login_required
+ authorized? || access_denied
+ end
+
+ # Redirect as appropriate when an access request fails.
+ #
+ # The default action is to redirect to the login screen.
+ #
+ # Override this method in your controllers if you want to have special
+ # behavior in case the user is not authorized
+ # to access the requested action. For example, a popup window might
+ # simply close itself.
+ def access_denied
+ respond_to do |format|
+ format.html do
+ store_location
+ redirect_to new_session_path
+ end
+ format.any do
+ request_http_basic_authentication 'Web Password'
+ end
+ end
+ end
+
+ # Store the URI of the current request in the session.
+ #
+ # We can return to this location by calling #redirect_back_or_default.
+ def store_location
+ session[:return_to] = request.request_uri
+ end
+
+ # Redirect to the URI stored by the most recent store_location call or
+ # to the passed default.
+ def redirect_back_or_default(default)
+ redirect_to(session[:return_to] || default)
+ session[:return_to] = nil
+ end
+
+ # Inclusion hook to make #current_user and #logged_in?
+ # available as ActionView helper methods.
+ def self.included(base)
+ base.send :helper_method, :current_user, :logged_in?
+ end
+
+ # Called from #current_user. First attempt to login by the user id stored in the session.
+ def login_from_session
+ self.current_user = User.find_by_id(session[:user_id]) if session[:user_id]
+ end
+
+ # Called from #current_user. Now, attempt to login by basic authentication information.
+ def login_from_basic_auth
+ authenticate_with_http_basic do |username, password|
+ self.current_user = User.authenticate(username, password)
+ end
+ end
+
+ # Called from #current_user. Finaly, attempt to login by an expiring token in the cookie.
+ def login_from_cookie
+ user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])
+ if user && user.remember_token?
+ cookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }
+ self.current_user = user
+ end
+ end
+end
View
10 lib/authenticated_test_helper.rb
@@ -0,0 +1,10 @@
+module AuthenticatedTestHelper
+ # Sets the current user in the session from the user fixtures.
+ def login_as(user)
+ @request.session[:user_id] = user ? users(user).id : nil
+ end
+
+ def authorize_as(user)
+ @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'test') : nil
+ end
+end
View
17 lib/tasks/cruise.rake
@@ -0,0 +1,17 @@
+desc 'Continuous build target'
+
+task :cruise do
+ # Force db:migrate
+ ENV['RAILS_ENV'] = 'test'
+ Rake::Task["db:migrate"].invoke
+
+ out = ENV['CC_BUILD_ARTIFACTS']
+ mkdir_p out unless File.directory? out if out
+
+ # publish blog
+ sh "/usr/bin/redcloth BLOG.textile > BLOG.html; mv BLOG.html #{out}" if out
+
+ # Relocates the coverage folder to make it a visible custom build artifact in CruiseControl
+ Rake::Task["spec:rcov"].invoke
+ mv 'coverage', "#{out}/spec_coverage" if out
+end
View
4 lib/tasks/db.rake
@@ -0,0 +1,4 @@
+namespace :db do
+ desc 'Drops, creates, migrates & populates.'
+ task :remake => [:drop, :create, :migrate, :populate]
+end
View
7 lib/tasks/populate.rake
@@ -0,0 +1,7 @@
+namespace :db do
+ desc "Loads initial database models for the current environment."
+ task :populate => :environment do
+ Dir[File.join(RAILS_ROOT, 'db', 'fixtures', '*.rb')].sort.each { |fixture| load fixture }
+ Dir[File.join(RAILS_ROOT, 'db', 'fixtures', RAILS_ENV, '*.rb')].sort.each { |fixture| load fixture }
+ end
+end
View
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"
View
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>
View
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>
View
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 (500)</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>
View
10 public/dispatch.cgi
@@ -0,0 +1,10 @@
+#!/usr/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
View
24 public/dispatch.fcgi
@@ -0,0 +1,24 @@
+#!/usr/local/bin/ruby
+#
+# You may specify the path to the FastCGI crash log (a log of unhandled
+# exceptions which forced the FastCGI instance to exit, great for debugging)
+# and the number of requests to process before running garbage collection.
+#
+# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
+# and the GC period is nil (turned off). A reasonable number of requests
+# could range from 10-100 depending on the memory footprint of your app.
+#
+# Example:
+# # Default log path, normal GC behavior.
+# RailsFCGIHandler.process!
+#
+# # Default log path, 50 requests between GC.
+# RailsFCGIHandler.process! nil, 50
+#
+# # Custom log path, normal GC behavior.
+# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
+#
+require File.dirname(__FILE__) + "/../config/environment"
+require 'fcgi_handler'
+
+RailsFCGIHandler.process!
View
10 public/dispatch.rb
@@ -0,0 +1,10 @@
+#!/usr/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
View
0  public/favicon.ico
No changes.
View
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.
View
277 public/index.html
@@ -0,0 +1,277 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title>Ruby on Rails: Welcome aboard</title>
+ <style type="text/css" media="screen">
+ body {
+ margin: 0;
+ margin-bottom: 25px;
+ padding: 0;
+ background-color: #f0f0f0;
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
+ font-size: 13px;
+ color: #333;
+ }
+
+ h1 {
+ font-size: 28px;
+ color: #000;
+ }
+
+ a {color: #03c}
+ a:hover {
+ background-color: #03c;
+ color: white;
+ text-decoration: none;
+ }
+
+
+ #page {
+ background-color: #f0f0f0;
+ width: 750px;
+ margin: 0;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ #content {
+ float: left;
+ background-color: white;
+ border: 3px solid #aaa;
+ border-top: none;
+ padding: 25px;
+ width: 500px;
+ }
+
+ #sidebar {
+ float: right;
+ width: 175px;
+ }
+
+ #footer {
+ clear: both;
+ }
+
+
+ #header, #about, #getting-started {
+ padding-left: 75px;
+ padding-right: 30px;
+ }
+
+
+ #header {
+ background-image: url("images/rails.png");
+ background-repeat: no-repeat;
+ background-position: top left;
+ height: 64px;
+ }
+ #header h1, #header h2 {margin: 0}
+ #header h2 {
+ color: #888;
+ font-weight: normal;
+ font-size: 16px;
+ }
+
+
+ #about h3 {
+ margin: 0;
+ margin-bottom: 10px;
+ font-size: 14px;
+ }
+
+ #about-content {
+ background-color: #ffd;
+ border: 1px solid #fc0;
+ margin-left: -11px;
+ }
+ #about-content table {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 11px;
+ border-collapse: collapse;
+ }
+ #about-content td {
+ padding: 10px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ }
+ #about-content td.name {color: #555}
+ #about-content td.value {color: #000}
+
+ #about-content.failure {
+ background-color: #fcc;
+ border: 1px solid #f00;
+ }
+ #about-content.failure p {
+ margin: 0;
+ padding: 10px;
+ }
+
+
+ #getting-started {
+ border-top: 1px solid #ccc;
+ margin-top: 25px;
+ padding-top: 15px;
+ }
+ #getting-started h1 {
+ margin: 0;
+ font-size: 20px;
+ }
+ #getting-started h2 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ color: #333;
+ margin-bottom: 25px;
+ }
+ #getting-started ol {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #getting-started li {
+ font-size: 18px;
+ color: #888;
+ margin-bottom: 25px;
+ }
+ #getting-started li h2 {
+ margin: 0;
+ font-weight: normal;
+ font-size: 18px;
+ color: #333;
+ }
+ #getting-started li p {
+ color: #555;
+ font-size: 13px;
+ }
+
+
+ #search {
+ margin: 0;
+ padding-top: 10px;
+ padding-bottom: 10px;
+ font-size: 11px;
+ }
+ #search input {
+ font-size: 11px;
+ margin: 2px;
+ }
+ #search-text {width: 170px}
+
+
+ #sidebar ul {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #sidebar ul h3 {
+ margin-top: 25px;
+ font-size: 16px;
+ padding-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+ }
+ #sidebar li {
+ list-style-type: none;
+ }
+ #sidebar ul.links li {
+ margin-bottom: 5px;
+ }
+
+ </style>
+ <script type="text/javascript" src="javascripts/prototype.js"></script>
+ <script type="text/javascript" src="javascripts/effects.js"></script>
+ <script type="text/javascript">
+ function about() {
+ if (Element.empty('about-content')) {
+ new Ajax.Updater('about-content', 'rails/info/properties', {
+ method: 'get',
+ onFailure: function() {Element.classNames('about-content').add('failure')},
+ onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
+ });
+ } else {
+ new Effect[Element.visible('about-content') ?
+ 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
+ }
+ }
+
+ window.onload = function() {
+ $('search-text').value = '';
+ $('search').onsubmit = function() {
+ $('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
+ }
+ }
+ </script>
+ </head>
+ <body>
+ <div id="page">
+ <div id="sidebar">
+ <ul id="sidebar-items">
+ <li>
+ <form id="search" action="http://www.google.com/search" method="get">
+ <input type="hidden" name="hl" value="en" />
+ <input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
+ <input type="submit" value="Search" /> the Rails site
+ </form>
+ </li>
+
+ <li>
+ <h3>Join the community</h3>
+ <ul class="links">
+ <li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
+ <li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
+ <li><a href="http://lists.rubyonrails.org/">Mailing lists</a></li>
+ <li><a href="http://wiki.rubyonrails.org/rails/pages/IRC">IRC channel</a></li>
+ <li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
+ <li><a href="http://dev.rubyonrails.org/">Bug tracker</a></li>
+ </ul>
+ </li>
+
+ <li>
+ <h3>Browse the documentation</h3>
+ <ul class="links">
+ <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
+ <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
+ <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ <div id="content">
+ <div id="header">
+ <h1>Welcome aboard</h1>
+ <h2>You&rsquo;re riding Ruby on Rails!</h2>
+ </div>
+
+ <div id="about">
+ <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
+ <div id="about-content" style="display: none"></div>
+ </div>
+
+ <div id="getting-started">
+ <h1>Getting started</h1>
+ <h2>Here&rsquo;s how to get rolling:</h2>
+
+ <ol>
+ <li>
+ <h2>Create your databases and edit <tt>config/database.yml</tt></h2>
+ <p>Rails needs to know your login and password.</p>
+ </li>
+
+ <li>
+ <h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
+ <p>To see all available options, run it without parameters.</p>
+ </li>
+
+ <li>
+ <h2>Set up a default route and remove or rename this file</h2>
+ <p>Routes are set up in config/routes.rb.</p>
+ </li>
+ </ol>
+ </div>
+ </div>
+
+ <div id="footer">&nbsp;</div>
+ </div>
+ </body>
+</html>
View
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
View
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) {