refinerycms 0.9.8 → 0.9.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/Gemfile +6 -6
  2. data/app/controllers/application_controller.rb +2 -1
  3. data/bin/refinerycms +36 -32
  4. data/changelog.md +471 -0
  5. data/config/environments/production.rb +1 -1
  6. data/db/migrate/20100606135207_change_thumbnail_sizes_for_dragonfly.rb +4 -4
  7. data/db/migrate/20100826232810_move_inquiry_settings_to_refinery_settings.rb +2 -2
  8. data/db/migrate/20100831122919_move_page_to_nested_set.rb +28 -0
  9. data/db/schema.rb +7 -1
  10. data/db/seeds/refinery_settings.rb +2 -4
  11. data/license.md +21 -0
  12. data/readme.md +97 -0
  13. data/todo.md +61 -0
  14. data/vendor/refinerycms/authentication/app/views/admin/users/index.html.erb +5 -13
  15. data/vendor/refinerycms/authentication/app/views/layouts/login.html.erb +1 -1
  16. data/vendor/refinerycms/authentication/config/locales/de.yml +53 -56
  17. data/vendor/refinerycms/authentication/config/locales/en.yml +1 -2
  18. data/vendor/refinerycms/authentication/config/locales/lv.yml +38 -38
  19. data/vendor/refinerycms/authentication/config/locales/pt-BR.yml +21 -48
  20. data/vendor/refinerycms/authentication/features/lost_password.feature +40 -0
  21. data/vendor/refinerycms/authentication/features/manage_users.feature +57 -0
  22. data/vendor/refinerycms/authentication/features/step_definitions/lost_password.rb +8 -0
  23. data/vendor/refinerycms/authentication/features/step_definitions/user_steps.rb +32 -0
  24. data/vendor/refinerycms/authentication/features/support/factories.rb +17 -0
  25. data/vendor/refinerycms/authentication/features/support/paths.rb +24 -0
  26. data/vendor/refinerycms/authentication/lib/authenticated_system.rb +1 -1
  27. data/vendor/refinerycms/authentication/lib/authentication.rb +1 -1
  28. data/vendor/refinerycms/core/app/views/admin/_head.html.erb +4 -4
  29. data/vendor/refinerycms/core/app/views/admin/_menu_tab.html.erb +2 -2
  30. data/vendor/refinerycms/core/app/views/layouts/admin.html.erb +1 -1
  31. data/vendor/refinerycms/core/app/views/layouts/admin_dialog.html.erb +1 -1
  32. data/vendor/refinerycms/core/app/views/shared/_footer.html.erb +1 -1
  33. data/vendor/refinerycms/core/app/views/shared/_google_analytics.html.erb +1 -1
  34. data/vendor/refinerycms/core/app/views/shared/_header.html.erb +1 -1
  35. data/vendor/refinerycms/core/app/views/shared/_menu.html.erb +5 -2
  36. data/vendor/refinerycms/core/app/views/shared/_menu_branch.html.erb +6 -3
  37. data/vendor/refinerycms/core/app/views/shared/_site_bar.html.erb +11 -15
  38. data/vendor/refinerycms/core/app/views/shared/admin/_form_actions.html.erb +1 -0
  39. data/vendor/refinerycms/core/app/views/shared/admin/_image_picker.html.erb +3 -3
  40. data/vendor/refinerycms/core/app/views/shared/admin/_make_sortable.html.erb +2 -1
  41. data/vendor/refinerycms/core/app/views/shared/admin/_resource_picker.html.erb +24 -17
  42. data/vendor/refinerycms/core/app/views/wymiframe.html.erb +1 -1
  43. data/vendor/refinerycms/core/config/locales/de.yml +50 -51
  44. data/vendor/refinerycms/core/config/locales/en.yml +5 -2
  45. data/vendor/refinerycms/core/config/locales/lv.yml +6 -3
  46. data/vendor/refinerycms/core/config/locales/pt-BR.yml +34 -38
  47. data/vendor/refinerycms/core/crud.md +12 -12
  48. data/vendor/refinerycms/core/features/engine_generator.feature +27 -0
  49. data/vendor/refinerycms/core/features/search.feature +56 -0
  50. data/vendor/refinerycms/core/features/site_bar.feature +24 -0
  51. data/vendor/refinerycms/core/features/step_definitions/core_steps.rb +61 -0
  52. data/vendor/refinerycms/core/features/step_definitions/engine_generator_steps.rb +19 -0
  53. data/vendor/refinerycms/core/features/step_definitions/generator_steps.rb +11 -0
  54. data/vendor/refinerycms/core/features/support/paths.rb +14 -0
  55. data/vendor/refinerycms/core/features/uploads/beach.jpeg +0 -0
  56. data/vendor/refinerycms/core/features/uploads/refinery_is_awesome.txt +1 -0
  57. data/vendor/refinerycms/core/lib/core.rb +52 -53
  58. data/vendor/refinerycms/core/lib/generators/refinery_engine/refinery_engine_generator.rb +14 -3
  59. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/controllers/admin/plural_name_controller.rb +3 -1
  60. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/models/singular_name.rb +4 -3
  61. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/_form.html.erb +2 -1
  62. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/_singular_name.html.erb +6 -2
  63. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/plural_name/index.html.erb +3 -1
  64. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/plural_name/show.html.erb +7 -3
  65. data/vendor/refinerycms/core/lib/refinery/application_controller.rb +85 -75
  66. data/vendor/refinerycms/core/lib/refinery/application_helper.rb +10 -190
  67. data/vendor/refinerycms/core/lib/refinery/crud.rb +283 -0
  68. data/vendor/refinerycms/core/lib/refinery/{form_helpers.rb → helpers/form_helper.rb} +0 -0
  69. data/vendor/refinerycms/core/lib/refinery/helpers/html_truncation_helper.rb +26 -0
  70. data/vendor/refinerycms/core/lib/refinery/helpers/image_helper.rb +37 -0
  71. data/vendor/refinerycms/core/lib/refinery/helpers/menu_helper.rb +38 -0
  72. data/vendor/refinerycms/core/lib/refinery/helpers/meta_helper.rb +67 -0
  73. data/vendor/refinerycms/core/lib/refinery/helpers/script_helper.rb +36 -0
  74. data/vendor/refinerycms/core/lib/refinery/helpers/site_bar_helper.rb +26 -0
  75. data/vendor/refinerycms/core/lib/refinery/helpers/tag_helper.rb +19 -0
  76. data/vendor/refinerycms/core/lib/refinery/helpers/translation_helper.rb +17 -0
  77. data/vendor/refinerycms/core/lib/refinery/plugin.rb +3 -3
  78. data/vendor/refinerycms/core/lib/tasks/refinery.rake +4 -3
  79. data/vendor/refinerycms/core/public/javascripts/refinery/admin.js +93 -101
  80. data/vendor/refinerycms/core/public/javascripts/refinery/core.js +3 -0
  81. data/vendor/refinerycms/core/public/javascripts/refinery/nestedsortables.js +164 -0
  82. data/vendor/refinerycms/core/public/javascripts/refinery/serializelist.js +66 -0
  83. data/vendor/refinerycms/core/public/stylesheets/refinery/refinery.css +11 -73
  84. data/vendor/refinerycms/dashboard/config/locales/de.yml +6 -6
  85. data/vendor/refinerycms/dashboard/config/locales/pt-BR.yml +3 -5
  86. data/vendor/refinerycms/dashboard/features/dashboard.feature +54 -0
  87. data/vendor/refinerycms/dashboard/features/support/paths.rb +14 -0
  88. data/vendor/refinerycms/images/app/controllers/admin/images_controller.rb +6 -6
  89. data/vendor/refinerycms/images/app/helpers/admin/images_helper.rb +1 -1
  90. data/vendor/refinerycms/images/app/views/admin/images/_existing_image.html.erb +15 -13
  91. data/vendor/refinerycms/images/app/views/admin/images/_grid_view.html.erb +1 -1
  92. data/vendor/refinerycms/images/app/views/admin/images/_list_view_image.html.erb +1 -1
  93. data/vendor/refinerycms/images/config/locales/de.yml +21 -25
  94. data/vendor/refinerycms/images/config/locales/pt-BR.yml +13 -23
  95. data/vendor/refinerycms/images/features/manage_images.feature +48 -0
  96. data/vendor/refinerycms/images/features/step_definitions/image_steps.rb +37 -0
  97. data/vendor/refinerycms/images/features/support/paths.rb +17 -0
  98. data/vendor/refinerycms/images/features/uploads/beach.jpeg +0 -0
  99. data/vendor/refinerycms/images/features/uploads/id-rather-be-here.jpg +0 -0
  100. data/vendor/refinerycms/images/features/uploads/refinery_is_awesome.txt +1 -0
  101. data/vendor/refinerycms/images/lib/images.rb +6 -0
  102. data/vendor/refinerycms/images/readme.md +12 -36
  103. data/vendor/refinerycms/pages/app/controllers/admin/pages_controller.rb +4 -42
  104. data/vendor/refinerycms/pages/app/controllers/pages_controller.rb +1 -1
  105. data/vendor/refinerycms/pages/app/models/page.rb +3 -4
  106. data/vendor/refinerycms/pages/app/sweepers/page_sweeper.rb +18 -0
  107. data/vendor/refinerycms/pages/app/views/admin/pages/_form_advanced_options.html.erb +1 -1
  108. data/vendor/refinerycms/pages/app/views/admin/pages/_page.html.erb +6 -5
  109. data/vendor/refinerycms/pages/config/locales/de.yml +66 -36
  110. data/vendor/refinerycms/pages/config/locales/pt-BR.yml +29 -57
  111. data/vendor/refinerycms/pages/features/manage_pages.feature +45 -0
  112. data/vendor/refinerycms/pages/features/step_definitions/page_steps.rb +29 -0
  113. data/vendor/refinerycms/pages/features/support/paths.rb +18 -0
  114. data/vendor/refinerycms/pages/lib/pages.rb +5 -0
  115. data/vendor/refinerycms/pages/spec/models/page_spec.rb +13 -0
  116. data/vendor/refinerycms/refinery.rb +1 -1
  117. data/vendor/refinerycms/resources/app/views/admin/resources/_existing_resource.html.erb +2 -2
  118. data/vendor/refinerycms/resources/config/locales/de.yml +16 -17
  119. data/vendor/refinerycms/resources/config/locales/pt-BR.yml +15 -17
  120. data/vendor/refinerycms/resources/features/manage_files.feature +39 -0
  121. data/vendor/refinerycms/resources/features/step_definitions/file_steps.rb +21 -0
  122. data/vendor/refinerycms/resources/features/support/paths.rb +17 -0
  123. data/vendor/refinerycms/resources/features/uploads/beach.jpeg +0 -0
  124. data/vendor/refinerycms/resources/features/uploads/refinery_is_awesome.txt +1 -0
  125. data/vendor/refinerycms/resources/lib/resources.rb +17 -1
  126. data/vendor/refinerycms/settings/app/models/refinery_setting.rb +82 -64
  127. data/vendor/refinerycms/settings/config/locales/de.yml +36 -16
  128. data/vendor/refinerycms/settings/config/locales/pt-BR.yml +32 -34
  129. data/vendor/refinerycms/settings/features/manage_refinery_settings.feature +5 -0
  130. data/vendor/refinerycms/settings/lib/settings.rb +1 -1
  131. metadata +86 -53
  132. data/vendor/refinerycms/core/lib/crud.rb +0 -265
  133. data/vendor/refinerycms/core/lib/refinery/html_truncation_helper.rb +0 -22
  134. data/vendor/refinerycms/core/public/javascripts/jquery/jquery.nestedsortables.js +0 -186
