OSDN Git Service

move...
[fswiki/sandbox.git] / takezoe / plugin / book / Wordcount.pm
1 ################################################################################
2 #
3 # <p>¸½ºßɽ¼¨¤·¤Æ¤¤¤ë¥Ú¡¼¥¸¤Îʸ»ú¿ô¤òɽ¼¨¤¹¤ë¥¤¥ó¥é¥¤¥ó¥×¥é¥°¥¤¥ó¤Ç¤¹¡£</p>
4 # <pre>
5 # Ê¸»ú¿ô¡§{{wordcount}}
6 # </pre>
7 # <p>°ú¿ô¤Ç¥«¥¦¥ó¥ÈÂоݤΥڡ¼¥¸¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£</p>
8 # <pre>
9 # Ê¸»ú¿ô¡§{{wordcount ¥Ú¡¼¥¸Ì¾}}
10 # </pre>
11 #
12 ################################################################################
13 package plugin::book::Wordcount;
14 use Encode qw(decode);
15 #==============================================================================
16 # ¥³¥ó¥¹¥È¥é¥¯¥¿
17 #==============================================================================
18 sub new {
19         my $class = shift;
20         my $self = {};
21         return bless $self,$class;
22 }
23
24 #==============================================================================
25 # ¥¤¥ó¥é¥¤¥ó¥á¥½¥Ã¥É
26 #==============================================================================
27 sub inline {
28         my $self = shift;
29         my $wiki = shift;
30         my $page = shift;
31         
32         $page = $wiki->get_CGI->param('page') unless $page;
33         my $source = Jcode::convert($wiki->get_page($page), 'utf8', 'euc');
34         
35         return length(decode('utf-8', $source));
36 }
37
38 1;