[dokuwiki] Re: create new pages with a bash-script

On Thu, 28 Jul 2005 19:59:13 +0200
Martin Baum <martin.baum@xxxxxxxxx> wrote:

> Hello.
> 
> Is there a easy way to add new pages in dokuwiki? I will create a 
> photo-gallary and need _many_ nearly equal pages. I think, I will do
> it in bash and will use the command tool php for it.
> 
> So can I call the functions act_save(..) or saveWikiText(..) for it?
> Can anyone give me a short example for the right parameter I need?

You don't need that. Just create text files in the appropriate namespaces (be 
sure to save them UTF-8 encoded)

If you want some additional info (like recent changes) add your addition to the 
changes.log

something like this should work:

-------------------
#!/bin/bash

mkdir -p data/pages/gallery
for file in `find data/media/gallery/ -name '*.jpg'`
do
  name=`basename "$file" '.jpg'`
  page="data/pages/gallery/$name.txt"

  echo "====== $name ======

{{ gallery:$name.jpg?300 }}

" > $page

  time=`stat -c '%Y' $page`

  echo -e "$time\t127.0.0.1\t$name\tandi\tautomatic creation" \
  >> data/changes.log
fi
--------------------

This is some untested 5 minutes work, but you should get the idea.
And it's a good example why flatfiles rule :-D

Andi

Other related posts: