trusty-cms 4.1.2 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +25 -25
- data/Rakefile +7 -7
- data/app/assets/stylesheets/admin/partials/_content.scss +1 -2
- data/app/controllers/admin/assets_controller.rb +22 -21
- data/app/controllers/admin/configuration_controller.rb +9 -11
- data/app/controllers/admin/extensions_controller.rb +3 -3
- data/app/controllers/admin/layouts_controller.rb +3 -4
- data/app/controllers/admin/page_attachments_controller.rb +5 -5
- data/app/controllers/admin/page_fields_controller.rb +3 -4
- data/app/controllers/admin/page_parts_controller.rb +4 -5
- data/app/controllers/admin/pages_controller.rb +55 -56
- data/app/controllers/admin/references_controller.rb +1 -1
- data/app/controllers/admin/resource_controller.rb +132 -130
- data/app/controllers/admin/sites_controller.rb +4 -4
- data/app/controllers/admin/snippets_controller.rb +3 -4
- data/app/controllers/admin/users_controller.rb +16 -16
- data/app/controllers/application_controller.rb +47 -48
- data/app/controllers/site_controller.rb +51 -48
- data/app/controllers/social_mailer_controller.rb +13 -16
- data/app/helpers/admin/configuration_helper.rb +19 -20
- data/app/helpers/admin/layouts_helper.rb +0 -1
- data/app/helpers/admin/node_helper.rb +27 -24
- data/app/helpers/admin/pages_helper.rb +2 -2
- data/app/helpers/admin/preferences_helper.rb +0 -1
- data/app/helpers/admin/references_helper.rb +9 -10
- data/app/helpers/admin/regions_helper.rb +3 -3
- data/app/helpers/application_helper.rb +32 -33
- data/app/helpers/rad_social_helper.rb +8 -11
- data/app/helpers/scoped_helper.rb +1 -3
- data/app/helpers/sites_helper.rb +4 -4
- data/app/mailers/devise_mailer.rb +3 -4
- data/app/mailers/rad_social_mailer.rb +8 -8
- data/app/models/asset.rb +62 -63
- data/app/models/asset_type.rb +38 -39
- data/app/models/deprecated_tags.rb +3 -4
- data/app/models/file_not_found_page.rb +1 -3
- data/app/models/haml_filter.rb +1 -1
- data/app/models/layout.rb +4 -5
- data/app/models/legacy_user.rb +2 -2
- data/app/models/menu_renderer.rb +16 -18
- data/app/models/page.rb +96 -93
- data/app/models/page_attachment.rb +1 -2
- data/app/models/page_context.rb +11 -12
- data/app/models/page_part.rb +3 -4
- data/app/models/rails_page.rb +10 -12
- data/app/models/site.rb +22 -21
- data/app/models/snippet.rb +6 -8
- data/app/models/snippet_finder.rb +3 -3
- data/app/models/snippet_tags.rb +4 -4
- data/app/models/standard_tags.rb +258 -252
- data/app/models/status.rb +8 -8
- data/app/models/trusty_cms/config.rb +25 -25
- data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
- data/app/models/user.rb +15 -14
- data/app/models/user_action_observer.rb +3 -3
- data/bin/rails +4 -4
- data/bin/trusty_cms +3 -5
- data/config.ru +1 -1
- data/config/application.rb +14 -15
- data/config/boot.rb +1 -2
- data/config/environment.rb +1 -1
- data/config/environments/production.rb +0 -1
- data/config/environments/test.rb +1 -2
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/kraken.rb +2 -2
- data/config/initializers/tmp.rb +1 -1
- data/config/initializers/trusty_cms_config.rb +48 -48
- data/config/routes.rb +6 -6
- data/lib/active_record_extensions/active_record_extensions.rb +1 -2
- data/lib/annotatable.rb +3 -5
- data/lib/configuration_extensions/configuration_extensions.rb +1 -1
- data/lib/inheritable_class_attributes.rb +13 -9
- data/lib/login_system.rb +73 -73
- data/lib/method_observer.rb +13 -12
- data/lib/ostruct.rb +7 -10
- data/lib/simpleton.rb +0 -4
- data/lib/string_extensions/string_extensions.rb +3 -3
- data/lib/symbol_extensions/symbol_extensions.rb +1 -1
- data/lib/tasks/database.rake +28 -28
- data/lib/tasks/extensions.rake +18 -18
- data/lib/tasks/framework.rake +68 -68
- data/lib/tasks/radiant_config.rake +4 -4
- data/lib/tasks/snippets_extension_tasks.rake +11 -11
- data/lib/tasks/translate.rake +14 -14
- data/lib/tasks/upgrade_to_devise.rake +1 -1
- data/lib/translation_support.rb +22 -22
- data/lib/trusty_cms.rb +2 -2
- data/lib/trusty_cms/admin_ui.rb +19 -16
- data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
- data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
- data/lib/trusty_cms/available_locales.rb +2 -4
- data/lib/trusty_cms/config/definition.rb +11 -8
- data/lib/trusty_cms/engine.rb +14 -14
- data/lib/trusty_cms/extension.rb +14 -16
- data/lib/trusty_cms/extension_loader.rb +6 -6
- data/lib/trusty_cms/extension_migrator.rb +42 -41
- data/lib/trusty_cms/extension_path.rb +20 -19
- data/lib/trusty_cms/initializer.rb +5 -8
- data/lib/trusty_cms/pagination/controller.rb +7 -10
- data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
- data/lib/trusty_cms/resource_responses.rb +3 -3
- data/lib/trusty_cms/setup.rb +130 -132
- data/lib/trusty_cms/taggable.rb +19 -22
- data/lib/trusty_cms/task_support.rb +9 -6
- data/public/dispatch.fcgi +1 -1
- data/public/dispatch.rb +2 -2
- data/script/extension +1 -1
- data/script/rails +2 -2
- data/trusty_cms.gemspec +23 -23
- metadata +32 -32
data/lib/trusty_cms/engine.rb
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
module TrustyCms
|
|
2
2
|
class Engine < Rails::Engine
|
|
3
|
-
paths[
|
|
4
|
-
initializer
|
|
3
|
+
paths['app/helpers'] = []
|
|
4
|
+
initializer 'trusty_cms.assets.precompile' do |app|
|
|
5
5
|
app.config.assets.paths << Rails.root.join('../trusty-cms/node_modules')
|
|
6
6
|
app.config.assets.precompile += %w(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
admin/main.css admin.js
|
|
8
|
+
ckeditor/config.js
|
|
9
|
+
ckeditor/contents.css
|
|
10
|
+
ckeditor/config.js
|
|
11
|
+
ckeditor/styles.js
|
|
12
|
+
ckeditor/skins/moono/editor.css
|
|
13
|
+
ckeditor/lang/en.js
|
|
14
|
+
rad_social/rad_screen.css
|
|
15
|
+
rad_social/captcha.js
|
|
16
|
+
rad_social/rad_email.js
|
|
17
|
+
rad_social/rad_widget.js
|
|
18
|
+
)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
data/lib/trusty_cms/extension.rb
CHANGED
|
@@ -33,7 +33,7 @@ module TrustyCms
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def migrations_path
|
|
36
|
-
File.join(
|
|
36
|
+
File.join(root, 'db', 'migrate')
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def migrates_from
|
|
@@ -41,11 +41,11 @@ module TrustyCms
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def routing_file
|
|
44
|
-
File.join(
|
|
44
|
+
File.join(root, 'config', 'routes.rb')
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def load_initializers
|
|
48
|
-
Dir["#{
|
|
48
|
+
Dir["#{root}/config/initializers/**/*.rb"].sort.each do |initializer|
|
|
49
49
|
require initializer
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -53,7 +53,7 @@ module TrustyCms
|
|
|
53
53
|
def migrator
|
|
54
54
|
unless @migrator
|
|
55
55
|
extension = self
|
|
56
|
-
@migrator = Class.new(ExtensionMigrator){ self.extension = extension }
|
|
56
|
+
@migrator = Class.new(ExtensionMigrator) { self.extension = extension }
|
|
57
57
|
end
|
|
58
58
|
@migrator
|
|
59
59
|
end
|
|
@@ -62,7 +62,7 @@ module TrustyCms
|
|
|
62
62
|
AdminUI.instance
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def tab(name, options={}, &block)
|
|
65
|
+
def tab(name, options = {}, &block)
|
|
66
66
|
@the_tab = admin.nav[name]
|
|
67
67
|
unless @the_tab
|
|
68
68
|
@the_tab = TrustyCms::AdminUI::NavTab.new(name)
|
|
@@ -81,7 +81,7 @@ module TrustyCms
|
|
|
81
81
|
if block_given?
|
|
82
82
|
block.call(@the_tab)
|
|
83
83
|
end
|
|
84
|
-
|
|
84
|
+
@the_tab
|
|
85
85
|
end
|
|
86
86
|
alias :add_tab :tab
|
|
87
87
|
|
|
@@ -95,18 +95,16 @@ module TrustyCms
|
|
|
95
95
|
# ThirdPartyExtension.extend(MyExtension::IntegrationPoints)
|
|
96
96
|
# end
|
|
97
97
|
def extension_enabled?(extension)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
false
|
|
103
|
-
end
|
|
98
|
+
extension = (extension.to_s.camelcase + 'Extension').constantize
|
|
99
|
+
extension.enabled?
|
|
100
|
+
rescue NameError
|
|
101
|
+
false
|
|
104
102
|
end
|
|
105
103
|
|
|
106
104
|
class << self
|
|
107
|
-
|
|
108
105
|
def activate_extension
|
|
109
106
|
return if instance.active?
|
|
107
|
+
|
|
110
108
|
instance.activate_extension if instance.respond_to? :activate
|
|
111
109
|
Dir["#{Rails.root}/config/routes/**/*.rb"].each do |route_file|
|
|
112
110
|
end
|
|
@@ -115,6 +113,7 @@ module TrustyCms
|
|
|
115
113
|
|
|
116
114
|
def deactivate_extension
|
|
117
115
|
return unless instance.active?
|
|
116
|
+
|
|
118
117
|
instance.active = false
|
|
119
118
|
instance.deactivate if instance.respond_to? :deactivate
|
|
120
119
|
end
|
|
@@ -124,14 +123,13 @@ module TrustyCms
|
|
|
124
123
|
subclass.extension_name = subclass.name.to_name('Extension')
|
|
125
124
|
end
|
|
126
125
|
|
|
127
|
-
def migrate_from(extension_name, until_migration=nil)
|
|
126
|
+
def migrate_from(extension_name, until_migration = nil)
|
|
128
127
|
instance.migrates_from[extension_name] = until_migration
|
|
129
128
|
end
|
|
130
129
|
|
|
131
|
-
def extension_config
|
|
130
|
+
def extension_config
|
|
132
131
|
yield Rails.configuration
|
|
133
132
|
end
|
|
134
|
-
|
|
135
133
|
end
|
|
136
134
|
end
|
|
137
135
|
end
|
|
@@ -17,11 +17,11 @@ module TrustyCms
|
|
|
17
17
|
@config = rails_config
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def before_clear(*
|
|
20
|
+
def before_clear(*_args) #:nodoc
|
|
21
21
|
ExtensionLoader.deactivate_extensions
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def after_clear(*
|
|
24
|
+
def after_clear(*_args) #:nodoc
|
|
25
25
|
ExtensionLoader.load_extensions
|
|
26
26
|
ExtensionLoader.activate_extensions
|
|
27
27
|
end
|
|
@@ -77,7 +77,7 @@ module TrustyCms
|
|
|
77
77
|
extension.path = extension_path
|
|
78
78
|
extension
|
|
79
79
|
rescue LoadError, NameError => e
|
|
80
|
-
|
|
80
|
+
warn "Could not load extension: #{name}.\n#{e.inspect}"
|
|
81
81
|
nil
|
|
82
82
|
end
|
|
83
83
|
end
|
|
@@ -104,14 +104,14 @@ module TrustyCms
|
|
|
104
104
|
if configuration.extensions.first == :all
|
|
105
105
|
ordered_extensions = extensions
|
|
106
106
|
else
|
|
107
|
-
configuration.extensions.each {|name| ordered_extensions << select_extension(name)
|
|
107
|
+
configuration.extensions.each { |name| ordered_extensions << select_extension(name) }
|
|
108
108
|
end
|
|
109
109
|
ordered_extensions.flatten.each(&:activate)
|
|
110
110
|
Page.load_subclasses
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def select_extension(name)
|
|
114
|
-
extensions.select {|ext| ext.extension_name.symbolize == name}
|
|
114
|
+
extensions.select { |ext| ext.extension_name.symbolize == name }
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
alias :reactivate :activate_extensions
|
|
@@ -122,7 +122,7 @@ module TrustyCms
|
|
|
122
122
|
# An extension name can be supplied in addition to the path. It will be processed in the usual way to
|
|
123
123
|
# remove trusty- and -extension and any verion numbering.
|
|
124
124
|
#
|
|
125
|
-
def record_path(path, name=nil)
|
|
125
|
+
def record_path(path, name = nil)
|
|
126
126
|
ExtensionPath.from_path(path, name)
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -13,7 +13,7 @@ module TrustyCms
|
|
|
13
13
|
|
|
14
14
|
def get_all_versions
|
|
15
15
|
ActiveRecord::Base.connection.select_values("SELECT version FROM #{sanitize(schema_migrations_table_name)}").
|
|
16
|
-
select { |version| version.starts_with?("#{@extension.extension_name}-")}.
|
|
16
|
+
select { |version| version.starts_with?("#{@extension.extension_name}-") }.
|
|
17
17
|
map { |version| version.sub("#{@extension.extension_name}-", '').to_i }.sort
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -25,58 +25,59 @@ module TrustyCms
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
private
|
|
28
|
-
def quote(s)
|
|
29
|
-
ActiveRecord::Base.connection.quote(s)
|
|
30
|
-
end
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
def quote(s)
|
|
30
|
+
ActiveRecord::Base.connection.quote(s)
|
|
31
|
+
end
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
def extension_name
|
|
34
|
+
self.class.extension.extension_name
|
|
35
|
+
end
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
def version_string(version)
|
|
38
|
+
"#{extension_name}-#{version}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def initialize_extension_schema_migrations
|
|
42
|
+
current_version = ActiveRecord::Base.connection.select_value("SELECT schema_version FROM extension_meta WHERE name = #{sanitize(quote(extension_name))}")
|
|
43
|
+
if current_version
|
|
44
|
+
assume_migrated_upto_version(current_version.to_i)
|
|
45
|
+
ActiveRecord::Base.connection.delete("DELETE FROM extension_meta WHERE name = #{sanitize(quote(extension_name))}")
|
|
46
46
|
end
|
|
47
|
+
end
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
end
|
|
49
|
+
def initialize_received_migrations
|
|
50
|
+
if donors = self.class.extension.migrates_from
|
|
51
|
+
donors.each do |extension_name, until_migration|
|
|
52
|
+
replaced = ActiveRecord::Base.connection.select_values("SELECT version FROM #{sanitize(ActiveRecord::Migrator.schema_migrations_table_name)} WHERE version LIKE '#{extension_name}-%'").map { |v| v.sub(/^#{extension_name}\-/, '').to_i }
|
|
53
|
+
replaced.delete_if { |v| v > until_migration.to_i } if until_migration
|
|
54
|
+
assume_migrated_upto_version(replaced.max) if replaced.any?
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
|
+
end
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
def assume_migrated_upto_version(version)
|
|
60
|
+
version = version.to_i
|
|
61
|
+
sm_table = self.class.schema_migrations_table_name
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
migrated = self.class.get_all_versions
|
|
64
|
+
versions = Dir["#{@migrations_path}/[0-9]*_*.rb"].map do |filename|
|
|
65
|
+
filename.split('/').last.split('_').first.to_i
|
|
66
|
+
end
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
unless migrated.include?(version)
|
|
69
|
+
ActiveRecord::Base.connection.execute "INSERT INTO #{sm_table} (version) VALUES (#{sanitize(quote(version_string(version)))})"
|
|
70
|
+
end
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
end
|
|
72
|
+
inserted = Set.new
|
|
73
|
+
(versions - migrated).each do |v|
|
|
74
|
+
if inserted.include?(v)
|
|
75
|
+
raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict."
|
|
76
|
+
elsif v < version
|
|
77
|
+
ActiveRecord::Base.connection.execute "INSERT INTO #{sm_table} (version) VALUES (#{sanitize(quote(version_string(v)))})"
|
|
78
|
+
inserted << v
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
|
+
end
|
|
81
82
|
end
|
|
82
83
|
end
|
|
@@ -24,7 +24,8 @@ module TrustyCms
|
|
|
24
24
|
@@known_paths = {}
|
|
25
25
|
|
|
26
26
|
def initialize(options = {}) #:nodoc
|
|
27
|
-
@name
|
|
27
|
+
@name = options[:name].underscore
|
|
28
|
+
@path = options[:path]
|
|
28
29
|
@@known_paths[@name.to_sym] = self
|
|
29
30
|
end
|
|
30
31
|
|
|
@@ -43,10 +44,10 @@ module TrustyCms
|
|
|
43
44
|
#
|
|
44
45
|
# If two arguments are given, the second is taken to be the full extension name.
|
|
45
46
|
#
|
|
46
|
-
def self.from_path(path, name=nil)
|
|
47
|
+
def self.from_path(path, name = nil)
|
|
47
48
|
name = path if name.blank?
|
|
48
49
|
name = File.basename(name).gsub(/^trusty-|-extension(-[\d\.a-z]+|-[a-z\d]+)*$/, '')
|
|
49
|
-
new(:
|
|
50
|
+
new(name: name, path: path)
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
# Forgets all recorded extension paths.
|
|
@@ -77,7 +78,7 @@ module TrustyCms
|
|
|
77
78
|
# Call the class method ExtensionPath.plugin_paths to get a list of the plugin paths found in all enabled extensions.
|
|
78
79
|
#
|
|
79
80
|
def plugin_paths
|
|
80
|
-
check_subdirectory(
|
|
81
|
+
check_subdirectory('vendor/plugins')
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
# Returns a list of names of all the locale files found within this extension root.
|
|
@@ -85,8 +86,8 @@ module TrustyCms
|
|
|
85
86
|
# in reverse order so that locale definitions override one another correctly.
|
|
86
87
|
#
|
|
87
88
|
def locale_paths
|
|
88
|
-
if check_subdirectory(
|
|
89
|
-
Dir[File.join(
|
|
89
|
+
if check_subdirectory('config/locales')
|
|
90
|
+
Dir[File.join(path.to_s, 'config/locales', '*.{rb,yml}')]
|
|
90
91
|
end
|
|
91
92
|
end
|
|
92
93
|
|
|
@@ -94,21 +95,21 @@ module TrustyCms
|
|
|
94
95
|
# Call the class method ExtensionPath.helper_paths to get a list of the helper paths found in all enabled extensions.
|
|
95
96
|
#
|
|
96
97
|
def helper_paths
|
|
97
|
-
check_subdirectory(
|
|
98
|
+
check_subdirectory('app/helpers')
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
# Returns the app/models path if it is found within this extension root.
|
|
101
102
|
# Call the class method ExtensionPath.model_paths to get a list of the model paths found in all enabled extensions.
|
|
102
103
|
#
|
|
103
104
|
def model_paths
|
|
104
|
-
check_subdirectory(
|
|
105
|
+
check_subdirectory('app/models')
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
# Returns the app/controllers path if it is found within this extension root.
|
|
108
109
|
# Call the class method ExtensionPath.controller_paths to get a list of the controller paths found in all enabled extensions.
|
|
109
110
|
#
|
|
110
111
|
def controller_paths
|
|
111
|
-
check_subdirectory(
|
|
112
|
+
check_subdirectory('app/controllers')
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
# Returns the app/views path if it is found within this extension root.
|
|
@@ -116,21 +117,21 @@ module TrustyCms
|
|
|
116
117
|
# in reverse order so that views override one another correctly.
|
|
117
118
|
#
|
|
118
119
|
def view_paths
|
|
119
|
-
check_subdirectory(
|
|
120
|
+
check_subdirectory('app/views')
|
|
120
121
|
end
|
|
121
122
|
|
|
122
123
|
# Returns the app/metal path if it is found within this extension root.
|
|
123
124
|
# Call the class method ExtensionPath.metal_paths to get a list of the metal paths found in all enabled extensions.
|
|
124
125
|
#
|
|
125
126
|
def metal_paths
|
|
126
|
-
check_subdirectory(
|
|
127
|
+
check_subdirectory('app/metal')
|
|
127
128
|
end
|
|
128
129
|
|
|
129
130
|
# Returns a list of all the rake task files found within this extension root.
|
|
130
131
|
#
|
|
131
132
|
def rake_task_paths
|
|
132
|
-
if check_subdirectory(
|
|
133
|
-
Dir[File.join(
|
|
133
|
+
if check_subdirectory('lib/tasks')
|
|
134
|
+
Dir[File.join(path.to_s, 'lib/tasks/**', '*.rake')]
|
|
134
135
|
end
|
|
135
136
|
end
|
|
136
137
|
|
|
@@ -149,6 +150,7 @@ module TrustyCms
|
|
|
149
150
|
#
|
|
150
151
|
def find(name)
|
|
151
152
|
raise LoadError, "Cannot return path for unknown extension: #{name}" unless @@known_paths[name.to_sym]
|
|
153
|
+
|
|
152
154
|
@@known_paths[name.to_sym]
|
|
153
155
|
end
|
|
154
156
|
|
|
@@ -175,19 +177,19 @@ module TrustyCms
|
|
|
175
177
|
enabled.map(&:path)
|
|
176
178
|
end
|
|
177
179
|
|
|
178
|
-
[
|
|
180
|
+
%i[load_paths plugin_paths helper_paths model_paths controller_paths eager_load_paths].each do |m|
|
|
179
181
|
define_method(m) do
|
|
180
|
-
enabled.map{|ep| ep.send(m)}.flatten.compact
|
|
182
|
+
enabled.map { |ep| ep.send(m) }.flatten.compact
|
|
181
183
|
end
|
|
182
184
|
end
|
|
183
|
-
[
|
|
185
|
+
%i[locale_paths view_paths metal_paths rake_task_paths].each do |m|
|
|
184
186
|
define_method(m) do
|
|
185
|
-
enabled.map{|ep| ep.send(m)}.flatten.compact.reverse
|
|
187
|
+
enabled.map { |ep| ep.send(m) }.flatten.compact.reverse
|
|
186
188
|
end
|
|
187
189
|
end
|
|
188
190
|
end
|
|
189
191
|
|
|
190
|
-
|
|
192
|
+
private
|
|
191
193
|
|
|
192
194
|
# If the supplied path within the extension root exists and is a directory, its absolute path is returned. Otherwise, nil.
|
|
193
195
|
#
|
|
@@ -195,6 +197,5 @@ module TrustyCms
|
|
|
195
197
|
subdirectory = File.join(path, subpath)
|
|
196
198
|
subdirectory if File.directory?(subdirectory)
|
|
197
199
|
end
|
|
198
|
-
|
|
199
200
|
end
|
|
200
201
|
end
|
|
@@ -11,7 +11,7 @@ require 'trusty_cms/engine'
|
|
|
11
11
|
|
|
12
12
|
# This is a wild and probably terrible hack built to initialize extension engines.
|
|
13
13
|
# I have no idea what the repercussions will be. Revisit later.
|
|
14
|
-
Gem.loaded_specs.each_with_object([]) do |(gemname, gemspec),
|
|
14
|
+
Gem.loaded_specs.each_with_object([]) do |(gemname, gemspec), _found|
|
|
15
15
|
if gemname =~ /trusty-.*-extension$/
|
|
16
16
|
ep = TrustyCms::ExtensionLoader.record_path(gemspec.full_gem_path, gemname)
|
|
17
17
|
require "#{ep.name}/engine"
|
|
@@ -19,15 +19,12 @@ Gem.loaded_specs.each_with_object([]) do |(gemname, gemspec), found|
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
module TrustyCms
|
|
22
|
-
|
|
23
22
|
module Initializer
|
|
24
|
-
|
|
25
23
|
# Rails::Initializer is essentially a list of startup steps and we extend it here by:
|
|
26
24
|
# * overriding or extending some of those steps so that they use trusty and extension paths
|
|
27
25
|
# as well as (or instead of) the rails defaults.
|
|
28
26
|
# * appending some extra steps to set up the admin UI and activate extensions
|
|
29
27
|
|
|
30
|
-
|
|
31
28
|
# Returns true in the very unusual case where trusty has been deployed as a rails app itself, rather than
|
|
32
29
|
# loaded as a gem or from vendor/. This is only likely in situations where trusty is customised so heavily
|
|
33
30
|
# that extensions are not sufficient.
|
|
@@ -54,7 +51,8 @@ module TrustyCms
|
|
|
54
51
|
|
|
55
52
|
configuration.middleware.insert_before(
|
|
56
53
|
:"ActionController::ParamsParser",
|
|
57
|
-
Rails::Rack::Metal, :
|
|
54
|
+
Rails::Rack::Metal, if: Rails::Rack::Metal.metals.any?
|
|
55
|
+
)
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
# Extends the Rails initializer to add locale paths from TRUSTY_CMS_ROOT and from trusty extensions.
|
|
@@ -120,7 +118,7 @@ module TrustyCms
|
|
|
120
118
|
#
|
|
121
119
|
def after_initialize
|
|
122
120
|
super
|
|
123
|
-
extension_loader.activate_extensions
|
|
121
|
+
extension_loader.activate_extensions # also calls initialize_views
|
|
124
122
|
TrustyCms::Application.config.add_controller_paths(extension_loader.paths(:controller))
|
|
125
123
|
TrustyCms::Application.config.add_eager_load_paths(extension_loader.paths(:eager_load))
|
|
126
124
|
end
|
|
@@ -157,8 +155,7 @@ module TrustyCms
|
|
|
157
155
|
# Returns the ExtensionLoader singleton that will eventually load extensions.
|
|
158
156
|
#
|
|
159
157
|
def extension_loader
|
|
160
|
-
ExtensionLoader.instance {|l| l.initializer = self }
|
|
158
|
+
ExtensionLoader.instance { |l| l.initializer = self }
|
|
161
159
|
end
|
|
162
|
-
|
|
163
160
|
end
|
|
164
161
|
end
|