trusty-cms 4.1.0 → 4.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +98 -98
  4. data/README.md +1 -1
  5. data/Rakefile +7 -7
  6. data/app/assets/javascripts/admin/assets.js +1 -1
  7. data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
  8. data/app/assets/javascripts/rad_social/rad_email.js +0 -1
  9. data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
  10. data/app/assets/stylesheets/admin/partials/_forms.scss +1 -1
  11. data/app/assets/stylesheets/admin/partials/_messages.scss +7 -2
  12. data/app/assets/stylesheets/admin/partials/_popup.scss +1 -1
  13. data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
  14. data/app/controllers/admin/assets_controller.rb +21 -31
  15. data/app/controllers/admin/configuration_controller.rb +9 -11
  16. data/app/controllers/admin/extensions_controller.rb +3 -3
  17. data/app/controllers/admin/layouts_controller.rb +3 -4
  18. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  19. data/app/controllers/admin/page_fields_controller.rb +3 -4
  20. data/app/controllers/admin/page_parts_controller.rb +4 -5
  21. data/app/controllers/admin/pages_controller.rb +55 -56
  22. data/app/controllers/admin/references_controller.rb +1 -1
  23. data/app/controllers/admin/resource_controller.rb +132 -130
  24. data/app/controllers/admin/sites_controller.rb +4 -4
  25. data/app/controllers/admin/snippets_controller.rb +3 -4
  26. data/app/controllers/admin/users_controller.rb +16 -16
  27. data/app/controllers/application_controller.rb +47 -48
  28. data/app/controllers/site_controller.rb +51 -48
  29. data/app/controllers/social_mailer_controller.rb +12 -22
  30. data/app/helpers/admin/configuration_helper.rb +19 -20
  31. data/app/helpers/admin/layouts_helper.rb +0 -1
  32. data/app/helpers/admin/node_helper.rb +27 -24
  33. data/app/helpers/admin/pages_helper.rb +2 -2
  34. data/app/helpers/admin/preferences_helper.rb +0 -1
  35. data/app/helpers/admin/references_helper.rb +9 -10
  36. data/app/helpers/admin/regions_helper.rb +3 -3
  37. data/app/helpers/application_helper.rb +32 -33
  38. data/app/helpers/rad_social_helper.rb +8 -11
  39. data/app/helpers/scoped_helper.rb +1 -3
  40. data/app/helpers/sites_helper.rb +4 -4
  41. data/app/mailers/devise_mailer.rb +3 -4
  42. data/app/mailers/rad_social_mailer.rb +8 -8
  43. data/app/models/asset.rb +62 -63
  44. data/app/models/asset_type.rb +38 -39
  45. data/app/models/deprecated_tags.rb +3 -4
  46. data/app/models/file_not_found_page.rb +1 -3
  47. data/app/models/haml_filter.rb +1 -1
  48. data/app/models/layout.rb +4 -5
  49. data/app/models/legacy_user.rb +2 -2
  50. data/app/models/menu_renderer.rb +16 -18
  51. data/app/models/page.rb +96 -93
  52. data/app/models/page_attachment.rb +1 -2
  53. data/app/models/page_context.rb +11 -12
  54. data/app/models/page_part.rb +3 -4
  55. data/app/models/rails_page.rb +10 -12
  56. data/app/models/site.rb +22 -21
  57. data/app/models/snippet.rb +6 -8
  58. data/app/models/snippet_finder.rb +3 -3
  59. data/app/models/snippet_tags.rb +4 -4
  60. data/app/models/standard_tags.rb +258 -252
  61. data/app/models/status.rb +8 -8
  62. data/app/models/trusty_cms/config.rb +25 -25
  63. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  64. data/app/models/user.rb +15 -14
  65. data/app/models/user_action_observer.rb +3 -3
  66. data/app/views/admin/assets/edit.html.haml +0 -9
  67. data/app/views/admin/assets/new.html.haml +0 -3
  68. data/app/views/admin/assets/remove.html.haml +1 -1
  69. data/app/views/admin/layouts/remove.html.haml +4 -3
  70. data/app/views/admin/page_parts/_page_part.html.haml +1 -1
  71. data/app/views/admin/pages/remove.html.haml +2 -1
  72. data/app/views/admin/sites/index.haml +3 -1
  73. data/app/views/admin/snippets/remove.html.haml +5 -4
  74. data/app/views/admin/users/remove.html.haml +2 -2
  75. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  76. data/app/views/widget/_email_form.html.haml +0 -5
  77. data/bin/rails +4 -4
  78. data/bin/trusty_cms +3 -5
  79. data/config.ru +1 -1
  80. data/config/application.rb +14 -15
  81. data/config/boot.rb +1 -2
  82. data/config/environment.rb +1 -1
  83. data/config/environments/production.rb +0 -1
  84. data/config/environments/test.rb +1 -2
  85. data/config/initializers/devise.rb +1 -1
  86. data/config/initializers/kraken.rb +2 -2
  87. data/config/initializers/tmp.rb +1 -1
  88. data/config/initializers/trusty_cms_config.rb +48 -48
  89. data/config/locales/en.yml +8 -8
  90. data/config/routes.rb +6 -7
  91. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  92. data/lib/annotatable.rb +3 -5
  93. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  94. data/lib/inheritable_class_attributes.rb +13 -9
  95. data/lib/login_system.rb +73 -73
  96. data/lib/method_observer.rb +13 -12
  97. data/lib/ostruct.rb +7 -10
  98. data/lib/simpleton.rb +0 -4
  99. data/lib/string_extensions/string_extensions.rb +3 -3
  100. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  101. data/lib/tasks/database.rake +28 -28
  102. data/lib/tasks/extensions.rake +18 -18
  103. data/lib/tasks/framework.rake +68 -68
  104. data/lib/tasks/radiant_config.rake +4 -4
  105. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  106. data/lib/tasks/translate.rake +14 -14
  107. data/lib/tasks/upgrade_to_devise.rake +1 -1
  108. data/lib/translation_support.rb +22 -22
  109. data/lib/trusty_cms.rb +2 -2
  110. data/lib/trusty_cms/admin_ui.rb +19 -16
  111. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  112. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  113. data/lib/trusty_cms/available_locales.rb +2 -4
  114. data/lib/trusty_cms/config/definition.rb +11 -8
  115. data/lib/trusty_cms/engine.rb +13 -14
  116. data/lib/trusty_cms/extension.rb +14 -16
  117. data/lib/trusty_cms/extension_loader.rb +6 -6
  118. data/lib/trusty_cms/extension_migrator.rb +42 -41
  119. data/lib/trusty_cms/extension_path.rb +20 -19
  120. data/lib/trusty_cms/initializer.rb +5 -8
  121. data/lib/trusty_cms/pagination/controller.rb +7 -10
  122. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  123. data/lib/trusty_cms/resource_responses.rb +3 -3
  124. data/lib/trusty_cms/setup.rb +130 -132
  125. data/lib/trusty_cms/taggable.rb +19 -22
  126. data/lib/trusty_cms/task_support.rb +9 -6
  127. data/package.json +1 -1
  128. data/public/dispatch.fcgi +1 -1
  129. data/public/dispatch.rb +2 -2
  130. data/script/extension +1 -1
  131. data/script/rails +2 -2
  132. data/spec/dummy/package.json +1 -1
  133. data/spec/dummy/yarn.lock +3 -3
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  135. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  136. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  137. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  138. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  139. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  140. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  141. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  142. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  143. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  144. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  145. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  146. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  147. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  149. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  150. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  151. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  152. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  153. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  154. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  155. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  156. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  157. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  158. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  159. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  160. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  161. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  162. data/trusty_cms.gemspec +25 -25
  163. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
  164. data/yarn.lock +7 -7
  165. metadata +7609 -105
  166. data/app/assets/javascripts/rad_social/captcha.js +0 -42
  167. data/app/views/admin/assets/refresh.html.haml +0 -14
