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.

[grubstreet] indexing patch 2

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

From: Ivor Williams
Subject: [grubstreet] indexing patch 2
Date: 00:36 on 19 May 2002
> Pipe pluslinks don't work. 

Fixed. [[+foo|bar]] and [[>foo|bar]] are both rendered as >bar

> There's no easy way to create a new page. There is also the related 
> problem that if you do a plus link and typo it, the Preview doesn't give 
> you the visual clue that you've done this in the same way that it would 
> if you typoed an ordinary link.

Fixed, although rendering a pair of [ ]s round the ? to aid mouse 
differentiation. E.g. [[+missing]] renders as [?] >Missing

> It's clumsy that there is no easy way to click on the heading and search. 

Added. There is now a link to the search on the index page.

> Multi word index links appear with square brackets, when the page 
> does not exist. 

No change. This is correct and normal Wiki behaviour with freelinks.

> It would be really handy to turn off the redirect sometimes. Can this 
> be a user profile setting?

Not fixed. I changed my mind about this one.

> It might be an idea to add a config setting to limit the depth that the 
> indexing goes to; for example, I can see us having something like 
> Site > Food And Drink > Food > Food Types > Vegetarian Food 
> Vegan Food, which would make the tree very wide. A nice default 
> might be to index to three levels. 

Feature added. There is now a listbox allowing you to pick 2,3,4,5 or all
levels. The default is 3. If any pages are obscured, this appears as a >
link to the right of the page name.

> Plus links to subpages e.g. [[+IvorW/Ratings]] don't work 

Fixed.

> Plus links are still indexed inside <nowiki> tags.

Fixed

__PATCH FOLLOWS__
796,798c796,797
<   my ($id,$prefix) = @_;
<   $prefix ||= '';
<   my $name = $prefix.$id;
---
>   my ($id,$name) = @_;
>   $name ||= $id;
871c870,871
<   return &ScriptLink("id=$id&action=index",$prefix.$name) if $prefix;
---
>   return '['.&GetEditLink($id,"?").'] '. 
>     &ScriptLink("id=$id&action=index",$prefix.$name) if $prefix;
2929c2929,2939
<   print '<br>';
---
>   print '<h3>Search for ',&GetSearchLink($id),
>    '</h3>',$q->startform,
>  '<h3>Show index levels: &nbsp; ',"\n",
>     &GetHiddenValue('id',$id),
>  &GetHiddenValue('action','index'),
>  $q->popup_menu(
>   -name => 'depth',
>   -values => [2,3,4,5,'All'],
>   -default=> 3),
>  $q->submit(name=>'Go'),
>  $q->endform,"</h3>\n";
3076a3087,3089
>   my $pending = '';
>   my $parent_page;
>   my $depth = &GetParam('depth','3');
3080,3082c3093,3101
<  my @plusses = /\+/g; 
<  print "..." x @plusses;
<     print &GetPageLink($pagename), "<br>\n";
---
>  my $indent_level = scalar @{[/\+/g]}; 
>  if (($depth eq 'All') || ($indent_level < $depth)) {
>   print $pending,"..." x $indent_level;
>      print &GetPageLink($pagename), "\n";
>   $pending = '<br>';
>   $parent_page = $pagename;
>  } else {
>   $pending = "&nbsp;&nbsp;".&GetIndexLink($parent_page,">").'<br>';
>  }
3083a3103
>   print $pending,"\n";
3457c3477
<   my (%appearsOn);
---
>   my ($appears) = &IndexCrossRef($id,$id);
3459,3467c3479
<   &OpenPage($id);
<   &OpenDefaultText();
<   my $txt = $Text{'text'};
<     
<   foreach my $refer ($txt =~ /\[\+(.+?)\]/g) {
<    $refer = &FreeToNormal($refer);
<    $appearsOn{$refer}++;
<   }
<   return if !%appearsOn;
---
>   return if !%$appears;
3469c3481
<   print &GetIndexLink($_,'>'),"<BR>\n" foreach (sort keys %appearsOn);
---
>   print &GetIndexLink($_,">$_"),"<BR>\n" foreach (sort keys %$appears);
3472,3473c3484,3485
< sub PageIndex {
<   my ($string) = @_;
---
> sub IndexCrossRef {
>   my ($string,@pages) = @_;
3477c3489
<   foreach $name (&AllPagesList()) {
---
>   foreach $name (@pages) {
3481,3482c3493,3496
<     
<  foreach my $refer ($txt =~ /\[\+(.+?)\]/g) {
---
>     my ($root) = ($name =~ m!^([^/]*)!);
>  
>  $txt =~ s!<nowiki>.*?</nowiki>!!gs;
>  foreach my $refer ($txt =~ /\[\+(.+?)[|\]]/g) {
3483a3498
>   $refer =~ s!^/!$root/!;
3491c3506,3511
<   
---
>   (\%appearsOn,\%found);
> }
> 
> sub PageIndex {
>   my $string = shift;
>   my ($appears,$results) = &IndexCrossRef($string,&AllPagesList());
3495c3515
<  foreach (my @k = keys %found) {
---
>  foreach (my @k = keys %$results) {
3497c3517
<    foreach my $child (@{$appearsOn{$parent}}) {
---
>    foreach my $child (@{$appears->{$parent}}) {
3499,3500c3519,3520
<   next if $found{$_.'+'.$child};
<   $found{$_.'+'.$child} = 1;
---
>   next if $results->{$_.'+'.$child};
>   $results->{$_.'+'.$child} = 1;
3505c3525
<   foreach (my @k = keys %found) {
---
>   foreach (my @k = keys %$results) {
3507c3527
<    delete $found{$'};
---
>    delete $results->{$'};
3509d3528
<  #delete $found{$_} if !/^$string/;
3511,3512c3530
<  
<   sort keys %found;
---
>   sort keys %$results;
__END OF PATCH__


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