=================================================================== RCS file: /cvs/todotxt/Text-Todo/bin/dudelicious.pl,v retrieving revision 1.6 retrieving revision 1.9 diff -u -r1.6 -r1.9 --- todotxt/Text-Todo/bin/dudelicious.pl 2010/04/30 07:18:33 1.6 +++ todotxt/Text-Todo/bin/dudelicious.pl 2010/04/30 18:30:57 1.9 @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/usr/bin/perl package Dudelicious; @@ -8,7 +8,7 @@ BEGIN { use FindBin; use lib "$FindBin::Bin/../lib"; - use lib "$FindBin::Bin/mojo/lib"; + use lib "$FindBin::Bin/../mojo/lib"; } use Carp qw/ carp croak /; @@ -36,36 +36,33 @@ $self->render( files => \@files, layout => 'todotxt' ); } => 'index'; +get '/todotxt' => 'todotxt'; + get '/l/:file' => sub { my $self = shift; my $file = $self->stash('file') . '.txt'; my $format = $self->stash('format') || 'html'; + my $list = _get_list( $self, $file ); if ( $format eq 'json' ) { - $self->render_json( _get_list( $self, $file ) ); + $self->render_json($list); } else { - $self->render( - list => _get_list( $self, $file ), - layout => 'todotxt' - ); + $self->render( list => $list, layout => 'todotxt' ); } } => 'list'; get '/l/:file/e/:line' => sub { my $self = shift; my $file = $self->stash('file') . '.txt'; - my $entry = $self->stash('line') - 1; my $format = $self->stash('format') || 'html'; + my $entry = _get_list( $self, $file )->[ $self->stash('line') - 1 ]; if ( $format eq 'json' ) { - $self->render_json( _get_list( $self, $file )->[$entry] ); + $self->render_json($entry); } else { - $self->render( - entry => _get_list( $self, $file )->[$entry], - layout => 'todotxt' - ); + $self->render( entry => $entry, layout => 'todotxt' ); } } => 'entry'; @@ -130,10 +127,24 @@ @@ layouts/todotxt.html.ep -