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

WalWiki/カスタマイズ/差分履歴RSS

編集

RecentDiffsのRSSを出力します。

[recent diffs rss]

編集

差分履歴のRSSをこのように出力出来るようにします。

Wikiアンテナで捕捉することも可能です。

関連するカスタマイズ

編集

グローバル変数定義

編集
my $max_description_length = 500;                           # yakty add [recent diffs rss]
my $RecentDiffsRss = 'RecentDiffsRss';                      # yakty add [recent diffs rss]

%page_commandへの追加

編集
my %page_command = (
    $IndexPage => 'index',
    $SearchPage => 'searchform',
    $CreatePage => 'create',
    $RssPage => 'rss',
    $AdminChangePassword => 'adminchangepasswordform',
    $FrontPage => 'FrontPage',
    $RecentChanges => 'recent',                             # yakty add [modify recentpage]
    $RecentDiffs => 'recentdiff',                           # yakty add [recent diffs]
    $CategoryPage => 'category',                            # yakty add [category]
    $RecentDiffsRss => 'diffsrss',                          # yakty add [recent diffs 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]
    recent => \&do_recent,                                  # yakty add [modify recentpage]
    recentdiff => \&do_recent_diffs,                        # yakty add [recent diffs]
    login => \&do_login,                                    # yakty add [secret page]
    logout => \&do_logout,                                  # yakty add [secret page]
    category => \&do_category,                              # yakty add [category]
    diffsrss => \&do_diffsrss,                              # yakty add [recent diffs rss]
);

make_description()追加

編集
# yakty add [recent diffs rss] start
sub make_description {
    my @description = @_;
    my $description;
    my @lines;
    foreach my $line (@description){
        $line = &remove_modification($line, 1);
        push(@lines, $line);
    }
    $description = join(" ", @lines);
    $description =~ s/\s+/ /g;
    $description = substr($description, 0, $max_description_length) . ' ...' if(length($description) > $max_description_length);
    return &escape($description);
}
# yakty add [recent diffs rss] end

do_diffsrss()追加

編集
# yakty add [recent diffs rss] start
sub do_diffsrss {
    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 $recentdiffs = $database{$RecentDiffs};
    my $count = 0;
    my @description;
    my ($dc_date, $title, $escaped_title, $link, $description);
    foreach (split(/\n/, $recentdiffs)) {
        #last if ($count >= 15);
        # Walrus mod [dc:date in rss] start
#       /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.
#       my $title = &unarmor_name($1);
        if(/^\- (\d\d\d\d\-\d\d\-\d\d) \(...\) (\d\d:\d\d:\d\d) (\S+)/){
            if(@description){
                $description = &make_description(@description);
                $rss->add_item(
                    title   => $escaped_title,
                    link    => $link,
                    description => $description,
                    dc_date => $dc_date,
                );
                undef @description;
                $count++;
                last if ($count >= 15);
            }
            $dc_date = "$1T$2+09:00";
            $title = &unarmor_name($3);
            # Walrus mod [dc:date in rss] end
            $escaped_title = &escape($title);
            $link = $modifier_rss_link . '?' . &encode($title);
        } else {
            if(/^\s\+(.*)/){
                push(@description, $1);
            }
        }
    }
    if(@description){
        $description = &make_description(@description);
        $rss->add_item(
            title   => $escaped_title,
            link    => $link,
            description => $description,
            dc_date => $dc_date,
        );
    }
    # print RSS information (as XML).
    print <<"EOD"
Content-type: text/xml

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

02676