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:47 on 10 May 2002
This is instead of the existing patch

__patch follows__
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
(/^\|(?:\[\[\+?)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {
__End of patch__


----- Original Message -----
From: Ivor Williams <ivor.williams@xxxxxxx.xx.xx>
To: <grubstreet@xxxxxxx.xxxxx.xx>
Sent: 09 May 2002 22:59
Subject: Re: [grubstreet] Wiki indexing patch


>
> > Kate L Pugh <kake@xxxxx.xx> wrote:
> > >> Ivor, did you see my previous mail discussing problems with the
patch?
> >
> > Just a few notes on initial testing:
>
> > If you try to index something (eg by URL munging) that doesn't have
>  > any results, the page is just blank; it doesn't say "no results".
> > See for example
> >
http://the.earth.li/~kake/cgi-bin/wikibeta.pl?id=Marmalade&action=index
>
> OK, making it say "no results" is quite easy to do. I will do so.
>
> > If you do a plus-link (+Foo) to a nonexistent page, then it displays
> > as Foo? where the ? is a link to edit the page -- there is nothing to
> > click on to index it.  I'm not sure whether this is a bug or a
> > feature; I'd say the former, since it breaks the expected behaviour of
> > a plus-link -- as I understand it, the plus links are about indexes
> > rather than pages.  See for example
> >    http://the.earth.li/~kake/cgi-bin/wikibeta.pl?Chinese_Food
>
> This was intended as a 'feature'. However, thinking about it, why does an
> index have to have a real page?
>
> This will probably require a refactoring of my change to the freelink
> handling code - but it's doable.
>
> > I can't seem to make the second kind of link (>Foo) work at all; see for
> > example
> >    http://the.earth.li/~kake/cgi-bin/wikibeta.pl?Vegetarian_Food
>
> Ah, oops! A debugging I will go.
>
> Will post when I have a new patch ready.
>
> By the way, any thoughts about version numbers? It might make discussion a
> bit easier.
>
> Ivor.
>
>
> --
> grubstreet mailing list
> grubstreet@xxxxxxx.xxxxx.xx
> http://london.openguides.org/old-list-archives/


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