Not logged in. · Lost password · Register
Forum: General Help and Support Features and Functionality RSS
Restructuring namespaces
Avatar
pchan #1
Member since Apr 2007 · 111 posts · Location: Lille, France
Group memberships: Members
Show profile · Link to this post
Subject: Restructuring namespaces
Hi, I wish to evaluate DokuWiki for heavy uses (up to 100,000 pages).
Namespaces is the solution to this situation. Now once the pages are so structured,
are there tools to restructure them easily ?
E.g. Change references in all pages from x:subject to y:subject ?

Maybe it's easy to build such a  plugin (which will take time to run, ok).
Avatar
Falkor #2
Member since Apr 2007 · 32 posts
Group memberships: Members
Show profile · Link to this post
If you are inserting the pages into a new installation dokuwiki (not moving them around),
one can easily make a perl-script that will do this for you.

I'm assuming that each file has either in content or in filename an indication of what namespace they should be moved.

Let's say the files have names in the following structure: "namespace-title.txt". A _sample_ script that would do the job is:

#!/usr/bin/perl -w
use strict;
use File::Copy;

my @files = <*.txt>; #Assuming that's how they're named.

foreach(@files){
my ($ns, $title) = split(/-/, $_);

if(!-d $ns){
mkdir($ns);
}

move($_,$ns."/".$title);
chmod(0775, ); #you can give stricter permissions if you share a group with the webserver. Alternatively,
                           #comment out the line and run the script as the web server (can be very dangerous).
}

Please bear in mind that this is just a quick script - DO NOT USE IT AS IS.
It will not honor that the file in the namespace already exists.
It will not make any changes to a file other then creating dirs or renaming.
It cannot make subdirs, this functionality is something you must add (recursive for example).
It will not understand if you go over the file limit of the fs (it will probably just crash).

The reason it works is because dokuwiki allows you to just drop new files in the folders (as long as you give dokuwiki permission to
access them).

If you want to change all references, you have to read each file and substitute (either with perl or some other unix tools like cat+awk).
There is already a plugin for this, but it only does single files. It's source can defintely give you inspiration tho ;-)

Good luck,

//Falkor
Avatar
pchan #3
Member since Apr 2007 · 111 posts · Location: Lille, France
Group memberships: Members
Show profile · Link to this post
Thank you very much for the hint!
In fact, I've found the plugin called pagemove.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-08-22, 02:38:07 (UTC +02:00)