Hello,i've got the same problem. Reorganizing the wiki's namespaces,pages and mediafiles is a common task for every wikiadmin
and should therefore be an integrated part of dokuwiki. I do the job using a bash script (see below), but its really a hack.One should reindex the wiki after doing that, because the script works on the filesystem level only.
One thing so solve is to handle relative namespaces [[.:----]] on moving.
Oliver ------------------------------------------------- #!/bin/bash # # Move complete namespace (pages and media) to new location # changeing all references in pages # # USAGE: nsmove [wikiname [old namespace [new namespace]]] ##----------------------------------------------------------------------- -------#
BIN=$(dirname $0) # get commandline params wiki="$1" nsold="$2" ns="$3" if [ -z "$wiki" ] then read -p "Which wiki [adminwiki]: " wiki test -z "$wiki" && wiki="adminwiki" else echo "Use wiki: $wiki" fi DOKU_BASE=/opt/kreisbote/$wiki/dokuwikitest ! -d "$DOKU_BASE" && { echo "Wiki '$wiki' does not exist!"; exit 1; }
DOKU_SAVEDIR=$($BIN/dw_savedir "$DOKU_BASE") || exit 1 DOKU_PAGES="$DOKU_SAVEDIR/pages" DOKU_MEDIA="$DOKU_SAVEDIR/media" if [ -z "$nsold" ] then read -p "Old namespace: [[" nsold else echo "Old namespace: $nsold" fi nsold_dir="$DOKU_PAGES/${nsold//://}"test ! -d "$nsold_dir" && { echo "Old namespace not found: $nsold_dir"; exit 1; }
if [ -z "$ns" ] then read -p "New namespace: [[" ns else echo "New namespace: $ns" fi ns_dir="$DOKU_PAGES/${ns//://}" test -d "$ns_dir" && { echo "New namespace already exists!"; exit 1; } # find pages having links to namespace echo -n "Searching pages having links into old namespace... " pages=$(egrep -ril "\[\[$nsold\:" $DOKU_PAGES) if [ -z "$pages" ] then echo "No pages need to be changed." else n=$(echo "$pages" | wc -l) echo "$n pages need to changed." fi # make backup first echo "Backing up current pages to pages.bak..." mkdir -p "$DOKU_PAGES.bak" rsync -a "$DOKU_PAGES/" "$DOKU_PAGES.bak/" # replace links to old namespace if [ -n "$pages" ] then read -p "Replace wiki links in pages to new namespace? (y/n): " if [ "$RESULT" == "y" ]; then echo "Changeing links, please wait..." i=0 for file in $pages do i=$((i+1)) echo " file $i of $n: $file" sed -i 's/\[\['$nsold'\:/[['$ns':/g' $file || exit 1 done fi fi # move namespace directory if [ -d "$nsold_dir" ]; then echo "Move old page namespace to new location" echo " from: $nsold_dir" echo " to: $ns_dir" read -p "(C)ontinue, (S)kip, (A)bort: " RESULT case "$RESULT" in c|C) mv "$nsold_dir" "$ns_dir" || exit 1 ;; s|S) : ;; *) echo "Aborted by user"; exit 1;; esac fi # move media namespace diretory media_old="$DOKU_MEDIA/${nsold//://}" if [ -d "$media_old" ]; then media_new="$DOKU_MEDIA/${ns//://}" echo "Move old media namespace to new location" echo " from: $media_old" echo " to: $media_new" read -p "(C)ontinue, (S)kip, (A)bort: " RESULT case "$RESULT" in c|C) mv "$media_old" "$media_new" || exit 1 ;; s|S) : ;; *) echo "Aborted by user"; exit 1;; esac fi echo "Done." ---------------- #!/usr/bin/php <?php ## dw_savedir - Return the full path of the data directory for the given Dokuwiki (basedir)
# $wikidir = $argv[1]; $STDERR = fopen('php://stderr', 'w+'); if($argc < 2){ fwrite($STDERR, "Usage: ".basename($argv[0])." WIKIDIR\n"); exit(1); } if(!is_file($wikidir.'/inc/init.php')){fwrite($STDERR, "Given dir does not point to a dokuwiki: $wikidir \n");
exit(1); } $wikidir = realpath($wikidir); require_once($wikidir.'/inc/init.php'); $savedir = $conf['savedir']; # is it relative? if(substr($savedir,0,1) == '.'){ $savedir = $wikidir.'/'.$savedir; } print realpath($savedir)."\n"; ?> -- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist