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.
(Visited 9,846 times, 1 visits today)
14 Responses
[…] Update: Sample code has been posted here http://eric-blue.com/2010/02/12/example-document-browser-code/ […]
Hi Eric
Thanks for your sharing, this code really needed by me. I will try it on my online library in campus.
Regards
__me
Hi,
Can i run this sample code in IIS 6.0, i am getting error while i am clicking on treeview node “Internal SErver error, page can not be displayed”. An error comes from while i am browsing “http://localhost:456/convert.cgi?docurl=http://localhost:456/Documents/testv1.doc”
how can i run the .cgi file in IIS web server? which interpreter should i install to make this run?
hi,
great work , i am searching from long time for such simple solution thanks a lot
thanks for the sample code…i uploaded it to my localhost…fired up apache but its not loading the sample documents…did i get something wrong..pls help…
Thanks for the tip…was awesome
I tried this by ‘ftping’ to my site to test here…http://interactivejoyouscob.com/doc..but got no output…is there somthing wrong? please i need help
hai eric,
i’m very interesting with your sharing about document browser, but after i’m download doc_browser_1_0 and copy to folder htdocs in xammp or apache2triad the index.html can’t open.
The error is:
#!/usr/bin/perl use strict; use HTML::Entities (); #———————————————————– # jQuery File Tree Perl Connector # # Version 1.0 # # Oleg Burlaca # http://www.burlaca.com/2009/02/jquery-file-tree-connector/ # 12 February 2009 #———————————————————– # for security reasons, specify a root folder # to prevent the whole filesystem to be shown # for ex: the root folder of your webbrowser my $root = “/docs/”; #———————————————————- my $params = &getCGIParams(); print “Content-type: text/html\n\n”; my $dir = $params->{dir}; $dir=~s/%20/ /g; my $fullDir = $root . $dir; exit if ! -e $fullDir; opendir(BIN, $fullDir) or die “Can’t open $dir: $!”; my (@folders, @files); my $total = 0; while( defined (my $file = readdir BIN) ) { next if $file eq ‘.’ or $file eq ‘..’; $total++; if (-d “$fullDir/$file”) { push (@folders, $file); } else { push (@files, $file); } } closedir(BIN); return if $total == 0; print ”
…………..
What should i do?
please help me.. 🙁
hey Eric! I had the same problem as kurniadi
thank u eric.
cool
i waiting for this code..
😉
Nice sharing Eric.
I was try this code on my xampp,
and I had configure the root in list.cgi and url in index.html according to my path.
and the problem is the box field to show list folder is not working.
just blank. Only view 2 empty box.
any have idea?
Help please..
Thx before
riko if you find any solution please tell me. here is my email – [email protected]
Hi Eric,
Thanks for ! Describe levels of the code…
🙂
Hello,
there’s a bunch of us with the same problem, could you please solve it?
I was trying this code on my site, and I had configure the root in list.cgi and url in index.html according to my path. And the problem is the box field to show list folder is not working, just blank. Only view 2 empty box.
do you have any idea?
Thank you
I emailed you about this a few months back, but I was wondering if you could convert this into PHP. Perl is a bit more vulnerable, and I think an upgrade to PHP would be great for security.
Also, maybe replacing flexpaper and the zviewer with PDF.js would make this more HTML5/modern…
https://github.com/mozilla/pdf.js
Anyway great work this is awesome!!
P.S. If you want to get really crazy/awesome, you could add JSON layers to your pdf with PHP and give the ability to annotate pdfs by adding markups to a JSON file.