Changeset 274
- Timestamp:
- 11/27/06 15:58:20 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
HatenaKeywordLink/trunk/plugins/HatenaKeywordLink/HatenaKeywordLink.pl
r270 r274 13 13 use base 'MT::Plugin'; 14 14 use vars qw($VERSION); 15 $VERSION = '0.0 1';15 $VERSION = '0.02'; 16 16 17 17 my $plugin = __PACKAGE__->new({ 18 18 name => 'HatenaKeywordLink', 19 19 description => 'This plugin enables MT to set "Hatena Diary Keyword" links to the entry body.', 20 doc_link => 'http://code.as-is.net/wiki/HatenaKeywordLink ',20 doc_link => 'http://code.as-is.net/wiki/HatenaKeywordLink_Plugin', 21 21 author_name => 'Hirotaka Ogawa', 22 22 author_link => 'http://profile.typekey.com/ogawa/', … … 29 29 MT->add_plugin($plugin); 30 30 31 # global filter 31 # global filter and container 32 32 MT::Template::Context->add_global_filter('hatena_keyword_link', \&flt_link); 33 MT::Template::Context->add_container_tag(HatenaKeywordLink => \&ctr_link); 33 34 34 35 # pre_save handler … … 42 43 my ($str, $val, $ctx) = @_; 43 44 return $str unless $str && $val; 45 46 my $enc = MT::ConfigMgr->instance->PublishCharset; 47 my $text = rpc_setKeywordLink(encode_text($str, $enc, 'utf-8')); 48 return encode_text($text, 'utf-8', $enc) if $text; 49 $str; 50 } 51 52 sub ctr_link { 53 my ($ctx, $args, $cond) = @_; 54 my $builder = $ctx->stash('builder'); 55 my $tokens = $ctx->stash('tokens'); 56 defined(my $str = $builder->build($ctx, $tokens)) 57 or return $ctx->error($builder->errstr); 44 58 45 59 my $enc = MT::ConfigMgr->instance->PublishCharset;
