root/trunk/plagger/lib/Plagger/Plugin/Filter/Lou.pm

Revision 1918 (checked in by tomi-ru, 14 years ago)

Add new plugin Filter::Lou and Widget::Simple config for lou_trans.

Line 
1 package Plagger::Plugin::Filter::Lou;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Acme::Lou;
6
7 sub register {
8     my ($self, $context) = @_;
9     $context->register_hook(
10         $self,
11         'plugin.init'        => \&init_lou,
12         'update.entry.fixup' => \&filter,
13     );
14 }
15
16 sub init_lou {
17     my ($self, $context, $args) = @_;
18    
19     $context->log(debug => "initializing Acme::Lou");
20     $self->{lou} = Acme::Lou->new( $self->conf );
21 }
22
23 sub filter {
24     my ($self, $context, $args) = @_;
25     my $entry = $args->{entry};
26    
27     $entry->body( $self->{lou}->translate($entry->body) );
28 }
29
30 1;
31 __END__
32
33 =head1 NAME
34
35 Plagger::Plugin::Filter::Lou - Filer text to Lou Style
36
37 =head1 SYNOPSIS
38
39   - module: Filter::Lou
40     config:
41       lou_rate: 95
42       html_fx_rate: 40
43
44 =head1 DESCRIPTION
45
46 This plugin filters entry body to Lou Ohshiba Style.
47
48 =head1 CONFIG
49
50 Same as L<Acme::Lou>.
51
52 =over 4
53
54 =item lou_rate
55
56 Set percentage of translating. 100 means full translating,
57 0 means do nothing. Default is 100.
58
59 =item html_fx_rate
60
61 Set percentage of HTML style decoration. Default is 0.
62
63 =item format
64
65 This feature is of Acme::Lou v0.03. Default is C<%s>.
66
67   - module: Filter::Lou
68     config:
69       format: "<ruby><rb>%s</rb><rp>(</rp><rt>%s</rt><rp>)</rp></ruby>"
70
71 See more information at L<Acme::Lou>.
72
73 =back
74
75 =head1 AUTHOR
76
77 Naoki Tomita
78
79 =head1 SEE ALSO
80
81 L<Plagger>, L<Acme::Lou>
82
83 =cut
Note: See TracBrowser for help on using the browser.