[ 新規 | 編集 | 差分 ] [ 検索 | 一覧 | FrontPage ] [ 履歴 (RSS) | 差分履歴 (RSS) ] [ ログイン ]
【PR】Amazon | SL-C3000 | SL-C1000(3/18発売!) | SL-C860 | SL-6000W | SL-6000L | SL-6000N

WalWiki/カスタマイズ/検索結果RSS

編集

検索結果のRSSを出力します。

[search rss]

編集

%command_do への追加

編集
my %command_do = (
    read => \&do_read,
    edit => \&do_edit,
    adminedit => \&do_adminedit,
    adminchangepasswordform => \&do_adminchangepasswordform,
    adminchangepassword => \&do_adminchangepassword,
    write => \&do_write,
    index => \&do_index,
    searchform => \&do_searchform,
    search => \&do_search,
    create => \&do_create,
    createresult => \&do_createresult,
    FrontPage => \&do_FrontPage,
    comment => \&do_comment,
    rss => \&do_rss,
    diff => \&do_diff,
    interwikibox => \&do_interwiki_box, # Walrus add [InterWikiBox]
    searchrss => \&do_searchrss,                            # yakty add [search rss]
);

do_searchrss() 追加

編集
# yakty add [search rss] start
sub do_searchrss {
    my $rss = new Yuki::RSS(
        version => '1.0',
        encoding => $charset,
    );
    $rss->channel(
        title => $modifier_rss_title,
        link  => $modifier_rss_link,
        description => $modifier_rss_description,
    );

    my $word = &escape($form{mymsg});
    my $counter = 0;

    my $case_sense    = ($form{mycasesense} eq '1')    ? 1 : 0;
    my $combination   = ($form{mysearchcombo} eq 'or') ? 'or' : 'and';
    my $search_target = (grep {$_ eq $form{mysearchtarget}} qw(title page part)) ? $form{mysearchtarget} : 'part';
    $_ = $form{mymsg};
    s/(?:\x0D\x0A|[\x0D\x0A])?$/ /;
    my @search_words = map {/^"(.*)"$/ ? scalar($_ = $1, s/""/"/g, $_) : $_} (/("[^"]*(?:""[^"]*)*"|[^ ]*) /g);
    @search_words = grep { length($_) != 0 } @search_words;
    if (@search_words) {
        my $opt = {'margin' => 30, 'case_sense' => $case_sense, 'combination' => $combination};
        my @pages = ($sort_case_sense) ? (sort keys(%database)) : sort {lc($a) cmp lc($b)} keys(%database);   # Walrus add [sort case sense]
        foreach my $page (@pages) {
            #last if ($counter >= 15);
            next if (&is_secret($page));                  # yakty add [secret page]
            next if ($page eq $RecentChanges);
            next if ($page eq $RecentDiffs);              # yakty add [recent diffs]

            my $escaped_title = &escape($page);
            my $link = $modifier_rss_link . '?' . &encode($page);
            my $description = '';

            if ($search_target eq 'title') {
                my $result = &match_text($page, $opt, @search_words);
                $description = &escape(&get_subjectline($page)) if($result);
            } elsif ($search_target eq 'page') {
                my ($result, $text) = &match_text($page."\n".$database{$page}, $opt, @search_words);
                $description = &escape($text) if($result);
            }
            next unless ($description);
            $rss->add_item(
                title   => $escaped_title,
                link    => $link,
                description => $description
                );
            $counter++;
        }
    }
    print <<"EOD"
Content-type: text/xml

@{[$rss->as_string]}
EOD
}
# yakty add [search rss] end

02614