| 1 | package Text::Livedoor::Wiki::Plugin::Function::Lislog; | ||||||||||
| 2 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 11 | ▶ | use base qw/Text::Livedoor::Wiki::Plugin::Function/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | __PACKAGE__->function_name('lislog'); | |||||||||
| 6 | |||||||||||
| 7 | 27 | ▶ | sub prepare_args { | ||||||||
|
Subroutine
prepare_args: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 8 | 27 | my $class= shift; | |||||||||
| 9 | 27 | my $args = shift; | |||||||||
| 10 | |||||||||||
| 11 | # no args | ||||||||||
| 12 | 27 | ▶ | die 'no arg' unless scalar @$args ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | |||||||||||
| 14 | # not valid lislig url | ||||||||||
| 15 | 26 | my $url = $args->[0]; | |||||||||
| 16 | |||||||||||
| 17 | 26 | ▶ | die 'not valid url' unless $url =~ m{^http://(lislog|research.news)\.livedoor\.com/r/(\d+)}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 24 | my ($service, $listid ) = $url =~ m{^http://(lislog|research.news)\.livedoor\.com/r/(\d+)}; | |||||||||
| 19 | |||||||||||
| 20 | 24 | my $type = 'pie'; | |||||||||
| 21 | 24 | my $color = 'red'; | |||||||||
| 22 | 24 | for ( @$args ) { | |||||||||
| 23 | 44 | ▶ | if ( $_ =~ /^(pie|bar)$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 12 | $type = $_; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 44 | ▶ | if ( $_ =~ /^(red|orange|yellow|lime|green|sky|blue|purple|pink|black)$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 7 | $color = $_; | |||||||||
| 29 | } | ||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | # ok | ||||||||||
| 33 | 24 | return { listid => $listid , type => $type , color => $color }; | |||||||||
| 34 | } | ||||||||||
| 35 | 24 | ▶ | sub prepare_value { | ||||||||
|
Subroutine
prepare_value: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 36 | 24 | my $class = shift; | |||||||||
| 37 | 24 | my $value = shift; | |||||||||
| 38 | # no more large support but for legacy user | ||||||||||
| 39 | 24 | ▶ | $value = 'medium' if ( $value !~ m/^(?:small|medium|large)$/ ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 24 | ▶ | $value = 'middle' if ( $value eq 'medium' ); # medium is middle.... >_< | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 24 | return { size => $value }; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 23 | ▶ | sub process { | ||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 45 | 23 | my ( $class, $inline, $data ) = @_; | |||||||||
| 46 | 23 | my $listid = $data->{args}{listid}; | |||||||||
| 47 | 23 | my $type = $data->{args}{type}; | |||||||||
| 48 | 23 | my $color = $data->{args}{color}; | |||||||||
| 49 | 23 | my $size = $data->{value}{size}; | |||||||||
| 50 | |||||||||||
| 51 | 23 | return qq|<div><script language='javascript' type='text/javascript' charset='utf-8' src='http://research.news.livedoor.com/publish/$size/$listid/plugin.js?graph_type=$type&color=$color'></script></div>|; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | ▶ | sub process_mobile{ '' } | ||||||||
|
Subroutine
process_mobile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | 11 | 1; | |||||||||
| 56 | |||||||||||
| 57 | =head1 NAME | ||||||||||
| 58 | |||||||||||
| 59 | Text::Livedoor::Wiki::Plugin::Function::Lislog - Lislog Function Plugin | ||||||||||
| 60 | |||||||||||
| 61 | =head1 DESCRIPTION | ||||||||||
| 62 | |||||||||||
| 63 | let's your choice. | ||||||||||
| 64 | |||||||||||
| 65 | =head1 SYNOPSIS | ||||||||||
| 66 | |||||||||||
| 67 | &lislog(http://lislog.livedoor.com/r/20853) | ||||||||||
| 68 | &lislog(http://research.news.livedoor.com/r/20853){small} | ||||||||||
| 69 | &lislog(http://research.news.livedoor.com/r/20853){large} | ||||||||||
| 70 | &lislog(http://research.news.livedoor.com/r/20853){medium} | ||||||||||
| 71 | &lislog(http://research.news.livedoor.com/r/20853,bar) | ||||||||||
| 72 | &lislog(http://research.news.livedoor.com/r/20853,bar,green) | ||||||||||
| 73 | |||||||||||
| 74 | =head1 FUNCTION | ||||||||||
| 75 | |||||||||||
| 76 | =head2 prepare_args | ||||||||||
| 77 | |||||||||||
| 78 | =head2 prepare_value | ||||||||||
| 79 | |||||||||||
| 80 | =head2 process | ||||||||||
| 81 | |||||||||||
| 82 | =head2 process_mobile | ||||||||||
| 83 | |||||||||||
| 84 | =head1 SEE ALSO | ||||||||||
| 85 | |||||||||||
| 86 | http://research.news.livedoor.com | ||||||||||
| 87 | |||||||||||
| 88 | =head1 AUTHOR | ||||||||||
| 89 | |||||||||||
| 90 | polocky | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||