@@ -12,9 +12,9 @@ The best part about ``crudify`` is that this gives you a smart default and if th
12
12
 
13
13
  ## Where is it located?
14
14
 
15
- ``vendor/plugins/refinery/lib/crud.rb``
15
+ ``vendor/refinerycms/core/lib/refinery/crud.rb``
16
16
 
17
- ## How do I use it in my plugins?
17
+ ## How do I use it in my engines?
18
18
 
19
19
  All you need to do is call ``crudify`` in your controller.
20
20
 
@@ -27,7 +27,7 @@ If you used the Refinery generator you're plugin will already be using ``crudify
27
27
  crudify :news_item, :order => "created_at DESC"
28
28
 
29
29
  end
30
-
30
+
31
31
  ### Complex Example
32
32
 
33
33
  class NewsItemsController < ApplicationController
@@ -103,13 +103,13 @@ For performance optimisation, sometimes you might want to eager load other relat
103
103
  Instead of having to look up each user for each of the ``news_posts`` we iterate over, the ``:include`` option allows you to load the ``news_post`` and user all at the same time which'll allow you to save on expensive database queries.
104
104
 
105
105
  Here's an example of that.
106
-
106
+
107
107
  class NewsItem
108
-
108
+
109
109
  belongs_to :user
110
-
110
+
111
111
  end
