In my last post I detailed how to create a custom book in Coda using a locally hosted web site, for offline browsing.

After successfully bypassing the warning that I was offline, I could finally browse the local documentation, but was left with no way to search it.

To solve this problem I wrote a simple php page that greps through the html files and displays the results ordered by the number times the search term appears.

It’s a minimalist concept that was hacked together in about an hour, but it gets the job done. More elaborate site searches could be implemented that could display the actual matching string or the title of the file containing the match, but my code is simple and offloads the task of actually finding text within files to grep, so it is relatively fast.

You can see the php source code here: grep.php.txt.

After writing the script I was annoyed to discover that the cool “command+double click to search” feature was set to use the online version of the php docs when editing in PHP-HTML mode. I could not give my custom offline book priority even after selecting PHP-HTML from the “use for mode” drop down.

So now I can view and search offline documentation from within Coda and even though I can’t use my custom book for in-code searches, two out of three ain’t bad.