orphanedpages 매크로 추가
- 사용법 - <orphanedpages([+,-]숫자)>
- 역링크 페이지 수가 "숫자"개인 페이지들의 목록이 출력된다. 따라서 인자로 0 을 주면 역링크의 갯수가 0 인 OrphanedPages 들이 출력된다.
- 이 때, 자기 자신을 링크하고 있는 것은 포함하지 않는다. 즉, <orphanedpages(3)> 이라고 했을때 A 라는 페이지가 출력되었다면, 실제 A 페이지의 역링크는 3개일 수도 있고 4개(A 내에 A 가 링크되어 있을 경우)일 수도 있다.
- 숫자 앞에 별도로 + 또는 - 를 붙일 수 있다. -3 은 "역링크의 갯수가 3개 이하", +4 는 "역링크의 갯수가 4개 이상"인 페이지들의 목록을 출력한다.
- 부작용
- 매크로 치환을 한 번 할 때마다 전체 페이지 목록을 읽어야 한다. 한 페이지 내에 저 매크로를 두 번 이상 사용하는 것은 바람직하지 못하다. 페이지 수가 1000개 단위로 늘어날 경우 얼마나 느려질지 알 수 없다.
- "GetFullLinkList 함수에 파라메터 사용을 가능하게 함" 패치가 적용되어 있어야 한다.
-
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.
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...
- modify "CommonMarkup" subroutine (Following code comes from my modified version, so it may differ from yours)
s/$ISBNPattern/&StoreISBN($1)/geo;
s/CD:\s*(\d+)/&StoreHotTrack($1)/geo;
s/<orphanedpages>/&MacroOrphanedPages()/gei;
- Add "MacroOrphanedPages" subroutine
sub MacroOrphanedPages {
my ($less_or_more, $criterion) = ("", 0);
my (@allPages, $page, $pageline);
}
- 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.
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. :-)
위키위키분류