vJot’s a public code base, so I saw it unbecoming of an open-source guy to add my stats html to the repo. No worries, I’ll just add it with a little help via the wonder library, Capistrano:
task :after_symlink, :roles => :app do stats = <<-JS <script src="http://www.google-analytics.com/urchin.js"> </script> <script type="text/javascript"> _uacct = "UA-104904-8"; urchinTracker(); </script> JS layout = "#{current_path}/app/views/layouts/application.html.erb" run "sed -i 's?</body>?#{stats}</body>?' #{layout}" end
The code appends my Analytics’ javascript to the layout file and voilà, instant stats!
The secret sauce is that if you’ve defined an after_symlink task, Capistrano will run it during your regularly scheduled cap deploy. As a matter of fact, it has before_ and after_ hooks for all its tasks, including any tasks that you’ve written. Schweet.
Update: Thanks goes out to the unix gurus in the audience for shortening up my sed code.
Maybe you need to double-escape your sed backslashes?
I’m rocking the ? instead of / to avoid escaping woes, but maybe I’m missing something obvious.
sed’s in-place option (-i) is what you’re after.
run “sed -i’’ ’s?