[Pmwiki-users] Conversion tool for V2 // PHP-diff

Knut Alboldt alboldt
Tue Jun 8 09:18:40 CDT 2004


Just an idea for an implementation of an conversion tool (V0.6 to the new 
one ):

idea: implementing a change-all-strings-function

rough concept:

1) setting up a second wiki with the new version
2) copying the wiki.d dir from the old to the new wiki
3) implementing a new module (changewiki / changetext etc ...) described below
4) calling new function in new wiki which grabs all pages of the wiki, 
changes string and write them back into the wiki
if wanted "diff" can be turned on, so all changes are logged in the pages 
itself and a list of all changes can be generated

the new module could be implemented like that:
action=changewiki
1) display input-form with fields for:
1a) pairs of old / new string (or even regexs) to change in the pages
1b) optionally: fields to include / exclude groups and / or pages by 
name-matching (regex, wildcard etc)
some pages should be excluded by default (e.g. *.RecentChanges ...)
1c) optionally: fields to include / exclude pages by searchpatterns for 
textpassages

submitting this form (e.g. action=changewiki2) will
2) get list of all wikipages of original (specified) wiki
3) setting the wikipath for pageretrieval = "new.wiki.d" (will temporarily 
disable wikilib.d, the pages in there should be ok for the new version)
4) for each page of this list:
4a) check for specified group / page-filters (by name, by contents), if not 
mathces => skip page processing
4b) read page (should read the page from the old wiki cause of the 
wikilibpath-specification)
4c) do the specified textprocessing (change all string old to new, possibly 
mor fl?exible with regex-processing) = simulating a user's edit
4d) saving the changed text, if diff is on, these changes will be logged in 
the page as well.
4e) Optional getting the change-log for later display in a list
5) if implemented: display list of changes (diff-output), maybe with a link 
to a new browserwindow to easyly restore the version before this batchrun 
so a erroneous change could be done by running through that list and 
clicking the links for restoring the pages


comments:
on 4c) that might be a bit tricky: first to escape the input well and 
second to give the user a chance of testing their regex
on 4d) which pmwiki-function could be used: HandlePost ?
on 4e) requires a extension of the existing diff function (xdiff ? => 
activated only within action=changewiki) to collect the changes for later 
display

for the conversion: rollback could be done by deleteing wiki.d and copying 
it over again

This tool could be used for any batch changement of text within a wiki. 
action should be only allowed for admins :-)
I think a backup of wiki.d before running is a good idea. (action=backup / 
action=restore ???:-)
to use it for the conversion 1=>2 it could be called directly by 
action=changewiki2 giving predefined arguments for changing (maybe another 
action=convert1to2) the text: e.g. $change["[[groupheader]]"] => 
"[:groupheader:]"; or $change["/[[(no)*group(header|group)]]"] => 
"[:$1group$2:]" etc

the basic feature could be implemented to do the conversion job, later the 
featurelist could be expanded for a batch-processing of a wiki (e.g. 
(logically) deleting pages, renaming pages and all references, 
wiki-replication etc => year 2020 ? :-)


another topic:

I would like to have the PHP-diff shown in the cookbook implemented in the 
new version as well. Not all ISP's support external commands like diff 
(security reasons)


Knut




More information about the pmwiki-users mailing list