comfortable_mexican_sofa 0.0.18 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. data/.gitignore +8 -8
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +91 -0
  4. data/README.md +4 -0
  5. data/Rakefile +28 -57
  6. data/VERSION +1 -1
  7. data/app/controllers/application_controller.rb +5 -0
  8. data/app/controllers/cms_admin/base_controller.rb +1 -21
  9. data/app/controllers/cms_admin/layouts_controller.rb +23 -38
  10. data/app/controllers/cms_admin/pages_controller.rb +24 -40
  11. data/app/controllers/cms_admin/snippets_controller.rb +26 -34
  12. data/app/controllers/cms_admin/uploads_controller.rb +27 -0
  13. data/app/controllers/cms_content_controller.rb +22 -19
  14. data/app/models/cms_block.rb +20 -6
  15. data/app/models/cms_layout.rb +34 -80
  16. data/app/models/cms_page.rb +44 -102
  17. data/app/models/cms_snippet.rb +12 -7
  18. data/app/models/cms_upload.rb +36 -0
  19. data/app/views/cms_admin/layouts/_form.html.erb +6 -0
  20. data/app/views/cms_admin/layouts/_index_branch.html.erb +24 -0
  21. data/app/views/cms_admin/layouts/edit.html.erb +6 -0
  22. data/app/views/cms_admin/layouts/index.html.erb +6 -0
  23. data/app/views/cms_admin/layouts/new.html.erb +6 -0
  24. data/app/views/cms_admin/pages/_form.html.erb +14 -0
  25. data/app/views/cms_admin/pages/_form_blocks.html.erb +7 -0
  26. data/app/views/cms_admin/pages/_index_branch.html.erb +27 -0
  27. data/app/views/cms_admin/pages/edit.html.erb +6 -0
  28. data/app/views/cms_admin/pages/form_blocks.js.erb +1 -0
  29. data/app/views/cms_admin/pages/index.html.erb +6 -0
  30. data/app/views/cms_admin/pages/new.html.erb +6 -0
  31. data/app/views/cms_admin/snippets/_form.html.erb +2 -0
  32. data/app/views/cms_admin/snippets/edit.html.erb +6 -0
  33. data/app/views/cms_admin/snippets/index.html.erb +3 -0
  34. data/app/views/cms_admin/snippets/new.html.erb +6 -0
  35. data/app/views/cms_admin/uploads/_index.html.erb +8 -0
  36. data/app/views/cms_admin/uploads/_upload.html.erb +11 -0
  37. data/app/views/cms_admin/uploads/destroy.js.erb +3 -0
  38. data/app/views/cms_admin/uploads/index.html.erb +2 -0
  39. data/app/views/layouts/cms_admin.html.erb +36 -0
  40. data/comfortable_mexican_sofa.gemspec +141 -197
  41. data/config.ru +4 -0
  42. data/config/application.rb +44 -0
  43. data/config/boot.rb +13 -0
  44. data/{test/rails_root/config → config}/database.yml +0 -0
  45. data/config/environment.rb +5 -0
  46. data/config/environments/development.rb +22 -0
  47. data/config/environments/production.rb +49 -0
  48. data/config/environments/test.rb +35 -0
  49. data/{test/rails_root/config → config}/initializers/backtrace_silencers.rb +2 -2
  50. data/{test/rails_root/config → config}/initializers/inflections.rb +1 -1
  51. data/{test/rails_root/config → config}/initializers/mime_types.rb +0 -0
  52. data/config/initializers/paperclip.rb +3 -0
  53. data/config/initializers/secret_token.rb +7 -0
  54. data/config/initializers/session_store.rb +8 -0
  55. data/{test/rails_root/config → config}/locales/en.yml +1 -1
  56. data/config/routes.rb +20 -0
  57. data/db/migrate/01_create_cms.rb +73 -0
  58. data/db/seeds.rb +7 -0
  59. data/doc/README_FOR_APP +95 -0
  60. data/lib/comfortable_mexican_sofa.rb +34 -39
  61. data/lib/comfortable_mexican_sofa/cms_acts_as_tree.rb +42 -49
  62. data/lib/comfortable_mexican_sofa/cms_form_builder.rb +107 -0
  63. data/lib/comfortable_mexican_sofa/cms_rails_extensions.rb +25 -5
  64. data/lib/comfortable_mexican_sofa/cms_tag.rb +90 -85
  65. data/lib/comfortable_mexican_sofa/cms_tag/field_datetime.rb +26 -0
  66. data/lib/comfortable_mexican_sofa/cms_tag/field_integer.rb +26 -0
  67. data/lib/comfortable_mexican_sofa/cms_tag/field_string.rb +26 -0
  68. data/lib/comfortable_mexican_sofa/cms_tag/field_text.rb +26 -0
  69. data/lib/comfortable_mexican_sofa/cms_tag/page_datetime.rb +22 -0
  70. data/lib/comfortable_mexican_sofa/cms_tag/page_integer.rb +22 -0
  71. data/lib/comfortable_mexican_sofa/cms_tag/page_string.rb +22 -0
  72. data/lib/comfortable_mexican_sofa/cms_tag/page_text.rb +22 -0
  73. data/lib/comfortable_mexican_sofa/cms_tag/partial.rb +20 -0
  74. data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +18 -0
  75. data/{generators/cms/templates → lib/generators}/README +0 -20
  76. data/lib/generators/cms_generator.rb +28 -0
  77. data/public/404.html +26 -0
  78. data/public/422.html +26 -0
  79. data/public/500.html +26 -0
  80. data/{test/rails_root/public → public}/favicon.ico +0 -0
  81. data/public/images/comfortable_mexican_sofa/body_bg.jpg +0 -0
  82. data/{generators/cms/templates/images → public/images/comfortable_mexican_sofa}/icon_regular.gif +0 -0
  83. data/public/javascripts/comfortable_mexican_sofa/cms.js +53 -0
  84. data/public/javascripts/comfortable_mexican_sofa/jquery-ui.js +325 -0
  85. data/public/javascripts/comfortable_mexican_sofa/jquery.js +154 -0
  86. data/public/javascripts/comfortable_mexican_sofa/plupload/plupload.full.min.js +1 -0
  87. data/public/javascripts/comfortable_mexican_sofa/plupload/plupload.html4.min.js +1 -0
  88. data/public/javascripts/comfortable_mexican_sofa/plupload/plupload.html5.min.js +1 -0
  89. data/public/javascripts/comfortable_mexican_sofa/rails.js +132 -0
  90. data/public/javascripts/comfortable_mexican_sofa/uploader.js +47 -0
  91. data/{test/rails_root/public → public}/robots.txt +0 -0
  92. data/public/stylesheets/comfortable_mexican_sofa/jquery-ui.css +305 -0
  93. data/public/stylesheets/comfortable_mexican_sofa/reset.css +1 -0
  94. data/public/stylesheets/comfortable_mexican_sofa/structure.css +194 -0
  95. data/public/stylesheets/comfortable_mexican_sofa/typography.css +20 -0
  96. data/script/rails +6 -0
  97. data/test/fixtures/README.md +22 -0
  98. data/test/fixtures/cms_blocks.yml +10 -34
  99. data/test/fixtures/cms_layouts.yml +37 -33
  100. data/test/fixtures/cms_pages.yml +11 -32
  101. data/test/fixtures/cms_snippets.yml +2 -6
  102. data/test/fixtures/cms_uploads.yml +4 -0
  103. data/test/fixtures/files/invalid_file.gif +9 -0
  104. data/test/fixtures/files/valid_image.jpg +0 -0
  105. data/test/functional/cms_admin/base_controller_test.rb +9 -0
  106. data/test/functional/cms_admin/layouts_controller_test.rb +61 -46
  107. data/test/functional/cms_admin/pages_controller_test.rb +201 -102
  108. data/test/functional/cms_admin/snippets_controller_test.rb +46 -39
  109. data/test/functional/cms_admin/uploads_controller_test.rb +32 -0
  110. data/test/functional/cms_content_controller_test.rb +37 -32
  111. data/test/test_helper.rb +29 -9
  112. data/test/unit/cms_block_test.rb +60 -0
  113. data/test/unit/cms_layout_test.rb +48 -0
  114. data/test/unit/cms_page_test.rb +122 -0
  115. data/test/unit/cms_snippet_test.rb +23 -0
  116. data/test/unit/cms_tag_test.rb +149 -0
  117. data/test/unit/cms_tags/field_datetime_test.rb +36 -0
  118. data/test/unit/cms_tags/field_integer_test.rb +35 -0
  119. data/test/unit/cms_tags/field_string_test.rb +35 -0
  120. data/test/unit/cms_tags/field_text_test.rb +34 -0
  121. data/test/unit/cms_tags/page_datetime_test.rb +36 -0
  122. data/test/unit/cms_tags/page_integer_test.rb +35 -0
  123. data/test/unit/cms_tags/page_string_test.rb +35 -0
  124. data/test/unit/cms_tags/page_text_test.rb +36 -0
  125. data/test/unit/cms_tags/partial_test.rb +30 -0
  126. data/test/unit/cms_tags/snippet_test.rb +34 -0
  127. data/test/unit/cms_upload_test.rb +30 -0
  128. metadata +176 -215
  129. data/CHANGELOG.rdoc +0 -2
  130. data/LICENSE +0 -20
  131. data/README.rdoc +0 -55
  132. data/app/controllers/cms_admin/attachments_controller.rb +0 -55
  133. data/app/controllers/cms_admin/categories_controller.rb +0 -69
  134. data/app/controllers/cms_admin/sections_controller.rb +0 -17
  135. data/app/controllers/cms_common/render_page.rb +0 -47
  136. data/app/helpers/cms_helper.rb +0 -12
  137. data/app/models/cms_attachment.rb +0 -17
  138. data/app/models/cms_attachment_categorization.rb +0 -5
  139. data/app/models/cms_category.rb +0 -36
  140. data/app/models/cms_page_categorization.rb +0 -6
  141. data/app/views/cms_admin/attachments/_details.html.haml +0 -27
  142. data/app/views/cms_admin/attachments/_form.html.haml +0 -24
  143. data/app/views/cms_admin/attachments/edit.html.haml +0 -10
  144. data/app/views/cms_admin/attachments/index.html.haml +0 -36
  145. data/app/views/cms_admin/attachments/new.html.haml +0 -8
  146. data/app/views/cms_admin/categories/_category.html.haml +0 -21
  147. data/app/views/cms_admin/categories/_category_subform.html.haml +0 -12
  148. data/app/views/cms_admin/categories/_form.html.haml +0 -18
  149. data/app/views/cms_admin/categories/_new.html.haml +0 -7
  150. data/app/views/cms_admin/categories/_toggle_link.html.haml +0 -9
  151. data/app/views/cms_admin/categories/_tree_branch.html.haml +0 -36
  152. data/app/views/cms_admin/categories/children.js.rjs +0 -10
  153. data/app/views/cms_admin/categories/create.js.rjs +0 -9
  154. data/app/views/cms_admin/categories/edit.html.haml +0 -10
  155. data/app/views/cms_admin/categories/index.html.haml +0 -7
  156. data/app/views/cms_admin/categories/new.html.haml +0 -8
  157. data/app/views/cms_admin/categories/show.html.haml +0 -17
  158. data/app/views/cms_admin/layouts/_details.html.haml +0 -6
  159. data/app/views/cms_admin/layouts/_form.html.haml +0 -19
  160. data/app/views/cms_admin/layouts/_toggle_link.html.haml +0 -9
  161. data/app/views/cms_admin/layouts/_tree_branch.html.haml +0 -39
  162. data/app/views/cms_admin/layouts/children.js.rjs +0 -10
  163. data/app/views/cms_admin/layouts/edit.html.haml +0 -10
  164. data/app/views/cms_admin/layouts/index.html.haml +0 -7
  165. data/app/views/cms_admin/layouts/new.html.haml +0 -8
  166. data/app/views/cms_admin/pages/_details.html.haml +0 -25
  167. data/app/views/cms_admin/pages/_form.html.haml +0 -45
  168. data/app/views/cms_admin/pages/_form_blocks.html.haml +0 -48
  169. data/app/views/cms_admin/pages/_toggle_link.html.haml +0 -10
  170. data/app/views/cms_admin/pages/_tree_branch.html.haml +0 -41
  171. data/app/views/cms_admin/pages/children.js.rjs +0 -10
  172. data/app/views/cms_admin/pages/edit.html.haml +0 -11
  173. data/app/views/cms_admin/pages/form_blocks.js.rjs +0 -1
  174. data/app/views/cms_admin/pages/index.html.haml +0 -6
  175. data/app/views/cms_admin/pages/new.html.haml +0 -9
  176. data/app/views/cms_admin/sections/show.html.haml +0 -23
  177. data/app/views/cms_admin/snippets/_form.html.haml +0 -10
  178. data/app/views/cms_admin/snippets/edit.html.haml +0 -10
  179. data/app/views/cms_admin/snippets/index.html.haml +0 -26
  180. data/app/views/cms_admin/snippets/new.html.haml +0 -8
  181. data/app/views/cms_content/show.xml.rxml +0 -27
  182. data/app/views/cms_content/sitemap.xml.rxml +0 -16
  183. data/app/views/layouts/cms_admin.html.haml +0 -44
  184. data/config/cms_routes.rb +0 -25
  185. data/generators/cms/cms_generator.rb +0 -55
  186. data/generators/cms/templates/images/arrow_bottom.gif +0 -0
  187. data/generators/cms/templates/images/arrow_right.gif +0 -0
  188. data/generators/cms/templates/images/icon_attachment.gif +0 -0
  189. data/generators/cms/templates/images/icon_category.gif +0 -0
  190. data/generators/cms/templates/images/icon_draft.gif +0 -0
  191. data/generators/cms/templates/images/icon_layout.gif +0 -0
  192. data/generators/cms/templates/images/icon_move.gif +0 -0
  193. data/generators/cms/templates/images/icon_snippet.gif +0 -0
  194. data/generators/cms/templates/images/logo.png +0 -0
  195. data/generators/cms/templates/initializers/cms.rb +0 -14
  196. data/generators/cms/templates/initializers/paperclip.rb +0 -14
  197. data/generators/cms/templates/javascripts/codemirror_init.js +0 -16
  198. data/generators/cms/templates/javascripts/mce_init.js +0 -17
  199. data/generators/cms/templates/javascripts/utilities.js +0 -27
  200. data/generators/cms/templates/migrations/create_cms.rb +0 -113
  201. data/generators/cms/templates/stylesheets/cms_master.sass +0 -414
  202. data/init.rb +0 -1
  203. data/lib/comfortable_mexican_sofa/acts_as_categorized.rb +0 -87
  204. data/lib/comfortable_mexican_sofa/acts_as_published.rb +0 -60
  205. data/lib/comfortable_mexican_sofa/cms_tags/attachment.rb +0 -3
  206. data/lib/comfortable_mexican_sofa/cms_tags/block.rb +0 -117
  207. data/lib/comfortable_mexican_sofa/cms_tags/helper.rb +0 -3
  208. data/lib/comfortable_mexican_sofa/cms_tags/page_block.rb +0 -119
  209. data/lib/comfortable_mexican_sofa/cms_tags/partial.rb +0 -19
  210. data/lib/comfortable_mexican_sofa/cms_tags/snippet.rb +0 -19
  211. data/rails/init.rb +0 -1
  212. data/test/fixtures/cms_attachment_categorizations.yml +0 -7
  213. data/test/fixtures/cms_attachments.yml +0 -6
  214. data/test/fixtures/cms_categories.yml +0 -19
  215. data/test/fixtures/cms_page_categorizations.yml +0 -15
  216. data/test/fixtures/files/upload_file.txt +0 -1
  217. data/test/functional/cms_admin/attachments_controller_test.rb +0 -63
  218. data/test/functional/cms_admin/categories_controller_test.rb +0 -86
  219. data/test/functional/cms_admin/sections_controller_test.rb +0 -9
  220. data/test/models/cms_attachment_test.rb +0 -16
  221. data/test/models/cms_block_test.rb +0 -11
  222. data/test/models/cms_categorization_test.rb +0 -39
  223. data/test/models/cms_category_test.rb +0 -71
  224. data/test/models/cms_layout_test.rb +0 -44
  225. data/test/models/cms_page_test.rb +0 -55
  226. data/test/models/cms_snippet_test.rb +0 -16
  227. data/test/models/cms_tag_test.rb +0 -70
  228. data/test/rails_root/README +0 -243
  229. data/test/rails_root/Rakefile +0 -10
  230. data/test/rails_root/app/controllers/application_controller.rb +0 -10
  231. data/test/rails_root/app/helpers/application_helper.rb +0 -3
  232. data/test/rails_root/app/views/cms/under-development.html.haml +0 -1
  233. data/test/rails_root/app/views/complex_page/_example.html.erb +0 -1
  234. data/test/rails_root/config/boot.rb +0 -110
  235. data/test/rails_root/config/environment.rb +0 -48
  236. data/test/rails_root/config/environments/development.rb +0 -17
  237. data/test/rails_root/config/environments/production.rb +0 -28
  238. data/test/rails_root/config/environments/test.rb +0 -28
  239. data/test/rails_root/config/initializers/new_rails_defaults.rb +0 -19
  240. data/test/rails_root/config/initializers/session_store.rb +0 -15
  241. data/test/rails_root/config/routes.rb +0 -43
  242. data/test/rails_root/doc/README_FOR_APP +0 -2
  243. data/test/rails_root/public/404.html +0 -30
  244. data/test/rails_root/public/422.html +0 -30
  245. data/test/rails_root/public/500.html +0 -30
  246. data/test/rails_root/public/images/rails.png +0 -0
  247. data/test/rails_root/public/index.html +0 -275
  248. data/test/rails_root/public/javascripts/application.js +0 -2
  249. data/test/rails_root/public/javascripts/controls.js +0 -963
  250. data/test/rails_root/public/javascripts/dragdrop.js +0 -973
  251. data/test/rails_root/public/javascripts/effects.js +0 -1128
  252. data/test/rails_root/public/javascripts/prototype.js +0 -4320
  253. data/test/rails_root/public/stylesheets/sass/cms_master.sass +0 -414
  254. data/test/rails_root/script/about +0 -4
  255. data/test/rails_root/script/console +0 -3
  256. data/test/rails_root/script/dbconsole +0 -3
  257. data/test/rails_root/script/destroy +0 -3
  258. data/test/rails_root/script/generate +0 -3
  259. data/test/rails_root/script/performance/benchmarker +0 -3
  260. data/test/rails_root/script/performance/profiler +0 -3
  261. data/test/rails_root/script/plugin +0 -3
  262. data/test/rails_root/script/runner +0 -3
  263. data/test/rails_root/script/server +0 -3
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CmsSnippetTest < ActiveSupport::TestCase
4
-
5
- def test_fixtures_validity
6
- CmsSnippet.all.each do |snippet|
7
- assert snippet.valid?, snippet.errors.full_messages
8
- end
9
- end
10
-
11
- def test_get_content
12
- assert_equal cms_snippets(:complex).content, CmsSnippet.content_for('complex_snippet')
13
- assert_equal '', CmsSnippet.content_for('nonexistant_snippet')
14
- end
15
-
16
- end
@@ -1,70 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CmsTagTest < ActiveSupport::TestCase
4
-
5
- def test_tag_parsing
6
- layout = cms_layouts(:all_included_tags)
7
- tags = CmsTag::parse_tags(layout.content)
8
- assert_equal 4, tags.size
9
- end
10
-
11
- def test_block_tag
12
- layout = cms_layouts(:all_included_tags)
13
- tag = layout.tags.select{|t| t.tag_signature == 'cms_block:test_block:string'}.first
14
- assert tag
15
- assert_equal 'cms_block', tag.tag_type
16
- assert_equal 'test_block', tag.label
17
- assert_equal 'string', tag.format
18
-
19
- assert_equal 1, tag.class.render_priority
20
-
21
- # TODO: content pulling
22
- end
23
-
24
- def test_page_block_tag
25
- layout = cms_layouts(:all_included_tags)
26
- tag = layout.tags.select{|t| t.tag_signature == 'cms_page_block:test_page_block:string'}.first
27
- assert tag
28
- assert_equal 'cms_page_block', tag.tag_type
29
- assert_equal 'test_page_block', tag.label
30
- assert_equal 'string', tag.format
31
-
32
- assert_equal 1, tag.class.render_priority
33
-
34
- # TODO: content pulling
35
- end
36
-
37
- def test_snippet_tag
38
- layout = cms_layouts(:all_included_tags)
39
- tag = layout.tags.select{|t| t.tag_signature == 'cms_snippet:test_snippet'}.first
40
- assert tag
41
- assert_equal 'cms_snippet', tag.tag_type
42
- assert_equal 'test_snippet', tag.label
43
-
44
- assert_equal 2, tag.class.render_priority
45
-
46
- # TODO: content pulling
47
- end
48
-
49
- def test_partial_tag
50
- layout = cms_layouts(:all_included_tags)
51
- tag = layout.tags.select{|t| t.tag_signature == 'cms_partial:content/test_partial'}.first
52
- assert tag
53
- assert_equal 'cms_partial', tag.tag_type
54
- assert_equal 'content/test_partial', tag.label
55
-
56
- assert_equal 3, tag.class.render_priority
57
- assert_equal "<%= render :partial => 'content/test_partial' %>", tag.content
58
- end
59
-
60
- def test_tag_uniqueness
61
- layout = cms_layouts(:identical_tags)
62
- assert_equal 3, layout.tags.size
63
- tag_signatures = %w(cms_block:my_block_1:text cms_block:my_block_2:integer cms_block:my_block_3:boolean)
64
- layout.tags.each do |tag|
65
- assert tag_signatures.member?(tag.tag_signature)
66
- assert_equal tag.class, CmsTag::Block
67
- end
68
- end
69
-
70
- end
@@ -1,243 +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>script/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 are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
40
- with a variety of other web servers.
41
-
42
- Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
43
- suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
44
- getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
45
- More info at: http://mongrel.rubyforge.org
46
-
47
- Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
48
- Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
49
- FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
50
-
51
- == Apache .htaccess example for FCGI/CGI
52
-
53
- # General Apache options
54
- AddHandler fastcgi-script .fcgi
55
- AddHandler cgi-script .cgi
56
- Options +FollowSymLinks +ExecCGI
57
-
58
- # If you don't want Rails to look in certain directories,
59
- # use the following rewrite rules so that Apache won't rewrite certain requests
60
- #
61
- # Example:
62
- # RewriteCond %{REQUEST_URI} ^/notrails.*
63
- # RewriteRule .* - [L]
64
-
65
- # Redirect all requests not available on the filesystem to Rails
66
- # By default the cgi dispatcher is used which is very slow
67
- #
68
- # For better performance replace the dispatcher with the fastcgi one
69
- #
70
- # Example:
71
- # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
72
- RewriteEngine On
73
-
74
- # If your Rails application is accessed via an Alias directive,
75
- # then you MUST also set the RewriteBase in this htaccess file.
76
- #
77
- # Example:
78
- # Alias /myrailsapp /path/to/myrailsapp/public
79
- # RewriteBase /myrailsapp
80
-
81
- RewriteRule ^$ index.html [QSA]
82
- RewriteRule ^([^.]+)$ $1.html [QSA]
83
- RewriteCond %{REQUEST_FILENAME} !-f
84
- RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
85
-
86
- # In case Rails experiences terminal errors
87
- # Instead of displaying this message you can supply a file here which will be rendered instead
88
- #
89
- # Example:
90
- # ErrorDocument 500 /500.html
91
-
92
- ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
93
-
94
-
95
- == Debugging Rails
96
-
97
- Sometimes your application goes wrong. Fortunately there are a lot of tools that
98
- will help you debug it and get it back on the rails.
99
-
100
- First area to check is the application log files. Have "tail -f" commands running
101
- on the server.log and development.log. Rails will automatically display debugging
102
- and runtime information to these files. Debugging info will also be shown in the
103
- browser on requests from 127.0.0.1.
104
-
105
- You can also log your own messages directly into the log file from your code using
106
- the Ruby logger class from inside your controllers. Example:
107
-
108
- class WeblogController < ActionController::Base
109
- def destroy
110
- @weblog = Weblog.find(params[:id])
111
- @weblog.destroy
112
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
113
- end
114
- end
115
-
116
- The result will be a message in your log file along the lines of:
117
-
118
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
119
-
120
- More information on how to use the logger is at http://www.ruby-doc.org/core/
121
-
122
- Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
123
-
124
- * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
125
- * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
126
-
127
- These two online (and free) books will bring you up to speed on the Ruby language
128
- and also on programming in general.
129
-
130
-
131
- == Debugger
132
-
133
- Debugger support is available through the debugger command when you start your Mongrel or
134
- Webrick server with --debugger. This means that you can break out of execution at any point
135
- in the code, investigate and change the model, AND then resume execution!
136
- You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
137
- Example:
138
-
139
- class WeblogController < ActionController::Base
140
- def index
141
- @posts = Post.find(:all)
142
- debugger
143
- end
144
- end
145
-
146
- So the controller will accept the action, run the first line, then present you
147
- with a IRB prompt in the server window. Here you can do things like:
148
-
149
- >> @posts.inspect
150
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
151
- #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
152
- >> @posts.first.title = "hello from a debugger"
153
- => "hello from a debugger"
154
-
155
- ...and even better is that you can examine how your runtime objects actually work:
156
-
157
- >> f = @posts.first
158
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
159
- >> f.
160
- Display all 152 possibilities? (y or n)
161
-
162
- Finally, when you're ready to resume execution, you enter "cont"
163
-
164
-
165
- == Console
166
-
167
- You can interact with the domain model by starting the console through <tt>script/console</tt>.
168
- Here you'll have all parts of the application configured, just like it is when the
169
- application is running. You can inspect domain models, change values, and save to the
170
- database. Starting the script without arguments will launch it in the development environment.
171
- Passing an argument will specify a different environment, like <tt>script/console production</tt>.
172
-
173
- To reload your controllers and models after launching the console run <tt>reload!</tt>
174
-
175
- == dbconsole
176
-
177
- You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
178
- You would be connected to the database with the credentials defined in database.yml.
179
- Starting the script without arguments will connect you to the development database. Passing an
180
- argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
181
- Currently works for mysql, postgresql and sqlite.
182
-
183
- == Description of Contents
184
-
185
- app
186
- Holds all the code that's specific to this particular application.
187
-
188
- app/controllers
189
- Holds controllers that should be named like weblogs_controller.rb for
190
- automated URL mapping. All controllers should descend from ApplicationController
191
- which itself descends from ActionController::Base.
192
-
193
- app/models
194
- Holds models that should be named like post.rb.
195
- Most models will descend from ActiveRecord::Base.
196
-
197
- app/views
198
- Holds the template files for the view that should be named like
199
- weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
200
- syntax.
201
-
202
- app/views/layouts
203
- Holds the template files for layouts to be used with views. This models the common
204
- header/footer method of wrapping views. In your views, define a layout using the
205
- <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
206
- call <% yield %> to render the view using this layout.
207
-
208
- app/helpers
209
- Holds view helpers that should be named like weblogs_helper.rb. These are generated
210
- for you automatically when using script/generate for controllers. Helpers can be used to
211
- wrap functionality for your views into methods.
212
-
213
- config
214
- Configuration files for the Rails environment, the routing map, the database, and other dependencies.
215
-
216
- db
217
- Contains the database schema in schema.rb. db/migrate contains all
218
- the sequence of Migrations for your schema.
219
-
220
- doc
221
- This directory is where your application documentation will be stored when generated
222
- using <tt>rake doc:app</tt>
223
-
224
- lib
225
- Application specific libraries. Basically, any kind of custom code that doesn't
226
- belong under controllers, models, or helpers. This directory is in the load path.
227
-
228
- public
229
- The directory available for the web server. Contains subdirectories for images, stylesheets,
230
- and javascripts. Also contains the dispatchers and the default HTML files. This should be
231
- set as the DOCUMENT_ROOT of your web server.
232
-
233
- script
234
- Helper scripts for automation and generation.
235
-
236
- test
237
- Unit and functional tests along with fixtures. When using the script/generate scripts, template
238
- test files will be generated for you and placed in this directory.
239
-
240
- vendor
241
- External libraries that the application depends on. Also includes the plugins subdirectory.
242
- If the app has frozen rails, those gems also go here, under vendor/rails/.
243
- This directory is in the load path.
@@ -1,10 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
-
6
- require 'rake'
7
- require 'rake/testtask'
8
- require 'rake/rdoctask'
9
-
10
- require 'tasks/rails'
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- # filter_parameter_logging :password
10
- end
@@ -1,3 +0,0 @@
1
- # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
@@ -1 +0,0 @@
1
- file content
@@ -1,110 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $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.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- require 'rubygems'
86
- min_version = '1.3.1'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
100
-
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
107
- end
108
-
109
- # All that for this:
110
- Rails.boot!