Example Document Browser Code
Since I posted my article last month on How To Create Your Own Personal Document Viewer, I’ve had a few inquiries on how people could have a similar setup themselves. I thought it might be helpful to .zip up the docbrowser project and show some of the code that does the conversions using the utilities I illustrated in the article. Disclaimer: This code is by no means my finest work (it was hacked together on a Sat. afternoon), but it gets the job done. At a high-level the code is very simple:
- Determine the doc extension and perform the appropriate conversion (.doc.pdf.xls) or redirect using an external app (mindmapviewer or Google books)
- Assign conversion commands to be executed for each doc type
- Before doc display, lookup converted doc in cache to speed up render time (use MD5 hash on the title)
I’ve created a .zip file(4.1MB) of the entire Doc Browser sample code. It contains the simple .CGI Conversion script, along with jQueryFileTree for rendering the doc tree, FlexPaper, and some sample documents.