Home » Knowledge Management, Open Source, Software Development, Wiki

Example Document Browser Code

Submitted by on February 12, 2010 – 11:51 am 6,098 views 13 Comments

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.

Post to Twitter Post to Delicious

13 Comments »

  • Suwidi says:

    Hi Eric

    Thanks for your sharing, this code really needed by me. I will try it on my online library in campus.

    Regards
    __me

  • nirav says:

    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?

  • Rajesh N says:

    hi,
    great work , i am searching from long time for such simple solution thanks a lot

  • Cornelius says:

    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…

  • Bello Segun says:

    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

  • kurniadi says:

    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.. :(

  • gulube says:

    hey Eric! I had the same problem as kurniadi

  • esplendida says:

    thank u eric.
    cool
    i waiting for this code..
    ;-)

  • riko says:

    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

  • gulube says:

    riko if you find any solution please tell me. here is my email – cmgulube@hotmail.com

  • Vaibhav Lanjewar says:

    Hi Eric,

    Thanks for ! Describe levels of the code…

    :)

  • Alex says:

    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

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.