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

마지막으로 [b]

orphanedpages 매크로 추가

sub MacroSubst {
    ...
### 다음 라인 추가
    $txt =~ s/\&__LT__;orphanedpages\(([-+])?(\d+)\)\&__GT__;/&MacroOrphanedPages($1, $2)/gei;
###
    return $txt;
}
### 다음 함수를 통채로 추가
sub MacroOrphanedPages {
    my ($less_or_more, $criterion) = @_;
    my (@allPages, $page, $pageline, @pages, $id, @x);
    my %numOfReverse;
    my $txt;

    @allPages = &AllPagesList();

    foreach $page (@allPages) {
        $numOfReverse{$page} = 0;
    }

    foreach $pageline (&GetFullLinkList("exists=1&sort=0")) {
        my @links = split(' ', $pageline);
        my $id = shift(@links);
        my $link;
        foreach $link (@links) {
            $link = (split('/',$id))[0]."$link" if ($link =~ /^\//);
            next if ($id eq $link);
            $numOfReverse{$link}++;
        }
    }

    foreach $page (@allPages) {
        next if (($less_or_more eq "-") && ($numOfReverse{$page} > $criterion));
        next if (($less_or_more eq "+") && ($numOfReverse{$page} < $criterion));
        next if (($less_or_more eq "") && ($numOfReverse{$page} != $criterion));
        $txt .= ".... " if ($page =~ m|/|);
        $txt .= &GetPageLink($page) . "<br>";
    }

    return $txt;
}


Comment by User: Hi gypark, why $criterion?. I don`t understand where does this variable appear again?. Thanks

Wow, the first comments from a foreigner.. :-)

$criterion is the lexical variable that used in MacroOrphanedPages(). It stores the parameter "number" of <orphanedpage([+|-]number)>. For example, <orphanedpage(2)> prints the list of the pages that have 2 reverse-links. Most frequent parameter may be "0", which makes the macro print the pages with no reverse-link, that is, none of other pages has a link to the page.
-- Raymundo 2007-6-5 8:30 am

I tried to include only sub MacroOrphanedPages (in usemod pachted script for me). I must learn more about your sub MacroSubst. I suppose all this depends of other subs of usemodkr script. (in usemod based script seems works fine without $criterion, isn't it? just including sub MacroOrphanedPages alone - for only orphan purpose).
Yes, i am a foreigner but a wikizen, hehe.
-- http://www.usemod.org/cgi-bin/wiki.pl?JuanmaMP
Thanks!
-- 80.58.205.33 2007-6-7 7:34 am

Hmm... So, you want to add "finding orphaned pages" feature into your script, right? You don't need any other macros, and you don't need "criterion" parameter either.

Then, I suggest...
        s/$ISBNPattern/&StoreISBN($1)/geo;
        s/CD:\s*(\d+)/&StoreHotTrack($1)/geo;
        s/<orphanedpages>/&MacroOrphanedPages()/gei;    # here, or you can choose any appropriate position
sub MacroOrphanedPages {
    my ($less_or_more, $criterion) = ("", 0);   # modify this line
    my (@allPages, $page, $pageline);

# the rest of codes are same as the above code
}
Now, you can use <orphanedpages> in your wiki page to print the list.

However, I modified so many lines from the original usemodwiki 0.92. So there may be any other patches that this patch depends on. I'm not sure this patch would work for you.
-- Raymundo 2007-6-7 9:07 am

Hi, Raymundo:

Rigth, now i understand better ... thanks to:

my ($less_or_more, $criterion) = ("", 0);

it works fine, I like usemodkr because search into DatarDir/link (not always trough &OpenPage($name);

This patch works for me, I patched more subs from usemodkr. ( It's right than any "other patches that this patch depends on"):

- in usemodkr: GetFullLinkList (usemodkr) > GetPageFromFile > GetLinkFile or GetPageLinks if (!status)

- in usemod: GetFullLinkList (usemodkr) > GetPageLinks.

At least, I added in
sub DoOtherRequest {
...
elsif ($action eq 'orphan') {
&DoOrphanList();
...
not in s/<orphanedpages>/&MacroOrphanedPages()/gei;
(I suppose none side effect)

It's all. Thanks.
-- JuanmaMP
-- 80.58.205.32 2007-6-8 2:13 am

i wanted to say:
(">" is "depends on")
- in usemodkr: GetFullLinkList > GetPageFromFile > GetLinkFile or GetPageLinks if (!status)

- in usemod: GetFullLinkList > GetPageLinks.

Maybe, before, it was confused.

-- JuanmaMP
-- 80.58.205.32 2007-6-8 3:06 am

Yes, it took too long time to find all the links in each pages through the whole text using OpenPage(). So, as you said, usemodkr stores the links in a separate files in DataDir/link, that looks successful. :-)
-- Raymundo 2007-6-8 11:21 am
이름:  
Homepage:
내용:
 

위키위키분류

마지막 편집일: 2024-4-29 10:14 am (변경사항 [d])
1020 hits | Permalink | 변경내역 보기 [h] | 페이지 소스 보기