refinerycms 0.9.7.5 → 0.9.7.6
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.
- data/Gemfile +4 -4
- data/bin/refinery +3 -141
- data/bin/refinery-upgrade-096-to-097 +39 -32
- data/bin/refinerycms +150 -0
- data/changelog.md +25 -12
- data/db/schema.rb +1 -1
- data/features/refinery/site_bar.feature +5 -4
- data/features/step_definitions/refinery/page_steps.rb +6 -2
- data/lib/gemspec.rb +1 -1
- data/lib/refinery/tasks/refinery.rake +24 -18
- data/lib/tasks/rspec.rake +0 -1
- data/public/javascripts/refinery/admin.js +3 -9
- data/public/javascripts/refinery/boot_wym.js +3 -3
- data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +5 -5
- data/public/javascripts/wymeditor/lang/pt-br.js +44 -43
- data/public/stylesheets/refinery/refinery.css +37 -34
- data/readme.md +3 -6
- data/test/test_helper.rb +1 -1
- data/test/unit/image_test.rb +6 -2
- data/vendor/plugins/authentication/app/controllers/users_controller.rb +4 -5
- data/vendor/plugins/authentication/config/locales/pt-BR.yml +22 -19
- data/vendor/plugins/dashboard/config/locales/pt-BR.yml +2 -1
- data/vendor/plugins/images/app/controllers/admin/images_controller.rb +9 -5
- data/vendor/plugins/images/app/models/image.rb +15 -3
- data/vendor/plugins/images/app/views/admin/images/{_existing_image.erb → _existing_image.html.erb} +2 -2
- data/vendor/plugins/images/app/views/admin/images/index.html.erb +8 -4
- data/vendor/plugins/images/app/views/admin/images/insert.html.erb +28 -9
- data/vendor/plugins/images/config/locales/en.yml +5 -1
- data/vendor/plugins/images/config/locales/es.yml +1 -1
- data/vendor/plugins/images/config/locales/nl.yml +1 -1
- data/vendor/plugins/images/config/locales/pt-BR.yml +6 -2
- data/vendor/plugins/inquiries/app/views/admin/inquiries/index.html.erb +1 -1
- data/vendor/plugins/inquiries/app/views/admin/inquiries/show.html.erb +2 -2
- data/vendor/plugins/inquiries/app/views/admin/inquiries/spam.html.erb +1 -1
- data/vendor/plugins/inquiries/config/locales/en.yml +1 -0
- data/vendor/plugins/inquiries/config/locales/pt-BR.yml +12 -9
- data/vendor/plugins/pages/app/controllers/admin/{page_dialogs_controller.rb → pages_dialogs_controller.rb} +8 -6
- data/vendor/plugins/pages/app/models/page.rb +1 -1
- data/vendor/plugins/pages/app/views/admin/{page_dialogs → pages_dialogs}/_page_link.html.erb +0 -0
- data/vendor/plugins/pages/app/views/admin/{page_dialogs → pages_dialogs}/link_to.html.erb +11 -9
- data/vendor/plugins/pages/config/locales/en.yml +1 -1
- data/vendor/plugins/pages/config/locales/pt-BR.yml +27 -0
- data/vendor/plugins/pages/config/locales/sl.yml +1 -1
- data/vendor/plugins/pages/config/routes.rb +5 -3
- data/vendor/plugins/pages/rails/init.rb +1 -1
- data/vendor/plugins/refinery/app/views/shared/admin/_form_actions.html.erb +19 -12
- data/vendor/plugins/refinery/app/views/shared/admin/_image_picker.html.erb +15 -5
- data/vendor/plugins/refinery/config/locales/pt-BR.yml +2 -0
- data/vendor/plugins/refinery/lib/refinery.rb +1 -1
- data/vendor/plugins/refinery/lib/refinery/admin_base_controller.rb +0 -1
- data/vendor/plugins/refinery/lib/refinery/initializer.rb +2 -2
- data/vendor/plugins/refinery/lib/refinery/link_renderer.rb +6 -2
- data/vendor/plugins/refinery/lib/tasks/refinery.rake +1 -1
- data/vendor/plugins/refinery_dialogs/app/controllers/admin/dialogs_controller.rb +2 -4
- data/vendor/plugins/refinery_settings/app/controllers/admin/refinery_settings_controller.rb +2 -2
- data/vendor/plugins/refinery_settings/config/locales/pt-BR.yml +17 -17
- data/vendor/plugins/resources/app/controllers/admin/resources_controller.rb +4 -0
- data/vendor/plugins/resources/app/models/resource.rb +2 -6
- data/vendor/plugins/resources/app/views/admin/resources/_existing_resource.html.erb +3 -3
- data/vendor/plugins/resources/app/views/admin/resources/_form.html.erb +8 -5
- data/vendor/plugins/resources/app/views/admin/resources/insert.html.erb +33 -10
- data/vendor/plugins/resources/config/locales/da.yml +1 -1
- data/vendor/plugins/resources/config/locales/pt-BR.yml +4 -3
- metadata +15 -12
- data/vendor/plugins/authentication/test/functional/admin/base_controller_test.rb +0 -8
- data/vendor/plugins/authentication/test/functional/admin/dashboard_controller_test.rb +0 -8
- data/vendor/plugins/authentication/test/functional/admin/pages_controller_test.rb +0 -8
- data/vendor/plugins/authentication/test/test_helper.rb +0 -38
data/Gemfile
CHANGED
@@ -17,7 +17,7 @@ gem 'sqlite3-ruby', :require => 'sqlite3' #db_adapter=sqlite3
|
|
17
17
|
# gem 'aws-s3'
|
18
18
|
|
19
19
|
#===REFINERY REQUIRED GEMS===
|
20
|
-
gem 'acts_as_indexed', '= 0.6.
|
20
|
+
gem 'acts_as_indexed', '= 0.6.3', :require => 'acts_as_indexed'
|
21
21
|
gem 'authlogic', '= 2.1.5', :require => 'authlogic'
|
22
22
|
gem 'friendly_id', '= 3.0.6', :require => 'friendly_id'
|
23
23
|
gem 'rails', '= 2.3.8'
|
@@ -41,11 +41,11 @@ end
|
|
41
41
|
|
42
42
|
#===REQUIRED FOR REFINERY GEM INSTALL===
|
43
43
|
# Leave the gem below disabled (commented out) if you're not using the gem install method.
|
44
|
-
# gem 'refinerycms', '= 0.9.7.
|
44
|
+
# gem 'refinerycms', '= 0.9.7.6'
|
45
45
|
#===END OF REFINERY GEM INSTALL REQUIREMENTS===
|
46
46
|
|
47
47
|
# Bundle gems for certain environments:
|
48
48
|
|
49
49
|
# Specify your application's gem requirements here. See the examples below:
|
50
|
-
# gem
|
51
|
-
# gem
|
50
|
+
# gem 'refinerycms-news', '~> 0.9.8', :require => 'news'
|
51
|
+
# gem 'refinerycms-portfolio', '~> 0.9.7', :require => 'portfolio'
|
data/bin/refinery
CHANGED
@@ -1,142 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
refinery_root = (defined?(REFINERY_ROOT) && REFINERY_ROOT.is_a?(Pathname) ? REFINERY_ROOT : Pathname.new(File.expand_path(File.dirname(__FILE__) << "/..")))
|
6
|
-
unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
7
|
-
# if "" or "." or "./" is specified then get the current directory otherwise accept the specified app_path.
|
8
|
-
if (app_path.length <= 2 and ((is_current_dir = app_path =~ /(\.(\/)?)/).nil? or is_current_dir < 2))
|
9
|
-
rails_root = Dir.getwd
|
10
|
-
else
|
11
|
-
rails_root = app_path =~ /^\// ? app_path : File.expand_path(File.join(Dir.getwd, app_path.gsub(/^\.\//, '')))
|
12
|
-
end
|
13
|
-
|
14
|
-
if File.directory?(rails_root)
|
15
|
-
if ARGV.include?("--force")
|
16
|
-
# remove the contents of the current directory
|
17
|
-
Dir[File.join(rails_root, "*")].each {|dir| FileUtils::rm_rf(dir, :secure => true) }
|
18
|
-
else
|
19
|
-
puts "The path you specified already exists. If you want to override this directory (i.e. delete all the current contents) run this again with --force"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
unless File.directory?(rails_root) and !ARGV.include?("--force")
|
24
|
-
# make the application path directory
|
25
|
-
FileUtils::makedirs rails_root
|
26
|
-
|
27
|
-
# copy in all of the relevant directories and root files.
|
28
|
-
to_copy = %w(app config db lib public themes script *.md Rakefile .gitignore config.ru asdas).map do |dir|
|
29
|
-
(new_file_path = refinery_root.join(dir)).exist? ? new_file_path.to_s : nil
|
30
|
-
end
|
31
|
-
FileUtils::cp_r to_copy.compact, rails_root, :verbose => false
|
32
|
-
|
33
|
-
# ensure lib/refinery_initializer.rb and lib/gemspec.rb don't make it in.
|
34
|
-
FileUtils::rm File.join(%W(#{rails_root} lib refinery_initializer.rb)) if File.exists?(File.join(%W(#{rails_root} lib refinery_initializer.rb)))
|
35
|
-
FileUtils::rm File.join(%W(#{rails_root} lib gemspec.rb)) if File.exists?(File.join(%W(#{rails_root} lib gemspec.rb)))
|
36
|
-
|
37
|
-
# copy the appropriate database adapter as specified (or not)
|
38
|
-
db_adapter = 'sqlite3'
|
39
|
-
if ARGV.collect{|a| a.split('=').first}.include?('--database')
|
40
|
-
ARGV.each do |arg|
|
41
|
-
arg_parts = arg.split('=')
|
42
|
-
db_adapter = arg_parts.last if arg_parts.first == '--database'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
FileUtils::cp File.join(%W(#{rails_root} config database.yml.#{db_adapter})), File.join(%W(#{rails_root} config database.yml.example))
|
46
|
-
|
47
|
-
# add in the config files
|
48
|
-
%w(database amazon_s3 rackspace_cloudfiles).each do |config|
|
49
|
-
FileUtils::move File.join(%W(#{rails_root} config #{config}.yml.example)), File.join(%W(#{rails_root} config #{config}.yml))
|
50
|
-
|
51
|
-
# figure out the app name from the install path and swap out your_local_xxx with this name.
|
52
|
-
unless rails_root == "/" or RUBY_PLATFORM =~ /mswin/
|
53
|
-
app_name = rails_root.split(File::SEPARATOR).last
|
54
|
-
# read in the file and split up the lines
|
55
|
-
lines = File.open(File.join(%W(#{rails_root} config #{config}.yml)), "r").read.split("\n")
|
56
|
-
lines.each do |line|
|
57
|
-
line.gsub!("your_local_#{config}", "#{app_name}_development")
|
58
|
-
line.gsub!("your_test_#{config}", "#{app_name}_test")
|
59
|
-
line.gsub!("your_cucumber_#{config}", "#{app_name}_cucumber")
|
60
|
-
line.gsub!("your_production_#{config}", "#{app_name}_production")
|
61
|
-
end
|
62
|
-
# write the new content into the file.
|
63
|
-
config_file = File.open(File.join(%W(#{rails_root} config #{config}.yml)), "w")
|
64
|
-
config_file.puts(lines.join("\n"))
|
65
|
-
config_file.close
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# update the environment file with a new secret key.
|
70
|
-
require 'digest/sha1'
|
71
|
-
new_digest = ""
|
72
|
-
3.times { new_digest << Digest::SHA1.hexdigest("--refinery--#{Time.now.to_s}--#{rand(10000000)}--") }
|
73
|
-
|
74
|
-
# read in the file and split up the lines
|
75
|
-
app_config_file = File.exist?(File.join(%W(#{rails_root} config application.rb))) ? "application.rb" : "environment.rb"
|
76
|
-
lines = File.open(File.join(%W(#{rails_root} config #{app_config_file})), "r").read.split("\n")
|
77
|
-
lines.each do |line|
|
78
|
-
match = line.scan(/(:secret)([^']*)([\'])([^\']*)/).flatten.last
|
79
|
-
line.gsub!(match, new_digest) unless match.nil?
|
80
|
-
end
|
81
|
-
|
82
|
-
# write the new content into the config file.
|
83
|
-
app_config = File.open(File.join(%W(#{rails_root} config #{app_config_file})), "w")
|
84
|
-
app_config.puts(lines.join("\n"))
|
85
|
-
app_config.close
|
86
|
-
|
87
|
-
# read in the Gemfile and write it back out with the refinerycms gem enabled.
|
88
|
-
(lines = refinery_root.join('Gemfile').open('r').read.split("\n")).each do |line|
|
89
|
-
line.gsub!(/\#*\s?gem 'refinerycms'/, "gem 'refinerycms'")
|
90
|
-
|
91
|
-
# Ensure that the correct database gem libraries are included for the database adapter
|
92
|
-
# that the user has specified in the refinery install command.
|
93
|
-
if line =~ /\#db\_adapter\=/
|
94
|
-
if line =~ %r{#db_adapter=#{db_adapter}}
|
95
|
-
line.gsub!(/^(\#*\s?gem)/, 'gem')
|
96
|
-
else
|
97
|
-
line.gsub!(/^(\s?gem)/, '# gem')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# write the new content into the file.
|
103
|
-
app_gemfile = File.open(File.join(%W(#{rails_root} Gemfile)), "w")
|
104
|
-
app_gemfile.puts(lines.join("\n"))
|
105
|
-
app_gemfile.close
|
106
|
-
|
107
|
-
puts "\n---------"
|
108
|
-
puts "Refinery successfully installed in '#{rails_root}'!\n\n"
|
109
|
-
|
110
|
-
# automate..
|
111
|
-
Dir.chdir(rails_root) do
|
112
|
-
puts "Installing gem requirements using bundler..\n"
|
113
|
-
puts (cmd="bundle install --without test")
|
114
|
-
puts `#{cmd}`
|
115
|
-
|
116
|
-
puts "\n\nSetting up your development database..\n"
|
117
|
-
puts (cmd="rake -f '#{File.join(rails_root, 'Rakefile')}' db:setup")
|
118
|
-
puts `#{cmd}`
|
119
|
-
|
120
|
-
puts "\n\nUpdating some core refinery files..\n"
|
121
|
-
puts (cmd="rake -f '#{File.join(rails_root, 'Rakefile')}' refinery:update from_installer=true")
|
122
|
-
puts `#{cmd}`
|
123
|
-
end
|
124
|
-
|
125
|
-
# output helpful messages.
|
126
|
-
puts "\n=== ACTION REQUIRED ==="
|
127
|
-
puts "Now you can launch your webserver using:"
|
128
|
-
puts "\ncd #{rails_root}"
|
129
|
-
puts "script/server"
|
130
|
-
puts "\nThis will launch the built-in webserver at port 3000."
|
131
|
-
puts "You can now see your site running in your browser at http://localhost:3000"
|
132
|
-
puts "\nThanks for installing Refinery, enjoy creating your new application!"
|
133
|
-
puts "---------\n\n"
|
134
|
-
end
|
135
|
-
else
|
136
|
-
puts "\nPlease specify the path where you want to install Refinery. i.e. refinery /path/to/project [options]"
|
137
|
-
puts "\n"
|
138
|
-
puts "Options:"
|
139
|
-
puts "--force Forces the directory to be overriden if the directory already exists"
|
140
|
-
puts "--database=name Preconfigure for selected database (options: mysql/postgresql/sqlite3 - default: sqlite3)."
|
141
|
-
puts "\n"
|
142
|
-
end
|
2
|
+
# Running 'refinery' is the old way of generating an application and we want users to change.
|
3
|
+
# We could call it here for them, but it would mean that the entire task ran without printing anything to the user.
|
4
|
+
puts "We have renamed the 'refinery' task to 'refinerycms' so please use 'refinerycms' instead."
|
@@ -5,7 +5,6 @@ require 'yaml'
|
|
5
5
|
|
6
6
|
refinery_root = (defined?(REFINERY_ROOT) && REFINERY_ROOT.is_a?(Pathname) ? REFINERY_ROOT : Pathname.new(File.expand_path(File.dirname(__FILE__) << "/..")))
|
7
7
|
unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
8
|
-
puts "--------Updating--------\n\n"
|
9
8
|
# if "" or "." or "./" is specified then get the current directory otherwise accept the specified app_path.
|
10
9
|
if (app_path.length <= 2 and ((is_current_dir = app_path =~ /(\.(\/)?)/).nil? or is_current_dir < 2))
|
11
10
|
rails_root = Dir.getwd
|
@@ -13,7 +12,13 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
|
13
12
|
rails_root = app_path =~ /^\// ? app_path : File.expand_path(File.join(Dir.getwd, app_path.gsub(/^\.\//, '')))
|
14
13
|
end
|
15
14
|
rails_root = Pathname.new(rails_root.to_s)
|
16
|
-
|
15
|
+
|
16
|
+
if rails_root.join('Gemfile').exist?
|
17
|
+
puts "Your application appears to already be running Refinery CMS >= 0.9.7"
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
puts "--------Updating--------\n\n"
|
21
|
+
|
17
22
|
FileUtils::cp refinery_root.join('Gemfile').to_s, rails_root.join('Gemfile').to_s, :verbose => true
|
18
23
|
FileUtils::cp refinery_root.join('config', 'preinitializer.rb').to_s, rails_root.join('config', 'preinitializer.rb').to_s, :verbose => true
|
19
24
|
|
@@ -25,13 +30,13 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
|
25
30
|
db_adapter = db_config["development"]["adapter"]
|
26
31
|
end
|
27
32
|
end
|
28
|
-
|
33
|
+
|
29
34
|
db_adapter = 'sqlite3' unless %w(sqlite3 mysql postgresql).include?(db_adapter)
|
30
35
|
|
31
36
|
# read in the Gemfile and write it back out with the refinerycms gem enabled.
|
32
37
|
(lines = refinery_root.join('Gemfile').open('r').read.split("\n")).each do |line|
|
33
38
|
line.gsub!(/\#*\s?gem 'refinerycms'/, "gem 'refinerycms'")
|
34
|
-
|
39
|
+
|
35
40
|
# Ensure that the correct database gem libraries are included for the database adapter
|
36
41
|
# that the user has specified in the refinery install command.
|
37
42
|
if line =~ /\#db\_adapter\=/
|
@@ -51,18 +56,18 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
|
51
56
|
# backup the config file.
|
52
57
|
app_config_file = 'application.rb'
|
53
58
|
FileUtils.cp rails_root.join('config', app_config_file).cleanpath.to_s, rails_root.join('config', "#{app_config_file.gsub('.rb', '')}.autobackupbyrefineryupgrade.rb").cleanpath.to_s, :verbose => true
|
54
|
-
|
59
|
+
|
55
60
|
# copy the new config file.
|
56
61
|
FileUtils.cp refinery_root.join('config', app_config_file).cleanpath.to_s, rails_root.join('config', app_config_file).cleanpath.to_s, :verbose => true
|
57
62
|
|
58
63
|
unless File.exist?(rails_root.join('config', 'settings.rb'))
|
59
64
|
FileUtils.cp refinery_root.join('config', 'settings.rb').cleanpath.to_s, rails_root.join('config', 'settings.rb').cleanpath.to_s, :verbose => true
|
60
65
|
end
|
61
|
-
|
66
|
+
|
62
67
|
unless (aai_config_file = rails_root.join('config', 'acts_as_indexed_config.rb')).exist?
|
63
68
|
FileUtils::cp refinery_root.join('config', 'acts_as_indexed_config.rb').to_s, aai_config_file.to_s, :verbose => true
|
64
69
|
end
|
65
|
-
|
70
|
+
|
66
71
|
# update routes files
|
67
72
|
puts "\nNow I'm verifying and updating your routing in your files and your plugins...\n"
|
68
73
|
Dir[rails_root.join('**', 'config', 'routes.rb')].map{|f| Pathname.new(f)}.each do |routes_file|
|
@@ -71,11 +76,14 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
|
71
76
|
original_lines = lines.dup
|
72
77
|
open_routes_file.close
|
73
78
|
lines.each do |line|
|
79
|
+
if routes_file.to_s == rails_root.join('config', 'routes.rb').to_s
|
80
|
+
line.gsub!("ActionController::Routing::Routes.draw do |map|", "ActionController::Routing::Routes.draw do |map|\n map.filter(:locale)")
|
81
|
+
line.gsub!("map.connect 'admin/*path', :controller => 'admin/base', :action => 'error_404'",
|
82
|
+
"map.redirect 'admin/*path', :controller => 'admin/base'")
|
83
|
+
line.gsub!("map.connect '*path', :controller => 'application', :action => 'error_404'",
|
84
|
+
"map.connect 'refinery/*path', :controller => 'admin/base', :action => 'error_404'\n\n # Marketable URLs\n map.connect '*path', :controller => 'pages', :action => 'show'")
|
85
|
+
end
|
74
86
|
line.gsub!("map.namespace(:admin) do |admin|", "map.namespace(:admin, :path_prefix => 'refinery') do |admin|")
|
75
|
-
line.gsub!("map.connect 'admin/*path', :controller => 'admin/base', :action => 'error_404'",
|
76
|
-
"map.redirect 'admin/*path', :controller => 'admin/base'")
|
77
|
-
line.gsub!("map.connect '*path', :controller => 'application', :action => 'error_404'",
|
78
|
-
"map.connect 'refinery/*path', :controller => 'admin/base', :action => 'error_404'\n\n # Marketable URLs\n map.connect '*path', :controller => 'pages', :action => 'show'")
|
79
87
|
end
|
80
88
|
lines = lines.join("\n").split("\n")
|
81
89
|
open_routes_file = routes_file.open("w")
|
@@ -83,32 +91,31 @@ unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
|
83
91
|
open_routes_file.close
|
84
92
|
puts "Made modifications to routes in #{routes_file} please ensure they are still valid." if original_lines != lines
|
85
93
|
end
|
86
|
-
|
94
|
+
|
87
95
|
puts "\nCopied files required to support the new RefineryCMS version 0.9.7"
|
88
96
|
puts "I backed up your config/application.rb file to #{rails_root.join('config', "#{app_config_file.gsub('.rb', '')}.autobackupbyrefineryupgrade.rb").cleanpath.to_s}"
|
89
97
|
puts "\nI think your database adapter is #{db_adapter} so that is what will be installed by bundler.\n\n"
|
90
|
-
|
98
|
+
|
91
99
|
# automate..
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
puts "\nrake refinery:update"
|
109
|
-
end
|
100
|
+
puts "Installing gem requirements using bundler..\n"
|
101
|
+
puts (cmd="bundle install --without test")
|
102
|
+
puts `cd '#{rails_root}' && #{cmd}`
|
103
|
+
|
104
|
+
if rails_root.join('config', 'database.yml').exist?
|
105
|
+
puts "\n\nUpdating some core refinery files..\n"
|
106
|
+
puts (cmd="rake -f '#{File.join(rails_root, 'Rakefile')}' refinery:update from_installer=true")
|
107
|
+
puts `cd '#{rails_root}' && #{cmd}`
|
108
|
+
|
109
|
+
puts "\n\nMigrating your database..\n"
|
110
|
+
puts (cmd="rake -f '#{File.join(rails_root, 'Rakefile')}' db:migrate")
|
111
|
+
puts `cd '#{rails_root}' && #{cmd}`
|
112
|
+
else
|
113
|
+
puts "\nYour config/database.yml file is missing so I can't run a task that is required."
|
114
|
+
puts "Once you have your database file in place or are confident it will work without it please run:"
|
115
|
+
puts "\nrake refinery:update"
|
110
116
|
end
|
111
|
-
|
117
|
+
# end automation..
|
118
|
+
|
112
119
|
puts "\n--------Update complete--------\n\n"
|
113
120
|
|
114
121
|
else
|
data/bin/refinerycms
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError
|
8
|
+
puts "\n==ACTION REQUIRED=="
|
9
|
+
puts "Could not load the bundler gem. This is a required dependency of Refinery CMS.\n\n"
|
10
|
+
puts "Please install it with `gem install bundler`.\n\n"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
refinery_root = (defined?(REFINERY_ROOT) && REFINERY_ROOT.is_a?(Pathname) ? REFINERY_ROOT : Pathname.new(File.expand_path(File.dirname(__FILE__) << "/..")))
|
15
|
+
unless (app_path = ARGV.shift).nil? or app_path.length == 0
|
16
|
+
# if "" or "." or "./" is specified then get the current directory otherwise accept the specified app_path.
|
17
|
+
if (app_path.length <= 2 and ((is_current_dir = app_path =~ /(\.(\/)?)/).nil? or is_current_dir < 2))
|
18
|
+
rails_root = Dir.getwd
|
19
|
+
else
|
20
|
+
rails_root = app_path =~ /^\// ? app_path : File.expand_path(File.join(Dir.getwd, app_path.gsub(/^\.\//, '')))
|
21
|
+
end
|
22
|
+
|
23
|
+
if File.directory?(rails_root)
|
24
|
+
if ARGV.include?("--force")
|
25
|
+
# remove the contents of the current directory
|
26
|
+
Dir[File.join(rails_root, "*")].each {|dir| FileUtils::rm_rf(dir, :secure => true) }
|
27
|
+
else
|
28
|
+
puts "The path you specified already exists. If you want to override this directory (i.e. delete all the current contents) run this again with --force"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
unless File.directory?(rails_root) and !ARGV.include?("--force")
|
33
|
+
# make the application path directory
|
34
|
+
FileUtils::makedirs rails_root
|
35
|
+
|
36
|
+
# copy in all of the relevant directories and root files.
|
37
|
+
to_copy = %w(app config db lib public themes script *.md Rakefile .gitignore config.ru asdas).map do |dir|
|
38
|
+
(new_file_path = refinery_root.join(dir)).exist? ? new_file_path.to_s : nil
|
39
|
+
end
|
40
|
+
FileUtils::cp_r to_copy.compact, rails_root, :verbose => false
|
41
|
+
|
42
|
+
# ensure lib/refinery_initializer.rb and lib/gemspec.rb don't make it in.
|
43
|
+
FileUtils::rm File.join(%W(#{rails_root} lib refinery_initializer.rb)) if File.exists?(File.join(%W(#{rails_root} lib refinery_initializer.rb)))
|
44
|
+
FileUtils::rm File.join(%W(#{rails_root} lib gemspec.rb)) if File.exists?(File.join(%W(#{rails_root} lib gemspec.rb)))
|
45
|
+
|
46
|
+
# copy the appropriate database adapter as specified (or not)
|
47
|
+
db_adapter = 'sqlite3'
|
48
|
+
if ARGV.collect{|a| a.split('=').first}.include?('--database')
|
49
|
+
ARGV.each do |arg|
|
50
|
+
arg_parts = arg.split('=')
|
51
|
+
db_adapter = arg_parts.last if arg_parts.first == '--database'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
FileUtils::cp File.join(%W(#{rails_root} config database.yml.#{db_adapter})), File.join(%W(#{rails_root} config database.yml.example))
|
55
|
+
|
56
|
+
# add in the config files
|
57
|
+
%w(database amazon_s3 rackspace_cloudfiles).each do |config|
|
58
|
+
FileUtils::move File.join(%W(#{rails_root} config #{config}.yml.example)), File.join(%W(#{rails_root} config #{config}.yml))
|
59
|
+
|
60
|
+
# figure out the app name from the install path and swap out your_local_xxx with this name.
|
61
|
+
unless rails_root == "/" or RUBY_PLATFORM =~ /mswin/
|
62
|
+
app_name = rails_root.split(File::SEPARATOR).last
|
63
|
+
# read in the file and split up the lines
|
64
|
+
lines = File.open(File.join(%W(#{rails_root} config #{config}.yml)), "r").read.split("\n")
|
65
|
+
lines.each do |line|
|
66
|
+
line.gsub!("your_local_#{config}", "#{app_name}_development")
|
67
|
+
line.gsub!("your_test_#{config}", "#{app_name}_test")
|
68
|
+
line.gsub!("your_cucumber_#{config}", "#{app_name}_cucumber")
|
69
|
+
line.gsub!("your_production_#{config}", "#{app_name}_production")
|
70
|
+
end
|
71
|
+
# write the new content into the file.
|
72
|
+
config_file = File.open(File.join(%W(#{rails_root} config #{config}.yml)), "w")
|
73
|
+
config_file.puts(lines.join("\n"))
|
74
|
+
config_file.close
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# update the environment file with a new secret key.
|
79
|
+
require 'digest/sha1'
|
80
|
+
new_digest = ""
|
81
|
+
3.times { new_digest << Digest::SHA1.hexdigest("--refinery--#{Time.now.to_s}--#{rand(10000000)}--") }
|
82
|
+
|
83
|
+
# read in the file and split up the lines
|
84
|
+
app_config_file = File.exist?(File.join(%W(#{rails_root} config application.rb))) ? "application.rb" : "environment.rb"
|
85
|
+
lines = File.open(File.join(%W(#{rails_root} config #{app_config_file})), "r").read.split("\n")
|
86
|
+
lines.each do |line|
|
87
|
+
match = line.scan(/(:secret)([^']*)([\'])([^\']*)/).flatten.last
|
88
|
+
line.gsub!(match, new_digest) unless match.nil?
|
89
|
+
end
|
90
|
+
|
91
|
+
# write the new content into the config file.
|
92
|
+
app_config = File.open(File.join(%W(#{rails_root} config #{app_config_file})), "w")
|
93
|
+
app_config.puts(lines.join("\n"))
|
94
|
+
app_config.close
|
95
|
+
|
96
|
+
# read in the Gemfile and write it back out with the refinerycms gem enabled.
|
97
|
+
(lines = refinery_root.join('Gemfile').open('r').read.split("\n")).each do |line|
|
98
|
+
line.gsub!(/\#*\s?gem 'refinerycms'/, "gem 'refinerycms'")
|
99
|
+
|
100
|
+
# Ensure that the correct database gem libraries are included for the database adapter
|
101
|
+
# that the user has specified in the refinery install command.
|
102
|
+
if line =~ /\#db\_adapter\=/
|
103
|
+
if line =~ %r{#db_adapter=#{db_adapter}}
|
104
|
+
line.gsub!(/^(\#*\s?gem)/, 'gem')
|
105
|
+
else
|
106
|
+
line.gsub!(/^(\s?gem)/, '# gem')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# write the new content into the file.
|
112
|
+
app_gemfile = File.open(File.join(%W(#{rails_root} Gemfile)), "w")
|
113
|
+
app_gemfile.puts(lines.join("\n"))
|
114
|
+
app_gemfile.close
|
115
|
+
|
116
|
+
puts "\n---------"
|
117
|
+
puts "Refinery successfully installed in '#{rails_root}'!\n\n"
|
118
|
+
|
119
|
+
# automate..
|
120
|
+
puts "Installing gem requirements using bundler..\n"
|
121
|
+
puts "Running: " + (cmd="bundle install --without test")
|
122
|
+
puts `cd '#{rails_root}' && #{cmd}`
|
123
|
+
|
124
|
+
puts "\n\nSetting up your development database..\n"
|
125
|
+
puts "Running: " + (cmd="rake -f '#{File.join(rails_root, 'Rakefile')}' db:setup")
|
126
|
+
puts `cd '#{rails_root}' && #{cmd}`
|
127
|
+
|
128
|
+
puts "\n\nUpdating some core refinery files..\n"
|
129
|
+
puts "Running: " + (cmd="rake -f '#{File.join(rails_root, 'Rakefile')}' refinery:update from_installer=true")
|
130
|
+
puts `cd '#{rails_root}' && #{cmd}`
|
131
|
+
# end automation..
|
132
|
+
|
133
|
+
# output helpful messages.
|
134
|
+
puts "\n=== ACTION REQUIRED ==="
|
135
|
+
puts "Now you can launch your webserver using:"
|
136
|
+
puts "\ncd #{rails_root}"
|
137
|
+
puts "script/server"
|
138
|
+
puts "\nThis will launch the built-in webserver at port 3000."
|
139
|
+
puts "You can now see your site running in your browser at http://localhost:3000"
|
140
|
+
puts "\nThanks for installing Refinery, enjoy creating your new application!"
|
141
|
+
puts "---------\n\n"
|
142
|
+
end
|
143
|
+
else
|
144
|
+
puts "\nPlease specify the path where you want to install Refinery. i.e. refinery /path/to/project [options]"
|
145
|
+
puts "\n"
|
146
|
+
puts "Options:"
|
147
|
+
puts "--force Forces the directory to be overriden if the directory already exists"
|
148
|
+
puts "--database=name Preconfigure for selected database (options: mysql/postgresql/sqlite3 - default: sqlite3)."
|
149
|
+
puts "\n"
|
150
|
+
end
|