Privacy, caching and making Safari behave

One of the sites I’m working on has health related information, which is very important to keep private. In particular, after the user logs out, we have to make its pages unavailable via the Back button. it took some work to convince all browsers we meant it, but here’s what works for Safari 3, Firefox 2 & 3 (Mac OS 10.4 Intel), IE 7, Firefox 2 & 3 (Win XP and Vista), IE 6 (Win 2K):

Set the response headers in an after_filter:

def set_header
#Date in the past
headers["Expires"] = “Mon, 26 Jul 1997 05:00:00 GMT”
#always modified
headers["Last-Modified"] = “Mon, 26 Jul 1997 05:00:00 GMT”
headers["Cache-Control"] = “no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0″
#HTTP/1.0
headers["Pragma"] = “no-cache”
 end

To make Safari behave, add this to all pages:

<iframe style=”height:0px;width:0px;visibility:hidden” src=”about:blank”>
This frame prevents back forward cache in Safari.
</iframe>

Switched to WordPress

Typo just wasn’t making me happy.  There were little bugs I had to fix and annoyances with posting code snippets.  I poked around the internet a little, gathering up opinions and decided to give WordPress a try. You can install it on cPanel via Fantastico De Luxe, which made it easy to get started.  My next step is to understand manual installation and get it under git.  

Yikes….dangling commit!

 

 I discovered today what happens when you add and commit with git while you are not on any branch.  You get a dangling commit and it looks for all the world like there is no way to get that work back.  But all is not lost!  Between  this great post in Mathieu Martin’s blog and Eric available just when I needed him even though he’s over in France, I figured out that you can use “git fsck –lost-found” to get the sha code and then “git rebase sha” to merge that commit into your working branch.  Phew.  I had a ton of tiny, picky changes and was really not looking forward to redoing them all!

Running Rspec tests in TextMate

For a while I had a problem running my Rspec tests using the TextMate bundle.  It was calling the wrong lib for Ruby, even though I had the shell variables set correctly in the TextMate preferences.  When I tried to run a spec in TextMate, I got this:

/usr/lib/ruby/site_ruby/1.8/rubygems.rb:377:in
`report_activate_error’: Could not find RubyGem rails (>= 0)
(Gem::LoadError) from
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:309:in `activate’ from
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:76:in
`active_gem_with_options’ from
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem’ from
/Users/lisasawin/Rails Web Applications/CHC/config/boot.rb:39 from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require’ from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from /Users/lisasawin/Rails Web Applications
/CHC/config/environment.rb:11 from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require’ … 15 levels… from
/Users/lisasawin/Library/Application
Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:31:in
`chdir’ from
/Users/lisasawin/Library/Application
Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:31:in
`run’ from
/Users/lisasawin/Library/Application
Support/TextMate/Bundles/RSpec.tmbundle/Support/lib/spec/../spec/mate/runner.rb:14:in
`run_file’ from /tmp/temp_textmate.zQ2Hv1:4

 

I just couldn’t get TextMate to use the library in usr/local/bin/ruby instead  of looking in usr/lib/ruby,  I gave up for a while and ran tests manually in a shell, but that was a pain.  Another web search led me to dnite’s blog.  He described how to set up a new ~/.MacOSX/environment.plist with the correct PATH definition:

 <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN”
 <plist version=”1.0″>
 <dict>
     <key>PATH</key>
  <string>/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin</string>
 </dict>
 </plist>

Don’t forget to log out & in for it to take effect.  Worked for me!

Getting Started

A blog has seemed like a good idea for a long time.  Now I’m getting started.

Getting it up and running with Typo hosted by HostingRails was a snap.  I was a little concerned that fastcgi would be a problem, since the Typo install page didn’t mention it up front.  Down the page was info on how to make it work, but it seemed like there might be some hitches.  The excellent forums over a HostingRails mentioned:

If you don’t have dedicated memory with your account you need instead just download the typo.tgz and install it like any other rails application.

So, I just downloaded typo.tgz and followed the regular tutorial on getting a Rails app deployed.  It worked perfectly!  Now I just need to figure out the whole caching thing, which may or may not be a problem with typo via fastcgi.