GullFOSS
OpenOffice.org Engineering at Sun
 
 
 
 
More Flickr photos tagged with openoffice

Today's Page Hits: 1585

Locations of visitors to this page
« New: OpenOffice.org... | Main | New: OOo-Dev 3.0... »
Friday, 04 Jul 2008
ODF@WWW - Simply Install
Kay Ramme

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


As all of you are hopefully by now as enthusiastic about the ODF@WWW as I am, and as all of you by now know how it works, I would like to give detailed instructions on how to install it.

The prerequisites are the following:

You need some documents and images to get started with the ODF Wiki.

Last but not least you need some glue code, to tie everything together.

For your safety&convenience I packed everything into a tar file to be downloaded from mediacast. On my system I use the following directories:

  "/var/www" - For all the content, e.g. the documents listed above.

  "/usr/lib/cgi-bin" - For all the scritpts, and finally ...

  "/etc/apache2/" - For the httpd.conf file.

I did unzip the JODConverter in the "/usr/lib/cgi-bin" directory for easy access. You may need to move the files to the appropriate directories and may slightly need to adapt them to match your system. I just needed to untar the "odf-at-www.tgz" in the root directory:

  > su -
  > cd /
  > tar -xvzf odf-at-www.tgz
  > apache2ctl restart
  > soffice -accept="socket,port=8100;urp;"

That's it ... I hope you enjoy it :*)

Best regards

     Kay


And here comes the code (without any warranty ;-) :

httpd.conf

  LoadModule dav_module     /usr/lib/apache2/modules/mod_dav.so 
  LoadModule dav_fs_module  /usr/lib/apache2/modules/mod_dav_fs.so
  LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

  DAVLockDB /var/apache2/DAVLock
  <Directory /var/www>
    Dav On
    RewriteEngine On

    # Rewrite directory "/" to index.html, apply other rules.
    RewriteRule ^/$         /index.html [next]
    
    # Forward any html request to the converter.
    RewriteRule ^.*\.html$  cgi-bin/convert.sh       [PT=application/x-httpd-cgi]
  
    # Forward any odf indirector request to redirector.
    RewriteRule ^.*\.od.r$  cgi-bin/redirect-odf.sh [PT=application/x-httpd-cgi]
  </Directory>

convert.sh

  #!/bin/sh

  # Abort on error.
  set -e 

  # Save stdout and stderr.
  exec 6>&1
  exec 7>&2

  # Redirect stdout and stderr to log file.
  exec 2>&1 > /tmp/convert.sh.log

  # Do some logging.
  echo '********arg********\n' $* 
  echo '********env********\n' $(env)
  echo '********set********\n' $(set)
  echo '*******************'

  # The file we need to provide.
  file=$DOCUMENT_ROOT$REDIRECT_URL

  # Ensure that a HTML file is available.
  make -f convert.mk $file

  # Reset stdout redirection.
  exec 1>&6

  # Dump the content.
  echo "Content-Type: text/html"
  echo
  cat $file
  echo

redirect-odf.sh

  #!/bin/sh

  # Abort on error.
  set -e 

  # Save stdout and stderr
  exec 6>&1
  exec 7>&2

  # Redirect stdout and stderr to log file.
  exec 2>&1 > /tmp/redirect-odf.sh.log

  # Do some logging.
  echo '********arg********\n' $* 
  echo '********env********\n' $(env)
  echo '********set********\n' $(set)
  echo '*******************'

  # The documents base file name
  # is everything but the last 'r'.
  bfile=${REDIRECT_URL%r}

  # Ensure that an ODF file is available.
  make -f convert.mk "$DOCUMENT_ROOT$bfile"

  # Reset stdout redirection.
  exec 1>&6

  # Dump the content.
  echo "Content-Type: text/url"
  echo
  echo "http://$HTTP_HOST$bfile"

