Friday, 27 Jun 2008
Friday, 27 Jun 2008
GullFOSS postings related to ODF@WWW:
19 Jun 2008 - ODF@WWW (An ODF Wiki)
27 Jun 2008 - ODF@WWW -How it works
04 Jul 2008 - ODF@WWW - Simply Install
22 Jul 2008 - ODF@WWW - Going forward ...
While demoing the ODF Wiki to OpenOffice.org and Sun Folks (and by the way, I happily demo it to everybody stumbling into my office :-), I recognized different reactions of people, there were the ones who obviously use Wikis in their daily work and who immediately understood what I wanted to show, namely the possibility of an ODF based Wiki with rich editing capabilities (including graphics, formulas etc.), than there were the ones who seemed to be disappointed, as I just recombined already available stuff, and finally the ones, whose first thought was about how I did implement this. So, this posting is just for the people curious about how it works :-)
For
implementing the prototype of an ODF Wiki I used off-the-shelf
components only, I have to admit, that I only tried it on Linux and
OpenSolaris ... Windows just seemed too far away ;-)
Actually it is fairly simple, the OpenOffice.org suite already has WebDAV support build in, that means that you already can load and store documents from WebDAV enabled servers. For Apache the WebDAV extension can be enabled like this:
LoadModule dav_module mod_dav.so
LoadModule dav_fs_module mod_dav_fs.so
DAVLockDB /var/apache2/DAVLock
<directory "/var/www">
Dav On
<directory>
What was missing yet was a way to make any stored documents
available as HTML to web browsers, while ensuring that a browser can forward a
document to OOo again for editing purposes. WebDAV was already there,
thus I looked how I could interpose delivering HTML pages by the web server, Apache provides for this the "rewrite_module", e.g. with the following
rule
RewriteRule .*\.html$ cgi-bin/convert.sh [PT=application/x-httpd-cgi]
I can ask Apache to always call my "convert.sh" script the moment an HTML page gets requested, OK, the foot was in the door for HTML pages. Next problem was, that the browsers I knew of always downloaded any linked file which they could not render themselves to the "/tmp" directory, to than call any registered helper apps with this copied file. For my ODF documents that meant, that OOo always opened a copy, located in the "/tmp" directory, of any linked ODF file instead of the genuine file on the server. Changing respectively saving such copy does obviously not touch the genuine file at all. The (only) solution which came to my mind was, to use an indirection file which contains the URL of the genuine document. For that I "invented" the new HTTP Content-Type "text/url". Such an indirection dump look like this:
Content-Type: text/url http://localhost/aspread.ods
This URL gets then downloaded by the browser, which stores it in a temporary file and than executes a little helper, this helper retrieves the URL from the indirection file and calls OOo with it.
What I needed was a rule for Apache to be able to generate the
indirection content (the URL of the genuine document) on the fly, while not conflicting with OOo WebDAV
access (to retrieve and store .odt, .ods etc.):
RewriteRule .*\.od.r cgi-bin/redirect-odf.sh [PT=application/x-httpd-cgi]
The "redirect.sh" script gets executed because of an indirector URL, which basically is the URL of a genuine document with a trailing 'r' (for "redirect"), it than removes the trailing 'r' and puts the reduced URL into the reply, while the Content-Type is "text/url" :-)
Only missing piece was now the conversion from ODF to HTML and the addition of the "Edit" button to the resulting HTML documents.
Coincidently Stefan Zimmermann pointed me to the JODConverter, which actually did provide exactly the functionality I needed, I now could create HTML documents from ODF documents on the command line on the fly. A little sed script and some glue code than helped to patch the generated HTML documents to include the "Edit..." button and the indirector link (e.g. "http://localhost/aspread.odsr" - notice the trailing 'r'). I am no artist and happily accepted Lutz Hoegers offer to create the images for the buttons etc., now everything was together, quite hacky but usable to give a demo and to create the screencast ... :-)
I am sorry that I didn't yet give installation instructions but hope explaining how it works is already helpful. My next blog posting, going to be called "ODF@WWW - Simply Install", is already in preparation, please be patient, it is only a matter of days :-)
To be continued ...
Regards
Kay
tags: apache odf opendocument openoffice.org wiki
Just a comment about security, probably easy to take care off.
Does "WebDav On" not entail support for HTTP PUT's/DELETE's across other sites your Apache server may be hosting?
See for example the "Limiting DAV Access to Authorized Users" section at http://www.webdav.org/mod_dav/install.html
I think there are web scanners looking for such "open" DAV sites.
Stephan
Posted by Stephan Wehner on June 29, 2008 at 11:25 AM CEST #
Hi Stephan,
you are right, users are not required to log in or anything, though this is more or less an example configuration. I have to admit that I don't have any real clue on web site administration ... ;-)
Regards
Kay
Posted by Kay Ramme on July 02, 2008 at 11:23 AM CEST #