refinerycms-core 2.0.10 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/refinery/admin.js.erb +126 -234
- data/app/assets/javascripts/refinery/ajaxy_pagination.js.coffee +1 -1
- data/app/assets/javascripts/refinery/boot_wym.js.erb +4 -8
- data/app/assets/javascripts/refinery/core.js +1 -1
- data/app/assets/javascripts/refinery/interface.js.coffee.erb +3 -16
- data/app/assets/javascripts/refinery/modal_dialogs.js.erb +0 -3
- data/app/assets/javascripts/refinery/nestedsortables.js +312 -312
- data/app/assets/javascripts/refinery/refinery.js.erb +14 -15
- data/app/assets/javascripts/refinery/site_bar.js +3 -9
- data/app/assets/javascripts/refinery/sortable_list.js +145 -0
- data/app/assets/javascripts/refinery/sortable_menu.js.coffee +3 -4
- data/app/assets/javascripts/refinery/submit_continue.js.coffee.erb +1 -2
- data/app/assets/javascripts/refinery/tree.js +3 -3
- data/app/assets/javascripts/refinery/wymeditor.js +6 -6
- data/{public → app/assets/javascripts}/wymeditor/GPL-license.txt +0 -0
- data/{public → app/assets/javascripts}/wymeditor/MIT-license.txt +0 -0
- data/{public → app/assets/javascripts}/wymeditor/README +0 -0
- data/app/assets/javascripts/wymeditor/browsers/mozilla.js.erb +10 -11
- data/app/assets/javascripts/wymeditor/browsers/webkit.js.erb +17 -18
- data/app/assets/javascripts/wymeditor/classes.js.erb +3 -5
- data/app/assets/javascripts/wymeditor/functions.js.erb +5 -1
- data/app/assets/javascripts/wymeditor/prototypes.js.erb +0 -3
- data/app/assets/javascripts/wymeditor/setup.js.erb +5 -5
- data/app/assets/javascripts/wymeditor/skins/refinery/skin.js +1 -4
- data/app/assets/javascripts/wymeditor/validators.js.erb +3 -2
- data/app/assets/stylesheets/{formatting.css.scss → refinery/formatting.css.scss} +0 -0
- data/app/assets/stylesheets/refinery/layout.css.scss +41 -11
- data/app/assets/stylesheets/{theme.css.scss → refinery/theme.css.scss} +0 -0
- data/app/controllers/refinery/sitemap_controller.rb +1 -5
- data/app/helpers/refinery/admin_helper.rb +6 -0
- data/app/helpers/refinery/image_helper.rb +2 -1
- data/app/helpers/refinery/menu_helper.rb +0 -49
- data/app/helpers/refinery/meta_helper.rb +7 -3
- data/app/helpers/refinery/site_bar_helper.rb +3 -15
- data/app/models/refinery/core/base_model.rb +2 -0
- data/{lib → app/presenters}/refinery/base_presenter.rb +1 -2
- data/app/views/layouts/application.html.erb +8 -7
- data/app/views/refinery/_content_page.html.erb +1 -1
- data/app/views/refinery/_google_analytics.html.erb +12 -5
- data/app/views/refinery/_head.html.erb +11 -15
- data/app/views/refinery/_header.html.erb +1 -4
- data/app/views/refinery/_javascripts.html.erb +14 -8
- data/app/views/refinery/_site_bar.html.erb +4 -4
- data/app/views/refinery/admin/_form_advanced_options_menu.html.erb +12 -0
- data/app/views/refinery/admin/_javascripts.html.erb +13 -1
- data/app/views/refinery/admin/_locale_picker.html.erb +11 -0
- data/app/views/refinery/admin/_make_sortable.html.erb +8 -5
- data/app/views/refinery/admin/_search.html.erb +1 -7
- data/app/views/refinery/admin/_search_header.html.erb +1 -0
- data/app/views/refinery/admin/_wysiwyg.html.erb +16 -0
- data/config/initializers/will_paginate_monkeypatch.rb +1 -1
- data/config/locales/bg.yml +5 -1
- data/config/locales/cs.yml +5 -1
- data/config/locales/da.yml +5 -1
- data/config/locales/de.yml +7 -3
- data/config/locales/el.yml +5 -1
- data/config/locales/en.yml +7 -1
- data/config/locales/es.yml +5 -1
- data/config/locales/fi.yml +5 -1
- data/config/locales/fr.yml +5 -1
- data/config/locales/hu.yml +82 -0
- data/config/locales/it.yml +38 -34
- data/config/locales/ja.yml +5 -1
- data/config/locales/ko.yml +5 -1
- data/config/locales/lt.yml +5 -1
- data/config/locales/lv.yml +5 -1
- data/config/locales/nb.yml +5 -1
- data/config/locales/nl.yml +36 -29
- data/config/locales/pl.yml +8 -1
- data/config/locales/pt-BR.yml +7 -3
- data/config/locales/pt.yml +82 -0
- data/config/locales/rs.yml +5 -1
- data/config/locales/ru.yml +5 -1
- data/config/locales/sk.yml +10 -3
- data/config/locales/sl.yml +5 -1
- data/config/locales/sv.yml +5 -1
- data/config/locales/tr.yml +82 -0
- data/config/locales/uk.yml +77 -0
- data/config/locales/vi.yml +5 -1
- data/config/locales/zh-CN.yml +5 -1
- data/config/locales/zh-TW.yml +5 -1
- data/config/routes.rb +3 -3
- data/lib/generators/refinery/cms/cms_generator.rb +29 -0
- data/lib/generators/refinery/cms/templates/.gitignore +1 -0
- data/lib/generators/refinery/cms/templates/app/views/sitemap/index.xml.builder +13 -13
- data/lib/generators/refinery/core/templates/config/initializers/refinery/core.rb.erb +8 -12
- data/lib/generators/refinery/dummy/templates/rails/database.yml +3 -3
- data/lib/generators/refinery/engine/engine_generator.rb +8 -12
- data/lib/generators/refinery/engine/templates/Gemfile +5 -39
- data/lib/generators/refinery/engine/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +4 -4
- data/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb.erb +2 -3
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_actions.html.erb +1 -1
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_form.html.erb +31 -33
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +1 -3
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_singular_name.html.erb +2 -2
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/index.html.erb +1 -1
- data/lib/generators/refinery/engine/templates/config/locales/cs.yml +28 -0
- data/lib/generators/refinery/engine/templates/config/locales/it.yml +28 -0
- data/lib/generators/refinery/engine/templates/config/locales/nl.yml +6 -6
- data/lib/generators/refinery/engine/templates/config/locales/tr.yml +28 -0
- data/lib/generators/refinery/engine/templates/config/routes.rb.erb +2 -2
- data/lib/generators/refinery/engine/templates/db/seeds.rb.erb +1 -1
- data/lib/generators/refinery/engine/templates/lib/generators/refinery/extension_plural_name_generator.rb.erb +1 -1
- data/lib/generators/refinery/engine/templates/lib/refinery/plural_name/engine.rb.erb +1 -1
- data/lib/generators/refinery/engine/templates/spec/{requests → features}/refinery/namespace/admin/plural_name_spec.rb.erb +1 -1
- data/lib/generators/refinery/engine/templates/spec/spec_helper.rb +25 -49
- data/lib/generators/refinery/form/form_generator.rb +1 -13
- data/lib/generators/refinery/form/templates/app/models/refinery/namespace/singular_name.rb.erb +0 -4
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +2 -2
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/spam.html.erb +7 -6
- data/lib/generators/refinery/form/templates/config/locales/nl.yml +29 -29
- data/lib/generators/refinery/form/templates/config/locales/tr.yml +78 -0
- data/lib/generators/refinery/form/templates/config/routes.rb.erb +1 -1
- data/lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb +2 -6
- data/lib/generators/refinery/form/templates/db/seeds.rb.erb +1 -1
- data/lib/generators/refinery/form/templates/lib/refinery/plural_name/engine.rb.erb +1 -1
- data/lib/generators/refinery/form/templates/refinerycms-plural_name.gemspec +2 -5
- data/lib/refinery.rb +191 -0
- data/lib/refinery/admin/base_controller.rb +27 -16
- data/lib/refinery/application_controller.rb +15 -47
- data/lib/refinery/cli.rb +48 -27
- data/lib/refinery/core.rb +7 -183
- data/lib/refinery/core/configuration.rb +17 -9
- data/lib/refinery/core/engine.rb +11 -47
- data/lib/refinery/crud.rb +81 -66
- data/lib/refinery/engine.rb +52 -55
- data/lib/refinery/ext/action_view/helpers/form_builder.rb +2 -0
- data/lib/refinery/extension_generation.rb +208 -110
- data/lib/refinery/menu.rb +16 -7
- data/lib/refinery/menu_item.rb +56 -54
- data/lib/refinery/plugin.rb +11 -3
- data/lib/refinery/plugins.rb +14 -1
- data/lib/refinery/version.rb +3 -3
- data/refinerycms-core.gemspec +11 -10
- data/spec/controllers/refinery/admin/dummy_controller_spec.rb +57 -0
- data/spec/controllers/refinery/admin/refinery_core_controller_spec.rb +3 -4
- data/spec/controllers/refinery/sitemap_controller_spec.rb +1 -14
- data/spec/{requests → features}/refinery/admin/custom_assets_spec.rb +1 -1
- data/spec/{requests → features}/refinery/admin/dialogs_spec.rb +1 -1
- data/spec/features/refinery/admin/xhr_paging_spec.rb +55 -0
- data/spec/features/refinery/application_layout_spec.rb +19 -0
- data/spec/features/refinery/core_spec.rb +14 -0
- data/spec/{requests → features}/refinery/site_bar_spec.rb +1 -1
- data/spec/helpers/refinery/meta_helper_spec.rb +25 -0
- data/spec/lib/generators/refinery/cms/cms_generator_spec.rb +61 -0
- data/spec/lib/generators/refinery/engine/engine_generator_multiple_resources_spec.rb +28 -1
- data/spec/lib/generators/refinery/engine/engine_generator_sanity_check_spec.rb +7 -7
- data/spec/lib/generators/refinery/engine/engine_generator_spec.rb +69 -8
- data/spec/lib/generators/refinery/engine/engine_generator_with_i18n_spec.rb +0 -2
- data/spec/lib/generators/refinery/form/form_generator_spec.rb +9 -1
- data/spec/lib/refinery/application_controller_spec.rb +48 -63
- data/spec/lib/refinery/cli_spec.rb +136 -0
- data/spec/lib/refinery/core/configuration_spec.rb +17 -0
- data/spec/lib/refinery/core_spec.rb +19 -13
- data/spec/lib/refinery/crud_spec.rb +0 -4
- data/spec/lib/refinery/menu_spec.rb +16 -26
- data/spec/support/refinery.rb +6 -1
- data/{app → vendor}/assets/javascripts/jquery/GPL-LICENSE.txt +0 -0
- data/{app → vendor}/assets/javascripts/jquery/MIT-LICENSE.txt +0 -0
- data/vendor/assets/javascripts/jquery/jquery.browser.js +49 -0
- data/{app → vendor}/assets/javascripts/jquery/jquery.html5-placeholder-shim.js +0 -0
- data/{app → vendor}/assets/javascripts/jquery/jquery.jcarousel.js +0 -0
- data/{app → vendor}/assets/javascripts/jquery/jquery.textTruncate.js +0 -0
- data/{app → vendor}/assets/javascripts/jquery/jquery.timers.js +0 -0
- data/{app → vendor}/assets/javascripts/modernizr-min.js +0 -0
- metadata +231 -78
- data/app/assets/images/refinery/resolve_digital_footer_logo.png +0 -0
- data/app/assets/javascripts/dd_belatedpng.js +0 -13
- data/app/assets/javascripts/jquery/jquery.corner.js +0 -345
- data/app/assets/stylesheets/application.css.scss +0 -55
- data/app/assets/stylesheets/home.css.scss +0 -3
- data/app/views/refinery/_ie6check.html.erb +0 -63
- data/app/views/refinery/_menu.html.erb +0 -20
- data/app/views/refinery/_menu_branch.html.erb +0 -19
- data/lib/generators/refinery/engine/templates/Guardfile +0 -27
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_locale_picker.html.erb +0 -11
- data/lib/refinery/catch_all_routes.rb +0 -3
- data/lib/tasks/yard.rake +0 -30
- data/spec/requests/refinery/admin/controller_restriction_spec.rb +0 -27
- data/spec/requests/refinery/search_spec.rb +0 -71
@@ -4,22 +4,19 @@ module Refinery
|
|
4
4
|
|
5
5
|
config_accessor :rescue_not_found, :s3_backend, :base_cache_key, :site_name,
|
6
6
|
:google_analytics_page_code, :authenticity_token_on_frontend,
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:s3_secret_access_key, :force_ssl
|
7
|
+
:dragonfly_secret,
|
8
|
+
:wymeditor_whitelist_tags, :javascripts, :stylesheets,
|
9
|
+
:s3_bucket_name, :s3_region, :s3_access_key_id,
|
10
|
+
:s3_secret_access_key, :force_ssl, :backend_route,
|
11
|
+
:dragonfly_custom_backend_class, :dragonfly_custom_backend_opts
|
11
12
|
|
12
13
|
self.rescue_not_found = false
|
13
14
|
self.s3_backend = false
|
14
15
|
self.base_cache_key = :refinery
|
15
16
|
self.site_name = "Company Name"
|
16
17
|
self.google_analytics_page_code = "UA-xxxxxx-x"
|
17
|
-
self.authenticity_token_on_frontend =
|
18
|
-
self.menu_hide_children = false
|
19
|
-
self.menu_css = { :selected => "selected", :first => "first", :last => "last" }
|
18
|
+
self.authenticity_token_on_frontend = false
|
20
19
|
self.dragonfly_secret = Array.new(24) { rand(256) }.pack('C*').unpack('H*').first
|
21
|
-
self.ie6_upgrade_message_enabled = true
|
22
|
-
self.show_internet_explorer_upgrade_message = false
|
23
20
|
self.wymeditor_whitelist_tags = {}
|
24
21
|
self.javascripts = []
|
25
22
|
self.stylesheets = []
|
@@ -28,6 +25,9 @@ module Refinery
|
|
28
25
|
self.s3_access_key_id = ENV['S3_KEY']
|
29
26
|
self.s3_secret_access_key = ENV['S3_SECRET']
|
30
27
|
self.force_ssl = false
|
28
|
+
self.backend_route = "refinery"
|
29
|
+
self.dragonfly_custom_backend_class = ''
|
30
|
+
self.dragonfly_custom_backend_opts = {}
|
31
31
|
|
32
32
|
def config.register_javascript(name)
|
33
33
|
self.javascripts << name
|
@@ -46,6 +46,14 @@ module Refinery
|
|
46
46
|
self.stylesheets = []
|
47
47
|
end
|
48
48
|
|
49
|
+
def dragonfly_custom_backend?
|
50
|
+
config.dragonfly_custom_backend_class.present?
|
51
|
+
end
|
52
|
+
|
53
|
+
def dragonfly_custom_backend_class
|
54
|
+
config.dragonfly_custom_backend_class.constantize if dragonfly_custom_backend?
|
55
|
+
end
|
56
|
+
|
49
57
|
def site_name
|
50
58
|
::I18n.t('site_name', :scope => 'refinery.core.config', :default => config.site_name)
|
51
59
|
end
|
data/lib/refinery/core/engine.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
module Refinery
|
2
2
|
module Core
|
3
3
|
class Engine < ::Rails::Engine
|
4
|
-
|
4
|
+
extend Refinery::Engine
|
5
5
|
|
6
6
|
isolate_namespace Refinery
|
7
7
|
engine_name :refinery
|
8
8
|
|
9
9
|
class << self
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
[Rails.root, Refinery::Plugins.registered.pathnames].flatten.map { |p|
|
14
|
-
Dir[p.join('app', 'decorators', '**', '*_decorator.rb')]
|
15
|
-
}.flatten.uniq.each do |decorator|
|
16
|
-
Rails.application.config.cache_classes ? require(decorator) : load(decorator)
|
17
|
-
end
|
10
|
+
# Register all decorators from app/decorators/ and registered plugins' paths.
|
11
|
+
def register_decorators!
|
12
|
+
Decorators.register! Rails.root, Refinery::Plugins.registered.pathnames
|
18
13
|
end
|
19
14
|
|
20
15
|
# Performs the Refinery inclusion process which extends the currently loaded Rails
|
@@ -24,7 +19,7 @@ module Refinery
|
|
24
19
|
def refinery_inclusion!
|
25
20
|
before_inclusion_procs.each(&:call)
|
26
21
|
|
27
|
-
::ApplicationController
|
22
|
+
Refinery.include_once(::ApplicationController, Refinery::ApplicationController)
|
28
23
|
::ApplicationController.send :helper, Refinery::Core::Engine.helpers
|
29
24
|
|
30
25
|
after_inclusion_procs.each(&:call)
|
@@ -36,7 +31,7 @@ module Refinery
|
|
36
31
|
# Include the refinery controllers and helpers dynamically
|
37
32
|
config.to_prepare &method(:refinery_inclusion!).to_proc
|
38
33
|
|
39
|
-
after_inclusion &method(:
|
34
|
+
after_inclusion &method(:register_decorators!).to_proc
|
40
35
|
|
41
36
|
# Wrap errors in spans
|
42
37
|
config.to_prepare do
|
@@ -54,7 +49,6 @@ module Refinery
|
|
54
49
|
plugin.pathname = root
|
55
50
|
plugin.name = 'refinery_core'
|
56
51
|
plugin.class_name = 'RefineryEngine'
|
57
|
-
plugin.version = Refinery.version
|
58
52
|
plugin.hide_from_menu = true
|
59
53
|
plugin.always_allow_access = true
|
60
54
|
plugin.menu_match = /refinery\/(refinery_)?core$/
|
@@ -65,15 +59,16 @@ module Refinery
|
|
65
59
|
Refinery::Plugin.register do |plugin|
|
66
60
|
plugin.pathname = root
|
67
61
|
plugin.name = 'refinery_dialogs'
|
68
|
-
plugin.version = Refinery.version
|
69
62
|
plugin.hide_from_menu = true
|
70
63
|
plugin.always_allow_access = true
|
71
64
|
plugin.menu_match = /refinery\/(refinery_)?dialogs/
|
72
65
|
end
|
73
66
|
end
|
74
67
|
|
75
|
-
initializer "refinery.routes" do |app|
|
76
|
-
|
68
|
+
initializer "refinery.routes", :after => :set_routes_reloader_hook do |app|
|
69
|
+
Refinery::Core::Engine.routes.append do
|
70
|
+
get "#{Refinery::Core.backend_route}/*path" => 'admin#error_404'
|
71
|
+
end
|
77
72
|
end
|
78
73
|
|
79
74
|
initializer "refinery.autoload_paths" do |app|
|
@@ -84,40 +79,19 @@ module Refinery
|
|
84
79
|
].flatten
|
85
80
|
end
|
86
81
|
|
87
|
-
initializer "refinery.acts_as_indexed" do
|
88
|
-
ActiveSupport.on_load(:active_record) do
|
89
|
-
require 'acts_as_indexed'
|
90
|
-
ActsAsIndexed.configure do |config|
|
91
|
-
config.index_file = Rails.root.join('tmp', 'index')
|
92
|
-
config.index_file_depth = 3
|
93
|
-
config.min_word_size = 3
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
82
|
# set the manifests and assets to be precompiled
|
99
|
-
initializer "refinery.assets.precompile"
|
83
|
+
initializer "refinery.assets.precompile" do |app|
|
100
84
|
app.config.assets.precompile += [
|
101
|
-
"home.css",
|
102
|
-
"formatting.css",
|
103
|
-
"theme.css",
|
104
|
-
"admin.js",
|
105
85
|
"refinery/*",
|
106
86
|
"refinery/icons/*",
|
107
87
|
"wymeditor/lang/*",
|
108
88
|
"wymeditor/skins/refinery/*",
|
109
89
|
"wymeditor/skins/refinery/**/*",
|
110
90
|
"modernizr-min.js",
|
111
|
-
"dd_belatedpng.js",
|
112
91
|
"admin.js"
|
113
92
|
]
|
114
93
|
end
|
115
94
|
|
116
|
-
# Disable asset debugging - it's a performance killer in dev mode
|
117
|
-
initializer "refinery.assets.pipeline" do |app|
|
118
|
-
app.config.assets.debug = false
|
119
|
-
end
|
120
|
-
|
121
95
|
# active model fields which may contain sensitive data to filter
|
122
96
|
initializer "refinery.params.filter" do |app|
|
123
97
|
app.config.filter_parameters += [:password, :password_confirmation]
|
@@ -134,16 +108,6 @@ module Refinery
|
|
134
108
|
config.after_initialize do
|
135
109
|
Refinery.register_extension(Refinery::Core)
|
136
110
|
end
|
137
|
-
|
138
|
-
# We need to reload the routes here due to how Refinery sets them up
|
139
|
-
# The different facets of Refinery (dashboard, pages, etc.) append/prepend routes to Core
|
140
|
-
# *after* Core has been loaded.
|
141
|
-
#
|
142
|
-
# So we wait until after initialization is complete to do one final reload
|
143
|
-
# This then makes the appended/prepended routes available to the application.
|
144
|
-
config.after_initialize do
|
145
|
-
Rails.application.routes_reloader.reload!
|
146
|
-
end
|
147
111
|
end
|
148
112
|
end
|
149
113
|
end
|
data/lib/refinery/crud.rb
CHANGED
@@ -61,49 +61,22 @@ module Refinery
|
|
61
61
|
|
62
62
|
prepend_before_filter :find_#{singular_name},
|
63
63
|
:only => [:update, :destroy, :edit, :show]
|
64
|
+
prepend_before_filter :merge_position_into_params!, :only => :create
|
64
65
|
|
65
66
|
def new
|
66
67
|
@#{singular_name} = #{class_name}.new
|
67
68
|
end
|
68
69
|
|
69
70
|
def create
|
70
|
-
# if the position field exists, set this object as last object, given the conditions of this class.
|
71
|
-
if #{class_name}.column_names.include?("position") && params[:#{singular_name}][:position].nil?
|
72
|
-
params[:#{singular_name}].merge!({
|
73
|
-
:position => ((#{class_name}.maximum(:position, :conditions => #{options[:conditions].inspect})||-1) + 1)
|
74
|
-
})
|
75
|
-
end
|
76
|
-
|
77
71
|
if (@#{singular_name} = #{class_name}.create(params[:#{singular_name}])).valid?
|
78
72
|
flash.notice = t(
|
79
73
|
'refinery.crudify.created',
|
80
74
|
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'"
|
81
75
|
)
|
82
76
|
|
83
|
-
|
84
|
-
unless params[:continue_editing] =~ /true|on|1/
|
85
|
-
redirect_back_or_default(#{options[:redirect_to_url]})
|
86
|
-
else
|
87
|
-
unless request.xhr?
|
88
|
-
redirect_to :back
|
89
|
-
else
|
90
|
-
render :partial => '/refinery/message'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
else
|
94
|
-
self.index
|
95
|
-
@dialog_successful = true
|
96
|
-
render :index
|
97
|
-
end
|
77
|
+
create_or_update_successful
|
98
78
|
else
|
99
|
-
|
100
|
-
render :action => 'new'
|
101
|
-
else
|
102
|
-
render :partial => '/refinery/admin/error_messages', :locals => {
|
103
|
-
:object => @#{singular_name},
|
104
|
-
:include_object_name => true
|
105
|
-
}
|
106
|
-
end
|
79
|
+
create_or_update_unsuccessful 'new'
|
107
80
|
end
|
108
81
|
end
|
109
82
|
|
@@ -118,30 +91,9 @@ module Refinery
|
|
118
91
|
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'"
|
119
92
|
)
|
120
93
|
|
121
|
-
|
122
|
-
unless params[:continue_editing] =~ /true|on|1/
|
123
|
-
redirect_back_or_default(#{options[:redirect_to_url]})
|
124
|
-
else
|
125
|
-
unless request.xhr?
|
126
|
-
redirect_to :back
|
127
|
-
else
|
128
|
-
render :partial => '/refinery/message'
|
129
|
-
end
|
130
|
-
end
|
131
|
-
else
|
132
|
-
self.index
|
133
|
-
@dialog_successful = true
|
134
|
-
render :index
|
135
|
-
end
|
94
|
+
create_or_update_successful
|
136
95
|
else
|
137
|
-
|
138
|
-
render :action => 'edit'
|
139
|
-
else
|
140
|
-
render :partial => '/refinery/admin/error_messages', :locals => {
|
141
|
-
:object => @#{singular_name},
|
142
|
-
:include_object_name => true
|
143
|
-
}
|
144
|
-
end
|
96
|
+
create_or_update_unsuccessful 'edit'
|
145
97
|
end
|
146
98
|
end
|
147
99
|
|
@@ -152,7 +104,7 @@ module Refinery
|
|
152
104
|
flash.notice = t('destroyed', :scope => 'refinery.crudify', :what => "'\#{title}'")
|
153
105
|
end
|
154
106
|
|
155
|
-
redirect_to
|
107
|
+
redirect_to redirect_url
|
156
108
|
end
|
157
109
|
|
158
110
|
# Finds one single result based on the id params.
|
@@ -170,18 +122,39 @@ module Refinery
|
|
170
122
|
).order("#{options[:order]}")
|
171
123
|
end
|
172
124
|
|
125
|
+
def merge_position_into_params!
|
126
|
+
# if the position field exists, set this object as last object, given the conditions of this class.
|
127
|
+
if #{class_name}.column_names.include?("position") && params[:#{singular_name}][:position].nil?
|
128
|
+
params[:#{singular_name}].merge!({
|
129
|
+
:position => ((#{class_name}.maximum(:position, :conditions => #{options[:conditions].inspect})||-1) + 1)
|
130
|
+
})
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
173
134
|
# Paginate a set of @#{plural_name} that may/may not already exist.
|
174
135
|
def paginate_all_#{plural_name}
|
175
136
|
# If we have already found a set then we don't need to again
|
176
137
|
find_all_#{plural_name} if @#{plural_name}.nil?
|
177
138
|
|
178
|
-
|
139
|
+
@#{plural_name} = @#{plural_name}.paginate(:page => params[:page], :per_page => paginate_per_page)
|
140
|
+
end
|
141
|
+
|
142
|
+
def paginate_per_page
|
143
|
+
if #{options[:per_page].present?.inspect}
|
179
144
|
#{options[:per_page].inspect}
|
180
145
|
elsif #{class_name}.methods.map(&:to_sym).include?(:per_page)
|
181
146
|
#{class_name}.per_page
|
182
147
|
end
|
148
|
+
end
|
183
149
|
|
184
|
-
|
150
|
+
def redirect_url
|
151
|
+
if params[:page].present?
|
152
|
+
page = params[:page].to_i rescue 1
|
153
|
+
page -= 1 while #{class_name}.paginate(:page => page).empty? && page > 1
|
154
|
+
#{options[:redirect_to_url]}(:page => page)
|
155
|
+
else
|
156
|
+
#{options[:redirect_to_url]}
|
157
|
+
end
|
185
158
|
end
|
186
159
|
|
187
160
|
# If the controller is being accessed via an ajax request
|
@@ -193,6 +166,35 @@ module Refinery
|
|
193
166
|
end
|
194
167
|
end
|
195
168
|
|
169
|
+
def create_or_update_successful
|
170
|
+
if from_dialog?
|
171
|
+
self.index
|
172
|
+
@dialog_successful = true
|
173
|
+
render :index
|
174
|
+
else
|
175
|
+
if /true|on|1/ === params[:continue_editing]
|
176
|
+
if request.xhr?
|
177
|
+
render :partial => '/refinery/message'
|
178
|
+
else
|
179
|
+
redirect_to :back
|
180
|
+
end
|
181
|
+
else
|
182
|
+
redirect_back_or_default redirect_url
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def create_or_update_unsuccessful(action)
|
188
|
+
if request.xhr?
|
189
|
+
render :partial => '/refinery/admin/error_messages', :locals => {
|
190
|
+
:object => @#{singular_name},
|
191
|
+
:include_object_name => true
|
192
|
+
}
|
193
|
+
else
|
194
|
+
render :action => action
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
196
198
|
# Returns a weighted set of results based on the query specified by the user.
|
197
199
|
def search_all_#{plural_name}
|
198
200
|
# First find normal results.
|
@@ -207,13 +209,18 @@ module Refinery
|
|
207
209
|
protected :find_#{singular_name},
|
208
210
|
:find_all_#{plural_name},
|
209
211
|
:paginate_all_#{plural_name},
|
212
|
+
:paginate_per_page,
|
210
213
|
:render_partial_response?,
|
211
|
-
:search_all_#{plural_name}
|
214
|
+
:search_all_#{plural_name},
|
215
|
+
:redirect_url,
|
216
|
+
:create_or_update_successful,
|
217
|
+
:create_or_update_unsuccessful,
|
218
|
+
:merge_position_into_params!
|
212
219
|
)
|
213
220
|
|
214
221
|
# Methods that are only included when this controller is searchable.
|
215
222
|
if options[:searchable]
|
216
|
-
if options[:paging]
|
223
|
+
if options[:paging] || options[:xhr_paging]
|
217
224
|
module_eval %(
|
218
225
|
def index
|
219
226
|
search_all_#{plural_name} if searching?
|
@@ -237,7 +244,7 @@ module Refinery
|
|
237
244
|
end
|
238
245
|
|
239
246
|
else
|
240
|
-
if options[:paging]
|
247
|
+
if options[:paging] || options[:xhr_paging]
|
241
248
|
module_eval %(
|
242
249
|
def index
|
243
250
|
paginate_all_#{plural_name}
|
@@ -266,11 +273,8 @@ module Refinery
|
|
266
273
|
def update_positions
|
267
274
|
previous = nil
|
268
275
|
params[:ul].each do |_, list|
|
269
|
-
|
270
|
-
|
271
|
-
# because there won't be an ordering issue (see https://github.com/refinery/refinerycms/issues/1585)
|
272
|
-
list.sort_by {|k, v| k.to_i}.map { |item| item[1] }.each_with_index do |hash, index|
|
273
|
-
moved_item_id = hash['id'].split(/#{singular_name}\_?/).reject(&:empty?).first
|
276
|
+
list.each do |index, hash|
|
277
|
+
moved_item_id = hash['id'][/\\d+$/]
|
274
278
|
@current_#{singular_name} = #{class_name}.find_by_id(moved_item_id)
|
275
279
|
|
276
280
|
if @current_#{singular_name}.respond_to?(:move_to_root)
|
@@ -292,7 +296,8 @@ module Refinery
|
|
292
296
|
end
|
293
297
|
|
294
298
|
#{class_name}.rebuild! if #{class_name}.respond_to?(:rebuild!)
|
295
|
-
|
299
|
+
|
300
|
+
after_update_positions
|
296
301
|
end
|
297
302
|
|
298
303
|
def update_child_positions(_node, #{singular_name})
|
@@ -307,16 +312,26 @@ module Refinery
|
|
307
312
|
end
|
308
313
|
end
|
309
314
|
end
|
315
|
+
|
316
|
+
def after_update_positions
|
317
|
+
render :nothing => true
|
318
|
+
end
|
319
|
+
|
320
|
+
protected :after_update_positions
|
310
321
|
)
|
311
322
|
end
|
312
323
|
|
313
324
|
module_eval %(
|
314
325
|
class << self
|
315
326
|
def pageable?
|
316
|
-
#{options[:paging].to_s}
|
327
|
+
#{options[:paging].to_s} || #{options[:xhr_paging].to_s}
|
317
328
|
end
|
318
329
|
alias_method :paging?, :pageable?
|
319
330
|
|
331
|
+
def xhr_pageable?
|
332
|
+
#{options[:xhr_paging].to_s}
|
333
|
+
end
|
334
|
+
|
320
335
|
def sortable?
|
321
336
|
#{options[:sortable].to_s}
|
322
337
|
end
|
data/lib/refinery/engine.rb
CHANGED
@@ -1,65 +1,62 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
1
|
module Refinery
|
4
2
|
module Engine
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
# Specify a block of code to be run after the refinery inclusion step. See
|
4
|
+
# Refinery::Core::Engine#refinery_inclusion for details regarding the Refinery
|
5
|
+
# inclusion process.
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
# module Refinery
|
9
|
+
# module Images
|
10
|
+
# class Engine < Rails::Engine
|
11
|
+
# extend Refinery::Engine
|
12
|
+
# engine_name :images
|
13
|
+
#
|
14
|
+
# after_inclusion do
|
15
|
+
# # perform something here
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
def after_inclusion(&block)
|
21
|
+
if block && block.respond_to?(:call)
|
22
|
+
after_inclusion_procs << block
|
23
|
+
else
|
24
|
+
raise 'Anything added to be called after_inclusion must be callable (respond to #call).'
|
10
25
|
end
|
26
|
+
end
|
11
27
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
# Specify a block of code to be run before the refinery inclusion step. See
|
29
|
+
# Refinery::Core::Engine#refinery_inclusion for details regarding the Refinery
|
30
|
+
# inclusion process.
|
31
|
+
#
|
32
|
+
# Example:
|
33
|
+
# module Refinery
|
34
|
+
# module Images
|
35
|
+
# class Engine < Rails::Engine
|
36
|
+
# extend Refinery::Engine
|
37
|
+
# engine_name :images
|
38
|
+
#
|
39
|
+
# before_inclusion do
|
40
|
+
# # perform something here
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
def before_inclusion(&block)
|
46
|
+
if block && block.respond_to?(:call)
|
47
|
+
before_inclusion_procs << block
|
48
|
+
else
|
49
|
+
raise 'Anything added to be called before_inclusion must be callable (respond to #call).'
|
34
50
|
end
|
51
|
+
end
|
35
52
|
|
36
|
-
|
37
|
-
|
38
|
-
|
53
|
+
private
|
54
|
+
def after_inclusion_procs
|
55
|
+
@@after_inclusion_procs ||= []
|
56
|
+
end
|
39
57
|
|
40
|
-
|
41
|
-
|
42
|
-
# inclusion process.
|
43
|
-
#
|
44
|
-
# Example:
|
45
|
-
# module Refinery
|
46
|
-
# module Images
|
47
|
-
# class Engine < Rails::Engine
|
48
|
-
# engine_name :images
|
49
|
-
#
|
50
|
-
# before_inclusion do
|
51
|
-
# # perform something here
|
52
|
-
# end
|
53
|
-
# end
|
54
|
-
# end
|
55
|
-
# end
|
56
|
-
def before_inclusion(&block)
|
57
|
-
if block && block.respond_to?(:call)
|
58
|
-
before_inclusion_procs << block
|
59
|
-
else
|
60
|
-
raise 'Anything added to be called before_inclusion must be callable (respond to #call).'
|
61
|
-
end
|
62
|
-
end
|
58
|
+
def before_inclusion_procs
|
59
|
+
@@before_inclusion_procs ||= []
|
63
60
|
end
|
64
61
|
end
|
65
62
|
end
|