Visar inlägg med etikett html. Visa alla inlägg
Visar inlägg med etikett html. Visa alla inlägg

fredag 23 januari 2009

Generate static version of mediawiki site

Here are some random notes on how to generate a static dump of a mediawiki site
  1. Download the DumpHTML.php extension:
    cd /var/tmp/
    svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/DumpHTML
  2. Copy the extension to the mediawiki installation (mine is in /var/lib/mediawiki, I use the packaged version for Debian Lenny).
    Become root.
    cp -r /var/tmp/DumpHTML /var/lib/mediawiki/extensions/
  3. Decide where to put the content (I use /var/www/staticdump here) and call the script:
    php /var/lib/mediawiki/extensions/DumpHTML/dumpHTML.php -d /var/tmp/staticdump --image-snapshot --force-copy --no-overwrite
Then my other web server (not apache, which serves mediawiki) can show the pages in /var/tmp/staticdump which is a lot faster than generating them with php.
The drawback is that some pages are not generated, such as the page listing all pages on the wiki.

The manual page for the extension is here: http://www.mediawiki.org/wiki/Manual:DumpHTML.php

måndag 29 januari 2007

Konvertera worddokument till html

Jag gillar inte att få wordfiler - för många tillämpningar är det bättre att använda en vanlig textfil eller html om man vill ha mer avancerad formatering. Dessutom krävs att man använder ett jätteprogram som ms word eller openoffice.
(läs mer här eller här eller varför inte här)

Jag fick en zipfil med massa worddokument i. Alldeles för jobbigt att konvertera för hand med openoffice. Istället konverterade jag .doc-filerna med hjälp av wvWare och filnamnens kodning med convmv.
#!/bin/bash
zipfile=/tmp/Cookbook2.zip
cd /tmp
mkdir -p kokbok
rm -rf kokbok
mkdir -p kokbok
cd kokbok
cp $zipfile .
unzip *.zip
rm *.zip
#convert those filenames
convmv -f iso8859-1 -t utf-8 * --notest -r
#convert from .doc to .html
find . -type f -name "*.doc" -exec word2html.sh {} \;
#delete the word files
find . -type f -name "*.doc" -exec rm {} \;
#zip everything together
zip -r /tmp/htmlcookbook.zip .
...där word2html.sh är scriptet
#!/bin/bash
if [ $# -ne 1 ]; then
echo exactly one input arg required
exit 1
fi

if [ ! -e "$1" ] ; then
echo "input file does not exist"
fi

outname=`echo "$1" | sed -e 's/.doc$/.html/g'`
wvWare "$1" > "$outname"


och vips så är rubbet konvertertat på en gång.