typus 1.0.0.pre8 → 1.0.0.pre9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/CHANGELOG +4 -6
  2. data/Gemfile +16 -13
  3. data/Gemfile.lock +26 -2
  4. data/Rakefile +2 -3
  5. data/app/controllers/admin/base_controller.rb +3 -5
  6. data/app/controllers/admin/resources_controller.rb +24 -26
  7. data/app/helpers/admin/base_helper.rb +14 -22
  8. data/app/helpers/admin/dashboard_helper.rb +2 -5
  9. data/app/helpers/admin/filters_helper.rb +6 -8
  10. data/app/helpers/admin/form_helper.rb +3 -9
  11. data/app/helpers/admin/preview_helper.rb +4 -6
  12. data/app/helpers/admin/relationships_helper.rb +9 -11
  13. data/app/helpers/admin/resources_helper.rb +6 -24
  14. data/app/helpers/admin/search_helper.rb +1 -1
  15. data/app/helpers/admin/sidebar_helper.rb +12 -15
  16. data/app/helpers/admin/table_helper.rb +13 -13
  17. data/app/views/admin/dashboard/show.html.erb +1 -1
  18. data/app/views/admin/helpers/_apps.html.erb +4 -3
  19. data/app/views/admin/helpers/_header.html.erb +2 -2
  20. data/app/views/admin/helpers/dashboard/_applications.html.erb +3 -3
  21. data/app/views/admin/helpers/dashboard/_resources.html.erb +17 -13
  22. data/app/views/admin/helpers/filters/_filters.html.erb +9 -27
  23. data/app/views/admin/helpers/resources/_pagination.html.erb +8 -9
  24. data/app/views/admin/helpers/search/_search.html.erb +1 -1
  25. data/app/views/admin/mailer/reset_password_link.text.erb +3 -0
  26. data/app/views/admin/resources/_form.html.erb +4 -4
  27. data/app/views/admin/resources/edit.html.erb +2 -3
  28. data/app/views/admin/resources/index.html.erb +15 -13
  29. data/app/views/admin/resources/new.html.erb +2 -2
  30. data/app/views/admin/resources/show.html.erb +1 -2
  31. data/app/views/admin/templates/_boolean.html.erb +1 -1
  32. data/app/views/admin/templates/_has_many.html.erb +2 -4
  33. data/app/views/admin/templates/_has_n.html.erb +1 -1
  34. data/app/views/admin/templates/_selector.html.erb +0 -1
  35. data/app/views/admin/templates/_string.html.erb +1 -1
  36. data/app/views/layouts/admin/session.html.erb +1 -1
  37. data/config/available_locales/ca.yml +3 -5
  38. data/config/available_locales/de.yml +2 -4
  39. data/config/available_locales/es.yml +2 -4
  40. data/config/available_locales/fr.yml +40 -39
  41. data/config/available_locales/fr_models.yml +2 -2
  42. data/config/available_locales/hu.yml +3 -5
  43. data/config/available_locales/it.yml +0 -4
  44. data/config/available_locales/language.yml.template +2 -4
  45. data/config/available_locales/pt-BR.yml +2 -4
  46. data/config/available_locales/ru.yml +2 -4
  47. data/config/routes.rb +1 -0
  48. data/lib/generators/templates/config/initializers/typus.rb +5 -5
  49. data/lib/generators/templates/config/initializers/typus_authentication.rb +5 -5
  50. data/lib/generators/templates/config/initializers/typus_resources.rb +7 -7
  51. data/lib/generators/templates/config/typus/README +11 -13
  52. data/lib/generators/templates/controller.rb +0 -2
  53. data/lib/generators/templates/functional_test.rb +4 -15
  54. data/lib/generators/typus/migration_generator.rb +0 -1
  55. data/lib/support/active_record.rb +18 -9
  56. data/lib/support/fake_user.rb +42 -0
  57. data/lib/support/object.rb +1 -0
  58. data/lib/support/string.rb +0 -32
  59. data/lib/tasks/typus.rake +0 -8
  60. data/lib/typus.rb +34 -18
  61. data/lib/typus/authentication/base.rb +26 -0
  62. data/lib/typus/authentication/http_basic.rb +22 -0
  63. data/lib/typus/authentication/none.rb +19 -0
  64. data/lib/typus/authentication/session.rb +190 -0
  65. data/lib/typus/format.rb +12 -19
  66. data/lib/typus/orm/active_record.rb +13 -51
  67. data/lib/typus/resources.rb +0 -9
  68. data/lib/typus/version.rb +1 -1
  69. data/test/factories.rb +43 -0
  70. data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -1
  71. data/test/fixtures/rails_app/app/models/page.rb +0 -4
  72. data/test/fixtures/rails_app/config/application.rb +6 -3
  73. data/test/fixtures/rails_app/config/database.yml +12 -20
  74. data/test/fixtures/rails_app/config/typus/application.yml +4 -8
  75. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  76. data/test/fixtures/rails_app/log/test.log +227115 -0
  77. data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +2 -0
  78. data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +2 -0
  79. data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +2 -0
  80. data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +2 -0
  81. data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +2 -0
  82. data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +2 -0
  83. data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +2 -0
  84. data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +2 -0
  85. data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +2 -0
  86. data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +2 -0
  87. data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +2 -0
  88. data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +2 -0
  89. data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +2 -0
  90. data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +2 -0
  91. data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +2 -0
  92. data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +2 -0
  93. data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +2 -0
  94. data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +2 -0
  95. data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +2 -0
  96. data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +2 -0
  97. data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +2 -0
  98. data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +2 -0
  99. data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +2 -0
  100. data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +2 -0
  101. data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +2 -0
  102. data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +2 -0
  103. data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +2 -0
  104. data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +2 -0
  105. data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +2 -0
  106. data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +2 -0
  107. data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +2 -0
  108. data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +2 -0
  109. data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +2 -0
  110. data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +2 -0
  111. data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +2 -0
  112. data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +2 -0
  113. data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +2 -0
  114. data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +2 -0
  115. data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +2 -0
  116. data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +2 -0
  117. data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +2 -0
  118. data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +2 -0
  119. data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +2 -0
  120. data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +2 -0
  121. data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +2 -0
  122. data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +2 -0
  123. data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +2 -0
  124. data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +2 -0
  125. data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +2 -0
  126. data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +2 -0
  127. data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +2 -0
  128. data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +2 -0
  129. data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +2 -0
  130. data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +2 -0
  131. data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +2 -0
  132. data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +2 -0
  133. data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +2 -0
  134. data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +2 -0
  135. data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +2 -0
  136. data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +2 -0
  137. data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +2 -0
  138. data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +2 -0
  139. data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +2 -0
  140. data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +2 -0
  141. data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +2 -0
  142. data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +2 -0
  143. data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +2 -0
  144. data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +2 -0
  145. data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +2 -0
  146. data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +2 -0
  147. data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +2 -0
  148. data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +2 -0
  149. data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +2 -0
  150. data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +2 -0
  151. data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +2 -0
  152. data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +2 -0
  153. data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +2 -0
  154. data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +2 -0
  155. data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +2 -0
  156. data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +2 -0
  157. data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +2 -0
  158. data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +2 -0
  159. data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +2 -0
  160. data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +2 -0
  161. data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +2 -0
  162. data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +2 -0
  163. data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +2 -0
  164. data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +2 -0
  165. data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +2 -0
  166. data/test/functional/admin/account_controller_test.rb +1 -1
  167. data/test/functional/admin/{resources_controller_assets_relationships.rb → assets_controller_test.rb} +12 -16
  168. data/test/functional/admin/categories_controller_test.rb +62 -0
  169. data/test/functional/admin/{resources_controller_comments_toggle_test.rb → comments_controller_test.rb} +0 -0
  170. data/test/functional/admin/dashboard_controller_test.rb +34 -2
  171. data/test/functional/admin/posts_controller_test.rb +548 -0
  172. data/test/functional/admin/session_controller_test.rb +2 -2
  173. data/test/functional/admin/{resources_controller_tableless_resource_test.rb → status_controller_test.rb} +0 -0
  174. data/test/functional/admin/{resources_controller_typus_users_test.rb → typus_users_controller_test.rb} +2 -2
  175. data/test/helpers/admin/base_helper_test.rb +35 -37
  176. data/test/helpers/admin/dashboard_helper_test.rb +4 -8
  177. data/test/helpers/admin/form_helper_test.rb +9 -34
  178. data/test/helpers/admin/resources_helper_test.rb +28 -16
  179. data/test/helpers/admin/sidebar_helper_test.rb +14 -27
  180. data/test/helpers/admin/table_helper_test.rb +24 -68
  181. data/test/integration/login_test.rb +13 -0
  182. data/test/integration_test_helper.rb +21 -0
  183. data/test/lib/support/active_record_test.rb +72 -21
  184. data/test/lib/support/array_test.rb +2 -6
  185. data/test/lib/support/string_test.rb +21 -30
  186. data/test/lib/typus/active_record_test.rb +162 -100
  187. data/test/lib/typus/resource_test.rb +2 -3
  188. data/test/lib/typus_test.rb +25 -22
  189. data/test/test_helper.rb +4 -17
  190. data/test/unit/admin/mailer_test.rb +2 -2
  191. data/test/unit/typus_user_roles_test.rb +23 -23
  192. data/test/unit/typus_user_test.rb +30 -24
  193. data/typus.gemspec +0 -1
  194. metadata +111 -60
  195. data/app/models/admin/fake_user.rb +0 -46
  196. data/lib/generators/templates/model.yml +0 -10
  197. data/lib/typus/authentication.rb +0 -241
  198. data/lib/vendor/paginator.rb +0 -143
  199. data/test/factories/assets.rb +0 -5
  200. data/test/factories/categories.rb +0 -3
  201. data/test/factories/comments.rb +0 -6
  202. data/test/factories/pages.rb +0 -5
  203. data/test/factories/pictures.rb +0 -7
  204. data/test/factories/posts.rb +0 -6
  205. data/test/factories/typus_users.rb +0 -8
  206. data/test/fixtures/rails_app/README +0 -244
  207. data/test/fixtures/rails_app/app/helpers/application_helper.rb +0 -2
  208. data/test/fixtures/rails_app/app/views/layouts/application.html.erb +0 -14
  209. data/test/fixtures/rails_app/config/environments/development.rb +0 -19
  210. data/test/fixtures/rails_app/config/environments/production.rb +0 -42
  211. data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +0 -258
  212. data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +0 -98
  213. data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  214. data/test/fixtures/rails_app/config/initializers/inflections.rb +0 -10
  215. data/test/fixtures/rails_app/config/initializers/mime_types.rb +0 -5
  216. data/test/fixtures/rails_app/config/locales/en.yml +0 -5
  217. data/test/fixtures/rails_app/db/seeds.rb +0 -7
  218. data/test/fixtures/rails_app/public/404.html +0 -26
  219. data/test/fixtures/rails_app/public/422.html +0 -26
  220. data/test/fixtures/rails_app/public/500.html +0 -26
  221. data/test/fixtures/rails_app/public/favicon.ico +0 -0
  222. data/test/fixtures/rails_app/public/images/rails.png +0 -0
  223. data/test/fixtures/rails_app/public/index.html +0 -279
  224. data/test/fixtures/rails_app/public/javascripts/application.js +0 -2
  225. data/test/fixtures/rails_app/public/javascripts/controls.js +0 -965
  226. data/test/fixtures/rails_app/public/javascripts/dragdrop.js +0 -974
  227. data/test/fixtures/rails_app/public/javascripts/effects.js +0 -1123
  228. data/test/fixtures/rails_app/public/javascripts/prototype.js +0 -4874
  229. data/test/fixtures/rails_app/public/javascripts/rails.js +0 -118
  230. data/test/fixtures/rails_app/public/robots.txt +0 -5
  231. data/test/fixtures/rails_app/script/rails +0 -9
  232. data/test/functional/admin/dashboard_controller_http_basic_test.rb +0 -24
  233. data/test/functional/admin/dashboard_controller_none_test.rb +0 -18
  234. data/test/functional/admin/resources_controller_categories_before_test.rb +0 -10
  235. data/test/functional/admin/resources_controller_categories_lists_test.rb +0 -44
  236. data/test/functional/admin/resources_controller_categories_views_test.rb +0 -10
  237. data/test/functional/admin/resources_controller_posts_before_test.rb +0 -10
  238. data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +0 -27
  239. data/test/functional/admin/resources_controller_posts_crud_test.rb +0 -44
  240. data/test/functional/admin/resources_controller_posts_formats_test.rb +0 -39
  241. data/test/functional/admin/resources_controller_posts_forms_test.rb +0 -58
  242. data/test/functional/admin/resources_controller_posts_permissions_test.rb +0 -100
  243. data/test/functional/admin/resources_controller_posts_relationships_test.rb +0 -91
  244. data/test/functional/admin/resources_controller_posts_roles.rb +0 -52
  245. data/test/functional/admin/resources_controller_posts_views_test.rb +0 -143
  246. data/test/lib/vendor/paginator_test.rb +0 -141
  247. data/typus-1.0.0.pre7.gem +0 -0
