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] Index patch for Wikibeta: double pipe links

[prev] [thread] [next] [lurker] [Date index for 2002/12/18]

From: Ivor Williams
Subject: [grubstreet] Index patch for Wikibeta: double pipe links
Date: 00:31 on 18 Dec 2002
------=_NextPart_000_002C_01C2A62C.CFD96D20
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable



Here is the latest embedded indexing patch. This allows you to name the =
entry in the index as well as the entry on the page:

Example (the most general case):

Page blah1
...
text for page blah1
...
#INDEX [[foo]]


Page blah2
...
...
Index Links: [[+foo|bar|baz]]

What this means is that page blah1 has an index on it called foo. Foo =
here can be the same as blah1, but is an internal identifier which never =
appears on the page.

Page blah2 is entered into the index foo because of its plus link. This =
link appears on page blah2 as bar, and in the index foo as baz.

Kake, please can you apply it.

__PATCH FOLLOWS__
832c832
<     $name =3D $id;
---
>     $name =3D $prefix . $id;
851c851
<     return &GetPageLinkText($id, $prefix.$name);
---
>     return &GetPageLinkText($id, $name);
1207c1207
<       =
s/\[\[(\+)?$FreeLinkPattern\|([^\]]+)\]\]/&StorePageOrEditLink($2, $3, =
$1)/geo;
---
>       =
s/\[\[(\+)?$FreeLinkPattern\|([^|\]]+)(|[^\]]+)?\]\]/&StorePageOrEditLink=
($2, $3, $1)/geo;
2921,2922c2921,2922
<   my @PageList=3D&PageIndex(FreeToNormal($id));
<   foreach (@PageList) {
---
>   my %PageList=3D&PageIndex(FreeToNormal($id));
>   foreach (sort keys %PageList) {
2925c2925
<  my $depth =3D @{[/\+/g]};
---
>  my $depth =3D @{[/\+/g]} + 1;
2927c2927,2928
<  $outstr .=3D '*' x $depth . "[[$pagename]]\n";
---
>  my $alias =3D $PageList{$_} || '';
>  $outstr .=3D '*' x $depth . "[[$pagename$alias]]\n";
3449c3450,3452
<  foreach my $refer ($txt =3D~ /\[\+(.+?)[|\]]/g) {
---
>  while ($txt =3D~ /\[\[\+([^|\]]+)(\|[^|\]]+(\|[^\]]+)?)?\]/g) {
>   my $refer =3D $1;
>   my $alias =3D $3;
3452c3455
<   push @{$appearsOn{$refer}},$name;
---
>   push @{$appearsOn{$refer}},[$name,$alias];
3454,3455c3457
<   $found{$name}++ if !$string=20
<     || $name eq $string
---
>   $found{$name} =3D $alias if !$string=20
3470c3472,3473
<    foreach my $child (@{$appears->{$parent}}) {
---
>    foreach my $chcell (@{$appears->{$parent}}) {
>   my ($child,$chalias) =3D @$chcell;
3472,3473c3475,3476
<   next if $results->{$_.'+'.$child};
<   $results->{$_.'+'.$child} =3D 1;
---
>   next if exists $results->{$_.'+'.$child};
>   $results->{$_.'+'.$child} =3D $chalias;
3483c3486
<   sort keys %$results;
---
>   map {$_,$results->{$_}} keys %$results;
__END OF PATCH__

------=_NextPart_000_002C_01C2A62C.CFD96D20
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><BR></DIV>
<DIV><FONT size=3D2>Here is the latest embedded indexing patch. This =
allows you to=20
name the entry in the index as well as the entry on the =
page:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Example (the most general case):</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Page blah1</FONT></DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2>text for page blah1</FONT></DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2>#INDEX [[foo]]</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Page blah2</FONT></DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2>Index Links: [[+foo|bar|baz]]</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>What this means is that page blah1 has an index on =
it called=20
foo. Foo here can be the same as blah1, but is an internal identifier =
which=20
never appears on the page.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Page blah2 is entered into the index foo because of =
its plus=20
link. This link appears on page blah2 as bar, and in the index foo as=20
baz.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Kake, please can you apply it.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>__PATCH FOLLOWS__</FONT></DIV>
<DIV><FONT size=3D2>832c832<BR>&lt;&nbsp;&nbsp;&nbsp;&nbsp; $name =3D=20
$id;<BR>---<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $name =3D $prefix .=20
$id;<BR>851c851<BR>&lt;&nbsp;&nbsp;&nbsp;&nbsp; return =
&amp;GetPageLinkText($id,=20
$prefix.$name);<BR>---<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return=20
&amp;GetPageLinkText($id,=20
$name);<BR>1207c1207<BR>&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
s/\[\[(\+)?$FreeLinkPattern\|([^\]]+)\]\]/&amp;StorePageOrEditLink($2, =
$3,=20
$1)/geo;<BR>---<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
s/\[\[(\+)?$FreeLinkPattern\|([^|\]]+)(|[^\]]+)?\]\]/&amp;StorePageOrEdit=
Link($2,=20
$3, $1)/geo;<BR>2921,2922c2921,2922<BR>&lt;&nbsp;&nbsp; my=20
@PageList=3D&amp;PageIndex(FreeToNormal($id));<BR>&lt;&nbsp;&nbsp; =
foreach=20
(@PageList) {<BR>---<BR>&gt;&nbsp;&nbsp; my=20
%PageList=3D&amp;PageIndex(FreeToNormal($id));<BR>&gt;&nbsp;&nbsp; =
foreach (sort=20
keys %PageList) {<BR>2925c2925<BR>&lt; &nbsp;my $depth =3D=20
@{[/\+/g]};<BR>---<BR>&gt; &nbsp;my $depth =3D @{[/\+/g]} +=20
1;<BR>2927c2927,2928<BR>&lt; &nbsp;$outstr .=3D '*' x $depth .=20
"[[$pagename]]\n";<BR>---<BR>&gt; &nbsp;my $alias =3D $PageList{$_} || =
'';<BR>&gt;=20
&nbsp;$outstr .=3D '*' x $depth .=20
"[[$pagename$alias]]\n";<BR>3449c3450,3452<BR>&lt; &nbsp;foreach my =
$refer ($txt=20
=3D~ /\[\+(.+?)[|\]]/g) {<BR>---<BR>&gt; &nbsp;while ($txt =3D~=20
/\[\[\+([^|\]]+)(\|[^|\]]+(\|[^\]]+)?)?\]/g) {<BR>&gt; &nbsp;&nbsp;my =
$refer =3D=20
$1;<BR>&gt; &nbsp;&nbsp;my $alias =3D $3;<BR>3452c3455<BR>&lt; =
&nbsp;&nbsp;push=20
@{$appearsOn{$refer}},$name;<BR>---<BR>&gt; &nbsp;&nbsp;push=20
@{$appearsOn{$refer}},[$name,$alias];<BR>3454,3455c3457<BR>&lt;=20
&nbsp;&nbsp;$found{$name}++ if !$string <BR>&lt; =
&nbsp;&nbsp;&nbsp;&nbsp;||=20
$name eq $string<BR>---<BR>&gt; &nbsp;&nbsp;$found{$name} =3D $alias if =
!$string=20
<BR>3470c3472,3473<BR>&lt; &nbsp;&nbsp; foreach my $child=20
(@{$appears-&gt;{$parent}}) {<BR>---<BR>&gt; &nbsp;&nbsp; foreach my =
$chcell=20
(@{$appears-&gt;{$parent}}) {<BR>&gt; &nbsp;&nbsp;my ($child,$chalias) =
=3D=20
@$chcell;<BR>3472,3473c3475,3476<BR>&lt; &nbsp;&nbsp;next if=20
$results-&gt;{$_.'+'.$child};<BR>&lt; =
&nbsp;&nbsp;$results-&gt;{$_.'+'.$child} =3D=20
1;<BR>---<BR>&gt; &nbsp;&nbsp;next if exists=20
$results-&gt;{$_.'+'.$child};<BR>&gt; =
&nbsp;&nbsp;$results-&gt;{$_.'+'.$child} =3D=20
$chalias;<BR>3483c3486<BR>&lt;&nbsp;&nbsp; sort keys=20
%$results;<BR>---<BR>&gt;&nbsp;&nbsp; map {$_,$results-&gt;{$_}} keys=20
%$results;<BR>__END OF PATCH__</FONT></DIV></BODY></HTML>

------=_NextPart_000_002C_01C2A62C.CFD96D20--


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