convert.mk

  # Don't delete any intermediates.
  .SECONDARY:

  # Create a '.html' from an '.ods'.
  %.html: %.ods
        ./convert_ods.sh $^ $@ $(notdir $*)

  # Create a '.html' from an '.odt'.
  %.html: %.odt
	./convert_odt.sh $^ $@ $(notdir $*)

  # Create a '.html' from template.
  %.html:
	./make_dummy.sh $(dir $@)/dummy.html $@ $(notdir $*) 


  # Create an '.odt' from template.
  %.odt:
  	cp $(dir $@)/dummy.odt $@

  # Create an '.ods' from template.
  %.ods:
	cp $(dir $@)/dummy.ods $@

convert_odt.sh

  #!/bin/sh

  # Abort on error.
  set -e 

  source=$1 ; shift
  target=$1 ; shift
  stem=$1   ; shift

  thisDir=$(dirname $0)/

  temp=$(mktemp)
  java -jar ${thisDir}jodconverter-2.2.1/lib/jodconverter-cli-2.2.1.jar $source $temp.html

  btemp=$(basename $temp)

  body_tag='<BODY LANG="en-US" DIR="LTR">'
  edit_tag='<div style="position: fixed; background: url('tbbg.png') repeat-x; height: 38px; left: 0%; 
    padding-left: 5px; width: 100%; top: 0px; bottom: 38px;">\n  <a href="http://'${HTTP_HOST}
    /${stem}.odtr'">\n    <img alt="Edit..." src="tbbtn.png" width="112" height="38" border="0" 
    longdesc="Edit document in OpenOffice.org"/>\n  </a>\n</div>\n<br>\n<br>'

  sed "s!smb://!http://!g"                     $temp.html | \
  sed "s!\.odt\"!\.html\"!g"                              | \
  sed "s!\.ods\"!\.html\"!g"                              | \
  sed "s!SRC=\"$btemp!SRC=\"$stem!g"                      | \
  sed "s!${body_tag}!${body_tag}${edit_tag}!"             > $target

  set +e
  files=$(ls ${temp}_html_*)
  set -e

  target_stem=${target%%.*}
  for file in $files ; do
    varpart=${file##*_}

    cp $file ${target_stem}_html_${varpart}
  done

convert_ods.sh

  #!/bin/sh

  # Abort on error.
  set -e 

  source=$1 ; shift
  target=$1 ; shift
  stem=$1   ; shift

  thisDir=$(dirname $0)/

  temp=$(mktemp)
  java -jar ${thisDir}jodconverter-2.2.1/lib/jodconverter-cli-2.2.1.jar $source $temp.html

  btemp=$(basename $temp)

  body_tag='<BODY TEXT="#000000">'
  edit_tag='<div style="position: fixed; background: url('tbbg.png') repeat-x; height: 38px; left: 0%;
    padding-left: 5px; width: 100%; top: 0px; bottom: 38px;">\n  <a href="http://'${HTTP_HOST}
    /${stem}.odsr'">\n    <img alt="Edit..." src="tbbtn.png" width="112" height="38" border="0" 
    longdesc="Edit document in OpenOffice.org"/>\n  </a>\n</div>\n<br>\n<br>
    \n<br>'

  sed "s!\.odt\"!\.html\"!g"                  $temp.html | \
  sed "s!\.ods\"!\.html\"!g"                             | \
  sed 's!file://!http://localhost!g'                     | \

  sed "s!SRC=\"$btemp!SRC=\"$stem!g"                     | \
  sed "s!${body_tag}!${body_tag}${edit_tag}!"            > $target

  set +e
  files=$(ls ${temp}_html_*)
  set -e

  target_stem=${target%%.*}
  for file in $files ; do
    varpart=${file##*_}

    cp $file ${target_stem}_html_${varpart}
  done

make_dummy.sh

  #!/bin/sh

  # Abort on error.
  set -e 

  # Save stdout and stderr
  exec 6>&1
  exec 7>&2

  # Redirect stdout and stderr to log file.
  exec 2>&1 > /tmp/make_dummy.sh.log

  # Do some logging.
  echo '********arg********\n' $* 
  echo '********env********\n' $(env)
  echo '********set********\n' $(set)
  echo '*******************'

  source=$1 ; shift
  target=$1 ; shift
  stem=$1   ; shift

  sed 's!localhost/dddddddd!'$HTTP_HOST/$stem'!g' $source > $target

tags:

Posted by Kay Ramme on 04 Jul 2008  |  PermaLink |  Bookmark to Delicious To Delicious |  Digg this Digg this  |  Comments[7]

Comments

Dmitri Popov said:

Thank you so much for the great solution. Just out of curiosity, what Linux distro do you use with odf@www?

Posted by Dmitri Popov on July 08, 2008 at 09:06 PM CEST #

Kay Ramme said:

Hi Dmitri,

I first got this running on my laptop, which ... despite being a Mac Book ... most of the time runs "Debian unstable" :-)

Regards

Kay

P.S.: I know, I am a "version junkie" ;-)

