Web Developpers Documentation
Requirements
- javascript part only require a compatible browser with javascript enabled
- backoffice need a webserver supporting either php or python wsgi scripts.
- using the php backoffice, you need the ghostscript program
- using the python backoffice, you need preferentially the python poppler library, but it also works with ghostscript. You also need apache wsgi module.
Web server configuration
I use Apache as webserver, but it should work on any webserver capable of managing either php or python/wsgi script and setting alias or url rewriting.
Apache configuration sample
Alias /dare-dare /var/www/dare-dare/trunk/jslib SetEnv dare-dare.tempdir /tmp/dare-dare # uncomment if using php backend # ScriptAliasMatch /dare-dare/ws/.* /var/www/dare-dare/backend/php/dare-dare.php # uncomment if using python backend AddHandler wsgi-script .wsgi ScriptAliasMatch /dare-dare/ws/.* /var/www/dare-dare/backend/python/dare-dare.wsgi
per line explanation:
- Alias /dare-dare /var/www/dare-dare/trunk/jslib
path for the dare-dare.js file - SetEnv dare-dare.tempdir /tmp/dare-dare
this variable points to the directory where pdf documents are stored (see the following section for details) - ScriptAliasMatch /dare-dare/ws/.* /var/www/dare-dare/backend/php/dare-dare.php
If using php backend, uncomment this line (and set to the correct path) - AddHandler wsgi-script .wsgi
ScriptAliasMatch /dare-dare/ws/.* /var/www/dare-dare/backend/python/dare-dare.wsgi
If using python backend, uncomment those two lines (and set to the correct path). The AddHandler directive warns apache to interpret .wsgi files as python/wgsi scripts. See http://code.google.com/p/modwsgi/ for details on WSGI module configuration.
Documents storage
Documents that are intend to be viewed in Dare-Dare must be in the directory set to the dare-dare.tempdir variable (see upper). Then each document must be renamed src.pdf and placed in a subdirectory (which will be used as document name in HTML pages, when loading a document - see after).
For example, assuming we have both alice in wonderland.pdf and grimm's fairy tales.pdf documents, our storage hierarchy must look like:
/tmp/dare-dare/
. aliceinwonderland/
. src.pdf
. grimsfairytales/
. src.pdf
NOTE: directories must have read/write rights set to the webserver process owner
Insert Dare-Dare in your web pages
Here is a minimal HTML code for using Dare-Dare:
<html>
<head>
<script type="text/javascript" src="dare-dare/dare-dare.js"></script>
</head>
<body onload="docreader.init('aliceinwonderland', 'dare-dare/ws', undefined);">
<div id="docreader"></div>
</body>
Dare-Dare must be initialized after page load.
Call docreader.init() with the 3 following parameters:
- pdf document displayed at load. If set to undefined, we do not display any document at load.
- webservice path (related to your html page path).
- HTML element id where Dare-Dare is displayed in. If set to undefined, use HTML element where id = docreader.
You can load/change the displayed document afterward by calling docreader.open('mydocument').
