Streamline Rake Task
Refactor the upgrade_instiki rake task.
Based on the (very nice) JHerdman's
64d305f2a8
but defaults to 'production' environment, instead.
Instiki users don't know about production/development/test.
Instiki defaults to 'production'. So should its associated rake tasks.
This commit is contained in:
parent
336e57d6b4
commit
888e93a7fd
|
@ -85,7 +85,7 @@ module Engines
|
||||||
:html_math_output_mathml => false,
|
:html_math_output_mathml => false,
|
||||||
:html_math_output_png => true,
|
:html_math_output_png => true,
|
||||||
:html_png_engine => 'blahtex',
|
:html_png_engine => 'blahtex',
|
||||||
:html_png_dir => @content.web.files_path + '/pngs',
|
:html_png_dir => @content.web.files_path.join('pngs').to_s,
|
||||||
:html_png_url => '../files/pngs/',
|
:html_png_url => '../files/pngs/',
|
||||||
:content_only => true,
|
:content_only => true,
|
||||||
:author => @content.options[:engine_opts][:author],
|
:author => @content.options[:engine_opts][:author],
|
||||||
|
@ -99,7 +99,7 @@ module Engines
|
||||||
:html_math_output_mathml => false,
|
:html_math_output_mathml => false,
|
||||||
:html_math_output_png => true,
|
:html_math_output_png => true,
|
||||||
:html_png_engine => 'blahtex',
|
:html_png_engine => 'blahtex',
|
||||||
:html_png_dir => @content.web.files_path + '/pngs',
|
:html_png_dir => @content.web.files_path.join('pngs').to_s,
|
||||||
:html_png_url => '../files/pngs/'}).to_html
|
:html_png_url => '../files/pngs/'}).to_html
|
||||||
html.gsub(/\A<div class="maruku_wrapper_div">\n?(.*?)\n?<\/div>\Z/m, '\1')
|
html.gsub(/\A<div class="maruku_wrapper_div">\n?(.*?)\n?<\/div>\Z/m, '\1')
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
require 'active_record'
|
|
||||||
|
|
||||||
task :upgrade_instiki => :environment do
|
task :upgrade_instiki => :environment do
|
||||||
ActiveRecord::Base.establish_connection(:production)
|
RAILS_ENV = 'production' unless ENV['RAILS_ENV']
|
||||||
webs = ActiveRecord::Base.connection.execute( "select * from webs" )
|
puts "Upgrading Instiki in #{RAILS_ENV} environment."
|
||||||
webs.each do |row|
|
|
||||||
if File.exists?('public/' + row[4])
|
Web.all.each do |web|
|
||||||
if File.exists?('webs/' + row[4])
|
public_path = Rails.root.join("public", web.address)
|
||||||
print "Warning! The directory webs/#{row[4]} already exists. Skipping.\n"
|
if public_path.exist?
|
||||||
|
webs_path = Rails.root.join("webs", web.address)
|
||||||
|
if webs_path.exist?
|
||||||
|
puts "Warning! The directory #{webs_path} already exists. Skipping."
|
||||||
else
|
else
|
||||||
File.rename('public/' + row[4], 'webs/' + row[4])
|
public_path.rename(webs_path)
|
||||||
print "Moved: #{row[4]}\n"
|
puts "Moved #{public_path} to #{webs_path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue