[pmwiki-users] modifying wikish renaming pages/groups scripts to update links with spaces

Alex Eftimiades alexeftimiades at gmail.com
Sun Jul 22 23:00:32 CDT 2012


Hi again, I tried making this a page action as follows (in  
Site.PageActions)
* %item rel=nofollow% {(wikish source  
{$SiteGroup}.PageActions#RenamePage)}Rename Page:(:input text  
name=NewPage value={$FullName} size=30:)(:input submit name=submit  
value=Rename:)(:input end:)

(:if false:)
[[#RenamePage]]
wikish_form quickform process
if test -n "${submit}"
then
   if test "${NewPage}" ~= "/^[a-z0-9-]+(\.|\/)[a-z0-9-]+$/i"
   then
     if test {$Name}!={$Group}
       then
       set -s NewPagePN = `echo ${NewPage} | sed 's|\s||gi' | sed 's|/| 
\.|gi'`
       sed -i 's%({$Group}|{$Groupspaced})(/|\.)({$Name}|{$NameSpaced}) 
%${NewPage}%g' `pagelist link={$FullName} sep=\n`
       mv {$FullName} ${NewPagePN}
       wikish_form redirect target=${NewPagePN}
   fi
fi
[[#RenamePage]]
(:ifend:)

But with this setup the rename button is disabled. Could anyone tell  
me what part of this I need to fix? Perhaps I am going about this wrong.

Thanks,
Alex


On Jul 21, 2012, at 10:16 PM, Alex Eftimiades wrote:

> Yes this seems to work now. Thank you very much. I am going to try  
> to modify this into a page action and for renaming groups.
>
> Thanks
> Alex
>
> On Jul 21, 2012, at 12:53 PM, Peter Bowers wrote:
>
>> No that's fine.  If it's an action you do on a regular basis then
>> you'll probably want to put the code on a page and put it together
>> with a form, but that can easily be a future step.  Doing it in the
>> ControlPanel is a good way to get things working...
>>
>> I loaded the first command from your command history and noticed that
>> you have a newline in the middle of the line that should read like
>> this:
>>
>> sed -i 's|${OldGroup}([./]\)?)${OldPage}|${NewGroup}$1${NewPage}|gi'
>> `pagelist link=${OldGroupPN}.${OldPagePN} sep=\n`
>>
>> That should all be on one line with no newline before the  
>> `pagelist...
>>
>> It may have gotten confusing because the email may have automatically
>> wordwrapped it when I sent it to you.
>>
>> Anyway, I certainly don't want to come anywhere close to actually
>> running code like this on someone else's system, so I'm just letting
>> you know what needs to happen and then leave it up to you.
>>
>> If that works, please report back to the list that it was just a
>> newline due to the email wordwrapping.  If it doesn't work then let  
>> me
>> know and I'll take another look -- just give me the exact error
>> message since I'm wanting to avoid actually executing anything on  
>> your
>> system.
>>
>> -Peter
>




More information about the pmwiki-users mailing list