sub MacroSubst { ... ### 추가 $txt =~ s/\&__LT__;allpagesto\(([^\n]+)\)\&__GT__;/&MacroAllPagesTo($1)/gei; ### return $txt; }
### 함수를 통채로 추가 sub MacroAllPagesTo { my ($string) = @_; my @x = (); my ($pagelines, $pagename, $txt); my $pagename; $string = &RemoveLink($string); $string = &FreeToNormal($string); if (&ValidId($string) ne "") { return "<allpagesto($string)>"; } foreach $pagelines (&GetFullLinkList("empty=0&sort=1&reverse=$string")) { my @pages = split(' ', $pagelines); @x = (@x, shift(@pages)); } foreach $pagename (@x) { $txt .= ".... " if ($pagename =~ m|/|); $txt .= &GetPageLink($pagename) . "<br>"; } return $txt; }
I wonder if is there another way (I am not necessarily asking for how doing, only if it's possible and then I'll try the trail :)) to get a list of all LinKin; in other words, can be "hasheable" MacroAllPagesTo?
I' ve made (and seems works fine) with the other way, reading data base:
{{{#!vim perl
...
if ($action eq 'linkout') {
my $fname = $LinkDir . "/" . &GetPageDirectory($page) . "/$page.lnk";
($status, $outc) = &ReadFile($fname);
if ($status) {
$pgoutc{$page} = $outc;
}
@linklist = split(/urllinks/, $outc);
@pgoutc = split(/$FS2/, $linklist[0]);
if ((length($pgoutc[0]) > '19')
&& (substr($Text{'text'}, 0, 10) ne '#REDIRECT ')) {
$pgoutc{$page} = $#pgoutc+1;} else {$pgoutc{$page} = 0;}
push(@found, $pgoutc{$page});
@pages = sort { $pgoutc{$b} <=> $pgoutc{$a} || $a cmp $b}
keys %pgoutc;
}
...
}}}
Thanks and regards. --JuanmaMP
(Sorry, LinKin wanted to say, PagesTo) ...
I have an idea, (There is more than one way to do it ...;) ). When a page quoted to other page (linkto), then to add in .lnk-file other field, with name "urllinksfrom" for example and adds the page that called to this page. On this way, we have all in the same .lnk-file, linksfrom and linksto. Then, maybe it's more easy indexing too, all the linksfrom and all the linksto. I will try implement ...
Regards.
Hi Raymundo,
pages with REDIRECT returns false positives ...
What do you think about:
foreach $pagename (@x) {
&OpenPage($pagename);
&OpenDefaultText();
if (substr($Text{'text'}, 0, 10) ne '#REDIRECT ') {
...
Hi JuanmaMP~
It depends on whether we consider the arguement of REDIRECT as "a link" or not. I thought it is also a link. :-)
Maybe you are right and it would be better that we exclude pages with REDIRECT from the result. However, I doubt it is worth opening every pages and check each text. (although this processing time will depends on the size of @x, and @x will not be so big in most cases)
It's true, this raises some doubts (when @x carries too much weight). Other way is to define ad hoc "Incoming includes REDIRECT arguments"). Less semantic, but more simple.
Very Kind :)