This is the historical archive of the now-inactive 'grubstreet' list.
Discussion on OpenGuides development has now moved to OpenGuides-Dev. Discussion on The Open Guide to London now takes place on OpenGuides-London.

Re: [grubstreet] Wiki indexing patch

[prev] [thread] [next] [lurker] [Date index for 2002/5/10]

From: Ivor Williams
Subject: Re: [grubstreet] Wiki indexing patch
Date: 00:56 on 10 May 2002
794a795,807
> sub GetIndexLink {
>   my ($id,$prefix) = @_;
>   $prefix ||= '';
>   my $name = $prefix.$id;
> 
>   $id =~ s|^/|$MainPage/|;
>   if ($FreeLinks) {
>     $id = &FreeToNormal($id);
>     $name =~ s/_/ /g;
>   }
>   return &ScriptLink("id=$id&action=index", $name);
> }
> 
827c840
<   my ($id, $name) = @_;
---
>   my ($id, $name, $prefix) = @_;
849a863
>     return &ScriptLink("id=$id&action=index",$prefix.$name) if $prefix;
856a871
>   return &ScriptLink("id=$id&action=index",$prefix.$name) if $prefix;
963c978
<     $result .= $q->h1($header . &GetSearchLink($id));
---
>     $result .= $q->h1($header . &GetIndexLink($id));
1205,1206c1220,1221
<       s/\[\[$FreeLinkPattern\|([^\]]+)\]\]/&StorePageOrEditLink($1, $2)/geo;
<       s/\[\[$FreeLinkPattern\]\]/&StorePageOrEditLink($1, "")/geo;
---
>       s/\[\[(\+|&gt;)?$FreeLinkPattern\|([^\]]+)\]\]/&StorePageOrEditLink($2, $3, $1)/geo;
>       s/\[\[(\+|&gt;)?$FreeLinkPattern\]\]/&StorePageOrEditLink($2, "", $1)/geo;
1441c1456
<   my ($page, $name) = @_;
---
>   my ($page, $name, $indexLink) = @_;
1450c1465,1466
<   return &StoreRaw(&GetPageOrEditLink($page, $name));
---
>   $indexLink = '>' if $indexLink;
>   return &StoreRaw(&GetPageOrEditLink($page, $name, $indexLink));
2910c2926,2928
<   print &GetHeader('', T('Index of all pages'), '');
---
>   my $id = &GetParam('id');
>   my $head = 'Index of '.($id || 'all pages');
>   print &GetHeader('', T($head), '');
2912c2930,2936
<   &PrintPageList(&AllPagesList());
---
>   my @PageList=&PageIndex($id);
>   if (@PageList) {
>    &PrintPageListIndented(@PageList);
>   } else {
>    print "<h3>No Pages Found</h3>";
>   }
>   &PrintOuterIndices($id) if $id;
3049a3074,3085
> 
> sub PrintPageListIndented {
>   
>   foreach (@_) {
>     /(^|\+)([^+]+)$/;
>  my $pagename = $2;
>  my @plusses = /\+/g; 
>  print "..." x @plusses;
>     print &GetPageLink($pagename), "<br>\n";
>   }
> }
> 
3418a3455,3514
> sub PrintOuterIndices {
>   my ($id) = @_;
>   my (%appearsOn);
> 
>   &OpenPage($id);
>   &OpenDefaultText();
>   my $txt = $Text{'text'};
>     
>   foreach my $refer ($txt =~ /\[\+(.+?)\]/g) {
>    $refer = &FreeToNormal($refer);
>    $appearsOn{$refer}++;
>   }
>   return if !%appearsOn;
>   print "<HR>\n";
>   print &GetIndexLink($_,'>'),"<BR>\n" foreach (sort keys %appearsOn);
> }
> 
> sub PageIndex {
>   my ($string) = @_;
>   my ($name, %found);
>   my (%appearsOn);
> 
>   foreach $name (&AllPagesList()) {
>     &OpenPage($name);
>     &OpenDefaultText();
>  my $txt = $Text{'text'};
>     
>  foreach my $refer ($txt =~ /\[\+(.+?)\]/g) {
>   $refer = &FreeToNormal($refer);
>   push @{$appearsOn{$refer}},$name;
>  
>   $found{$name}++ if !$string 
>     || $name eq $string 
>     || $refer eq $string;
>  }
>   }
>   
>   my $goAgain = 1;
>   while ($goAgain) {
>     $goAgain = 0;
>  foreach (my @k = keys %found) {
>    my ($parent) = /([^+]+)$/;
>    foreach my $child (@{$appearsOn{$parent}}) {
>   next if /(^|\+)$child(\+|$)/;
>   next if $found{$_.'+'.$child};
>   $found{$_.'+'.$child} = 1;
>   $goAgain++; 
>   }
>    }
>  }
>   foreach (my @k = keys %found) {
>    while (/\+/g) {
>    delete $found{$'};
>  }
>  #delete $found{$_} if !/^$string/;
>   }
>  
>   sort keys %found;
> }
> 
3691c3787
<     } elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
---
>     } elsif (/^\=(?:\[\[\+?)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
3693c3789
<     } elsif (/^\|(?:\[\[)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {
---
>     } elsif (/^\|(?:\[\[\+?)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {



-- 
grubstreet mailing list
http://london.openguides.org/old-list-archives/