@@ -1,3 +0,0 @@
1
- Factory.define :category do |f|
2
- f.name "Category"
3
- end
@@ -1,6 +0,0 @@
1
- Factory.define :comment do |f|
2
- f.name "John"
3
- f.email "john@example.com"
4
- f.body "Body of the comment"
5
- f.association :post
6
- end
@@ -1,5 +0,0 @@
1
- Factory.define :page do |f|
2
- f.title "Title"
3
- f.body "Content"
4
- f.status "published"
5
- end
@@ -1,7 +0,0 @@
1
- Factory.define :picture do |f|
2
- f.title "Some picture"
3
- f.picture_file_name "dog.jpg"
4
- f.picture_content_type "image/jpeg"
5
- f.picture_file_size "175938"
6
- f.picture_updated_at 3.days.ago.to_s(:db)
7
- end
@@ -1,6 +0,0 @@
1
- Factory.define :post do |f|
2
- f.title "Post"
3
- f.body "Body"
4
- f.status "published"
5
- # f.association :typus_user
6
- end
@@ -1,8 +0,0 @@
1
- Factory.define :typus_user do |f|
2
- f.email "admin@example.com"
3
- f.role "admin"
4
- f.status true
5
- f.token "1A2B3C4D5E6F"
6
- f.password "12345678"
7
- f.preferences Hash.new({ :locale => :en })
8
- end
@@ -1,244 +0,0 @@
1
- == Welcome to Rails
2
-
3
- Rails is a web-application framework that includes everything needed to create
4
- database-backed web applications according to the Model-View-Control pattern.
5
-
6
- This pattern splits the view (also called the presentation) into "dumb" templates
7
- that are primarily responsible for inserting pre-built data in between HTML tags.
8
- The model contains the "smart" domain objects (such as Account, Product, Person,
9
- Post) that holds all the business logic and knows how to persist themselves to
10
- a database. The controller handles the incoming requests (such as Save New Account,
11
- Update Product, Show Post) by manipulating the model and directing data to the view.
12
-
13
- In Rails, the model is handled by what's called an object-relational mapping
14
- layer entitled Active Record. This layer allows you to present the data from
15
- database rows as objects and embellish these data objects with business logic
16
- methods. You can read more about Active Record in
17
- link:files/vendor/rails/activerecord/README.html.
18
-
19
- The controller and view are handled by the Action Pack, which handles both
20
- layers by its two parts: Action View and Action Controller. These two layers
21
- are bundled in a single package due to their heavy interdependence. This is
22
- unlike the relationship between the Active Record and Action Pack that is much
23
- more separate. Each of these packages can be used independently outside of
24
- Rails. You can read more about Action Pack in
25
- link:files/vendor/rails/actionpack/README.html.
26
-
27
-
28
- == Getting Started
29
-
30
- 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
- and your application name. Ex: rails myapp
32
- 2. Change directory into myapp and start the web server: <tt>rails server</tt> (run with --help for options)
33
- 3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
34
- 4. Follow the guidelines to start developing your application
35
-
36
-
37
- == Web Servers
38
-
39
- By default, Rails will try to use Mongrel if it's installed when started with <tt>rails server</tt>, otherwise
40
- Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
41
- with a variety of other web servers.
42
-
43
- Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
44
- suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
45
- getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
46
- More info at: http://mongrel.rubyforge.org
47
-
48
- Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
49
- Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
50
- FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
51
-
52
- == Apache .htaccess example for FCGI/CGI
53
-
54
- # General Apache options
55
- AddHandler fastcgi-script .fcgi
56
- AddHandler cgi-script .cgi
57
- Options +FollowSymLinks +ExecCGI
58
-
59
- # If you don't want Rails to look in certain directories,
60
- # use the following rewrite rules so that Apache won't rewrite certain requests
61
- #
62
- # Example:
63
- # RewriteCond %{REQUEST_URI} ^/notrails.*
64
- # RewriteRule .* - [L]
65
-
66
- # Redirect all requests not available on the filesystem to Rails
67
- # By default the cgi dispatcher is used which is very slow
68
- #
69
- # For better performance replace the dispatcher with the fastcgi one
70
- #
71
- # Example:
72
- # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
73
- RewriteEngine On
74
-
75
- # If your Rails application is accessed via an Alias directive,
76
- # then you MUST also set the RewriteBase in this htaccess file.
77
- #
78
- # Example:
79
- # Alias /myrailsapp /path/to/myrailsapp/public
80
- # RewriteBase /myrailsapp
81
-
82
- RewriteRule ^$ index.html [QSA]
83
- RewriteRule ^([^.]+)$ $1.html [QSA]
84
- RewriteCond %{REQUEST_FILENAME} !-f
85
- RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
86
-
87
- # In case Rails experiences terminal errors
88
- # Instead of displaying this message you can supply a file here which will be rendered instead
89
- #
90
- # Example:
91
- # ErrorDocument 500 /500.html
92
-
93
- ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
94
-
95
-
96
- == Debugging Rails
97
-
98
- Sometimes your application goes wrong. Fortunately there are a lot of tools that
99
- will help you debug it and get it back on the rails.
100
-
101
- First area to check is the application log files. Have "tail -f" commands running
102
- on the server.log and development.log. Rails will automatically display debugging
103
- and runtime information to these files. Debugging info will also be shown in the
104
- browser on requests from 127.0.0.1.
105
-
106
- You can also log your own messages directly into the log file from your code using
107
- the Ruby logger class from inside your controllers. Example:
108
-
109
- class WeblogController < ActionController::Base
110
- def destroy
111
- @weblog = Weblog.find(params[:id])
112
- @weblog.destroy
113
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
114
- end
115
- end
116
-
117
- The result will be a message in your log file along the lines of:
118
-
119
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
120
-
121
- More information on how to use the logger is at http://www.ruby-doc.org/core/
122
-
123
- Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
124
-
125
- * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
126
- * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
127
-
128
- These two online (and free) books will bring you up to speed on the Ruby language
129
- and also on programming in general.
130
-
131
-
132
- == Debugger
133
-
134
- Debugger support is available through the debugger command when you start your Mongrel or
135
- Webrick server with --debugger. This means that you can break out of execution at any point
136
- in the code, investigate and change the model, AND then resume execution!
137
- You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
138
- Example:
139
-
140
- class WeblogController < ActionController::Base
141
- def index
142
- @posts = Post.find(:all)
143
- debugger
144
- end
145
- end
146
-
147
- So the controller will accept the action, run the first line, then present you
148
- with a IRB prompt in the server window. Here you can do things like:
149
-
150
- >> @posts.inspect
151
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
152
- #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
153
- >> @posts.first.title = "hello from a debugger"
154
- => "hello from a debugger"
155
-
156
- ...and even better is that you can examine how your runtime objects actually work:
157
-
158
- >> f = @posts.first
159
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
160
- >> f.
161
- Display all 152 possibilities? (y or n)
162
-
163
- Finally, when you're ready to resume execution, you enter "cont"
164
-
165
-
166
- == Console
167
-
168
- You can interact with the domain model by starting the console through <tt>rails console</tt>.
169
- Here you'll have all parts of the application configured, just like it is when the
170
- application is running. You can inspect domain models, change values, and save to the
171
- database. Starting the script without arguments will launch it in the development environment.
172
- Passing an argument will specify a different environment, like <tt>rails console production</tt>.
173
-
174
- To reload your controllers and models after launching the console run <tt>reload!</tt>
175
-
176
- == dbconsole
177
-
178
- You can go to the command line of your database directly through <tt>rails dbconsole</tt>.
179
- You would be connected to the database with the credentials defined in database.yml.
180
- Starting the script without arguments will connect you to the development database. Passing an
181
- argument will connect you to a different database, like <tt>rails dbconsole production</tt>.
182
- Currently works for mysql, postgresql and sqlite.
183
-
184
- == Description of Contents
185
-
186
- app
187
- Holds all the code that's specific to this particular application.
188
-
189
- app/controllers
190
- Holds controllers that should be named like weblogs_controller.rb for
191
- automated URL mapping. All controllers should descend from ApplicationController
192
- which itself descends from ActionController::Base.
193
-
194
- app/models
195
- Holds models that should be named like post.rb.
196
- Most models will descend from ActiveRecord::Base.
197
-
198
- app/views
199
- Holds the template files for the view that should be named like
200
- weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
201
- syntax.
202
-
203
- app/views/layouts
204
- Holds the template files for layouts to be used with views. This models the common
205
- header/footer method of wrapping views. In your views, define a layout using the
206
- <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
207
- call <% yield %> to render the view using this layout.
208
-
209
- app/helpers
210
- Holds view helpers that should be named like weblogs_helper.rb. These are generated
211
- for you automatically when using rails generate for controllers. Helpers can be used to
212
- wrap functionality for your views into methods.
213
-
214
- config
215
- Configuration files for the Rails environment, the routing map, the database, and other dependencies.
216
-
217
- db
218
- Contains the database schema in schema.rb. db/migrate contains all
219
- the sequence of Migrations for your schema.
220
-
221
- doc
222
- This directory is where your application documentation will be stored when generated
223
- using <tt>rake doc:app</tt>
224
-
225
- lib
226
- Application specific libraries. Basically, any kind of custom code that doesn't
227
- belong under controllers, models, or helpers. This directory is in the load path.
228
-
229
- public
230
- The directory available for the web server. Contains subdirectories for images, stylesheets,
231
- and javascripts. Also contains the dispatchers and the default HTML files. This should be
232
- set as the DOCUMENT_ROOT of your web server.
233
-
234
- script
235
- Helper scripts for automation and generation.
236
-
237
- test
238
- Unit and functional tests along with fixtures. When using the rails generate command, template
239
- test files will be generated for you and placed in this directory.
240
-
241
- vendor
242
- External libraries that the application depends on. Also includes the plugins subdirectory.
243
- If the app has frozen rails, those gems also go here, under vendor/rails/.
244
- This directory is in the load path.
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>RailsApp</title>
5
- <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
7
- <%= csrf_meta_tag %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,19 +0,0 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/environment.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the webserver when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
- config.action_controller.perform_caching = false
16
-
17
- # Don't care if the mailer can't send
18
- config.action_mailer.raise_delivery_errors = false
19
- end
@@ -1,42 +0,0 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/environment.rb
3
-
4
- # The production environment is meant for finished, "live" apps.
5
- # Code is not reloaded between requests
6
- config.cache_classes = true
7
-
8
- # Full error reports are disabled and caching is turned on
9
- config.consider_all_requests_local = false
10
- config.action_controller.perform_caching = true
11
-
12
- # Specifies the header that your server uses for sending files
13
- config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
-
15
- # For nginx:
16
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
-
18
- # If you have no front-end server that supports something like X-Sendfile,
19
- # just comment this out and Rails will serve the files
20
-
21
- # See everything in the log (default is :info)
22
- # config.log_level = :debug
23
-
24
- # Use a different logger for distributed setups
25
- # config.logger = SyslogLogger.new
26
-
27
- # Use a different cache store in production
28
- # config.cache_store = :mem_cache_store
29
-
30
- # Disable Rails's static asset server
31
- # In production, Apache or nginx will already do this
32
- config.serve_static_assets = false
33
-
34
- # Enable serving of images, stylesheets, and javascripts from an asset server
35
- # config.action_controller.asset_host = "http://assets.example.com"
36
-
37
- # Disable delivery errors, bad email addresses will be ignored
38
- # config.action_mailer.raise_delivery_errors = false
39
-
40
- # Enable threaded mode
41
- # config.threadsafe!
42
- end
@@ -1,258 +0,0 @@
1
- module ActiveRecord
2
- module Acts #:nodoc:
3
- module List #:nodoc:
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
- end
7
-
8
- # This +acts_as+ extension provides the capabilities for sorting and reordering a number of objects in a list.
9
- # The class that has this specified needs to have a +position+ column defined as an integer on
10
- # the mapped database table.
11
- #
12
- # Todo list example:
13
- #
14
- # class TodoList < ActiveRecord::Base
15
- # has_many :todo_items, :order => "position"
16
- # end
17
- #
18
- # class TodoItem < ActiveRecord::Base
19
- # belongs_to :todo_list
20
- # acts_as_list :scope => :todo_list
21
- # end
22
- #
23
- # todo_list.first.move_to_bottom
24
- # todo_list.last.move_higher
25
- module ClassMethods
26
- # Configuration options are:
27
- #
28
- # * +column+ - specifies the column name to use for keeping the position integer (default: +position+)
29
- # * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach <tt>_id</tt>
30
- # (if it hasn't already been added) and use that as the foreign key restriction. It's also possible
31
- # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key.
32
- # Example: <tt>acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'</tt>
33
- def acts_as_list(options = {})
34
- configuration = { :column => "position", :scope => "1 = 1" }
35
- configuration.update(options) if options.is_a?(Hash)
36
-
37
- configuration[:scope] = "#{configuration[:scope]}_id".intern if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/
38
-
39
- if configuration[:scope].is_a?(Symbol)
40
- scope_condition_method = %(
41
- def scope_condition
42
- if #{configuration[:scope].to_s}.nil?
43
- "#{configuration[:scope].to_s} IS NULL"
44
- else
45
- "#{configuration[:scope].to_s} = \#{#{configuration[:scope].to_s}}"
46
- end
47
- end
48
- )
49
- else
50
- scope_condition_method = "def scope_condition() \"#{configuration[:scope]}\" end"
51
- end
52
-
53
- class_eval <<-EOV
54
- include ActiveRecord::Acts::List::InstanceMethods
55
-
56
- def acts_as_list_class
57
- ::#{self.name}
58
- end
59
-
60
- def position_column
61
- '#{configuration[:column]}'
62
- end
63
-
64
- #{scope_condition_method}
65
-
66
- before_destroy :remove_from_list
67
- before_create :add_to_list_bottom
68
- EOV
69
- end
70
- end
71
-
72
- # All the methods available to a record that has had <tt>acts_as_list</tt> specified. Each method works
73
- # by assuming the object to be the item in the list, so <tt>chapter.move_lower</tt> would move that chapter
74
- # lower in the list of all chapters. Likewise, <tt>chapter.first?</tt> would return +true+ if that chapter is
75
- # the first in the list of all chapters.
76
- module InstanceMethods
77
- # Insert the item at the given position (defaults to the top position of 1).
78
- def insert_at(position = 1)
79
- insert_at_position(position)
80
- end
81
-
82
- # Swap positions with the next lower item, if one exists.
83
- def move_lower
84
- return unless lower_item
85
-
86
- acts_as_list_class.transaction do
87
- lower_item.decrement_position
88
- increment_position
89
- end
90
- end
91
-
92
- # Swap positions with the next higher item, if one exists.
93
- def move_higher
94
- return unless higher_item
95
-
96
- acts_as_list_class.transaction do
97
- higher_item.increment_position
98
- decrement_position
99
- end
100
- end
101
-
102
- # Move to the bottom of the list. If the item is already in the list, the items below it have their
103
- # position adjusted accordingly.
104
- def move_to_bottom
105
- return unless in_list?
106
- acts_as_list_class.transaction do
107
- decrement_positions_on_lower_items
108
- assume_bottom_position
109
- end
110
- end
111
-
112
- # Move to the top of the list. If the item is already in the list, the items above it have their
113
- # position adjusted accordingly.
114
- def move_to_top
115
- return unless in_list?
116
- acts_as_list_class.transaction do
117
- increment_positions_on_higher_items
118
- assume_top_position
119
- end
120
- end
121
-
122
- # Removes the item from the list.
123
- def remove_from_list
124
- if in_list?
125
- decrement_positions_on_lower_items
126
- update_attribute position_column, nil
127
- end
128
- end
129
-
130
- # Increase the position of this item without adjusting the rest of the list.
131
- def increment_position
132
- return unless in_list?
133
- update_attribute position_column, self.send(position_column).to_i + 1
134
- end
135
-
136
- # Decrease the position of this item without adjusting the rest of the list.
137
- def decrement_position
138
- return unless in_list?
139
- update_attribute position_column, self.send(position_column).to_i - 1
140
- end
141
-
142
- # Return +true+ if this object is the first in the list.
143
- def first?
144
- return false unless in_list?
145
- self.send(position_column) == 1
146
- end
147
-
148
- # Return +true+ if this object is the last in the list.
149
- def last?
150
- return false unless in_list?
151
- self.send(position_column) == bottom_position_in_list
152
- end
153
-
154
- # Return the next higher item in the list.
155
- def higher_item
156
- return nil unless in_list?
157
- acts_as_list_class.find(:first, :conditions =>
158
- "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
159
- )
160
- end
161
-
162
- # Return the next lower item in the list.
163
- def lower_item
164
- return nil unless in_list?
165
- acts_as_list_class.find(:first, :conditions =>
166
- "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
167
- )
168
- end
169
-
170
- # Test if this record is in a list
171
- def in_list?
172
- !send(position_column).nil?
173
- end
174
-
175
- private
176
- def add_to_list_top
177
- increment_positions_on_all_items
178
- end
179
-
180
- def add_to_list_bottom
181
- self[position_column] = bottom_position_in_list.to_i + 1
182
- end
183
-
184
- # Overwrite this method to define the scope of the list changes
185
- def scope_condition() "1" end
186
-
187
- # Returns the bottom position number in the list.
188
- # bottom_position_in_list # => 2
189
- def bottom_position_in_list(except = nil)
190
- item = bottom_item(except)
191
- item ? item.send(position_column) : 0
192
- end
193
-
194
- # Returns the bottom item
195
- def bottom_item(except = nil)
196
- conditions = scope_condition
197
- conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
198
- acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
199
- end
200
-
201
- # Forces item to assume the bottom position in the list.
202
- def assume_bottom_position
203
- update_attribute(position_column, bottom_position_in_list(self).to_i + 1)
204
- end
205
-
206
- # Forces item to assume the top position in the list.
207
- def assume_top_position
208
- update_attribute(position_column, 1)
209
- end
210
-
211
- # This has the effect of moving all the higher items up one.
212
- def decrement_positions_on_higher_items(position)
213
- acts_as_list_class.update_all(
214
- "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}"
215
- )
216
- end
217
-
218
- # This has the effect of moving all the lower items up one.
219
- def decrement_positions_on_lower_items
220
- return unless in_list?
221
- acts_as_list_class.update_all(
222
- "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"
223
- )
224
- end
225
-
226
- # This has the effect of moving all the higher items down one.
227
- def increment_positions_on_higher_items
228
- return unless in_list?
229
- acts_as_list_class.update_all(
230
- "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}"
231
- )
232
- end
233
-
234
- # This has the effect of moving all the lower items down one.
235
- def increment_positions_on_lower_items(position)
236
- acts_as_list_class.update_all(
237
- "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}"
238
- )
239
- end
240
-
241
- # Increments position (<tt>position_column</tt>) of all items in the list.
242
- def increment_positions_on_all_items
243
- acts_as_list_class.update_all(
244
- "#{position_column} = (#{position_column} + 1)", "#{scope_condition}"
245
- )
246
- end
247
-
248
- def insert_at_position(position)
249
- remove_from_list
250
- increment_positions_on_lower_items(position)
251
- self.update_attribute(position_column, position)
252
- end
253
- end
254
- end
255
- end
256
- end
257
-
258
- ActiveRecord::Base.class_eval { include ActiveRecord::Acts::List }