[첫화면으로]UseModWiki소스수정/AllPagesTo매크로

마지막으로 [b]

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 - /매크로파라메터에이중대괄호허용
-- Raymundo 2005-11-19 6:09 pm

1.2. 사용자 의견

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)
-- Raymundo 2009-11-15 8:54 am

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
이름:  
Homepage:
내용:
 


위키위키분류

마지막 편집일: 2009-11-15 5:54 pm (변경사항 [d])
964 hits | Permalink | 변경내역 보기 [h] | 페이지 소스 보기