Skip to content
Browse files

initial import

  • Loading branch information...
0 parents commit 520ed9ed35734151c3a5d8597650f767a50b640e Raimonds Simanovskis committed Sep 25, 2008
Showing with 21,691 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +41 −0 README.txt
  3. +10 −0 Rakefile
  4. +15 −0 app/controllers/application.rb
  5. +5 −0 app/controllers/departments_controller.rb
  6. +14 −0 app/controllers/employees_controller.rb
  7. +10 −0 app/controllers/job_history_controller.rb
  8. +3 −0 app/helpers/application_helper.rb
  9. +2 −0 app/helpers/departments_helper.rb
  10. +2 −0 app/helpers/employees_helper.rb
  11. +2 −0 app/helpers/job_history_helper.rb
  12. +11 −0 app/models/department.rb
  13. +19 −0 app/models/employee.rb
  14. +10 −0 app/models/job.rb
  15. +13 −0 app/models/job_history.rb
  16. +11 −0 app/views/layouts/application.html.erb
  17. +109 −0 config/boot.rb
  18. +21 −0 config/database.yml
  19. +68 −0 config/environment.rb
  20. +17 −0 config/environments/development.rb
  21. +22 −0 config/environments/production.rb
  22. +22 −0 config/environments/test.rb
  23. +10 −0 config/initializers/inflections.rb
  24. +5 −0 config/initializers/mime_types.rb
  25. +17 −0 config/initializers/new_rails_defaults.rb
  26. +47 −0 config/routes.rb
  27. +2 −0 doc/README_FOR_APP
  28. 0 log/.gitignore
  29. +30 −0 public/404.html
  30. +30 −0 public/422.html
  31. +30 −0 public/500.html
  32. +33 −0 public/blank.html
  33. +10 −0 public/dispatch.cgi
  34. +24 −0 public/dispatch.fcgi
  35. +10 −0 public/dispatch.rb
  36. 0 public/favicon.ico
  37. +2 −0 public/images/active_scaffold/DO_NOT_EDIT
  38. BIN public/images/active_scaffold/default/add.gif
  39. BIN public/images/active_scaffold/default/arrow_down.gif
  40. BIN public/images/active_scaffold/default/arrow_up.gif
  41. BIN public/images/active_scaffold/default/close.gif
  42. BIN public/images/active_scaffold/default/cross.png
  43. BIN public/images/active_scaffold/default/indicator-small.gif
  44. BIN public/images/active_scaffold/default/indicator.gif
  45. BIN public/images/active_scaffold/default/magnifier.png
  46. BIN public/images/rails.png
  47. +274 −0 public/index.html
  48. +2 −0 public/javascripts/active_scaffold/DO_NOT_EDIT
  49. +418 −0 public/javascripts/active_scaffold/default/active_scaffold.js
  50. +942 −0 public/javascripts/active_scaffold/default/dhtml_history.js
  51. +89 −0 public/javascripts/active_scaffold/default/form_enhancements.js
  52. +370 −0 public/javascripts/active_scaffold/default/rico_corner.js
  53. +2 −0 public/javascripts/application.js
  54. +963 −0 public/javascripts/controls.js
  55. +972 −0 public/javascripts/dragdrop.js
  56. +1,120 −0 public/javascripts/effects.js
  57. +4,225 −0 public/javascripts/prototype.js
  58. +5 −0 public/robots.txt
  59. +2 −0 public/stylesheets/active_scaffold/DO_NOT_EDIT
  60. +35 −0 public/stylesheets/active_scaffold/default/stylesheet-ie.css
  61. +770 −0 public/stylesheets/active_scaffold/default/stylesheet.css
  62. +4 −0 script/about
  63. +3 −0 script/console
  64. +3 −0 script/dbconsole
  65. +3 −0 script/destroy
  66. +3 −0 script/generate
  67. +3 −0 script/performance/benchmarker
  68. +3 −0 script/performance/profiler
  69. +3 −0 script/performance/request
  70. +3 −0 script/plugin
  71. +3 −0 script/process/inspector
  72. +3 −0 script/process/reaper
  73. +3 −0 script/process/spawner
  74. +3 −0 script/runner
  75. +3 −0 script/server
  76. +7 −0 test/fixtures/departments.yml
  77. +7 −0 test/fixtures/employees.yml
  78. +7 −0 test/fixtures/job_histories.yml
  79. +7 −0 test/fixtures/jobs.yml
  80. +8 −0 test/functional/departments_controller_test.rb
  81. +8 −0 test/functional/employees_controller_test.rb
  82. +8 −0 test/functional/job_history_controller_test.rb
  83. +38 −0 test/test_helper.rb
  84. +8 −0 test/unit/department_test.rb
  85. +8 −0 test/unit/employee_test.rb
  86. +8 −0 test/unit/job_history_test.rb
  87. +8 −0 test/unit/job_test.rb
  88. +152 −0 vendor/plugins/activescaffold/CHANGELOG
  89. +20 −0 vendor/plugins/activescaffold/MIT-LICENSE
  90. +19 −0 vendor/plugins/activescaffold/README
  91. +24 −0 vendor/plugins/activescaffold/Rakefile
  92. +83 −0 vendor/plugins/activescaffold/environment.rb
  93. BIN vendor/plugins/activescaffold/frontends/default/images/add.gif
  94. BIN vendor/plugins/activescaffold/frontends/default/images/arrow_down.gif
  95. BIN vendor/plugins/activescaffold/frontends/default/images/arrow_up.gif
  96. BIN vendor/plugins/activescaffold/frontends/default/images/close.gif
  97. BIN vendor/plugins/activescaffold/frontends/default/images/cross.png
  98. BIN vendor/plugins/activescaffold/frontends/default/images/indicator-small.gif
  99. BIN vendor/plugins/activescaffold/frontends/default/images/indicator.gif
  100. BIN vendor/plugins/activescaffold/frontends/default/images/magnifier.png
  101. +418 −0 vendor/plugins/activescaffold/frontends/default/javascripts/active_scaffold.js
  102. +942 −0 vendor/plugins/activescaffold/frontends/default/javascripts/dhtml_history.js
  103. +89 −0 vendor/plugins/activescaffold/frontends/default/javascripts/form_enhancements.js
  104. +370 −0 vendor/plugins/activescaffold/frontends/default/javascripts/rico_corner.js
  105. +35 −0 vendor/plugins/activescaffold/frontends/default/stylesheets/stylesheet-ie.css
  106. +770 −0 vendor/plugins/activescaffold/frontends/default/stylesheets/stylesheet.css
  107. +40 −0 vendor/plugins/activescaffold/frontends/default/views/_add_existing_form.rhtml
  108. +45 −0 vendor/plugins/activescaffold/frontends/default/views/_create_form.rhtml
  109. +55 −0 vendor/plugins/activescaffold/frontends/default/views/_field_search.rhtml
  110. +18 −0 vendor/plugins/activescaffold/frontends/default/views/_form.rhtml
  111. +44 −0 vendor/plugins/activescaffold/frontends/default/views/_form_association.rhtml
  112. +42 −0 vendor/plugins/activescaffold/frontends/default/views/_form_association_footer.rhtml
  113. +10 −0 vendor/plugins/activescaffold/frontends/default/views/_form_association_header.rhtml
  114. +22 −0 vendor/plugins/activescaffold/frontends/default/views/_form_association_record.rhtml
  115. +12 −0 vendor/plugins/activescaffold/frontends/default/views/_form_attribute.rhtml
  116. +1 −0 vendor/plugins/activescaffold/frontends/default/views/_form_hidden_attribute.rhtml
  117. +5 −0 vendor/plugins/activescaffold/frontends/default/views/_form_messages.rhtml
  118. +34 −0 vendor/plugins/activescaffold/frontends/default/views/_list.rhtml
  119. +13 −0 vendor/plugins/activescaffold/frontends/default/views/_list_actions.rhtml
  120. +22 −0 vendor/plugins/activescaffold/frontends/default/views/_list_calculations.rhtml
  121. +32 −0 vendor/plugins/activescaffold/frontends/default/views/_list_column_headings.rhtml
  122. +12 −0 vendor/plugins/activescaffold/frontends/default/views/_list_header.rhtml
  123. +9 −0 vendor/plugins/activescaffold/frontends/default/views/_list_inline_adapter.rhtml
  124. +30 −0 vendor/plugins/activescaffold/frontends/default/views/_list_pagination_links.rhtml
  125. +31 −0 vendor/plugins/activescaffold/frontends/default/views/_list_record.rhtml
  126. +25 −0 vendor/plugins/activescaffold/frontends/default/views/_live_search.rhtml
  127. +10 −0 vendor/plugins/activescaffold/frontends/default/views/_messages.rhtml
  128. +44 −0 vendor/plugins/activescaffold/frontends/default/views/_nested.rhtml
  129. +21 −0 vendor/plugins/activescaffold/frontends/default/views/_search.rhtml
  130. +8 −0 vendor/plugins/activescaffold/frontends/default/views/_show.rhtml
  131. +11 −0 vendor/plugins/activescaffold/frontends/default/views/_show_columns.rhtml
  132. +49 −0 vendor/plugins/activescaffold/frontends/default/views/_update_form.rhtml
  133. +16 −0 vendor/plugins/activescaffold/frontends/default/views/add_existing.rjs
  134. +5 −0 vendor/plugins/activescaffold/frontends/default/views/add_existing_form.rhtml
  135. +19 −0 vendor/plugins/activescaffold/frontends/default/views/create.rjs
  136. +5 −0 vendor/plugins/activescaffold/frontends/default/views/create_form.rhtml
  137. +13 −0 vendor/plugins/activescaffold/frontends/default/views/delete.rhtml
  138. +9 −0 vendor/plugins/activescaffold/frontends/default/views/destroy.rjs
  139. +15 −0 vendor/plugins/activescaffold/frontends/default/views/edit_associated.rjs
  140. +5 −0 vendor/plugins/activescaffold/frontends/default/views/field_search.rhtml
  141. +1 −0 vendor/plugins/activescaffold/frontends/default/views/form_messages.rjs
  142. +25 −0 vendor/plugins/activescaffold/frontends/default/views/list.rhtml
  143. +5 −0 vendor/plugins/activescaffold/frontends/default/views/search.rhtml
  144. +5 −0 vendor/plugins/activescaffold/frontends/default/views/show.rhtml
  145. +10 −0 vendor/plugins/activescaffold/frontends/default/views/update.rjs
  146. +12 −0 vendor/plugins/activescaffold/frontends/default/views/update_column.rjs
  147. +5 −0 vendor/plugins/activescaffold/frontends/default/views/update_form.rhtml
  148. +16 −0 vendor/plugins/activescaffold/init.rb
  149. +40 −0 vendor/plugins/activescaffold/install.rb
  150. +36 −0 vendor/plugins/activescaffold/install_assets.rb
  151. +87 −0 vendor/plugins/activescaffold/lib/actions/core.rb
  152. +98 −0 vendor/plugins/activescaffold/lib/actions/create.rb
  153. +46 −0 vendor/plugins/activescaffold/lib/actions/delete.rb
  154. +51 −0 vendor/plugins/activescaffold/lib/actions/field_search.rb
  155. +75 −0 vendor/plugins/activescaffold/lib/actions/list.rb
  156. +44 −0 vendor/plugins/activescaffold/lib/actions/live_search.rb
  157. +211 −0 vendor/plugins/activescaffold/lib/actions/nested.rb
  158. +38 −0 vendor/plugins/activescaffold/lib/actions/search.rb
  159. +34 −0 vendor/plugins/activescaffold/lib/actions/show.rb
  160. +17 −0 vendor/plugins/activescaffold/lib/actions/subform.rb
  161. +112 −0 vendor/plugins/activescaffold/lib/actions/update.rb
  162. +127 −0 vendor/plugins/activescaffold/lib/active_record_permissions.rb
  163. +141 −0 vendor/plugins/activescaffold/lib/active_scaffold.rb
  164. +184 −0 vendor/plugins/activescaffold/lib/attribute_params.rb
  165. +52 −0 vendor/plugins/activescaffold/lib/bridges/bridge.rb
  166. +11 −0 vendor/plugins/activescaffold/lib/bridges/calendar_date_select/bridge.rb
  167. +53 −0 vendor/plugins/activescaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb
  168. +12 −0 vendor/plugins/activescaffold/lib/bridges/file_column/bridge.rb
  169. +48 −0 vendor/plugins/activescaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb
  170. +51 −0 vendor/plugins/activescaffold/lib/bridges/file_column/lib/file_column_helpers.rb
  171. +32 −0 vendor/plugins/activescaffold/lib/bridges/file_column/lib/form_ui.rb
  172. +26 −0 vendor/plugins/activescaffold/lib/bridges/file_column/lib/list_ui.rb
  173. +43 −0 vendor/plugins/activescaffold/lib/bridges/file_column/test/functional/file_column_keep_test.rb
  174. +9 −0 vendor/plugins/activescaffold/lib/bridges/file_column/test/mock_model.rb
  175. +15 −0 vendor/plugins/activescaffold/lib/bridges/file_column/test/test_helper.rb
  176. +37 −0 vendor/plugins/activescaffold/lib/config/base.rb
  177. +202 −0 vendor/plugins/activescaffold/lib/config/core.rb
  178. +34 −0 vendor/plugins/activescaffold/lib/config/create.rb
  179. +25 −0 vendor/plugins/activescaffold/lib/config/delete.rb
  180. +53 −0 vendor/plugins/activescaffold/lib/config/field_search.rb
  181. +49 −0 vendor/plugins/activescaffold/lib/config/form.rb
  182. +100 −0 vendor/plugins/activescaffold/lib/config/list.rb
  183. +52 −0 vendor/plugins/activescaffold/lib/config/live_search.rb
  184. +30 −0 vendor/plugins/activescaffold/lib/config/nested.rb
  185. +52 −0 vendor/plugins/activescaffold/lib/config/search.rb
  186. +39 −0 vendor/plugins/activescaffold/lib/config/show.rb
  187. +33 −0 vendor/plugins/activescaffold/lib/config/subform.rb
  188. +24 −0 vendor/plugins/activescaffold/lib/config/update.rb
  189. +29 −0 vendor/plugins/activescaffold/lib/configurable.rb
  190. +174 −0 vendor/plugins/activescaffold/lib/constraints.rb
  191. +92 −0 vendor/plugins/activescaffold/lib/data_structures/action_columns.rb
  192. +133 −0 vendor/plugins/activescaffold/lib/data_structures/action_link.rb
  193. +49 −0 vendor/plugins/activescaffold/lib/data_structures/action_links.rb
  194. +45 −0 vendor/plugins/activescaffold/lib/data_structures/actions.rb
  195. +247 −0 vendor/plugins/activescaffold/lib/data_structures/column.rb
  196. +62 −0 vendor/plugins/activescaffold/lib/data_structures/columns.rb
  197. +24 −0 vendor/plugins/activescaffold/lib/data_structures/error_message.rb
  198. +61 −0 vendor/plugins/activescaffold/lib/data_structures/set.rb
  199. +91 −0 vendor/plugins/activescaffold/lib/data_structures/sorting.rb
  200. +54 −0 vendor/plugins/activescaffold/lib/dhtml_confirm.rb
  201. +7 −0 vendor/plugins/activescaffold/lib/exceptions.rb
  202. +33 −0 vendor/plugins/activescaffold/lib/extensions/action_controller_rendering.rb
  203. +94 −0 vendor/plugins/activescaffold/lib/extensions/action_view_rendering.rb
  204. +7 −0 vendor/plugins/activescaffold/lib/extensions/array.rb
  205. +17 −0 vendor/plugins/activescaffold/lib/extensions/component_response_with_namespacing.rb
  206. +65 −0 vendor/plugins/activescaffold/lib/extensions/error_messages.rb
  207. +62 −0 vendor/plugins/activescaffold/lib/extensions/generic_view_paths.rb
  208. +61 −0 vendor/plugins/activescaffold/lib/extensions/hashes_in_url_for.rb
  209. +28 −0 vendor/plugins/activescaffold/lib/extensions/json_mime_type.rb
  210. +5 −0 vendor/plugins/activescaffold/lib/extensions/localize.rb
  211. +33 −0 vendor/plugins/activescaffold/lib/extensions/name_option_for_datetime.rb
  212. +7 −0 vendor/plugins/activescaffold/lib/extensions/nil_id_in_url_params.rb
  213. +26 −0 vendor/plugins/activescaffold/lib/extensions/resources.rb
  214. +56 −0 vendor/plugins/activescaffold/lib/extensions/reverse_associations.rb
  215. +9 −0 vendor/plugins/activescaffold/lib/extensions/to_label.rb
  216. +61 −0 vendor/plugins/activescaffold/lib/extensions/unsaved_associated.rb
  217. +20 −0 vendor/plugins/activescaffold/lib/extensions/unsaved_record.rb
  218. +149 −0 vendor/plugins/activescaffold/lib/finder.rb
  219. +40 −0 vendor/plugins/activescaffold/lib/helpers/association_helpers.rb
  220. +7 −0 vendor/plugins/activescaffold/lib/helpers/controller_helpers.rb
  221. +251 −0 vendor/plugins/activescaffold/lib/helpers/form_column_helpers.rb
  222. +119 −0 vendor/plugins/activescaffold/lib/helpers/id_helpers.rb
  223. +187 −0 vendor/plugins/activescaffold/lib/helpers/list_column_helpers.rb
  224. +37 −0 vendor/plugins/activescaffold/lib/helpers/pagination_helpers.rb
  225. +46 −0 vendor/plugins/activescaffold/lib/helpers/usa_state.rb
  226. +205 −0 vendor/plugins/activescaffold/lib/helpers/view_helpers.rb
  227. +136 −0 vendor/plugins/activescaffold/lib/paginator.rb
  228. +68 −0 vendor/plugins/activescaffold/lib/responds_to_parent.rb
  229. +33 −0 vendor/plugins/activescaffold/public/blank.html
  230. +47 −0 vendor/plugins/activescaffold/test/bridges/bridge_test.rb
  231. +17 −0 vendor/plugins/activescaffold/test/config/update_test.rb
  232. +36 −0 vendor/plugins/activescaffold/test/const_mocker.rb
  233. +119 −0 vendor/plugins/activescaffold/test/data_structures/action_columns_test.rb
  234. +78 −0 vendor/plugins/activescaffold/test/data_structures/action_link_test.rb
  235. +63 −0 vendor/plugins/activescaffold/test/data_structures/action_links_test.rb
  236. +25 −0 vendor/plugins/activescaffold/test/data_structures/actions_test.rb
  237. +41 −0 vendor/plugins/activescaffold/test/data_structures/association_column_test.rb
  238. +161 −0 vendor/plugins/activescaffold/test/data_structures/column_test.rb
  239. +69 −0 vendor/plugins/activescaffold/test/data_structures/columns_test.rb
  240. +28 −0 vendor/plugins/activescaffold/test/data_structures/error_message_test.rb
  241. +86 −0 vendor/plugins/activescaffold/test/data_structures/set_test.rb
  242. +96 −0 vendor/plugins/activescaffold/test/data_structures/sorting_test.rb
  243. +34 −0 vendor/plugins/activescaffold/test/data_structures/standard_column_test.rb
  244. +34 −0 vendor/plugins/activescaffold/test/data_structures/virtual_column_test.rb
  245. +45 −0 vendor/plugins/activescaffold/test/extensions/active_record_test.rb
  246. +12 −0 vendor/plugins/activescaffold/test/extensions/array.rb
  247. +154 −0 vendor/plugins/activescaffold/test/misc/active_record_permissions.rb
  248. +96 −0 vendor/plugins/activescaffold/test/misc/configurable_test.rb
  249. +175 −0 vendor/plugins/activescaffold/test/misc/constraints_test.rb
  250. +70 −0 vendor/plugins/activescaffold/test/misc/finder_test.rb
  251. +12 −0 vendor/plugins/activescaffold/test/misc/lang_test.rb
  252. +39 −0 vendor/plugins/activescaffold/test/model_stub.rb
  253. +8 −0 vendor/plugins/activescaffold/test/run_all.rb
  254. +13 −0 vendor/plugins/activescaffold/test/test_helper.rb
  255. +12 −0 vendor/plugins/activescaffold/uninstall.rb
