Messing with common i18n modules.
[blog.pm.git] / lib / Blog / View / TT.pm
blob7c62f02d3bd0dd099afd3d85bdb181a09487befc
1 package Blog::View::TT;
3 use warnings;
4 use strict;
6 use base 'Catalyst::View::TT';
7 #use Template::Constants qw(:debug);
9 use HTTP::Date;
10 use Encode 'encode_utf8';
12 __PACKAGE__->config(
14 COMPILE_DIR => Blog->path_to( 'tmp' ),
15 COMPILE_EXT => '.pl',
16 CATALYST_VAR => 'c',
17 INCLUDE_PATH => [
18 Blog->path_to( 'templates', 'lib' ),
19 Blog->path_to( 'templates', 'src', Blog->config->{ style })
21 TEMPLATE_EXTENSION => '.tt2',
22 TRIM => 1,
23 PRE_PROCESS => 'config',
24 WRAPPER => 'wrapper',
25 ERROR => 'error.tt2',
26 TIMER => 0,
27 #DEBUG => DEBUG_UNDEF,
28 EVAL_PERL => 1,
29 FILTERS => {
30 bbcode => \&bbcode,
31 ccode => \&ccode,
32 cut => \&cut,
33 encode_utf8 => \&encode_utf8
38 sub process {
39 my ( $self ) = shift;
40 my ( $c ) = @_;
42 my $feed = $c->stash->{ feed };
43 if ( $feed ) {
44 if ( keys %$feed ) {
45 $feed->{ description } = $feed->{ description };
46 if ( scalar @{ $feed->{ items } } ) {
47 $feed->{ lastBuildDate } =
48 time2str( $feed->{ items }->[ 0 ]->{ pubDate } );
50 foreach my $item ( @{ $feed->{ items } } ) {
51 $item->{ pubDate } = time2str( $item->{ pubDate } );
54 } else {
55 $feed->{ items } = [];
58 $c->stash->{ template } = 'feed';
61 $self->next::method(@_);
64 sub bbcode {
65 my $text = shift;
67 Blog->context->helper( 'BBCode' )->render( $text );
70 sub ccode {
71 my $text = shift;
73 Blog->context->helper( 'CCode' )->render( $text );
76 #sub ccode {
77 # my $text = shift;
79 # return unless $text;
81 # #$text =~ s/&/&/go;
82 # $text =~ s/</&lt;/go;
83 # $text =~ s/>/&gt;/go;
85 # $text =~ s/\x0D\x0A/\n/g;
86 # $text =~ tr/\x0D\x0A/\n\n/;
88 # $text =~ s{(?<!\n)(\n)(?!\n)}{<br />\n}g;
89 # $text = "<p>"
90 # . join( "</p>\n\n<p>\n", split( /(?:\r?\n){2,}/, $text ) )
91 # . "</p>\n";
93 # $text;
96 sub cut {
97 my ( $text, $maxlength ) = @_;
99 Blog->context->model('Util')->cut( $text, $maxlength);
102 =head1 AUTHOR
106 =head1 LICENSE
108 This library is free software, you can redistribute it and/or modify
109 it under the same terms as Perl itself.
111 =cut