Posted by Kay Ramme on July 09, 2008 at 08:43 AM CEST #

Dmitri Popov said:

Hi Kay,

Thanks for your reply. I'm considering writing an article about odf@www, but I'm having problems running it on Ubuntu 8.04. Could you help me with this? Just shoot me an email (dmpop at openoffice dot org) if you have time for this. Thank you!

Posted by Dmitri Popov on July 09, 2008 at 01:36 PM CEST #

Frank Peters said:

Hi Kay,

what an exciting concept!

I tried to install it here on my machine to play with it and noticed some pitfalls:

I am using apache2 and created a virtual host on :88 for the odfwiki. Redirector is enabled but redirection does not seem, to work with "/"

The index.odt file that you provide contains links to smb://so-xsomething/clientinstall.odt. The URL don't seem to have been saved as relative URLs.

When I click on the Edit button in the browser, it seems like a URL string is sent. If I assign this to OOo, the application opens with the URL string in a text doc instead of the URL itself. The mime type sent is text/url. What do I need to do to make soffice open the URL and not the string?

Posted by Frank Peters on July 09, 2008 at 02:35 PM CEST #

Juan Lavieri said:

Hi Kay and other friends

I'm having problems with the scripts and I think it's an apache configuration problem.

Directory /var/www is defined as follows: drwxr-xr-x 4 root root 4096 2008-07-11 18:16 www

When I type in the browser http://localhost/index.html, it responds with a 500 Internal server error. Apache log says: "Premature end of script headers: convert.sh". Performing a little debugging I can see the error is produced in the convert_odt.sh script in the moment when it about to write the index.html file in the directory I mean when the last sed instruction is executed (this line: sed "s!${body_tag}!${body_tag}${edit_tag}!" > $target"
The file is not written into the directory. If I change the permissions of the /var/www directory to 777 it actually writes the index.html file but with 0 bytes lenght. I don't know apache very well, so please help me if you can.

Best regards.

Juan

Posted by Juan Lavieri on July 12, 2008 at 12:58 AM CEST #

Kay Ramme said:

Juan,

there should be some log files in /tmp ending with .log, e.g. /tmp/convert.sh.log, which may help to debug this. To avoid the security problems you need to run the server site OOo as "root". I know this is not optimal, but the ODF@WWW is a rough prototype currently only anyway ;-)

I plan to provide some virtual boxes (OpenSolars, Ubuntu) with the ODF@WWW preinstalled by end of the week / early next week. This may help you, as you can compare a running system with you own installation.

I also plan to do another blog posting regarding communications channels etc. and I plan to organize an IRC meeting for further discussions ... unfortunately I have to do some travelling this week, so time is tigh ;-)

Best regards

Kay

Posted by Kay Ramme on July 14, 2008 at 11:29 AM CEST #

Juan Lavieri said:

Hi Kay, Thanks for your answer. I knew about the logs, I used them to trace where is the problem (I coded some "echo" inside the script saw the problem. Let me work as root and I'll tell you. Please let us know when the virtual box are ready I'd like to test OpenSolaris.

Thank you very much for your help

Juan

Posted by Juan Lavieri on July 14, 2008 at 11:18 PM CEST #

Post a Comment:
Comments are closed for this entry.
« New: OpenOffice.org... | Main | New: OOo-Dev 3.0... » GullFOSS