[Home]WikiPatches/GetSubpages

UseModWiki | WikiPatches | RecentChanges | Preferences

new command for the rename page: list of subpages for a given page.

Written by Tarquin for UnrealWiki.

usage:

 ?PageName?

Produces a list of all the subpages of PageName?.

This patch extends to WikiPatches/RenameSubpages


diff -r1.23 -r1.22
2772,2784d2771
< # tarq
< sub AllSubPagesList {
<   my $GivenPage = shift;
<   my @PageList = AllPagesList();
<   my @Results;
<   foreach ( @PageList ) {
<     if (/^$GivenPage\//i) {                  # BrianHunter
<       push @Results, $_;
<     }
<   }
<   return @Results;
< }
< 
4373d4359
<   print "<tt>?PageName</tt> -- gets list of all subpages of this page\n";#tarq

4382d4367
< 
4398,4399c4383
<     next  if (!(/^[=!|?]/));  # Only valid commands. tarq
<     #next  if (!(/^[=!|]/));  # Only valid commands.
---
>     next  if (!(/^[=!|]/));  # Only valid commands.
4407,4409d4390
<     } elsif (/^\?(.+)/) {
<       print "<b>Subpages of " . $1 . "<BR></b>";
<       print join("<br>", AllSubPagesList($1));
4733c4714
<   
---
> 


Could you please give some context here? The line numbers seem to fit only your personal patched script! I like your idea and wanted to implement the patch, but this info is simply insufficient without analysing the code thoroughly! This applies to WikiPatches/RenameSubpages as well. -- DavidAndel


I added automatic creation of hyperlinks in the list of the found SubPages. Here we are some context to this patch:

First block (2772,2784d2771) can be placed in anywhere (it is the whole subroutine AllSubPagesList?), for example just below subroutine AllPagesList:

 sub AllPagesList {
   ...
 }
 
 sub AllSubPagesList {
   my $GivenPage = shift;
   my @PageList = AllPagesList();
   my @Results;
   foreach (@PageList) {
     if (/^$GivenPage\//i) {      # BrianHunter
       push @Results, $_;
     }
   }
   return @Results;
 }

 
 sub CalcDay {
   ...

Second block (single line 4373d4359) falls into subroutine DoEditLinks? between these two lines:

   print "<p>Enter one command on each line.  Commands are:<br>",
         "<tt>?PageName</tt> -- gets list of all subpages of this page\n",
         "<tt>!PageName</tt> -- deletes the page called PageName<br>\n",

Third block (4382d4367) can be safely ignored.

Fourth block (4398,4399c4383) replaces this line in subroutine UpdateLinksList:

     s/\s+$//g;
     next  if (!(/^[=!|]/));  # Only valid commands.
     print "Processing $_<br>\n";

with this line:

     s/\s+$//g;
     next  if (!(/^[=!|?]/));  # Only valid commands.
     print "Processing $_<br>\n";

Fifth block (4407,4409d4390) goes under subroutine UpdateLinksList between these lines:

        &DeletePage($1, $doRC, $doText);
     } elsif (/^\?(.+)/) {
       print "<b>Subpages of " . &GetPageLink($1) . "<BR></b>";
       print join("<br>", map { &GetPageLink($_) } &AllSubPagesList($1));
       print "<br><br>";                                                              # BrianHunter
     } elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {

Sixth block (4733c4714) can be safely ignored.

-- FerdinandPrantl


The line in the second block should end with a <br>
   print "<p>Enter one command on each line.  Commands are:<br>",
         "<tt>?PageName</tt> -- gets list of all subpages of this page<br>\n",
         "<tt>!PageName</tt> -- deletes the page called PageName<br>\n",

-- Ralf Baerwaldt


The "diff -r1.23 -r1.22" shows the wrong direction !

For better readablity it should be the other way around:

"diff -r1.22 -r1.23"

-- Ralf Baerwaldt


I have corrected the match for identifying the subpage in the line
if (/$GivenPage\//i) {
to
if (/^$GivenPage\//i) {

The original match found subpages of pages whose name ended with the name of the main page.
e.g. ?Tech would find MyTech/SubPage as well as Tech/SubPage

This does not matter too much on a list BUT had an interesting effect when the WikiPatches/RenameSubpages patch was applied.
A rename of Tech/* to MyTech
=Tech/*=MyTech could be done muliple times. Each time the subpages would have an extra My prefixed to the main page name.

Also, after the line

       print join("<br>", map { &GetPageLink($_) } &AllSubPagesList($1)); 
I've added the line
       print "<br><br>"; 
to Ferdinands mod for an improved format list where multiple commands are issued.
--BrianHunter
But /^$GivenPage\//i match found subpages of pages whose name started with the name of the main page; i.e. TechFoo/SubPage--JuanmaMP

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited November 30, 2017 8:05 pm by JuanmaMP (diff)
Search: