trusty-cms 4.1.2 → 4.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +104 -104
- data/README.md +1 -1
- data/Rakefile +7 -7
- data/app/assets/javascripts/admin/assets.js +1 -1
- data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
- data/app/assets/javascripts/rad_social/rad_email.js +0 -1
- data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
- data/app/assets/stylesheets/admin/partials/_content.scss +1 -2
- data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
- 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 +12 -22
- 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/app/views/admin/assets/edit.html.haml +3 -0
- data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
- data/app/views/widget/_email_form.html.haml +0 -5
- 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/locales/en.yml +1 -0
- 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 +13 -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/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
- data/trusty_cms.gemspec +24 -24
- data/yarn.lock +3 -3
- metadata +7602 -103
- data/app/assets/javascripts/rad_social/captcha.js +0 -42
@@ -6,33 +6,30 @@ module TrustyCms
|
|
6
6
|
def configure_pagination
|
7
7
|
# unconfigured parameters remain at will_paginate defaults
|
8
8
|
# will_paginate controller options are not overridden by tag attribetus
|
9
|
-
WillPaginate::ViewHelpers.pagination_options[:param_name] = TrustyCms::Config[
|
10
|
-
WillPaginate::ViewHelpers.pagination_options[:per_page_param_name] = TrustyCms::Config[
|
9
|
+
WillPaginate::ViewHelpers.pagination_options[:param_name] = TrustyCms::Config['pagination.param_name'].to_sym unless TrustyCms::Config['pagination.param_name'].blank?
|
10
|
+
WillPaginate::ViewHelpers.pagination_options[:per_page_param_name] = TrustyCms::Config['pagination.per_page_param_name'].blank? ? :per_page : TrustyCms::Config['pagination.per_page_param_name'].to_sym
|
11
11
|
|
12
12
|
# will_paginate view options can be overridden by tag attributes
|
13
|
-
[
|
13
|
+
%i[class previous_label next_label inner_window outer_window separator container].each do |opt|
|
14
14
|
WillPaginate::ViewHelpers.pagination_options[opt] = TrustyCms::Config["pagination.#{opt}"] unless TrustyCms::Config["pagination.#{opt}"].blank?
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def pagination_parameters
|
19
19
|
{
|
20
|
-
:
|
21
|
-
:
|
20
|
+
page: params[WillPaginate::ViewHelpers.pagination_options[:param_name]] || 1,
|
21
|
+
per_page: params[WillPaginate::ViewHelpers.pagination_options[:per_page_param_name]] || TrustyCms::Config['pagination.per_page'] || 20,
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.included(base)
|
26
|
-
base.class_eval
|
26
|
+
base.class_eval do
|
27
27
|
helper_method :pagination_parameters
|
28
28
|
before_action :configure_pagination
|
29
|
-
|
29
|
+
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
33
|
end
|
37
34
|
|
38
35
|
|
@@ -23,10 +23,10 @@ module TrustyCms
|
|
23
23
|
linkclass = %{ class="#{attributes[:class]}"} if attributes[:class]
|
24
24
|
linkrel = %{ rel="#{attributes[:rel]}"} if attributes[:rel]
|
25
25
|
param_name = WillPaginate::ViewHelpers.pagination_options[:param_name]
|
26
|
-
%
|
26
|
+
%{<a href="#{@url_stem}?#{param_name}=#{page}"#{linkrel}#{linkclass}>#{text}</a>}
|
27
27
|
end
|
28
28
|
|
29
|
-
def page_span(
|
29
|
+
def page_span(_page, text, attributes = {})
|
30
30
|
%{<span class="#{attributes[:class]}">#{text}</span>}
|
31
31
|
end
|
32
32
|
end
|
@@ -39,7 +39,7 @@ module TrustyCms
|
|
39
39
|
lambda do
|
40
40
|
# Ruby 1.9.2 yields self in instance_eval... see https://gist.github.com/479572
|
41
41
|
# lambdas are as strict as methods in 1.9.x, making sure that the args match, Procs are not.
|
42
|
-
if RUBY_VERSION =~ /^1\.9/
|
42
|
+
if RUBY_VERSION =~ /^1\.9/ && proc.lambda? && (proc.arity != 1)
|
43
43
|
raise "You can only pass a proc ('Proc.new') or a lambda that takes exactly one arg (for self) to the wrap method."
|
44
44
|
end
|
45
45
|
|
@@ -51,7 +51,7 @@ module TrustyCms
|
|
51
51
|
class Collector < OpenStruct
|
52
52
|
def initialize
|
53
53
|
super
|
54
|
-
@table = Hash.new {|h,k| h[k] = Response.new }
|
54
|
+
@table = Hash.new { |h, k| h[k] = Response.new }
|
55
55
|
end
|
56
56
|
|
57
57
|
def initialize_copy(orig)
|
@@ -90,7 +90,7 @@ module TrustyCms
|
|
90
90
|
if block_given?
|
91
91
|
@publish_block = block
|
92
92
|
else
|
93
|
-
raise ArgumentError,
|
93
|
+
raise ArgumentError, 'Block required to publish' unless @publish_block
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
data/lib/trusty_cms/setup.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'highline'
|
2
|
+
require 'forwardable'
|
3
3
|
|
4
4
|
module TrustyCms
|
5
5
|
class Setup
|
6
|
-
|
7
6
|
class << self
|
8
7
|
def bootstrap(config)
|
9
8
|
setup = new
|
@@ -19,24 +18,24 @@ module TrustyCms
|
|
19
18
|
@admin = create_admin_user(config[:admin_name], config[:admin_username], config[:admin_password])
|
20
19
|
load_default_configuration
|
21
20
|
# load_database_template(config[:database_template])
|
22
|
-
announce
|
21
|
+
announce 'Finished.'
|
23
22
|
end
|
24
23
|
|
25
24
|
def create_admin_user(name, username, password)
|
26
|
-
unless name
|
27
|
-
announce
|
28
|
-
name
|
29
|
-
username
|
30
|
-
password
|
25
|
+
unless name && username && password
|
26
|
+
announce 'Create the admin user (press enter for defaults).'
|
27
|
+
name ||= prompt_for_admin_name
|
28
|
+
username ||= prompt_for_admin_username
|
29
|
+
password ||= prompt_for_admin_password
|
31
30
|
end
|
32
31
|
attributes = {
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
32
|
+
name: name,
|
33
|
+
login: username,
|
34
|
+
password: password,
|
35
|
+
password_confirmation: password,
|
37
36
|
}
|
38
37
|
admin = User.find_by(login: username)
|
39
|
-
admin
|
38
|
+
admin ||= User.new
|
40
39
|
admin.update_attributes(attributes)
|
41
40
|
admin.admin = true
|
42
41
|
admin.save
|
@@ -45,11 +44,11 @@ module TrustyCms
|
|
45
44
|
|
46
45
|
def load_default_configuration
|
47
46
|
feedback "\nInitializing configuration" do
|
48
|
-
step { TrustyCms::Config['admin.title'
|
47
|
+
step { TrustyCms::Config['admin.title'] = 'TrustyCms CMS' }
|
49
48
|
step { TrustyCms::Config['admin.subtitle'] = 'Publishing for Small Teams' }
|
50
|
-
step { TrustyCms::Config['defaults.page.parts'
|
51
|
-
step { TrustyCms::Config['defaults.page.status'
|
52
|
-
step { TrustyCms::Config['defaults.page.filter'
|
49
|
+
step { TrustyCms::Config['defaults.page.parts'] = 'body, extended' }
|
50
|
+
step { TrustyCms::Config['defaults.page.status'] = 'Draft' }
|
51
|
+
step { TrustyCms::Config['defaults.page.filter'] = nil }
|
53
52
|
step { TrustyCms::Config['defaults.page.fields'] = 'Keywords, Description' }
|
54
53
|
step { TrustyCms::Config['session_timeout'] = 2.weeks }
|
55
54
|
step { TrustyCms::Config['default_locale'] = 'en' }
|
@@ -60,11 +59,11 @@ module TrustyCms
|
|
60
59
|
template = nil
|
61
60
|
if filename
|
62
61
|
name = find_template_in_path(filename)
|
63
|
-
|
62
|
+
if name
|
63
|
+
template = load_template_file(name)
|
64
|
+
else
|
64
65
|
announce "Invalid template name: #{filename}"
|
65
66
|
filename = nil
|
66
|
-
else
|
67
|
-
template = load_template_file(name)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
unless filename
|
@@ -88,141 +87,140 @@ module TrustyCms
|
|
88
87
|
|
89
88
|
private
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
97
|
-
username = "Administrator" if username.blank?
|
98
|
-
username
|
90
|
+
def prompt_for_admin_name
|
91
|
+
username = ask('Name (Administrator): ', String) do |q|
|
92
|
+
q.validate = /^.{0,100}$/
|
93
|
+
q.responses[:not_valid] = 'Invalid name. Must be under 100 characters long.'
|
94
|
+
q.whitespace = :strip
|
99
95
|
end
|
96
|
+
username = 'Administrator' if username.blank?
|
97
|
+
username
|
98
|
+
end
|
100
99
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
username = "admin" if username.blank?
|
108
|
-
username
|
100
|
+
def prompt_for_admin_username
|
101
|
+
username = ask('Username (admin): ', String) do |q|
|
102
|
+
q.validate = /^(|.{3,40})$/
|
103
|
+
q.responses[:not_valid] = 'Invalid username. Must be at least 3 characters long.'
|
104
|
+
q.whitespace = :strip
|
109
105
|
end
|
106
|
+
username = 'admin' if username.blank?
|
107
|
+
username
|
108
|
+
end
|
110
109
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
password = default_password if password.blank?
|
120
|
-
password
|
110
|
+
def prompt_for_admin_password
|
111
|
+
default_password = 'trusty'
|
112
|
+
password = ask("Password (#{default_password}): ", String) do |q|
|
113
|
+
q.echo = false unless defined?(::JRuby) # JRuby doesn't support stty interaction
|
114
|
+
q.validate = /^(|.{5,40})$/
|
115
|
+
q.responses[:not_valid] = 'Invalid password. Must be at least 5 characters long.'
|
116
|
+
q.whitespace = :strip
|
121
117
|
end
|
118
|
+
password = default_password if password.blank?
|
119
|
+
password
|
120
|
+
end
|
122
121
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
122
|
+
def find_template_in_path(filename)
|
123
|
+
(
|
124
|
+
[
|
125
|
+
filename,
|
126
|
+
"#{TRUSTY_CMS_ROOT}/#{filename}",
|
127
|
+
"#{TRUSTY_CMS_ROOT}/db/templates/#{filename}",
|
128
|
+
"#{Rails.root}/#{filename}",
|
129
|
+
"#{Rails.root}/db/templates/#{filename}",
|
130
|
+
"#{Dir.pwd}/#{filename}",
|
131
|
+
"#{Dir.pwd}/db/templates/#{filename}",
|
132
|
+
] +
|
133
|
+
Dir.glob("#{TRUSTY_CMS_ROOT}/vendor/extensions/**/db/templates/#{filename}") +
|
134
|
+
Dir.glob("#{Rails.root}/vendor/extensions/**/db/templates/#{filename}") +
|
135
|
+
TrustyCms::Extension.descendants.inject([]) do |r, d|
|
136
|
+
r << "#{d.root}/db/templates/#{filename}"
|
137
|
+
end
|
138
|
+
).find { |name| File.file?(name) }
|
139
|
+
end
|
141
140
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
141
|
+
def find_and_load_templates(glob)
|
142
|
+
templates = Dir[glob]
|
143
|
+
templates.map! { |template| load_template_file(template) }
|
144
|
+
templates.sort_by { |template| template['name'] }
|
145
|
+
end
|
147
146
|
|
148
|
-
|
149
|
-
|
150
|
-
|
147
|
+
def load_template_file(filename)
|
148
|
+
YAML.load_file(filename)
|
149
|
+
end
|
151
150
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
151
|
+
def create_records(template)
|
152
|
+
records = template['records']
|
153
|
+
if records
|
154
|
+
puts
|
155
|
+
records.keys.each do |key|
|
156
|
+
feedback "Creating #{key.to_s.underscore.humanize}" do
|
157
|
+
model = model(key)
|
158
|
+
model.reset_column_information
|
159
|
+
record_pairs = order_by_id(records[key])
|
160
|
+
step do
|
161
|
+
record_pairs.each do |_id, record|
|
162
|
+
model.new(record).save
|
165
163
|
end
|
166
164
|
end
|
167
165
|
end
|
168
166
|
end
|
169
167
|
end
|
168
|
+
end
|
170
169
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
def order_by_id(records)
|
176
|
-
records.map { |name, record| [record['id'], record] }.sort { |a, b| a[0] <=> b[0] }
|
177
|
-
end
|
170
|
+
def model(model_name)
|
171
|
+
model_name.to_s.singularize.constantize
|
172
|
+
end
|
178
173
|
|
179
|
-
|
180
|
-
|
174
|
+
def order_by_id(records)
|
175
|
+
records.map { |_name, record| [record['id'], record] }.sort { |a, b| a[0] <=> b[0] }
|
176
|
+
end
|
181
177
|
|
182
|
-
|
183
|
-
|
184
|
-
end
|
178
|
+
extend Forwardable
|
179
|
+
def_delegators :terminal, :agree, :ask, :choose, :say
|
185
180
|
|
186
|
-
|
187
|
-
|
188
|
-
|
181
|
+
def terminal
|
182
|
+
@terminal ||= HighLine.new
|
183
|
+
end
|
189
184
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
185
|
+
def output
|
186
|
+
terminal.instance_variable_get('@output')
|
187
|
+
end
|
194
188
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
189
|
+
def wrap(string)
|
190
|
+
string = terminal.send(:wrap, string) unless terminal.wrap_at.nil?
|
191
|
+
string
|
192
|
+
end
|
199
193
|
|
200
|
-
|
201
|
-
|
202
|
-
|
194
|
+
def print(string)
|
195
|
+
output.print(wrap(string))
|
196
|
+
output.flush
|
197
|
+
end
|
203
198
|
|
204
|
-
|
205
|
-
|
206
|
-
|
199
|
+
def puts(string = "\n")
|
200
|
+
say string
|
201
|
+
end
|
207
202
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
puts "OK"
|
212
|
-
true
|
213
|
-
else
|
214
|
-
puts "FAILED"
|
215
|
-
false
|
216
|
-
end
|
217
|
-
rescue Exception => e
|
218
|
-
puts "FAILED"
|
219
|
-
raise e
|
220
|
-
end
|
203
|
+
def announce(string)
|
204
|
+
puts "\n#{string}"
|
205
|
+
end
|
221
206
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
207
|
+
def feedback(process)
|
208
|
+
print "#{process}..."
|
209
|
+
if yield
|
210
|
+
puts 'OK'
|
211
|
+
true
|
212
|
+
else
|
213
|
+
puts 'FAILED'
|
214
|
+
false
|
215
|
+
end
|
216
|
+
rescue Exception => e
|
217
|
+
puts 'FAILED'
|
218
|
+
raise e
|
219
|
+
end
|
226
220
|
|
221
|
+
def step
|
222
|
+
yield if block_given?
|
223
|
+
print '.'
|
224
|
+
end
|
227
225
|
end
|
228
226
|
end
|
data/lib/trusty_cms/taggable.rb
CHANGED
@@ -13,20 +13,21 @@ module TrustyCms::Taggable
|
|
13
13
|
end
|
14
14
|
class << new_base
|
15
15
|
def default_url_options
|
16
|
-
{:
|
16
|
+
{ controller: 'site', action: 'show_page', only_path: true }
|
17
17
|
end
|
18
18
|
end
|
19
|
-
new_base.tag_descriptions.merge!
|
19
|
+
new_base.tag_descriptions.merge! tag_descriptions
|
20
20
|
end
|
21
21
|
|
22
22
|
protected
|
23
|
-
def params
|
24
|
-
@params ||= request.parameters unless request.nil?
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def params
|
25
|
+
@params ||= request.parameters unless request.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def request_uri
|
29
|
+
@request_url ||= request.request_uri unless request.nil?
|
30
|
+
end
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -44,11 +45,11 @@ module TrustyCms::Taggable
|
|
44
45
|
Util.tags_in_array(methods)
|
45
46
|
end
|
46
47
|
|
47
|
-
def tag_descriptions(hash=nil)
|
48
|
+
def tag_descriptions(hash = nil)
|
48
49
|
self.class.tag_descriptions hash
|
49
50
|
end
|
50
51
|
|
51
|
-
def warn_of_tag_deprecation(tag_name, options={})
|
52
|
+
def warn_of_tag_deprecation(tag_name, options = {})
|
52
53
|
message = "Deprecated radius tag <r:#{tag_name}>"
|
53
54
|
message << " will be removed or significantly changed in trusty #{options[:deadline]}." if options[:deadline]
|
54
55
|
message << " Please use <r:#{options[:substitute]}> instead." if options[:substitute]
|
@@ -57,12 +58,12 @@ module TrustyCms::Taggable
|
|
57
58
|
|
58
59
|
module ClassMethods
|
59
60
|
def inherited(subclass)
|
60
|
-
subclass.tag_descriptions.reverse_merge!
|
61
|
+
subclass.tag_descriptions.reverse_merge! tag_descriptions
|
61
62
|
super
|
62
63
|
end
|
63
64
|
|
64
65
|
def tag_descriptions(hash = nil)
|
65
|
-
TrustyCms::Taggable.tag_descriptions[
|
66
|
+
TrustyCms::Taggable.tag_descriptions[name] ||= (hash || {})
|
66
67
|
end
|
67
68
|
|
68
69
|
def desc(text)
|
@@ -71,13 +72,13 @@ module TrustyCms::Taggable
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def tag(name, &block)
|
74
|
-
|
75
|
+
tag_descriptions[name] = TrustyCms::Taggable.last_description if TrustyCms::Taggable.last_description
|
75
76
|
TrustyCms::Taggable.last_description = nil
|
76
77
|
define_method("tag:#{name}", &block)
|
77
78
|
end
|
78
79
|
|
79
80
|
def tags
|
80
|
-
Util.tags_in_array(
|
81
|
+
Util.tags_in_array(instance_methods)
|
81
82
|
end
|
82
83
|
|
83
84
|
# Define a tag while also deprecating it. Normal usage:
|
@@ -98,7 +99,7 @@ module TrustyCms::Taggable
|
|
98
99
|
# raise TagError "..."
|
99
100
|
# end
|
100
101
|
#
|
101
|
-
def deprecated_tag(name, options={}, &dblock)
|
102
|
+
def deprecated_tag(name, options = {}, &dblock)
|
102
103
|
TrustyCms::Taggable.tag_deprecations[name] = options.dup
|
103
104
|
if dblock
|
104
105
|
tag(name) do |tag|
|
@@ -121,18 +122,14 @@ module TrustyCms::Taggable
|
|
121
122
|
|
122
123
|
def self.strip_leading_whitespace(text)
|
123
124
|
text = text.dup
|
124
|
-
text.gsub!("\t",
|
125
|
+
text.gsub!("\t", ' ')
|
125
126
|
lines = text.split("\n")
|
126
127
|
leading = lines.map do |line|
|
127
128
|
unless line =~ /^\s*$/
|
128
|
-
|
129
|
-
else
|
130
|
-
nil
|
129
|
+
line.match(/^(\s*)/)[0].length
|
131
130
|
end
|
132
131
|
end.compact.min
|
133
|
-
lines.inject([]) {|ary, line| ary << line.sub(/^[ ]{#{leading}}/,
|
132
|
+
lines.inject([]) { |ary, line| ary << line.sub(/^[ ]{#{leading}}/, '') }.join("\n")
|
134
133
|
end
|
135
|
-
|
136
134
|
end
|
137
|
-
|
138
135
|
end
|