trusty-cms 4.1.1 → 4.1.6
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 +107 -107
- 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/_forms.scss +1 -1
- data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
- data/app/controllers/admin/assets_controller.rb +21 -31
- 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 -9
- data/app/views/admin/assets/new.html.haml +0 -3
- data/app/views/admin/assets/remove.html.haml +1 -1
- data/app/views/admin/layouts/remove.html.haml +3 -2
- data/app/views/admin/page_parts/_page_part.html.haml +1 -1
- data/app/views/admin/snippets/remove.html.haml +3 -2
- 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 +5 -4
- data/config/routes.rb +6 -7
- 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/package.json +1 -1
- data/public/dispatch.fcgi +1 -1
- data/public/dispatch.rb +2 -2
- data/script/extension +1 -1
- data/script/rails +2 -2
- data/spec/dummy/package.json +1 -1
- data/spec/dummy/yarn.lock +3 -3
- 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 +25 -25
- data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
- data/yarn.lock +7 -7
- metadata +7609 -105
- data/app/assets/javascripts/rad_social/captcha.js +0 -42
- data/app/views/admin/assets/refresh.html.haml +0 -14
data/lib/tasks/extensions.rake
CHANGED
@@ -2,20 +2,20 @@ require 'rake/testtask'
|
|
2
2
|
|
3
3
|
namespace :db do
|
4
4
|
namespace :migrate do
|
5
|
-
desc
|
6
|
-
task :
|
5
|
+
desc 'Run all TrustyCms extension migrations'
|
6
|
+
task extensions: :environment do
|
7
7
|
require 'trusty_cms/extension_migrator'
|
8
8
|
TrustyCms::ExtensionMigrator.migrate_extensions
|
9
9
|
Rake::Task['db:schema:dump'].invoke
|
10
10
|
end
|
11
11
|
end
|
12
12
|
namespace :remigrate do
|
13
|
-
desc
|
14
|
-
task :
|
13
|
+
desc 'Migrate down and back up all TrustyCms extension migrations'
|
14
|
+
task extensions: :environment do
|
15
15
|
require 'highline/import'
|
16
16
|
if agree("This task will destroy any data stored by extensions in the database. Are you sure you want to \ncontinue? [yn] ")
|
17
17
|
require 'trusty_cms/extension_migrator'
|
18
|
-
TrustyCms::Extension.descendants.each {|ext| ext.migrator.migrate(0) }
|
18
|
+
TrustyCms::Extension.descendants.each { |ext| ext.migrator.migrate(0) }
|
19
19
|
Rake::Task['db:migrate:extensions'].invoke
|
20
20
|
Rake::Task['db:schema:dump'].invoke
|
21
21
|
end
|
@@ -24,13 +24,13 @@ namespace :db do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
namespace :test do
|
27
|
-
desc
|
28
|
-
task :
|
27
|
+
desc 'Runs tests on all available TrustyCms extensions, pass EXT=extension_name to test a single extension'
|
28
|
+
task extensions: 'db:test:prepare' do
|
29
29
|
extensions = TrustyCms.configuration.enabled_extensions
|
30
|
-
if ENV[
|
31
|
-
extensions = extensions & [ENV[
|
30
|
+
if ENV['EXT']
|
31
|
+
extensions = extensions & [ENV['EXT'].to_sym]
|
32
32
|
if extensions.empty?
|
33
|
-
puts
|
33
|
+
puts 'Sorry, that extension is not installed.'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
extensions.each do |extension|
|
@@ -49,13 +49,13 @@ namespace :test do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
namespace :spec do
|
52
|
-
desc
|
53
|
-
task :
|
52
|
+
desc 'Runs specs on all available TrustyCms extensions, pass EXT=extension_name to test a single extension'
|
53
|
+
task extensions: 'db:test:prepare' do
|
54
54
|
extensions = TrustyCms.configuration.enabled_extensions
|
55
|
-
if ENV[
|
56
|
-
extensions = extensions & [ENV[
|
55
|
+
if ENV['EXT']
|
56
|
+
extensions = extensions & [ENV['EXT'].to_sym]
|
57
57
|
if extensions.empty?
|
58
|
-
puts
|
58
|
+
puts 'Sorry, that extension is not installed.'
|
59
59
|
end
|
60
60
|
end
|
61
61
|
extensions.each do |extension|
|
@@ -76,10 +76,10 @@ end
|
|
76
76
|
|
77
77
|
namespace :trusty_cms do
|
78
78
|
namespace :extensions do
|
79
|
-
desc
|
80
|
-
task :
|
79
|
+
desc 'Runs update asset task for all extensions'
|
80
|
+
task update_all: [:environment] do
|
81
81
|
extension_update_tasks = TrustyCms.configuration.enabled_extensions.map { |n| "trusty_cms:extensions:#{n}:update" }.select { |t| Rake::Task.task_defined?(t) }
|
82
|
-
extension_update_tasks.each {|t| Rake::Task[t].invoke }
|
82
|
+
extension_update_tasks.each { |t| Rake::Task[t].invoke }
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/lib/tasks/framework.rake
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
unless File.directory? "#{Rails.root}/app"
|
3
3
|
namespace :trusty_cms do
|
4
4
|
namespace :freeze do
|
5
|
-
desc
|
5
|
+
desc 'Lock this application to the current gems (by unpacking them into vendor/trusty)'
|
6
6
|
task :gems do
|
7
7
|
require 'rubygems'
|
8
8
|
require 'rubygems/gem_runner'
|
9
9
|
|
10
10
|
trusty = (version = ENV['VERSION']) ?
|
11
11
|
Gem.cache.search('trusty-cms', "= #{version}").first :
|
12
|
-
Gem.cache.search('trusty-cms').
|
12
|
+
Gem.cache.search('trusty-cms').max_by { |g| g.version }
|
13
13
|
|
14
14
|
version ||= trusty.version
|
15
15
|
|
@@ -19,49 +19,48 @@ unless File.directory? "#{Rails.root}/app"
|
|
19
19
|
end
|
20
20
|
|
21
21
|
puts "Freezing to the gems for TrustyCms #{trusty.version}"
|
22
|
-
rm_rf
|
22
|
+
rm_rf 'vendor/trusty'
|
23
23
|
|
24
|
-
chdir(
|
25
|
-
Gem::GemRunner.new.run([
|
26
|
-
FileUtils.mv(Dir.glob(
|
24
|
+
chdir('vendor') do
|
25
|
+
Gem::GemRunner.new.run(['unpack', 'trusty', '--version', "=#{version}"])
|
26
|
+
FileUtils.mv(Dir.glob('trusty*').first, 'trusty')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
desc
|
30
|
+
desc 'Lock to latest Edge TrustyCms or a specific revision with REVISION=X (ex: REVISION=245484e), a tag with TAG=Y (ex: TAG=0.6.6), or a branch with BRANCH=Z (ex: BRANCH=mental)'
|
31
31
|
task :edge do
|
32
32
|
$verbose = false
|
33
|
-
unless system
|
34
|
-
|
33
|
+
unless system 'git --version'
|
34
|
+
warn 'ERROR: Must have git available in the PATH to lock this application to Edge TrustyCms'
|
35
35
|
exit 1
|
36
36
|
end
|
37
37
|
|
38
|
-
trusty_git =
|
38
|
+
trusty_git = 'git://github.com/pgharts/trusty-cms.git'
|
39
39
|
|
40
|
-
if File.exist?(
|
41
|
-
cd(
|
40
|
+
if File.exist?('vendor/trusty_cms/.git/HEAD')
|
41
|
+
cd('vendor/trusty') { system 'git checkout master'; system 'git pull origin master' }
|
42
42
|
else
|
43
43
|
system "git clone #{trusty_git} vendor/trusty"
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
cd("vendor/trusty") { system "git checkout -b REV_#{ENV['REVISION']} #{ENV['REVISION']}"}
|
46
|
+
if ENV['TAG']
|
47
|
+
cd('vendor/trusty') { system "git checkout -b v#{ENV['TAG']} #{ENV['TAG']}" }
|
48
|
+
elsif ENV['BRANCH']
|
49
|
+
cd('vendor/trusty') { system "git checkout --track -b #{ENV['BRANCH']} origin/#{ENV['BRANCH']}" }
|
50
|
+
elsif ENV['REVISION']
|
51
|
+
cd('vendor/trusty') { system "git checkout -b REV_#{ENV['REVISION']} #{ENV['REVISION']}" }
|
53
52
|
end
|
54
53
|
|
55
|
-
cd(
|
54
|
+
cd('vendor/trusty') { system 'git submodule update --init' }
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
desc
|
58
|
+
desc 'Unlock this application from freeze of gems or edge and return to a fluid use of system gems'
|
60
59
|
task :unfreeze do
|
61
|
-
rm_rf
|
60
|
+
rm_rf 'vendor/trusty'
|
62
61
|
end
|
63
62
|
|
64
|
-
desc
|
63
|
+
desc 'Update configs, scripts, html, images, sass, stylesheets and javascripts from TrustyCms.'
|
65
64
|
task :update do
|
66
65
|
tasks = %w{scripts javascripts configs static_html images sass stylesheets cached_assets bundle}
|
67
66
|
tasks = tasks & ENV['ONLY'].split(',') if ENV['ONLY']
|
@@ -74,9 +73,9 @@ unless File.directory? "#{Rails.root}/app"
|
|
74
73
|
end
|
75
74
|
|
76
75
|
namespace :update do
|
77
|
-
desc
|
76
|
+
desc 'Add new scripts to the instance script/ directory'
|
78
77
|
task :scripts do
|
79
|
-
local_base =
|
78
|
+
local_base = 'script'
|
80
79
|
edge_base = "#{File.dirname(__FILE__)}/../../script"
|
81
80
|
|
82
81
|
local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) }
|
@@ -84,33 +83,34 @@ unless File.directory? "#{Rails.root}/app"
|
|
84
83
|
edge = edge.reject { |f| f =~ /(generate|plugin|destroy)$/ }
|
85
84
|
|
86
85
|
edge.each do |script|
|
87
|
-
base_name = script[(edge_base.length+1)..-1]
|
88
|
-
next if local.detect { |path| base_name == path[(local_base.length+1)..-1] }
|
86
|
+
base_name = script[(edge_base.length + 1)..-1]
|
87
|
+
next if local.detect { |path| base_name == path[(local_base.length + 1)..-1] }
|
88
|
+
|
89
89
|
if !File.directory?("#{local_base}/#{File.dirname(base_name)}")
|
90
90
|
mkdir_p "#{local_base}/#{File.dirname(base_name)}"
|
91
91
|
end
|
92
|
-
install script, "#{local_base}/#{base_name}", :
|
92
|
+
install script, "#{local_base}/#{base_name}", mode: 0o755
|
93
93
|
end
|
94
|
-
install "#{File.dirname(__FILE__)}/../generators/instance/templates/instance_generate", "#{local_base}/generate", :
|
94
|
+
install "#{File.dirname(__FILE__)}/../generators/instance/templates/instance_generate", "#{local_base}/generate", mode: 0o755
|
95
95
|
end
|
96
96
|
|
97
|
-
desc
|
97
|
+
desc 'Update your javascripts from your current trusty install'
|
98
98
|
task :javascripts do
|
99
99
|
FileUtils.mkdir_p("#{Rails.root}/public/javascripts/admin/")
|
100
100
|
copy_javascripts = proc do |project_dir, scripts|
|
101
|
-
scripts.reject!{|s| File.basename(s) == 'overrides.js'} if File.exists?(project_dir + 'overrides.js')
|
101
|
+
scripts.reject! { |s| File.basename(s) == 'overrides.js' } if File.exists?(project_dir + 'overrides.js')
|
102
102
|
FileUtils.cp(scripts, project_dir)
|
103
103
|
end
|
104
104
|
copy_javascripts[Rails.root + '/public/javascripts/', Dir["#{File.dirname(__FILE__)}/../../public/javascripts/*.js"]]
|
105
105
|
copy_javascripts[Rails.root + '/public/javascripts/admin/', Dir["#{File.dirname(__FILE__)}/../../public/javascripts/admin/*.js"]]
|
106
106
|
end
|
107
107
|
|
108
|
-
desc
|
108
|
+
desc 'Update the cached assets for the admin UI'
|
109
109
|
task :cached_assets do
|
110
110
|
TrustyCms::TaskSupport.cache_admin_js
|
111
111
|
end
|
112
112
|
|
113
|
-
desc
|
113
|
+
desc 'Update Gemfile from your current trusty install, backing up if required.'
|
114
114
|
task :bundle do
|
115
115
|
require 'erb'
|
116
116
|
file = "#{Rails.root}/Gemfile"
|
@@ -123,7 +123,7 @@ unless File.directory? "#{Rails.root}/app"
|
|
123
123
|
'mysql2' => 'mysql2',
|
124
124
|
'pg' => 'postgresql',
|
125
125
|
'db2' => 'db2',
|
126
|
-
'activerecord-sqlserver-adapter' => 'sqlserver'
|
126
|
+
'activerecord-sqlserver-adapter' => 'sqlserver',
|
127
127
|
}
|
128
128
|
active_db_gem = db_gems.keys.find { |g| Gem.loaded_specs[g] } || 'sqlite3'
|
129
129
|
|
@@ -134,7 +134,7 @@ unless File.directory? "#{Rails.root}/app"
|
|
134
134
|
end
|
135
135
|
|
136
136
|
unless File.exist?(file) && FileUtils.compare_file(file, tmpfile)
|
137
|
-
warning =
|
137
|
+
warning = ''
|
138
138
|
if File.exist?(file)
|
139
139
|
FileUtils.cp(file, backfile)
|
140
140
|
warning << "** WARNING **
|
@@ -149,44 +149,44 @@ A Gemfile has been created in your application directory. If you have config.gem
|
|
149
149
|
puts warning
|
150
150
|
end
|
151
151
|
|
152
|
-
desc
|
152
|
+
desc 'Update configuration files from your current trusty install'
|
153
153
|
task :configs do
|
154
154
|
require 'erb'
|
155
155
|
instances = {
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
156
|
+
env: "#{Rails.root}/config/environment.rb",
|
157
|
+
development: "#{Rails.root}/config/environments/development.rb",
|
158
|
+
test: "#{Rails.root}/config/environments/test.rb",
|
159
|
+
cucumber: "#{Rails.root}/config/environments/cucumber.rb",
|
160
|
+
production: "#{Rails.root}/config/environments/production.rb",
|
161
161
|
}
|
162
162
|
tmps = {
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
166
|
-
:
|
167
|
-
:
|
163
|
+
env: "#{Rails.root}/config/environment.tmp",
|
164
|
+
development: "#{Rails.root}/config/environments/development.tmp",
|
165
|
+
test: "#{Rails.root}/config/environments/test.tmp",
|
166
|
+
cucumber: "#{Rails.root}/config/environments/cucumber.rb",
|
167
|
+
production: "#{Rails.root}/config/environments/production.tmp",
|
168
168
|
}
|
169
169
|
gens = {
|
170
|
-
:
|
171
|
-
:
|
172
|
-
:
|
173
|
-
:
|
174
|
-
:
|
170
|
+
env: "#{File.dirname(__FILE__)}/../generators/instance/templates/instance_environment.rb",
|
171
|
+
development: "#{File.dirname(__FILE__)}/../../config/environments/development.rb",
|
172
|
+
test: "#{File.dirname(__FILE__)}/../../config/environments/test.rb",
|
173
|
+
cucumber: "#{File.dirname(__FILE__)}/../../config/environments/cucumber.rb",
|
174
|
+
production: "#{File.dirname(__FILE__)}/../../config/environments/production.rb",
|
175
175
|
}
|
176
176
|
backups = {
|
177
|
-
:
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
181
|
-
:
|
177
|
+
env: "#{Rails.root}/config/environment.bak",
|
178
|
+
development: "#{Rails.root}/config/environments/development.bak",
|
179
|
+
test: "#{Rails.root}/config/environments/test.bak",
|
180
|
+
cucumber: "#{Rails.root}/config/environments/cucumber.bak",
|
181
|
+
production: "#{Rails.root}/config/environments/production.bak",
|
182
182
|
}
|
183
183
|
|
184
184
|
FileUtils.cp("#{File.dirname(__FILE__)}/../generators/instance/templates/instance_boot.rb", Rails.root + '/config/boot.rb')
|
185
185
|
FileUtils.cp("#{File.dirname(__FILE__)}/../../config/preinitializer.rb", Rails.root + '/config/preinitializer.rb')
|
186
|
-
warning =
|
187
|
-
[
|
186
|
+
warning = ''
|
187
|
+
%i[env development test cucumber production].each do |env_file|
|
188
188
|
File.open(tmps[env_file], 'w') do |f|
|
189
|
-
app_name
|
189
|
+
app_name = File.basename(File.expand_path(Rails.root))
|
190
190
|
trusty_version = TrustyCms::VERSION.to_s
|
191
191
|
f.write ERB.new(File.read(gens[env_file])).result(binding)
|
192
192
|
end
|
@@ -206,14 +206,14 @@ the new files: #{warning}"
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
|
-
desc
|
209
|
+
desc 'Update static HTML files from your current trusty install'
|
210
210
|
task :static_html do
|
211
|
-
project_dir = Rails.root +
|
211
|
+
project_dir = Rails.root + '/public/'
|
212
212
|
html_files = Dir["#{File.dirname(__FILE__)}/../../public/*.html"].delete_if { |f| f =~ /404.html|500.html/ }
|
213
213
|
FileUtils.cp(html_files, project_dir)
|
214
214
|
end
|
215
215
|
|
216
|
-
desc
|
216
|
+
desc 'Update admin and trusty images from your current trusty install'
|
217
217
|
task :images do
|
218
218
|
%w{admin trusty}.each do |d|
|
219
219
|
project_dir = Rails.root + "/public/images/#{d}/"
|
@@ -223,22 +223,22 @@ the new files: #{warning}"
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
-
desc
|
226
|
+
desc 'Update admin stylesheets from your current trusty install'
|
227
227
|
task :stylesheets do
|
228
228
|
project_dir = Rails.root + '/public/stylesheets/admin/'
|
229
229
|
|
230
230
|
copy_stylesheets = proc do |project_dir, styles|
|
231
|
-
styles.reject!{|s| File.basename(s) == 'overrides.css'} if File.exists?(project_dir + 'overrides.css')
|
231
|
+
styles.reject! { |s| File.basename(s) == 'overrides.css' } if File.exists?(project_dir + 'overrides.css')
|
232
232
|
FileUtils.cp(styles, project_dir)
|
233
233
|
end
|
234
|
-
copy_stylesheets[Rails.root + '/public/stylesheets/admin/',Dir["#{File.dirname(__FILE__)}/../../public/stylesheets/admin/*.css"]]
|
234
|
+
copy_stylesheets[Rails.root + '/public/stylesheets/admin/', Dir["#{File.dirname(__FILE__)}/../../public/stylesheets/admin/*.css"]]
|
235
235
|
end
|
236
236
|
|
237
|
-
desc
|
237
|
+
desc 'Update admin sass files from your current trusty install'
|
238
238
|
task :sass do
|
239
239
|
copy_sass = proc do |project_dir, sass_files|
|
240
|
-
sass_files.reject!{|s| File.basename(s) == 'overrides.sass'} if File.exists?(project_dir + 'overrides.sass') || File.exists?(project_dir + '../overrides.css')
|
241
|
-
sass_files.reject!{|s| File.directory?(s) }
|
240
|
+
sass_files.reject! { |s| File.basename(s) == 'overrides.sass' } if File.exists?(project_dir + 'overrides.sass') || File.exists?(project_dir + '../overrides.css')
|
241
|
+
sass_files.reject! { |s| File.directory?(s) }
|
242
242
|
FileUtils.mkpath(project_dir)
|
243
243
|
FileUtils.cp(sass_files, project_dir)
|
244
244
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'trusty_cms/task_support'
|
2
2
|
namespace :trusty_cms do
|
3
3
|
namespace :config do
|
4
|
-
desc
|
5
|
-
task :
|
4
|
+
desc 'Export TrustyCms::Config to Rails.root/config/trusty_config.yml. Specify a path with TRUSTY_CONFIG_PATH - defaults to Rails.root/config/trusty_config.yml'
|
5
|
+
task export: :environment do
|
6
6
|
config_path = ENV['TRUSTY_CONFIG_PATH'] || "#{Rails.root}/config/trusty_config.yml"
|
7
7
|
clear = ENV['CLEAR_CONFIG'] || nil
|
8
8
|
TrustyCms::TaskSupport.config_export(config_path)
|
9
9
|
end
|
10
10
|
|
11
|
-
desc
|
12
|
-
task :
|
11
|
+
desc 'Import TrustyCms::Config from Rails.root/config/trusty_config.yml. Specify a path with TRUSTY_CONFIG_PATH - defaults to Rails.root/config/trusty_config.yml Set CLEAR_CONFIG=true to delete all existing settings before import'
|
12
|
+
task import: :environment do
|
13
13
|
config_path = ENV['TRUSTY_CONFIG_PATH'] || "#{Rails.root}/config/trusty_config.yml"
|
14
14
|
clear = ENV['CLEAR_CONFIG'] || nil
|
15
15
|
TrustyCms::TaskSupport.config_import(config_path, clear)
|
@@ -1,9 +1,8 @@
|
|
1
1
|
namespace :trusty do
|
2
2
|
namespace :extensions do
|
3
3
|
namespace :snippets do
|
4
|
-
|
5
4
|
desc 'Runs the migration of the Snippets extension'
|
6
|
-
task :
|
5
|
+
task migrate: :environment do
|
7
6
|
require 'trusty_cms/extension_migrator'
|
8
7
|
if ENV['VERSION']
|
9
8
|
SnippetsExtension.migrator.migrate(ENV['VERSION'].to_i)
|
@@ -15,30 +14,31 @@ namespace :trusty do
|
|
15
14
|
end
|
16
15
|
|
17
16
|
desc 'Copies public assets of the Snippets to the instance public/ directory.'
|
18
|
-
task :
|
19
|
-
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
17
|
+
task update: :environment do
|
18
|
+
is_svn_or_dir = proc { |path| path =~ /\.svn/ || File.directory?(path) }
|
20
19
|
puts 'Copying assets from SnippetsExtension'
|
21
20
|
Dir[SnippetsExtension.root + '/public/**/*'].reject(&is_svn_or_dir).each do |file|
|
22
21
|
path = file.sub(SnippetsExtension.root, '')
|
23
22
|
directory = File.dirname(path)
|
24
|
-
mkdir_p Rails.root + directory, :
|
25
|
-
cp file, Rails.root + path, :
|
23
|
+
mkdir_p Rails.root + directory, verbose: false
|
24
|
+
cp file, Rails.root + path, verbose: false
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
27
|
+
|
29
28
|
desc 'Syncs all available translations for this ext to the English ext master'
|
30
|
-
task :
|
29
|
+
task sync: :environment do
|
31
30
|
# The main translation root, basically where English is kept
|
32
31
|
language_root = SnippetsExtension.root + '/config/locales'
|
33
32
|
words = TranslationSupport.get_translation_keys(language_root)
|
34
|
-
|
33
|
+
|
35
34
|
Dir['#{language_root}/*.yml'].each do |filename|
|
36
35
|
next if filename.match('_available_tags')
|
36
|
+
|
37
37
|
basename = File.basename(filename, '.yml')
|
38
38
|
puts "Syncing #{basename}"
|
39
39
|
(comments, other) = TranslationSupport.read_file(filename, basename)
|
40
|
-
words.each { |k,
|
41
|
-
other.delete_if { |k,
|
40
|
+
words.each { |k, _v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
41
|
+
other.delete_if { |k, _v| !words[k] } # Remove if not defined in en.yml
|
42
42
|
TranslationSupport.write_file(filename, basename, comments, other)
|
43
43
|
end
|
44
44
|
end
|
data/lib/tasks/translate.rake
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
namespace :trusty_cms do
|
2
2
|
namespace :i18n do
|
3
|
-
|
4
|
-
|
5
|
-
task :sync => :environment do
|
3
|
+
desc 'Syncs all available translations to the English master'
|
4
|
+
task sync: :environment do
|
6
5
|
# All places TrustyCms can store locales
|
7
6
|
locale_paths = TrustyCms::AvailableLocales.locale_paths
|
8
7
|
# The main translation root, basically where English is kept
|
@@ -12,31 +11,32 @@ namespace :trusty_cms do
|
|
12
11
|
if path == language_root || path.match('language_pack')
|
13
12
|
Dir["#{path}/*.yml"].each do |filename|
|
14
13
|
next if filename.match('_available_tags')
|
14
|
+
|
15
15
|
basename = File.basename(filename, '.yml')
|
16
16
|
puts "Syncing #{basename}"
|
17
17
|
(comments, other) = TranslationSupport.read_file(filename, basename)
|
18
|
-
words.each { |k,
|
19
|
-
other.delete_if { |k,
|
18
|
+
words.each { |k, _v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
19
|
+
other.delete_if { |k, _v| !words[k] } # Remove if not defined in en.yml
|
20
20
|
TranslationSupport.write_file(filename, basename, comments, other)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
desc
|
27
|
-
task :
|
26
|
+
desc 'Creates or updates the English available tag descriptions'
|
27
|
+
task available_tags: :environment do
|
28
28
|
descriptions = Hash.new
|
29
29
|
Page.tag_descriptions.sort.each do |tag, desc|
|
30
|
-
tag = ' ' + tag.gsub(':','-') + ':'
|
31
|
-
desc = desc.gsub(' ',' ')
|
32
|
-
descriptions[tag] = ' "' + desc.gsub('%','%').gsub('"','\"').strip + '"'
|
30
|
+
tag = ' ' + tag.gsub(':', '-') + ':'
|
31
|
+
desc = desc.gsub(' ', ' ')
|
32
|
+
descriptions[tag] = ' "' + desc.gsub('%', '%').gsub('"', '\"').strip + '"'
|
33
33
|
end
|
34
34
|
comments = ''
|
35
|
-
TranslationSupport.write_file("#{TRUSTY_CMS_ROOT}/config/locales/en_available_tags.yml","---\nen:\n desc",comments,descriptions)
|
35
|
+
TranslationSupport.write_file("#{TRUSTY_CMS_ROOT}/config/locales/en_available_tags.yml", "---\nen:\n desc", comments, descriptions)
|
36
36
|
end
|
37
37
|
|
38
|
-
desc
|
39
|
-
task :
|
38
|
+
desc 'Syncs all translations available_tags to the English master'
|
39
|
+
task sync_available_tags: :environment do
|
40
40
|
# All places TrustyCms can store locales
|
41
41
|
locale_paths = TrustyCms::AvailableLocales.locale_paths
|
42
42
|
# The main translation root, basically where English is kept
|
@@ -46,6 +46,7 @@ namespace :trusty_cms do
|
|
46
46
|
if path == language_root || path.match('language_pack')
|
47
47
|
Dir["#{path}/*.yml"].each do |filename|
|
48
48
|
next unless filename.match('_available_tags')
|
49
|
+
|
49
50
|
basename = File.basename(filename, '_available_tags.yml')
|
50
51
|
puts "Syncing #{basename}"
|
51
52
|
(comments, other) = TranslationSupport.open_available_tags(filename)
|
@@ -54,6 +55,5 @@ namespace :trusty_cms do
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
57
|
-
|
58
58
|
end
|
59
59
|
end
|