112
-
112
+
113
113
  class NewsItemsController < ApplicationController
114
114
 
115
115
  crudify :news_item, :order => "created_at DESC", :include => [:user]
@@ -139,18 +139,18 @@ Say we have a pages controller that is going to manage pages.
139
139
  crudify :page
140
140
 
141
141
  end
142
-
142
+
143
143
  In this controller, automatically I have these methods:
144
144
 
145
145
  find_page()
146
146
  find_all_pages()
147
-
147
+
148
148
  So say I wanted to change the way all pages are found, all I do is override the ``find_all_pages`` method.
149
149
 
150
150
  class PagesController < ApplicationController
151
151
 
152
152
  crudify :page
153
-
153
+
154
154
  def find_all_pages
155
155
  @pages = Page.find(...) # apply any logic I want here to get all pages.
156
156
  end
@@ -170,7 +170,7 @@ Let's go back to the example above with the pages controller.
170
170
  crudify :page
171
171
 
172
172
  end
173
-
173
+
174
174
  Say every time someone deletes a page I want my ``NotificationMailer`` to email me to say someone just deleted a page.
175
175
 
176
176
  When I look in the ``crud.rb`` file I see that my controller has this added to it
@@ -179,7 +179,7 @@ When I look in the ``crud.rb`` file I see that my controller has this added to i
179
179
  flash[:notice] = "'\#{@#{singular_name}.#{options[:title_attribute]}}' was successfully deleted." if @#{singular_name}.destroy
