Skip to content

Instantly share code, notes, and snippets.

@milesmatthias
Created April 29, 2014 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milesmatthias/9b3b73e287a63d310f71 to your computer and use it in GitHub Desktop.
Save milesmatthias/9b3b73e287a63d310f71 to your computer and use it in GitHub Desktop.
part of a rake task to create an index and thank you page from given title and primary color
desc "given a name and primary color, build static index and thank you pages, returning directory path of files"
task :build, :site_id, :name, :primary_color do |t, args|
dirname = DateTime.now.to_s
dirname += '_' + args[:site_id] if args[:site_id].length > 0
dirpath = Rails.root.join("tmp/static_builds", dirname)
system("mkdir -p #{ dirpath.to_path }")
system("cp -r #{ Rails.root }/static/* #{ dirpath.to_path }")
puts("name = #{ args[:name] }")
puts("primary_color = #{ args[:primary_color] }")
puts("dirpath = #{ dirpath }")
Dir.glob(dirpath.to_path + "/*").each do |fn|
IO.write(fn, File.open(fn){|f|
f.read
.gsub('__MVP__NAME__', args[:name])
.gsub('__MVP__PRIMARY_COLOR__', args[:primary_color])
})
end
dirpath.to_path
end
@milesmatthias
Copy link
Author

this is from manualviableproduct.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment