allpagesto 매크로 추가
- 특정한 페이지의 역링크 목록을 출력하는 매크로
- 매크로 이름은 애초에 "Links To" 로 하려고 했으나.. WikiX 에서 이미 같은 용도의 매크로가 있기에 같은 이름이 나을 것 같아 "All Pages To"로 정했다.
- 사용법 - <allpagesto(페이지이름)>
-
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;
}
1.1. 추가 업데이트 내역
ext1.90 - /매크로파라메터에이중대괄호허용함
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 --
JustSameJuanmaMP
2009-7-31 6:29 am
(Sorry, LinKin wanted to say, PagesTo) ... --
JustSameJuanmaMP
2009-7-31 6:34 am
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. --
JustSameJuanmaMP
2009-8-15 7:38 pm
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 ') {
...
Regards and thanks. --
JustSameJuanmaMP
2009-11-15 6:32 am
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 :) --
JustSameJuanmaMP
2009-11-15 5:54 pm
위키위키분류