Skip to content

Instantly share code, notes, and snippets.

@resolve
Created October 1, 2009 21:03
Show Gist options
  • Save resolve/199237 to your computer and use it in GitHub Desktop.
Save resolve/199237 to your computer and use it in GitHub Desktop.
namespace :refinery do
desc "Prepare a basic environment with blank directories ready to override core files safely."
task :override => :environment do
dirs = ["app", "app/views", "app/views/layouts", "app/views/admin", "app/views/shared", "app/controllers", "app/models", "app/controllers/admin", "app/helpers", "app/helpers/admin"]
dirs.each do |dir|
dir = File.join([RAILS_ROOT] | dir.split('/'))
Dir.mkdir dir unless File.directory? dir
end
end
desc "Required to upgrade from <= 0.9.0 to 0.9.1 and above"
task :fix_image_paths_in_content => :environment do
Page.all.each do |p|
p.parts.each do |pp|
pp.update_attribute(:body, pp.body.gsub(/\/images\/system\//, "/system/images/"))
end
end
NewsItem.all.each do |ni|
ni.update_attribute(:body, ni.body.gsub(/\/images\/system\//, "/system/images/"))
ni.update_attribute(:blurb, ni.body.gsub(/\/images\/system\//, "/system/images/"))
end
end
#http://resolvedigital.com/pages/frequently-asked-questions
desc "Convert ISO DB to unicode"
task :fix_encoding => :environment do
NewsItem.all.each do |ni|
body = ni.body
ni.body = body.gsub("’", "'").gsub("“", "\"").gsub("“", "\"").gsub("’", "'").gsub("—", "&mdash;").gsub("―", "&mdash;").gsub("…", "&hellip;").gsub("â„¢", "&trade;").gsub("â€", "").gsub("ò", "o")
puts "YES saved" if ni.save
blurb = ni.blurb
ni.blurb = blurb.gsub("’", "'").gsub("“", "\"").gsub("“", "\"").gsub("’", "'").gsub("—", "&mdash;").gsub("―", "&mdash;").gsub("…", "&hellip;").gsub("â„¢", "&trade;").gsub("â€", "").gsub("ò", "o")
puts "YES saved" if ni.save
end
PagePart.all.each do |pp|
body = pp.body
pp.body = body.gsub("’", "'").gsub("“", "\"").gsub("“", "\"").gsub("’", "'").gsub("—", "&mdash;").gsub("―", "&mdash;").gsub("…", "&hellip;").gsub("â„¢", "&trade;").gsub("â€", "").gsub("ò", "o")
puts "YES saved" if pp.save
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment