Changeset 12556 for lang/perl/App-Chariot
- Timestamp:
- 05/27/08 21:39:28 (6 months ago)
- Location:
- lang/perl/App-Chariot/trunk
- Files:
-
- 7 added
- 4 modified
-
assets/tmpl/item-parts.tt (modified) (1 diff)
-
config.yaml (modified) (1 diff)
-
lib/App/Chariot.pm (modified) (5 diffs)
-
lib/App/Chariot/C (added)
-
lib/App/Chariot/C/Index.pm (added)
-
lib/App/Chariot/C/Permalink.pm (added)
-
lib/App/Chariot/C/RSS.pm (added)
-
lib/App/Chariot/Config.pm (modified) (1 diff)
-
lib/App/Chariot/Formatter (added)
-
lib/App/Chariot/Formatter/Hatena.pm (added)
-
lib/App/Chariot/Formatter/Markdown.pm (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-Chariot/trunk/assets/tmpl/item-parts.tt
r12554 r12556 1 [% USE Markdown %]2 3 1 <div class="entry"> 4 2 <h3 class="entry-header"><a href="[% item.permalink %]">[% item.title %]</a></h3> 5 <div class="entry-content"><div class="entry-body">[% FILTER markdown %][% item.content %][% END%]</div></div>3 <div class="entry-content"><div class="entry-body">[% format(item.content) %]</div></div> 6 4 <div class="entry-footer"> 7 5 <span class="post-footers">[% item.entry.header.date %]</span> -
lang/perl/App-Chariot/trunk/config.yaml
r12554 r12556 3 3 css_filename: http://bulknews.typepad.com/test/styles.css 4 4 clog_url: ./ 5 formatter: Hatena -
lang/perl/App-Chariot/trunk/lib/App/Chariot.pm
r12554 r12556 11 11 use XML::RSS; 12 12 use Scalar::Util; 13 use Module::Find; 14 my @CONTROLLERS = useall 'App::Chariot::C'; 13 15 14 16 do { … … 41 43 }; 42 44 43 sub say { print "@_\n" }44 45 45 has dat => ( 46 46 is => 'rw', … … 61 61 } 62 62 ); 63 }, 64 ); 65 66 has formatter => ( 67 is => 'ro', 68 isa => 'CodeRef', 69 lazy => 1, 70 default => sub { 71 my $self = shift; 72 my $formatter = $self->config->formatter; 73 $formatter = "App::Chariot::Formatter::$formatter"; 74 Class::MOP::load_class($formatter); 75 $formatter->meta->get_method('format')->body; 63 76 }, 64 77 ); … … 101 114 sub create { 102 115 my $self = shift; 103 $self->create_index_page();104 $self->create_rss();105 $self->create_permalink_pages();106 }107 116 108 sub create_dir { 109 my $self = shift; 110 say "create dir"; 117 print "create dir\n"; 111 118 mkdir $self->config->output_dir; 112 } 113 114 sub create_permalink_pages { 115 my ($self, ) = @_; 116 117 say "create permalink pages"; 118 my $ifile = File::Spec->catfile($self->config->assets_dir, 'tmpl', 'item.tt'); 119 for my $entry (@{$self->dat->list}) { 120 my $cnt = 1; 121 for my $item (reverse @{$entry->items->list}) { 122 $item->count($cnt); 123 $item->entry( $entry ); 124 my $ofile = File::Spec->catfile($self->config->output_dir, $item->permalink); 125 $self->render( 126 $ifile => $ofile, 127 { 128 item => $item, 129 }, 130 ); 131 132 $cnt++; 133 } 119 for my $controller (@CONTROLLERS) { 120 $controller->meta->get_method('create')->body->( $self ); 134 121 } 135 }136 137 sub create_index_page {138 my ($self, ) = @_;139 140 say "create index page";141 my @list = reverse @{$self->dat->list};142 my $ifile = File::Spec->catfile($self->config->assets_dir, 'tmpl', 'index.tt');143 my $ofile = File::Spec->catfile($self->config->output_dir, 'index.html');144 145 $self->render(146 $ifile => $ofile, {147 entries => [ @list[0..($self->config->index_stop)] ],148 }149 );150 }151 152 sub create_rss {153 my $self = shift;154 155 say "create rss";156 157 my $ofname = File::Spec->catfile( $self->config->output_dir, $self->config->rss_filename );158 159 my $rss = XML::RSS->new(version => '1.0');160 $rss->channel(161 title => $self->config->title,162 link => $self->config->clog_url,163 description => $self->config->changelog_description,164 );165 166 my @list = reverse @{$self->dat->list};167 for my $entry (@list[0..($self->config->index_stop)]) {168 my $cnt = 1;169 for my $item (reverse @{$entry->items->list}) {170 $item->count($cnt);171 $item->entry( $entry );172 173 $rss->add_item(174 title => $item->title,175 link => $self->config->clog_url . $item->permalink,176 description => $item->content,177 content => {178 encoded => $item->content,179 },180 );181 182 $cnt++;183 }184 }185 say "-- save to $ofname";186 $rss->save($ofname);187 122 } 188 123 … … 190 125 my ($self, $ifile, $ofile, $params) = @_; 191 126 192 say "-- render $ifile => $ofile";127 print "-- render $ifile => $ofile\n"; 193 128 $self->tt->process( 194 129 $ifile, 195 130 { 196 conf => $self->config, 131 conf => $self->config, 132 format => $self->formatter, 197 133 %$params, 198 134 }, -
lang/perl/App-Chariot/trunk/lib/App/Chariot/Config.pm
r12554 r12556 58 58 ); 59 59 60 has formatter => ( 61 is => 'ro', 62 isa => 'Str', 63 default => 'Markdown', 64 ); 65 60 66 1;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)