4 .gitignore
@@ -0,0 +1,4 @@
+log/*.log
+tmp/*/*
+db/*.sqlite3
+sqlnet.log
41 README.txt
@@ -0,0 +1,41 @@
+== DESCRIPTION:
+
+This sample app demonstrates how to use Ruby on Rails with legacy Oracle database schemas using oracle_enhanced adapter
+and composite_primary_keys gem.
+
+This application requires Oracle XE database with default sample HR schema. Ensure that you have defines XE alias
+in your tnsnames.ora file or change database.yml to point to correct connection.
+
+If you use Rails 2.1.1 then you need to use oracle_enhanced adapter version 1.1.8 or later which fixes bug in Rails 2.1.1
+when used together with composite_primary_keys gem. Or other option is to change version of Rails to 2.1.0 in
+environment.rb file.
+
+== MORE INFORMATION:
+
+This demo was created by Raimonds Simanovskis for Oracle OpenWorld 2008 unconference session.
+Please visit http://blog.rayapps.com for more information about using Ruby on Rails and Oracle.
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2008 Raimonds Simanovskis
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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'
15 app/controllers/application.rb
@@ -0,0 +1,15 @@
+# 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 => '8b6e31af96643f0e8f7795f39c76dc4b'
+
+ # See ActionController::Base for details
+ # Uncomment this to filter the contents of submitted sensitive data parameters
+ # from your application log (in this case, all fields with names like "password").
+ # filter_parameter_logging :password
+end
5 app/controllers/departments_controller.rb
@@ -0,0 +1,5 @@
+class DepartmentsController < ApplicationController
+
+ active_scaffold :department
+
+end
14 app/controllers/employees_controller.rb
@@ -0,0 +1,14 @@
+class EmployeesController < ApplicationController
+
+ active_scaffold :employee do |config|
+ config.list.columns = [:first_name, :last_name, :job, :job_history, :manager, :department, :manager_of]
+
+ config.columns[:job].form_ui = :select
+ config.columns[:department].form_ui = :select
+ config.columns[:manager].form_ui = :select
+
+ config.update.columns.remove :manager_of, :subordinates, :job_history
+
+ end
+
+end
10 app/controllers/job_history_controller.rb
@@ -0,0 +1,10 @@
+class JobHistoryController < ApplicationController
+
+ active_scaffold :job_history do |config|
+ config.columns = [:job, :start_date, :end_date]
+
+ config.list.sorting = {:start_date => 'ASC'}
+
+ end
+
+end
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
2 app/helpers/departments_helper.rb
@@ -0,0 +1,2 @@
+module DepartmentsHelper
+end
2 app/helpers/employees_helper.rb
@@ -0,0 +1,2 @@
+module EmployeesHelper
+end
2 app/helpers/job_history_helper.rb
@@ -0,0 +1,2 @@
+module JobHistoryHelper
+end
11 app/models/department.rb
@@ -0,0 +1,11 @@
+class Department < ActiveRecord::Base
+ set_primary_key :department_id
+
+ belongs_to :manager, :class_name => "Employee", :foreign_key => "manager_id"
+ has_many :employees
+
+ def name
+ department_name
+ end
+
+end
19 app/models/employee.rb
@@ -0,0 +1,19 @@
+class Employee < ActiveRecord::Base
+ set_primary_key :employee_id
+
+ set_date_columns :hire_date
+
+ belongs_to :manager, :class_name => "Employee", :foreign_key => "manager_id"
+ has_many :subordinates, :class_name => "Employee", :foreign_key => "manager_id"
+ belongs_to :department
+ has_one :manager_of, :class_name => "Department", :foreign_key => "manager_id"
+
+ belongs_to :job
+
+ has_many :job_history
+
+ def name
+ "#{first_name} #{last_name}"
+ end
+
+end
10 app/models/job.rb
@@ -0,0 +1,10 @@
+class Job < ActiveRecord::Base
+ set_primary_key :job_id
+
+ has_many :employees
+
+ def name
+ job_title
+ end
+
+end
13 app/models/job_history.rb
@@ -0,0 +1,13 @@
+class JobHistory < ActiveRecord::Base
+ set_table_name "job_history"
+ set_primary_keys :employee_id, :start_date
+
+ set_date_columns :start_date, :end_date
+
+ belongs_to :employee
+ belongs_to :job
+
+ def name
+ job.name
+ end
+end
11 app/views/layouts/application.html.erb
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>HR demo</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <%= javascript_include_tag :defaults %>
+ <%= active_scaffold_includes %>
+</head>
+<body>
+ <%= yield %>
+</body>
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!
21 config/database.yml
@@ -0,0 +1,21 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: oracle_enhanced
+ database: xe
+ username: hr
+ password: hr
+ encoding: utf8
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ timeout: 5000
68 config/environment.rb
@@ -0,0 +1,68 @@
+# Be sure to restart your server when you modify this file
+
+# Uncomment below to force Rails into production mode when
+# you don't control web/app server and can't set it the proper way
+# ENV['RAILS_ENV'] ||= 'production'
+
+# 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"
+ config.gem "composite_primary_keys"
+
+ # 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 additional load paths for your own custom dirs
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
+
+ # 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. Comment line 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.
+ config.action_controller.session = {
+ :session_key => '_hr_session',
+ :secret => '837f4c2c37ba98d4dec989381d2dcb3c1a282363acf8276312b2947dd68c3f625f2e75f54737303942b81ef4990a9aa42877282624a402a9dfd7262bbed52996'
+ }
+
+ # 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
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
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
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 Action Mailer 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
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):
+# ActiveSupport::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
17 config/initializers/new_rails_defaults.rb
@@ -0,0 +1,17 @@
+# These settings change the behavior of Rails 2 apps and will be defaults
+# for Rails 3. You can remove this initializer when Rails 3 is released.
+
+if defined?(ActiveRecord)
+ # Include Active Record class name as root for JSON serialized output.
+ ActiveRecord::Base.include_root_in_json = true
+
+ # Store the full class name (including module namespace) in STI type column.
+ ActiveRecord::Base.store_full_sti_class = true
+end
+
+# Use ISO 8601 format for JSON serialized times and dates.
+ActiveSupport.use_standard_json_time_format = true
+
+# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
+# if you're including raw json in an HTML page.
+ActiveSupport.escape_html_entities_in_json = false
47 config/routes.rb
@@ -0,0 +1,47 @@
+ActionController::Routing::Routes.draw do |map|
+ # The priority is based upon order of creation: first created -> highest priority.
+
+ # Sample of regular route:
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # 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
+
+ map.resources :employees, :active_scaffold => true
+ map.resources :departments, :active_scaffold => true
+ map.resources :job_history, :active_scaffold => true
+
+ # Sample resource route with more complex sub-resources
+ # map.resources :products do |products|
+ # products.resources :comments
+ # products.resources :sales, :collection => { :recent => :get }
+ # end
+
+ # 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"
+
+ # Install the default routes as the lowest priority.
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
+ # consider removing the them or commenting them out if you're using named routes and resources.
+ # map.connect ':controller/:action/:id'
+ # map.connect ':controller/:action/:id.:format'
+end
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.
0 log/.gitignore
No changes.
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 (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>
33 public/blank.html
@@ -0,0 +1,33 @@
+<!--
+ Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
+ http://codinginparadise.org
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-->
+
+<html>
+ <script language="JavaScript">
+ function pageLoaded() {
+ window.parent.dhtmlHistory.iframeLoaded(window.location);
+ }
+ </script>
+ <body onload="pageLoaded()">
+ <h1>blank.html - Needed for Internet Explorer's hidden IFrame</h1>
+ </body>
+</html>
10 public/dispatch.cgi
@@ -0,0 +1,10 @@
+#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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
24 public/dispatch.fcgi
@@ -0,0 +1,24 @@
+#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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!
10 public/dispatch.rb
@@ -0,0 +1,10 @@
+#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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.
2 public/images/active_scaffold/DO_NOT_EDIT
@@ -0,0 +1,2 @@
+Any changes made to files in sub-folders will be lost.
+See http://activescaffold.com/tutorials/faq#custom-css.
BIN public/images/active_scaffold/default/add.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/arrow_down.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/arrow_up.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/close.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/cross.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/indicator-small.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/indicator.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN public/images/active_scaffold/default/magnifier.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
274 public/index.html
@@ -0,0 +1,274 @@
+<!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://wiki.rubyonrails.org/">Wiki</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>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>
+
+ <li>
+ <h2>Create your database</h2>
+ <p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
+ </li>
+ </ol>
+ </div>
+ </div>
+
+ <div id="footer">&nbsp;</div>
+ </div>
+ </body>
+</html>
2 public/javascripts/active_scaffold/DO_NOT_EDIT
@@ -0,0 +1,2 @@
+Any changes made to files in sub-folders will be lost.
+See http://activescaffold.com/tutorials/faq#custom-css.
418 public/javascripts/active_scaffold/default/active_scaffold.js
@@ -0,0 +1,418 @@
+if (typeof Prototype == 'undefined')
+{
+ warning = "ActiveScaffold Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (e.g. <%= javascript_include_tag :defaults %>) *before* it includes active_scaffold.js (e.g. <%= active_scaffold_includes %>).";
+ alert(warning);
+}
+if (Prototype.Version.substring(0, 3) != '1.6')
+{
+ warning = "ActiveScaffold Error: Prototype version 1.6.x is required. Please update prototype.js (rake rails:update:javascripts).";
+ alert(warning);
+}
+
+/*
+ * Simple utility methods
+ */
+
+var ActiveScaffold = {
+ records_for: function(tbody_id) {
+ var rows = [];
+ var child = $(tbody_id).down('.record');
+ while (child) {
+ rows.push(child);
+ child = child.next('.record');
+ }
+ return rows;
+ },
+ stripe: function(tbody_id) {
+ var even = false;
+ var rows = this.records_for(tbody_id);
+ for (var i = 0; i < rows.length; i++) {
+ var child = rows[i];
+ //Make sure to skip rows that are create or edit rows or messages
+ if (child.tagName != 'SCRIPT'
+ && !child.hasClassName("create")
+ && !child.hasClassName("update")
+ && !child.hasClassName("inline-adapter")
+ && !child.hasClassName("active-scaffold-calculations")) {
+
+ if (even) child.addClassName("even-record");
+ else child.removeClassName("even-record");
+
+ even = !even;
+ }
+ }
+ },
+ hide_empty_message: function(tbody, empty_message_id) {
+ if (this.records_for(tbody).length != 0) {
+ $(empty_message_id).hide();
+ }
+ },
+ reload_if_empty: function(tbody, url) {
+ var content_container_id = tbody.replace('tbody', 'content');
+ if (this.records_for(tbody).length == 0) {
+ new Ajax.Updater($(content_container_id), url, {
+ method: 'get',
+ asynchronous: true,
+ evalScripts: true
+ });
+ }
+ },
+ removeSortClasses: function(scaffold_id) {
+ $$('#' + scaffold_id + ' td.sorted').each(function(element) {
+ element.removeClassName("sorted");
+ });
+ $$('#' + scaffold_id + ' th.sorted').each(function(element) {
+ element.removeClassName("sorted");
+ element.removeClassName("asc");
+ element.removeClassName("desc");
+ });
+ },
+ decrement_record_count: function(scaffold_id) {
+ count = $$('#' + scaffold_id + ' span.active-scaffold-records').first();
+ count.innerHTML = parseInt(count.innerHTML) - 1;
+ },
+ increment_record_count: function(scaffold_id) {
+ count = $$('#' + scaffold_id + ' span.active-scaffold-records').first();
+ count.innerHTML = parseInt(count.innerHTML) + 1;
+ },
+
+ server_error_response: '',
+ report_500_response: function(active_scaffold_id) {
+ messages_container = $(active_scaffold_id).down('td.messages-container');
+ new Insertion.Top(messages_container, this.server_error_response);
+ }
+}
+
+/*
+ * DHTML history tie-in
+ */
+function addActiveScaffoldPageToHistory(url, active_scaffold_id) {
+ if (typeof dhtmlHistory == 'undefined') return; // it may not be loaded
+
+ var array = url.split('?');
+ var qs = new Querystring(array[1]);
+ var sort = qs.get('sort')
+ var dir = qs.get('sort_direction')
+ var page = qs.get('page')
+ if (sort || dir || page) dhtmlHistory.add(active_scaffold_id+":"+page+":"+sort+":"+dir, url);
+}
+
+/*
+ * Add-ons/Patches to Prototype
+ */
+
+/* patch to support replacing TR/TD/TBODY in Internet Explorer, courtesy of http://dev.rubyonrails.org/ticket/4273 */
+Element.replace = function(element, html) {
+ element = $(element);
+ if (element.outerHTML) {
+ try {
+ element.outerHTML = html.stripScripts();
+ } catch (e) {
+ var tn = element.tagName;
+ if(tn=='TBODY' || tn=='TR' || tn=='TD')
+ {
+ var tempDiv = document.createElement("div");
+ tempDiv.innerHTML = '<table id="tempTable" style="display: none">' + html.stripScripts() + '</table>';
+ element.parentNode.replaceChild(tempDiv.getElementsByTagName(tn).item(0), element);
+ }
+ else throw e;
+ }
+ } else {
+ var range = element.ownerDocument.createRange();
+ /* patch to fix <form> replaces in Firefox. see http://dev.rubyonrails.org/ticket/8010 */
+ range.selectNodeContents(element.parentNode);
+ element.parentNode.replaceChild(range.createContextualFragment(html.stripScripts()), element);
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+};
+
+/*
+ * URL modification support. Incomplete functionality.
+ */
+Object.extend(String.prototype, {
+ append_params: function(params) {
+ url = this;
+ if (url.indexOf('?') == -1) url += '?';
+ else if (url.lastIndexOf('&') != url.length) url += '&';
+
+ url += $H(params).collect(function(item) {
+ return item.key + '=' + item.value;
+ }).join('&');
+
+ return url;
+ }
+});
+
+/*
+ * Prototype's implementation was throwing an error instead of false
+ */
+Element.Methods.Simulated = {
+ hasAttribute: function(element, attribute) {
+ var t = Element._attributeTranslations;
+ attribute = (t.names && t.names[attribute]) || attribute;
+ // Return false if we get an error here
+ try {
+ return $(element).getAttributeNode(attribute).specified;
+ } catch (e) {
+ return false;
+ }
+ }
+};
+
+/**
+ * A set of links. As a set, they can be controlled such that only one is "open" at a time, etc.
+ */
+ActiveScaffold.Actions = new Object();
+ActiveScaffold.Actions.Abstract = function(){}
+ActiveScaffold.Actions.Abstract.prototype = {
+ initialize: function(links, target, loading_indicator, options) {
+ this.target = $(target);
+ this.loading_indicator = $(loading_indicator);
+ this.options = options;
+ this.links = links.collect(function(link) {
+ return this.instantiate_link(link);
+ }.bind(this));
+ },
+
+ instantiate_link: function(link) {
+ throw 'unimplemented'
+ }
+}
+
+/**
+ * A DataStructures::ActionLink, represented in JavaScript.
+ * Concerned with AJAX-enabling a link and adapting the result for insertion into the table.
+ */
+ActiveScaffold.ActionLink = new Object();
+ActiveScaffold.ActionLink.Abstract = function(){}
+ActiveScaffold.ActionLink.Abstract.prototype = {
+ initialize: function(a, target, loading_indicator) {
+ this.tag = $(a);
+ this.url = this.tag.href;
+ this.target = target;
+ this.loading_indicator = loading_indicator;
+ this.hide_target = false;
+ this.position = this.tag.getAttribute('position');
+ this.page_link = this.tag.getAttribute('page_link');
+
+ this.onclick = this.tag.onclick;
+ this.tag.onclick = null;
+ this.tag.observe('click', function(event) {
+ this.open();
+ Event.stop(event);
+ }.bind(this));
+
+ this.tag.action_link = this;
+ },
+
+ open: function() {
+ if (this.is_disabled()) return;
+
+ if (this.tag.hasAttribute( "dhtml_confirm")) {
+ if (this.onclick) this.onclick();
+ return;
+ } else {
+ if (this.onclick && !this.onclick()) return;//e.g. confirmation messages
+ this.open_action();
+ }
+ },
+
+ open_action: function() {
+ if (this.position) this.disable();
+
+ if (this.page_link) {
+ window.location = this.url;
+ } else {
+ if (this.loading_indicator) this.loading_indicator.style.visibility = 'visible';
+ new Ajax.Request(this.url, {
+ asynchronous: true,
+ evalScripts: true,
+
+ onSuccess: function(request) {
+ if (this.position) {
+ this.insert(request.responseText);
+ if (this.hide_target) this.target.hide();
+ } else {
+ request.evalResponse();
+ }
+ }.bind(this),
+
+ onFailure: function(request) {
+ ActiveScaffold.report_500_response(this.scaffold_id());
+ if (this.position) this.enable()
+ }.bind(this),
+
+ onComplete: function(request) {
+ if (this.loading_indicator) this.loading_indicator.style.visibility = 'hidden';
+ }.bind(this)
+ });
+ }
+ },
+
+ insert: function(content) {
+ throw 'unimplemented'
+ },
+
+ close: function() {
+ this.enable();
+ this.adapter.remove();
+ if (this.hide_target) this.target.show();
+ },
+
+ register_cancel_hooks: function() {
+ // anything in the insert with a class of cancel gets the closer method, and a reference to this object for good measure
+ var self = this;
+ this.adapter.select('.cancel').each(function(elem) {
+ elem.observe('click', this.close_handler.bind(this));
+ elem.link = self;
+ }.bind(this))
+ },
+
+ reload: function() {
+ this.close();
+ this.open();
+ },
+
+ get_new_adapter_id: function() {
+ var id = 'adapter_';
+ var i = 0;
+ while ($(id + i)) i++;
+ return id + i;
+ },
+
+ enable: function() {
+ return this.tag.removeClassName('disabled');
+ },
+
+ disable: function() {
+ return this.tag.addClassName('disabled');
+ },
+
+ is_disabled: function() {
+ return this.tag.hasClassName('disabled');
+ },
+
+ scaffold_id: function() {
+ return this.tag.up('div.active-scaffold').id;
+ }
+}
+
+/**
+ * Concrete classes for record actions
+ */
+ActiveScaffold.Actions.Record = Class.create();
+ActiveScaffold.Actions.Record.prototype = Object.extend(new ActiveScaffold.Actions.Abstract(), {
+ instantiate_link: function(link) {
+ var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
+ l.refresh_url = this.options.refresh_url;
+ if (l.position) l.url = l.url.append_params({adapter: '_list_inline_adapter'});
+ l.set = this;
+ return l;
+ }
+});
+
+ActiveScaffold.ActionLink.Record = Class.create();
+ActiveScaffold.ActionLink.Record.prototype = Object.extend(new ActiveScaffold.ActionLink.Abstract(), {
+ insert: function(content) {
+ this.set.links.each(function(item) {
+ if (item.url != this.url && item.is_disabled() && item.adapter) item.close();
+ }.bind(this));
+
+ if (this.position == 'replace') {
+ this.position = 'after';
+ this.hide_target = true;
+ }
+
+ if (this.position == 'after') {
+ new Insertion.After(this.target, content);
+ this.adapter = this.target.next();
+ }
+ else if (this.position == 'before') {
+ new Insertion.Before(this.target, content);
+ this.adapter = this.target.previous();
+ }
+ else {
+ return false;
+ }
+
+ this.adapter.down('a.inline-adapter-close').observe('click', this.close_handler.bind(this));
+ this.register_cancel_hooks();
+
+ new Effect.Highlight(this.adapter.down('td'));
+ },
+
+ close_handler: function(event) {
+ this.close_with_refresh();
+ if (event) Event.stop(event);
+ },
+
+ /* it might simplify things to just override the close function. then the Record and Table links could share more code ... wouldn't need custom close_handler functions, for instance */
+ close_with_refresh: function() {
+ new Ajax.Request(this.refresh_url, {
+ asynchronous: true,
+ evalScripts: true,
+
+ onSuccess: function(request) {
+ Element.replace(this.target, request.responseText);
+ var new_target = $(this.target.id);
+ if (this.target.hasClassName('even-record')) new_target.addClassName('even-record');
+ this.target = new_target;
+ this.close();
+ }.bind(this),
+
+ onFailure: function(request) {
+ ActiveScaffold.report_500_response(this.scaffold_id());
+ }
+ });
+ },
+
+ enable: function() {
+ this.set.links.each(function(item) {
+ if (item.url != this.url) return;
+ item.tag.removeClassName('disabled');
+ }.bind(this));
+ },
+
+ disable: function() {
+ this.set.links.each(function(item) {
+ if (item.url != this.url) return;
+ item.tag.addClassName('disabled');
+ }.bind(this));
+ }
+});
+
+/**
+ * Concrete classes for table actions
+ */
+ActiveScaffold.Actions.Table = Class.create();
+ActiveScaffold.Actions.Table.prototype = Object.extend(new ActiveScaffold.Actions.Abstract(), {
+ instantiate_link: function(link) {
+ var l = new ActiveScaffold.ActionLink.Table(link, this.target, this.loading_indicator);
+ if (l.position) l.url = l.url.append_params({adapter: '_list_inline_adapter'});
+ return l;
+ }
+});
+
+ActiveScaffold.ActionLink.Table = Class.create();
+ActiveScaffold.ActionLink.Table.prototype = Object.extend(new ActiveScaffold.ActionLink.Abstract(), {
+ insert: function(content) {
+ if (this.position == 'top') {
+ new Insertion.Top(this.target, content);
+ this.adapter = this.target.immediateDescendants().first();
+ }
+ else {
+ throw 'Unknown position "' + this.position + '"'
+ }
+
+ this.adapter.down('a.inline-adapter-close').observe('click', this.close_handler.bind(this));
+ this.register_cancel_hooks();
+
+ new Effect.Highlight(this.adapter.down('td'));
+ },
+
+ close_handler: function(event) {
+ this.close();
+ if (event) Event.stop(event);
+ }
+});
942 public/javascripts/active_scaffold/default/dhtml_history.js
@@ -0,0 +1,942 @@
+/**
+ Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
+ http://codinginparadise.org
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ The JSON class near the end of this file is
+ Copyright 2005, JSON.org
+*/
+
+/** An object that provides DHTML history, history data, and bookmarking
+ for AJAX applications. */
+window.dhtmlHistory = {
+ /** Initializes our DHTML history. You should
+ call this after the page is finished loading. */
+ /** public */ initialize: function() {
+ // only Internet Explorer needs to be explicitly initialized;
+ // other browsers don't have its particular behaviors.
+ // Basicly, IE doesn't autofill form data until the page
+ // is finished loading, which means historyStorage won't
+ // work until onload has been fired.
+ if (this.isInternetExplorer() == false) {
+ return;
+ }
+
+ // if this is the first time this page has loaded...
+ if (historyStorage.hasKey("DhtmlHistory_pageLoaded") == false) {
+ this.fireOnNewListener = false;
+ this.firstLoad = true;
+ historyStorage.put("DhtmlHistory_pageLoaded", true);
+ }
+ // else if this is a fake onload event
+ else {
+ this.fireOnNewListener = true;
+ this.firstLoad = false;
+ }
+ },
+
+ /** Adds a history change listener. Note that
+ only one listener is supported at this
+ time. */
+ /** public */ addListener: function(callback) {
+ this.listener = callback;
+
+ // if the page was just loaded and we
+ // should not ignore it, fire an event
+ // to our new listener now
+ if (this.fireOnNewListener == true) {
+ this.fireHistoryEvent(this.currentLocation);
+ this.fireOnNewListener = false;
+ }
+ },
+
+ /** public */ add: function(newLocation, historyData) {
+ // most browsers require that we wait a certain amount of time before changing the
+ // location, such as 200 milliseconds; rather than forcing external callers to use
+ // window.setTimeout to account for this to prevent bugs, we internally handle this
+ // detail by using a 'currentWaitTime' variable and have requests wait in line
+ var self = this;
+ var addImpl = function() {
+ // indicate that the current wait time is now less
+ if (self.currentWaitTime > 0)
+ self.currentWaitTime = self.currentWaitTime - self.WAIT_TIME;
+
+ // remove any leading hash symbols on newLocation
+ newLocation = self.removeHash(newLocation);
+
+ // IE has a strange bug; if the newLocation
+ // is the same as _any_ preexisting id in the
+ // document, then the history action gets recorded
+ // twice; throw a programmer exception if there is
+ // an element with this ID
+ var idCheck = $(newLocation);
+ if (idCheck != undefined || idCheck != null) {
+ var message =
+ "Exception: History locations can not have "
+ + "the same value as _any_ id's "
+ + "that might be in the document, "
+ + "due to a bug in Internet "
+ + "Explorer; please ask the "
+ + "developer to choose a history "
+ + "location that does not match "
+ + "any HTML id's in this "
+ + "document. The following ID "
+ + "is already taken and can not "
+ + "be a location: "
+ + newLocation;
+
+ throw message;
+ }
+
+ // store the history data into history storage
+ historyStorage.put(newLocation, historyData);
+
+ // indicate to the browser to ignore this upcomming
+ // location change
+ self.ignoreLocationChange = true;
+
+ // indicate to IE that this is an atomic location change
+ // block
+ this.ieAtomicLocationChange = true;
+
+ // save this as our current location
+ self.currentLocation = newLocation;
+
+ // change the browser location
+ window.location.hash = newLocation;
+
+ // change the hidden iframe's location if on IE
+ if (self.isInternetExplorer())
+ self.iframe.src = "/blank.html?" + newLocation;
+
+ // end of atomic location change block
+ // for IE
+ this.ieAtomicLocationChange = false;
+ };
+
+ // now execute this add request after waiting a certain amount of time, so as to
+ // queue up requests
+ window.setTimeout(addImpl, this.currentWaitTime);
+
+ // indicate that the next request will have to wait for awhile
+ this.currentWaitTime = this.currentWaitTime + this.WAIT_TIME;
+ },
+
+ /** public */ isFirstLoad: function() {
+ if (this.firstLoad == true) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ },
+
+ /** public */ isInternational: function() {
+ return false;
+ },
+
+ /** public */ getVersion: function() {
+ return "0.05";
+ },
+
+ /** Gets the current hash value that is in the browser's
+ location bar, removing leading # symbols if they are present. */
+ /** public */ getCurrentLocation: function() {
+ var currentLocation = escape(this.removeHash(window.location.hash));
+
+ return currentLocation;
+ },
+
+
+
+
+
+ /** Our current hash location, without the "#" symbol. */
+ /** private */ currentLocation: null,
+
+ /** Our history change listener. */
+ /** private */ listener: null,
+
+ /** A hidden IFrame we use in Internet Explorer to detect history
+ changes. */
+ /** private */ iframe: null,
+
+ /** Indicates to the browser whether to ignore location changes. */
+ /** private */ ignoreLocationChange: null,
+
+ /** The amount of time in milliseconds that we should wait between add requests.
+ Firefox is okay with 200 ms, but Internet Explorer needs 400. */
+ /** private */ WAIT_TIME: 200,
+
+ /** The amount of time in milliseconds an add request has to wait in line before being
+ run on a window.setTimeout. */
+ /** private */ currentWaitTime: 0,
+
+ /** A flag that indicates that we should fire a history change event
+ when we are ready, i.e. after we are initialized and
+ we have a history change listener. This is needed due to
+ an edge case in browsers other than Internet Explorer; if
+ you leave a page entirely then return, we must fire this
+ as a history change event. Unfortunately, we have lost
+ all references to listeners from earlier, because JavaScript
+ clears out. */
+ /** private */ fireOnNewListener: null,
+
+ /** A variable that indicates whether this is the first time
+ this page has been loaded. If you go to a web page, leave
+ it for another one, and then return, the page's onload
+ listener fires again. We need a way to differentiate
+ between the first page load and subsequent ones.
+ This variable works hand in hand with the pageLoaded
+ variable we store into historyStorage.*/
+ /** private */ firstLoad: null,
+
+ /** A variable to handle an important edge case in Internet
+ Explorer. In IE, if a user manually types an address into
+ their browser's location bar, we must intercept this by
+ continiously checking the location bar with an timer
+ interval. However, if we manually change the location
+ bar ourselves programmatically, when using our hidden
+ iframe, we need to ignore these changes. Unfortunately,
+ these changes are not atomic, so we surround them with
+ the variable 'ieAtomicLocationChange', that if true,
+ means we are programmatically setting the location and
+ should ignore this atomic chunked change. */
+ /** private */ ieAtomicLocationChange: null,
+
+ /** Creates the DHTML history infrastructure. */