root/trunk/plagger/assets/plugins/filter-entryfulltext/hatena_diary.pl

Revision 474 (checked in by miyagawa, 14 years ago)
Line 
1 sub handle {
2     my($self, $args) = @_;
3     $args->{entry}->link =~ qr!^http://d\.hatena\.ne\.jp/!;
4 }
5
6 sub extract_body {
7     my($self, $args) = @_;
8     my $name     = ( $args->{entry}->link =~ /\#([\w\-]+)$/ )[0];
9     my $day_only = $args->{entry}->link =~ qr!^http://d\.hatena\.ne\.jp/[\w\-]+/\d+/?$!;
10
11     my $match =
12          $name     ? qq!<h3><a href=".*?" name="$name">.*?</h3>(.*?)</div>! :
13          $day_only ? qq!<div class="section">(.*?)</div>! :
14                      qq!</h3>(.*?)</div>!;
15
16     if ( $args->{content} =~ /$match/s ){
17         return "<div>$1</div>";
18     }
19     return;
20 }
21
Note: See TracBrowser for help on using the browser.