180
180
  redirect_to admin_#{plural_name}_url
181
181
  end
182
-
182
+
183
183
  To override this all I would is create my own delete method that works the same but just with my mailer code on it.
184
184
 
185
185
  class PagesController < ApplicationController
@@ -0,0 +1,27 @@
1
+ @engine-generator @generator
2
+ Feature: Engine generation
3
+ In order to create my own engine
4
+ As a refinery user
5
+ I want to generate a basic engine directory structure
6
+
7
+ Scenario: Generating an engine with a name
8
+ Given I have a refinery application
9
+ When I generate an engine with the arguments of "product title:string description:text image:image brochure:resource"
10
+ Then I should have a directory "vendor/engines/products"
11
+ And I should have a directory "vendor/engines/products/app"
12
+ And I should have a directory "vendor/engines/products/lib"
13
+ And I should have a directory "vendor/engines/products/config"
14
+ And I should have a file "vendor/engines/products/app/controllers/admin/products_controller.rb"
15
+ And I should have a file "vendor/engines/products/app/controllers/products_controller.rb"
16
+ And I should have a file "vendor/engines/products/app/models/product.rb"
17
+ And I should have a file "vendor/engines/products/config/routes.rb"
18
+ And I should have a file "vendor/engines/products/config/locales/en.yml"
19
+ And I should have a file "vendor/engines/products/lib/products.rb"
20
+ And I should have a file "vendor/engines/products/app/views/admin/products/_form.html.erb"
21
+ And I should have a file "vendor/engines/products/app/views/admin/products/_sortable_list.html.erb"
22
+ And I should have a file "vendor/engines/products/app/views/admin/products/edit.html.erb"
23
+ And I should have a file "vendor/engines/products/app/views/admin/products/index.html.erb"
24
+ And I should have a file "vendor/engines/products/app/views/admin/products/new.html.erb"
25
+ And I should have a file "vendor/engines/products/app/views/admin/products/_product.html.erb"
26
+ And I should have a file "vendor/engines/products/app/views/products/index.html.erb"
27
+ And I should have a file "vendor/engines/products/app/views/products/show.html.erb"
@@ -0,0 +1,56 @@
1
+ @search
2
+ Feature: Search
3
+ In order find content more quickly
4
+ As an administrator
5
+ I want to use search
6
+
7
+ Background:
8
+ Given I am a logged in refinery user
9
+
10
+ @search-existing
11
+ Scenario Outline: Search Existing Item
12
+ Given I have a <item> titled "<title>"
13
+ When I go to the list of <location>
14
+ And I fill in "search" with "<title>"
15
+ And I press "Search"
16
+ Then I should see "<title>"
17
+
18
+ Examples:
19
+ | item | title | location |
20
+ |page |testitem|pages |
21
+ |inquiry |testitem|inquiries |
22
+ |inquiry |testitem|spam inquiries|
23
+
24
+ # This will only run when resources engine is installed.
25
+ @search-file
26
+ Scenario: Search File
27
+ When I upload the file at "refinery_is_awesome.txt"
28
+ And I go to the list of files
29
+ And I fill in "search" with "Refinery Is Awesome"
30
+ And I press "Search"
31
+ Then I should see "Refinery Is Awesome"
32
+
33
+ # This will only run when images engine is installed.
34
+ @search-image
35
+ Scenario: Search Image
36
+ When I upload the image at "beach.jpeg"
37
+ And I go to the list of images
38
+ And I fill in "search" with "Beach"
39
+ And I press "Search"
40
+ Then I should see "Beach"
41
+
42
+ @search-nonexisting
43
+ Scenario Outline: Search Nonexisting Item
44
+ Given I have no <item>
45
+ When I go to the list of <location>
46
+ And I fill in "search" with "nonexisting"
47
+ And I press "Search"
48
+ Then I should see "Sorry, no results found"
49
+
50
+ Examples:
51
+ | item | location |
52
+ |pages |pages |
53
+ |images |images |
54
+ |files |files |
55
+ |inquiries|inquiries |
56
+ |inquiries|spam inquiries|
@@ -0,0 +1,24 @@
1
+ @site_bar
2
+ Feature: Site Bar
3
+ In order to allow administrators to easily switch between editing and viewing their website
4
+ I want logged in refinery users to see a site bar
5
+ And I want logged in customers to not see a site bar
6
+
7
+ Background:
8
+ Given I have a page titled "Home" with a custom url "/"
9
+ And I am not logged in
10
+
11
+ Scenario: Not logged in
12
+ When I go to the home page
13
+ Then I should not see "Log out"
14
+
15
+ Scenario: Logged in as a Refinery user
16
+ Given I am a logged in refinery user
17
+ When I go to the home page
18
+ Then I should see "Log out"
19
+
20
+ Scenario: Logged in as a customer
21
+ Given A Refinery user exists
22
+ And I am a logged in customer
23
+ When I go to the home page
24
+ Then I should not see "Switch to your website editor"
@@ -0,0 +1,61 @@
1
+ # Login stuff
2
+ Given %r`not logged in$` do
3
+ visit logout_path
4
+ end
5
+
6
+ Given /locale is (.+?)$/ do |locale|
7
+ if defined?(::Refinery::I18n)
8
+ ::Refinery::I18n.current_locale = locale.to_sym
9
+ end
10
+ end
11
+
12
+ Given %r`(?:log|am logged) in as "([^\"]+)"$` do |login|
13
+ @my_username = login
14
+ visit login_path
15
+ And %Q`enter the username "#{login}"`
16
+ And %Q`enter the password "#{login}-123"`
17
+ And "press the login button"
18
+ end
19
+
20
+ Then 'I should( not)? see a login form' do |negative|
21
+ expect_opposite_if(negative) do
22
+ response.should have_tag('form#new_user_session') do
23
+ field_labeled('Username').should_not be_nil
24
+ field_labeled('Password', :password).should_not be_nil
25
+ end
26
+ end
27
+ end
28
+
29
+ When %r`enter the username "(.+)"$` do |login|
30
+ fill_in 'user_session[login]' , :with => login
31
+ end
32
+
33
+ When %r`enter the password "(.+)-123"$` do |login|
34
+ fill_in 'user_session[password]', :with => "#{login}-123"
35
+ end
36
+
37
+ When %r`press the login button$` do
38
+ click_button 'Sign In'
39
+ end
40
+
41
+ Then %r`not be allowed to log in$` do
42
+ When %Q`log in as "#{@my_username}"`
43
+ Then 'I should see a login form'
44
+ end
45
+
46
+ Then %r`be redirected to login$` do
47
+ request.request_uri.should == login_path
48
+ end
49
+
50
+ Then /^"([^\"]*)" can log in$/ do |name|
51
+ user = User.find_by_login!(name)
52
+ visit login_path
53
+ When %Q`I enter the username "#{name}"`
54
+ And %Q`I enter the password "#{name}-123"`
55
+ And 'I press the login button'
56
+ Then 'I should not see a login form'
57
+ end
58
+
59
+ Then /^I should be redirected back to "([^"]*)"$/ do |page_name|
60
+ visit path_to(page_name)
61
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path("../../../lib/generators/refinery_engine/refinery_engine_generator", __FILE__)
2
+
3
+ Before do
4
+ @engine_generator_root = File.expand_path('../../../', __FILE__)
5
+ @tmp_refinery_app_name = "tmp_refinery_app"
6
+ @tmp_refinery_app_root = File.join(@engine_generator_root, @tmp_refinery_app_name)
7
+ @app_root = @tmp_refinery_app_root
8
+ end
9
+
10
+ After do
11
+ FileUtils.rm_rf(@tmp_refinery_app_root)
12
+ end
13
+
14
+ When /^I generate an engine with the arguments of "([^"]*)"$/ do |arguments|
15
+ generator = RefineryEngineGenerator.new(arguments.split(" "))
16
+ generator.destination_root = @app_root
17
+ generator.options = {:quiet => true}
18
+ generator.generate
19
+ end
@@ -0,0 +1,11 @@
1
+ Given /^I have a refinery application$/ do
2
+ FileUtils.mkdir(File.join(@app_root))
3
+ end
4
+
5
+ Then /^I should have a directory "([^"]*)"$/ do |name|
6
+ File.exist?(File.join(@tmp_refinery_app_root, name)).should be_true
7
+ end
8
+
9
+ Then /^I should have a file "([^"]*)"$/ do |name|
10
+ File.exist?(File.join(@tmp_refinery_app_root, name)).should be_true
11
+ end
@@ -0,0 +1,14 @@
1
+ module NavigationHelpers
2
+ module Refinery
3
+ module Core
4
+ def path_to(page_name)
5
+ # no paths
6
+ nil
7
+ #case page_name
8
+ #else
9
+ # nil
10
+ #end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ http://www.refineryhq.com/
@@ -1,76 +1,75 @@
1
1
  require 'rails/all'
