Manually creating dokuwiki pages

I recently worked on a project where it would be really convenient to create some dokuwik pages using a script on some html content. I ended up using the CPAN/Perl module to convert HTML content to dokuwiki content, and then script the process necessary to create the pages inside dokuwiki.

In general, for a page to exist in dokuwiki, it must have 3 files present – *must be all lowercase*:

data/pages/$namespace/$page.txt
data/meta/$namespace/$page.meta
data/meta/$namespace/$page.indexed

The contents of the indexed page was simple 7 without a line ending in my case.

And then, it’s very useful to link to the page off of another page so that it can be accessed by means other than the search box.

I ended up generating the dokuwiki pages files using a perl script and then scp’ing them to the dokuwiki server (~100 files). Once there, I copied them into a namespace directory and added them to the page that was there using a simple bash script.

# add all files to existing page
for file in $(ls *.txt); 
do 
  echo "  * [[${file%%.txt}]]" >> $my_page.txt; 
done

#
# rename files to lowercase
# - note that even with upper case characters in the page they 
#   are referenced from, they must be lowercase files
#
for file in $(ls *.txt); 
do
  lowercase=$(echo ${file} | tr '[:upper:]' '[:lower:]');
  mv ${file} ${lowercase}; 
done

# create the indexed and meta files
cd data/meta/$namespace/
for file in $(ls ../../../pages/$namespace/); 
do 
  touch ${file%%.txt}.meta;
  echo -n "7" > ${file%%.txt}.indexed;
done

Once I had used this process, all of the new pages showed up on the page they were linked from.

2 thoughts on “Manually creating dokuwiki pages”

  1. Thanks for taking the time to post this. I’m looking to do something similar. We’ve got a ton of metadata about applications we develop, and while we can pull this together into a file and dump it onto the wiki server, it’s interesting to know about these other files.

    This was a few years ago, so I’m wondering if anything else came up from this? I.e. anything changed with dokuwiki upgrades etc.

  2. Hi Graham,

    I haven’t worked with this task since I posted back in early 2015 so I’m not sure how it might have changed. The client was acquired and started the migration to Sharepoint and I have moved on as well.

    Best,
    Josh

Leave a Reply

Your email address will not be published. Required fields are marked *