@@ -317,4 +317,4 @@ class GemBoot < Boot
317
317
  def load_error_message
318
318
  "Have you run `bundle install`?'."
319
319
  end
320
- end
320
+ end
@@ -20,26 +20,26 @@ module InheritableClassAttributes
20
20
 
21
21
  def cattr_inheritable_reader(*symbols)
22
22
  symbols.each do |symbol|
23
- self.inheritable_cattr_readers << symbol
24
- self.module_eval %{
23
+ inheritable_cattr_readers << symbol
24
+ module_eval %{
25
25
  def self.#{symbol}
26
26
  @#{symbol}
27
27
  end
28
28
  }
29
29
  end
30
- self.inheritable_cattr_readers.uniq!
30
+ inheritable_cattr_readers.uniq!
31
31
  end
32
32
 
33
33
  def cattr_inheritable_writer(*symbols)
34
34
  symbols.each do |symbol|
35
- self.inheritable_cattr_writers << symbol
36
- self.module_eval %{
35
+ inheritable_cattr_writers << symbol
36
+ module_eval %{
37
37
  def self.#{symbol}=(value)
38
38
  @#{symbol} = value
39
39
  end
40
40
  }
41
41
  end
42
- self.inheritable_cattr_writers.uniq!
42
+ inheritable_cattr_writers.uniq!
43
43
  end
44
44
 
45
45
  def cattr_inheritable_accessor(*symbols)
@@ -52,12 +52,16 @@ module InheritableClassAttributes
52
52
 
53
53
  readers = inheritable_cattr_readers.dup
54
54
  writers = inheritable_cattr_writers.dup
55
- inheritables = [:inheritable_cattr_readers, :inheritable_cattr_writers]
55
+ inheritables = %i[inheritable_cattr_readers inheritable_cattr_writers]
56
56
 
57
57
  (readers + writers + inheritables).uniq.each do |attr|
58
58
  var = "@#{attr}"
59
- old_value = self.module_eval(var)
60
- new_value = (old_value.dup rescue old_value)
59
+ old_value = module_eval(var)
60
+ new_value = (begin
61
+ old_value.dup
62
+ rescue StandardError
63
+ old_value
64
+ end)
61
65
  klass.module_eval("#{var} = new_value")
62
66
  end
63
67
  end
@@ -2,93 +2,94 @@ module LoginSystem
2
2
  def self.included(base)
3
3
  base.extend ClassMethods
4
4
  base.class_eval do
5
- #prepend_before_action :authenticate
6
- #prepend_before_action :authorize
7
- #helper_method :current_user
5
+ # prepend_before_action :authenticate
6
+ # prepend_before_action :authorize
7
+ # helper_method :current_user
8
8
  end
9
9
  end
10
10
 
11
11
  protected
12
12
 
13
- # def current_user
13
+ # def current_user
14
+ # end
15
+
16
+ # def current_user=(value=nil)
17
+ # if value && value.is_a?(User)
18
+ # @current_user = value
19
+ # session['user_id'] = value.id
20
+ # else
21
+ # @current_user = nil
22
+ # session['user_id'] = nil
23
+ # end
24
+ # @current_user
25
+ # end
26
+
27
+ def authenticate
28
+ # puts _process_action_callbacks.map(&:filter)
29
+ # if current_user
30
+ # session['user_id'] = current_user.id
31
+ # true
32
+ # else
33
+ # session[:return_to] = request.original_url
34
+ # respond_to do |format|
35
+ # format.html { redirect_to login_url }
36
+ # format.any(:xml,:json) { request_http_basic_authentication }
37
+ # end
38
+ # false
14
39
  # end
40
+ true
41
+ end
15
42
 
16
- # def current_user=(value=nil)
17
- # if value && value.is_a?(User)
18
- # @current_user = value
19
- # session['user_id'] = value.id
20
- # else
21
- # @current_user = nil
22
- # session['user_id'] = nil
43
+ def authorize
44
+ # puts _process_action_callbacks.map(&:filter)
45
+ # action = action_name.to_s.intern
46
+ # if user_has_access_to_action?(action)
47
+ # true
48
+ # else
49
+ # permissions = self.class.controller_permissions[action]
50
+ # flash[:error] = permissions[:denied_message] || 'Access denied.'
51
+ # respond_to do |format|
52
+ # format.html { redirect_to(permissions[:denied_url] || { :action => :index }) }
53
+ # format.any(:xml, :json) { head :forbidden }
23
54
  # end
24
- # @current_user
55
+ # false
25
56
  # end
57
+ true
58
+ end
26
59
 
27
- def authenticate
28
- #puts _process_action_callbacks.map(&:filter)
29
- # if current_user
30
- # session['user_id'] = current_user.id
31
- # true
32
- # else
33
- # session[:return_to] = request.original_url
34
- # respond_to do |format|
35
- # format.html { redirect_to login_url }
36
- # format.any(:xml,:json) { request_http_basic_authentication }
37
- # end
38
- # false
39
- # end
40
- true
41
- end
42
-
43
- def authorize
44
- #puts _process_action_callbacks.map(&:filter)
45
- # action = action_name.to_s.intern
46
- # if user_has_access_to_action?(action)
47
- # true
48
- # else
49
- # permissions = self.class.controller_permissions[action]
50
- # flash[:error] = permissions[:denied_message] || 'Access denied.'
51
- # respond_to do |format|
52
- # format.html { redirect_to(permissions[:denied_url] || { :action => :index }) }
53
- # format.any(:xml, :json) { head :forbidden }
54
- # end
55
- # false
56
- # end
57
- true
58
- end
59
-
60
- def user_has_access_to_action?(action)
61
- self.class.user_has_access_to_action?(current_user, action, self)
62
- end
60
+ def user_has_access_to_action?(action)
61
+ self.class.user_has_access_to_action?(current_user, action, self)
62
+ end
63
63
 
64
- def login_from_session
65
- User.unscoped.find(session['user_id']) rescue nil
66
- end
64
+ def login_from_session
65
+ User.unscoped.find(session['user_id'])
66
+ rescue StandardError
67
+ nil
68
+ end
67
69
 
68
- def login_from_cookie
69
- if !cookies[:session_token].blank? && user = User.find_by_session_token(cookies[:session_token]) # don't find by empty value
70
- user.remember_me
71
- set_session_cookie(user)
72
- user
73
- end
70
+ def login_from_cookie
71
+ if !cookies[:session_token].blank? && user = User.find_by_session_token(cookies[:session_token]) # don't find by empty value
72
+ user.remember_me
73
+ set_session_cookie(user)
74
+ user
74
75
  end
76
+ end
75
77
 
76
- def login_from_http
77
- if [Mime[:xml], Mime[:json]].include?(request.format)
78
- authenticate_with_http_basic do |user_name, password|
79
- User.authenticate(user_name, password)
80
- end
78
+ def login_from_http
79
+ if [Mime[:xml], Mime[:json]].include?(request.format)
80
+ authenticate_with_http_basic do |user_name, password|
81
+ User.authenticate(user_name, password)
81
82
  end
82
83
  end
84
+ end
83
85
 
84
- def set_session_cookie(user = current_user)
85
- cookies[:session_token] = { :value => user.session_token , :expires => (Time.now + ((TrustyCms::Config['session_timeout'].to_i)/86400).days).utc }
86
- end
86
+ def set_session_cookie(user = current_user)
87
+ cookies[:session_token] = { value: user.session_token, expires: (Time.now + (TrustyCms::Config['session_timeout'].to_i / 86400).days).utc }
88
+ end
87
89
 
88
90
  module ClassMethods
89
-
90
91
  def login_required?
91
- filter_chain.any? {|f| f.method == :authenticate || f.method == :authorize }
92
+ filter_chain.any? { |f| f.method == :authenticate || f.method == :authorize }
92
93
  end
93
94
 
94
95
  def login_required
@@ -99,7 +100,7 @@ module LoginSystem
99
100
 
100
101
  def only_allow_access_to(*args)
101
102
  options = {}
102
- options = args.pop.dup if args.last.kind_of?(Hash)
103
+ options = args.pop.dup if args.last.is_a?(Hash)
103
104
  options.symbolize_keys!
104
105
  actions = args.map { |a| a.to_s.intern }
105
106
  actions.each do |action|
@@ -108,16 +109,15 @@ module LoginSystem
108
109
  end
109
110
 
110
111
  def controller_permissions
111
- @controller_permissions ||= Hash.new { |h,k| h[k.to_s.intern] = Hash.new }
112
+ @controller_permissions ||= Hash.new { |h, k| h[k.to_s.intern] = Hash.new }
112
113
  end
113
114
 
114
- def user_has_access_to_action?(user, action, instance=new)
115
+ def user_has_access_to_action?(user, action, instance = new)
115
116
  permissions = controller_permissions[action.to_s.intern]
116
- case
117
- when allowed_roles = permissions[:when]
117
+ if allowed_roles = permissions[:when]
118
118
  allowed_roles = [allowed_roles].flatten
119
119
  user.present? ? allowed_roles.any? { |role| user.has_role?(role) } : false
120
- when condition_method = permissions[:if]
120
+ elsif condition_method = permissions[:if]
121
121
  instance.send(condition_method)
122
122
  else
123
123
  true
@@ -1,5 +1,4 @@
1
1
  class MethodObserver
2
-
3
2
  attr_reader :target
4
3
  attr_accessor :result
5
4
 
@@ -11,6 +10,7 @@ class MethodObserver
11
10
 
12
11
  def observe(target)
13
12
  raise ObserverCannotObserveTwiceError if @target
13
+
14
14
  @target = target
15
15
  make_observable(target)
16
16
  end
@@ -26,25 +26,26 @@ class MethodObserver
26
26
  end
27
27
 
28
28
  private
29
- def make_observable(target)
30
- methods_to_observe.each do |method|
31
- target.instance_eval %{
29
+
30
+ def make_observable(target)
31
+ methods_to_observe.each do |method|
32
+ target.instance_eval %{
32
33
  def #{method}(*args, &block)
33
- observer = #{self.class}.instances[#{self.object_id}]
34
+ observer = #{self.class}.instances[#{object_id}]
34
35
  observer.send(:before_#{method}, *args, &block) if observer.respond_to? :before_#{method}
35
36
  observer.result = super
36
37
  observer.send(:after_#{method}, *args, &block) if observer.respond_to? :after_#{method}
37
38
  observer.result
38
39
  end
39
40
  }
40
- end
41
41
  end
42
+ end
42
43
 
43
- def methods_to_observe
44
- (methods_for(:before) + methods_for(:after)).uniq
45
- end
44
+ def methods_to_observe
45
+ (methods_for(:before) + methods_for(:after)).uniq
46
+ end
46
47
 
47
- def methods_for(name)
48
- methods.grep(/^#{name}_/).map { |n| n.to_s.gsub(/^#{name}_/, '').intern }
49
- end
48
+ def methods_for(name)
49
+ methods.grep(/^#{name}_/).map { |n| n.to_s.gsub(/^#{name}_/, '').intern }
50
+ end
50
51
  end
@@ -2,22 +2,19 @@
2
2
  # See more here: http://stackoverflow.com/questions/39278864/openstruct-issue-with-ruby-2-3-1/39280374#39280374
3
3
 
4
4
  class OpenStruct
5
-
6
- def initialize(hash=nil)
5
+ def initialize(hash = nil)
7
6
  @table = {}
8
- if hash
9
- hash.each_pair do |k, v|
10
- k = k.to_sym
11
- @table[k] = v
12
- new_ostruct_member(k)
13
- end
7
+ hash&.each_pair do |k, v|
8
+ k = k.to_sym
9
+ @table[k] = v
10
+ new_ostruct_member(k)
14
11
  end
15
12
  end
16
13
 
17
14
  def modifiable
18
15
  begin
19
16
  @modifiable = true
20
- rescue
17
+ rescue StandardError
21
18
  raise RuntimeError, "can't modify frozen #{self.class}", caller(3)
22
19
  end
23
20
  @table
@@ -41,6 +38,7 @@ class OpenStruct
41
38
  if len != 1
42
39
  raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
43
40
  end
41
+
44
42
  modifiable[new_ostruct_member(mname)] = args[0]
45
43
  elsif len == 0
46
44
  @table[mid]
@@ -50,5 +48,4 @@ class OpenStruct
50
48
  raise err
51
49
  end
52
50
  end
53
-
54
51
  end
@@ -1,11 +1,9 @@
1
1
  module Simpleton
2
-
3
2
  def self.included(base)
4
3
  base.extend(ClassMethods)
5
4
  end
6
5
 
7
6
  module ClassMethods
8
-
9
7
  def instance(&block)
10
8
  @instance ||= new
11
9
  block.call(@instance) if block_given?
@@ -15,7 +13,5 @@ module Simpleton
15
13
  def method_missing(method, *args, &block)
16
14
  instance.respond_to?(method) ? instance.send(method, *args, &block) : super
17
15
  end
18
-
19
16
  end
20
-
21
17
  end
@@ -2,15 +2,15 @@ require 'stringex'
2
2
 
3
3
  class String
4
4
  def symbolize
5
- self.gsub(/[^A-Za-z0-9]+/, "_").gsub(/(^_+|_+$)/, "").underscore.to_sym
5
+ gsub(/[^A-Za-z0-9]+/, '_').gsub(/(^_+|_+$)/, '').underscore.to_sym
6
6
  end
7
7
 
8
8
  def titlecase
9
- self.gsub(/((?:^|\s)[a-z])/) { $1.to_s.upcase }
9
+ gsub(/((?:^|\s)[a-z])/) { $1.to_s.upcase }
10
10
  end
11
11
 
12
12
  def to_name(last_part = '')
13
- self.underscore.gsub('/', ' ').humanize.titlecase.gsub(/\s*#{last_part}$/, '')
13
+ underscore.gsub('/', ' ').humanize.titlecase.gsub(/\s*#{last_part}$/, '')
14
14
  end
15
15
 
16
16
  unless methods.include?('parameterize')
@@ -1,5 +1,5 @@
1
1
  class Symbol
2
2
  def symbolize
3
- self.to_s.symbolize
3
+ to_s.symbolize
4
4
  end
5
5
  end
@@ -1,44 +1,44 @@
1
1
  namespace :db do
2
- desc "Migrate schema to version 0 and back up again. WARNING: Destroys all data in tables!!"
3
- task :remigrate => :environment do
2
+ desc 'Migrate schema to version 0 and back up again. WARNING: Destroys all data in tables!!'
3
+ task remigrate: :environment do
4
4
  require 'highline/import'
5
- if ENV['OVERWRITE'].to_s.downcase == 'true' or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
5
+ if (ENV['OVERWRITE'].to_s.downcase == 'true') || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
6
6
 
7
7
  # Migrate downward
8
8
  ActiveRecord::Migrator.migrate("#{TRUSTY_CMS_ROOT}/db/migrate/", 0)
9
9
 
10
10
  # Migrate upward
11
- Rake::Task["db:migrate"].invoke
11
+ Rake::Task['db:migrate'].invoke
12
12
 
13
13
  # Dump the schema
14
- Rake::Task["db:schema:dump"].invoke
14
+ Rake::Task['db:schema:dump'].invoke
15
15
  else
16
- say "Task cancelled."
16
+ say 'Task cancelled.'
17
17
  exit
18
18
  end
19
19
  end
20
20
 
21
- task :remigrate => :environment do
21
+ task remigrate: :environment do
22
22
  require 'highline/import'
23
- if ENV['OVERWRITE'].to_s.downcase == 'true' or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
23
+ if (ENV['OVERWRITE'].to_s.downcase == 'true') || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
24
24
 
25
25
  # Migrate downward
26
26
  ActiveRecord::Migrator.migrate("#{TRUSTY_CMS_ROOT}/db/migrate/", 0)
27
27
 
28
28
  # Migrate upward
29
- Rake::Task["db:migrate"].invoke
29
+ Rake::Task['db:migrate'].invoke
30
30
 
31
31
  # Dump the schema
32
- Rake::Task["db:schema:dump"].invoke
32
+ Rake::Task['db:schema:dump'].invoke
33
33
  else
34
- say "Task cancelled."
34
+ say 'Task cancelled.'
35
35
  exit
36
36
  end
37
37
  end
38
38
 
39
- task :initialize => :environment do
39
+ task initialize: :environment do
40
40
  require 'highline/import'
41
- if ENV['OVERWRITE'].to_s.downcase == 'true' or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
41
+ if (ENV['OVERWRITE'].to_s.downcase == 'true') || agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
42
42
 
43
43
  # We need to erase and remove all existing trusty-cms tables, but we don't want to
44
44
  # assume that the administrator has access to drop and create the database.
@@ -48,21 +48,21 @@ namespace :db do
48
48
  ActiveRecord::Base.connection.tables.each do |table|
49
49
  ActiveRecord::Migration[5.2].drop_table table
50
50
  end
51
- Rake::Task["db:migrate"].invoke
51
+ Rake::Task['db:migrate'].invoke
52
52
  else
53
- say "Task cancelled."
53
+ say 'Task cancelled.'
54
54
  exit
55
55
  end
56
56
  end
57
57
 
58
- desc "Bootstrap your database for TrustyCms."
59
- task :bootstrap => :initialize do
58
+ desc 'Bootstrap your database for TrustyCms.'
59
+ task bootstrap: :initialize do
60
60
  require 'trusty_cms/setup'
61
61
  TrustyCms::Setup.bootstrap(
62
- :admin_name => ENV['ADMIN_NAME'],
63
- :admin_username => ENV['ADMIN_USERNAME'],
64
- :admin_password => ENV['ADMIN_PASSWORD'],
65
- :database_template => ENV['DATABASE_TEMPLATE']
62
+ admin_name: ENV['ADMIN_NAME'],
63
+ admin_username: ENV['ADMIN_USERNAME'],
64
+ admin_password: ENV['ADMIN_PASSWORD'],
65
+ database_template: ENV['DATABASE_TEMPLATE'],
66
66
  )
67
67
  puts %{
68
68
  Your TrustyCms application is ready to use. Run `rails s -e production` to
@@ -78,16 +78,16 @@ To add more extensions just add them to your Gemfile and run `bundle install`.
78
78
  }
79
79
  end
80
80
 
81
- desc "Migrate the database through all available migration scripts (looks for db/migrate/* in trusty-cms, in extensions and in your site) and update db/schema.rb by invoking db:schema:dump. Turn off output with VERBOSE=false."
82
- task :migrate => [:environment, 'db:migrate:trusty_cms', 'db:migrate:extensions'] do
83
- ActiveRecord::Migration[5.2].verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
84
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
81
+ desc 'Migrate the database through all available migration scripts (looks for db/migrate/* in trusty-cms, in extensions and in your site) and update db/schema.rb by invoking db:schema:dump. Turn off output with VERBOSE=false.'
82
+ task migrate: [:environment, 'db:migrate:trusty_cms', 'db:migrate:extensions'] do
83
+ ActiveRecord::Migration[5.2].verbose = ENV['VERBOSE'] ? ENV['VERBOSE'] == 'true' : true
84
+ Rake::Task['db:schema:dump'].invoke if ActiveRecord::Base.schema_format == :ruby
85
85
  end
86
86
 
87
87
  namespace :migrate do
88
- desc "Migrates the database through steps defined in the core trusty-cms distribution. Usual db:migrate options can apply."
89
- task :trusty_cms => :environment do
90
- ActiveRecord::Migration[5.2].verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
88
+ desc 'Migrates the database through steps defined in the core trusty-cms distribution. Usual db:migrate options can apply.'
89
+ task trusty_cms: :environment do
90
+ ActiveRecord::Migration[5.2].verbose = ENV['VERBOSE'] ? ENV['VERBOSE'] == 'true' : true
91
91
  Rake::Task['db:migrate'].invoke
92
92
  end
93
93
  end