Permalink
Browse files

update default seeds to make more sense, extended the refinery binary…

… installer tasks to be far more flexible (now sets up the database name using the app's path).
  • Loading branch information...
parndt committed Nov 5, 2009
1 parent ba086af commit f0c84b091a0c293cd5acbd9e5c78a5bfdac5ac28
Showing with 45 additions and 17 deletions.
  1. +33 −9 bin/refinery
  2. +8 −4 bin/refinery-update-core
  3. +2 −2 db/seeds.rb
  4. +2 −2 refinerycms.gemspec
View
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
require 'fileutils'
REFINERY_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
-unless (RAILS_ROOT = ARGV.shift).nil? or RAILS_ROOT.length == 0
+unless (app_path = ARGV.shift).nil? or app_path.length == 0
+ RAILS_ROOT = app_path =~ /(\.(\/)?)/ ? Dir.getwd : app_path
if File.exists? RAILS_ROOT
if ARGV.include?("--force")
# remove the contents of the current directory
@@ -23,6 +24,22 @@ unless (RAILS_ROOT = ARGV.shift).nil? or RAILS_ROOT.length == 0
# add in the database config file.
FileUtils::move File.join(RAILS_ROOT, %w(config database.yml.example)), File.join(RAILS_ROOT, %w(config database.yml))
+
+ # figure out the database name from the install path and swap out your_local_database with this name.
+ unless RAILS_ROOT == "/" or RUBY_PLATFORM =~ /mswin/
+ database_name = RAILS_ROOT.split(File::SEPARATOR).last
+ # read in the file and split up the lines
+ lines = File.open(File.join(RAILS_ROOT, %w(config database.yml)), "r").read.split("\n")
+ lines.each do |line|
+ line.gsub!("your_local_database", database_name)
+ line.gsub!("your_test_database", "#{database_name}_test")
+ line.gsub!("your_production_database", "#{database_name}_production")
+ end
+ # write the new content into the file.
+ File.open(File.join(RAILS_ROOT, %w(config database.yml)), "w").puts(lines.join("\n"))
+ else
+ database_name = "your_local_database"
+ end
# update the environment file with a new secret key.
require 'digest/sha1'
@@ -34,19 +51,26 @@ unless (RAILS_ROOT = ARGV.shift).nil? or RAILS_ROOT.length == 0
lines.each do |line|
match = line.scan(/(:secret)([^']*)([\'])([^\']*)/).flatten.last
line.gsub!(match, new_digest) unless match.nil?
- end
+ end
+ # write the new content into the file.
File.open(File.join(RAILS_ROOT, %w(config environment.rb)), "w").puts(lines.join("\n"))
- puts "---------"
- puts "Refinery installed in #{RAILS_ROOT}."
+ puts "\n---------"
+ puts "Refinery successfully installed in '#{RAILS_ROOT}'!\n\n"
# update core script files with symlinks.
- system "refinery-update-core #{RAILS_ROOT}"
+ system "refinery-update-core #{RAILS_ROOT} --from-refinery-installer"
- puts "---------"
- puts "** Remember to run rake gems:install from inside your application's directory (#{RAILS_ROOT}) **"
- puts "Enjoy creating your new application using Refinery."
- puts "---------"
+ puts "=== ACTION REQUIRED ==="
+ puts "\nNow run these commands:"
+ puts "\ncd #{RAILS_ROOT}"
+ puts "rake gems:install"
+ puts "rake db:setup"
+ puts "\nruby script/server"
+ puts "\nThis will install all the required gems, set up your database (named '#{database_name}') and launches the built-in webserver."
+ puts "You can now see your site running in your browser at http://localhost:3000"
+ puts "\nThanks for installing Refinery, enjoy creating your new application!"
+ puts "---------\n\n"
end
else
puts "Please specify the path where you want to install Refinery. i.e. refinery /path/to/project"
View
@@ -20,9 +20,13 @@ unless RAILS_ROOT.nil? or RAILS_ROOT.length == 0
# copy any rake tasks from plugins to the main lib directory so they can be run.
FileUtils::cp Dir[File.join(REFINERY_ROOT, %w(** tasks *.rake))], File.join(RAILS_ROOT, %w(lib tasks))
- puts "---------"
- puts "Copied new Refinery core assets."
- puts "Please run rake db:migrate to ensure your database is at the correct version."
+ unless ARGV.include?("--from-refinery-installer")
+ puts "---------"
+ puts "Copied new Refinery core assets."
+ puts "Please run rake db:migrate to ensure your database is at the correct version."
+ end
else
- puts "Please specify the path of the refinery project that you want to update, i.e. refinery-update-core /path/to/project"
+ unless ARGV.include?("--from-refinery-installer")
+ puts "Please specify the path of the refinery project that you want to update, i.e. refinery-update-core /path/to/project"
+ end
end
View
@@ -82,7 +82,7 @@
:parent_id => 4).parts.create(
{
:title => "body",
- :body => "<p>We've received your inquiry and will get back to you with a response shortly.</p><a href='/'>Return to the home page</a>"
+ :body => "<p>We've received your inquiry and will get back to you with a response shortly.</p><p><a href='/'>Return to the home page</a></p>"
})
Page.create(:title => "Page not found",
@@ -105,5 +105,5 @@
}).page.parts.create(
{
:title => "side_body",
- :body => "<p></p>"
+ :body => ""
})
View

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit f0c84b0

Please sign in to comment.