2
- require 'acts_as_tree'
2
+
3
3
  require 'acts_as_indexed'
4
+ require 'authlogic'
5
+ require 'awesome_nested_set'
6
+ require 'dragonfly'
4
7
  require 'friendly_id'
5
8
  require 'truncate_html'
6
9
  require 'will_paginate'
7
10
 
8
11
  module Refinery
12
+ autoload :Plugin, File.expand_path('../refinery/plugin', __FILE__)
13
+ autoload :Plugins, File.expand_path('../refinery/plugins', __FILE__)
14
+ autoload :Activity, File.expand_path('../refinery/activity', __FILE__)
9
15
 
10
- autoload :Plugin, 'refinery/plugin'
11
- autoload :Plugins, 'refinery/plugins'
12
- autoload :Activity, 'refinery/activity'
13
-
14
- class Engine < Rails::Engine
15
- initializer "static assets" do |app|
16
- app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
17
- end
18
-
19
- config.autoload_paths += %W( #{config.root}/lib )
20
-
21
- initializer 'add catch all routes' do |app|
22
- app.routes_reloader.paths << File.expand_path('../refinery/catch_all_routes.rb', __FILE__)
23
- end
16
+ module Core
17
+ class Engine < Rails::Engine
18
+ initializer "static assets" do |app|
19
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
20
+ end
24
21
 
25
- config.to_prepare do
26
- Rails.cache.clear
22
+ config.autoload_paths += %W( #{config.root}/lib )
27
23
 
28
- require_dependency 'refinery/form_helpers'
29
- require_dependency 'refinery/base_presenter'
24
+ initializer 'add catch all routes' do |app|
25
+ app.routes_reloader.paths << File.expand_path('../refinery/catch_all_routes.rb', __FILE__)
26
+ end
30
27
 
31
- [
32
- Refinery.root.join("vendor", "plugins", "*", "app", "presenters"),
33
- Rails.root.join("app", "presenters")
34
- ].each do |path|
35
- Dir[path.to_s].each do |presenters_path|
36
- $LOAD_PATH << presenters_path
37
- ::ActiveSupport::Dependencies.load_paths << presenters_path
38
- end
28
+ initializer 'add presenters' do |app|
29
+ app.config.load_paths += [
30
+ Rails.root.join("app", "presenters"),
31
+ Rails.root.join("vendor", "**", "**", "app", "presenters"),
32
+ Refinery.root.join("vendor", "refinerycms", "*", "app", "presenters")
33
+ ].flatten
39
34
  end
40
35
 
41
- # Figure out a better way to cache assets.
42
- ::ActionView::Helpers::AssetTagHelper.module_eval do
43
- def asset_file_path(path)
44
- unless File.exist?(return_path = File.join(config.assets_dir, path.split('?').first))
45
- ::Refinery::Plugins.registered.collect{|p| p.pathname}.compact.each do |pathname|
46
- if File.exist?(plugin_asset_path = File.join(pathname.to_s, 'public', path.split('?').first))
47
- return_path = plugin_asset_path.to_s
36
+ config.to_prepare do
37
+ Rails.cache.clear
38
+
39
+ # TODO: Is there a better way to cache assets in engines?
40
+ ::ActionView::Helpers::AssetTagHelper.module_eval do
41
+ def asset_file_path(path)
42
+ unless File.exist?(return_path = File.join(config.assets_dir, path.split('?').first))
43
+ ::Refinery::Plugins.registered.collect{|p| p.pathname}.compact.each do |pathname|
44
+ if File.exist?(plugin_asset_path = File.join(pathname.to_s, 'public', path.split('?').first))
45
+ return_path = plugin_asset_path.to_s
46
+ end
48
47
  end
49
48
  end
50
- end
51
49
 
52
- return_path
50
+ return_path
51
+ end
53
52
  end
54
53
  end
55
- end
56
54
 
57
- config.after_initialize do
58
- Refinery::Plugin.register do |plugin|
59
- plugin.name ="refinery_core"
60
- plugin.class_name ="RefineryEngine"
61
- plugin.version = %q{0.9.8}
62
- plugin.hide_from_menu = true
63
- plugin.always_allow_access = true
64
- plugin.menu_match = /(refinery|admin)\/(refinery_core|base)$/
65
- end
55
+ config.after_initialize do
56
+ Refinery::Plugin.register do |plugin|
57
+ plugin.name ="refinery_core"
58
+ plugin.class_name ="RefineryEngine"
59
+ plugin.version = %q{0.9.8}
60
+ plugin.hide_from_menu = true
61
+ plugin.always_allow_access = true
62
+ plugin.menu_match = /(refinery|admin)\/(refinery_core|base)$/
63
+ end
66
64
 
67
- # Register the dialogs plugin
68
- Refinery::Plugin.register do |plugin|
69
- plugin.name = "refinery_dialogs"
70
- plugin.version = %q{0.9.8}
71
- plugin.hide_from_menu = true
72
- plugin.always_allow_access = true
73
- plugin.menu_match = /(refinery|admin)\/(refinery_)?dialogs/
65
+ # Register the dialogs plugin
66
+ Refinery::Plugin.register do |plugin|
67
+ plugin.name = "refinery_dialogs"
68
+ plugin.version = %q{0.9.8}
69
+ plugin.hide_from_menu = true
70
+ plugin.always_allow_access = true
71
+ plugin.menu_match = /(refinery|admin)\/(refinery_)?dialogs/
72
+ end
74
73
  end
75
74
  end
76
75
  end
@@ -16,7 +16,7 @@ class RefineryEngineGenerator < Rails::Generators::NamedBase
16
16
  end
17
17
 
18
18
  # Update the gem file
19
- unless Rails.env == 'test'
19
+ if Rails.env != 'test' and self.behavior != :revoke
20
20
  Rails.root.join('Gemfile').open('a') do |f|
21
21
  f.write "\ngem 'refinerycms-#{plural_name}', '1.0', :path => 'vendor/engines', :require => '#{plural_name}'"
22
22
  end
@@ -26,6 +26,9 @@ class RefineryEngineGenerator < Rails::Generators::NamedBase
26
26
  puts "bundle install"
27
27
  puts "rake db:migrate"
28
28
  puts "------------------------"
29
+ elsif self.behavior == :revoke
30
+ lines = Rails.root.join('Gemfile').open('r').read.split("\n")
31
+ Rails.root.join('Gemfile').open('w').puts(lines.reject {|l| l =~ %r{refinerycms-#{plural_name}}}.join("\n"))
29
32
  end
30
33
  else
31
34
  puts "You must specify at least one field. For help: rails generate refinery_engine"
@@ -41,8 +44,16 @@ protected
41
44
  path = path.gsub(".migration", '')
42
45
 
43
46
  # hack can be removed after issue is fixed
44
- next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
45
- path = path.gsub("migration_number", next_migration_number)
47
+ unless self.behavior == :revoke
48
+ next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
49
+ else
50
+ if (migrations = Dir[Rails.root.join('db', 'migrate', "*create_#{plural_name}*.rb").to_s]).any?
51
+ next_migration_number = migrations.first.split('/').last.split('_').first
52
+ else
53
+ next_migration_number = ''
54
+ end
55
+ end
56
+ path = path.gsub("migration_number", next_migration_number.to_s)
46
57
 
47
58
  # replace our local db path with the app one instead.
48
59
  path = path.gsub("/db/", "/../../../db/")