Archive for July 2009

Building PHP 5.3.0 with Tidy Support

I dug around a bit, but most resources I came across on Google were about using the tidy extension for PHP rather than doing a custom build of PHP that included the tidy extension. Once I figured the details out, I thought I’d share. They admittedly seemed somewhat obvious after the fact, though also were not communicated as explicitly as I would have liked anywhere that I could see.

You’ll need a system with a CVS client installed to do this. The system I intended to build on didn’t have one, so I used my laptop, did a CVS checkout, made a gzipped tarball out of the CVS checkout directory, used scp to push it up to the remote server, and decompressed and extracted the archive from there.

  1. Download a PHP 5.3.0 tarball and decompress it.
    $ wget -c http://us2.php.net/get/php-5.3.0.tar.gz/from/a/mirror
    $ tar -zxf php-5.3.0.tar.gz
  2. Follow the anonymous checkout instructions to download tidy. Enter the first command shown here, press Enter without entering anything when prompted for a password, then enter the second command shown here.
    $ cvs -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy login
    Logging in to :pserver:anonymous@tidy.cvs.sourceforge.net:2401/cvsroot/tidy
    CVS password:
    $ cvs -z3 -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy co -P tidy
  3. When configuring the PHP build and specifying the path for tidy, just point to the root CVS checkout directory.
    $ ls tidy
    CVS  CVSROOT  bin  build  console  experimental  htmldoc  include  lib  src  test
    $ cd php-5.3.0
    $ mkdir build/php_build
    $ ./configure --prefix=`pwd`/build/php_build --with-tidy=../tidy
    $ make
    $ make install

I didn’t run into any problems when following this process. php -m shows the tidy module and it appears to run without issue. Hope this helps someone else.

OpenOffice Batch Export

I’m currently using Ubuntu Jaunty 9.04 as my primary operating system. I’ve been working with a set of presentation files that were originally in Microsoft PowerPoint format (PPT), but that I converted to OpenOffice Impress format (ODP) when it appeared that OpenOffice had an issue with retaining content formatting when exporting to PPT.

Multiple people have to handle these presentation files, though, and PPT is the most universal format supported by presentation programs like OpenOffice Impress and Keynote. Additionally, when the presentations are actually used, PDF is the required final format.

To alleviate myself of the need to export the ODP version to PDF and PPT manually each time I made changes to a presentation, I did some digging and came across the wonderful unoconv utility, which uses the OpenOffice UNO bindings to allow for conversion of documents between OpenOffice-supported formats.

If you have Ubuntu, installing the unoconv package via synaptic is all it takes to make this utility available to you. The only issue I ran into with that package is that the –list flag to return a list of supported formats returns the error "unable to get gail version number" without any output. Actual document conversion seems to work without issue.

If you don’t have Ubuntu, the unoconv web site makes Red Hat and Debian packages available as well as a tarball of the source code.

Below is the bash script I used.

#!/bin/bash
for file in `ls -1 *.odp`; do
    unoconv -d presentation -f pdf --stdout $file > PDF/${file/%odp/pdf};
    unoconv -d presentation -f ppt --stdout $file > .PPT/${file/%odp/ppt};
done