get '/mods/doc/:modname' => sub { my %params = params; my $ruri = request->request_uri(); if( $ruri =~ s/%3A/:/g ) { ## workaround for Pod::Simple::HTML , I prefer : over %3A ## and I preserve the rest http://localhost/mods/doc/Dancer%3A%3AReques%74 return redirect( $ruri ); } my $ret = eval { modlist::pod2html( %params ) }; if( !defined $ret or !length $ret ) { return meta_redirect( params, redirect => uri_for( "/mods" ) ); } return cache_page $ret; }; sub modlist::pod2html { my %opts = @_; my $module = $opts{modname}; my $modfile = $INC{$module}; $modfile ||= do { use Config(); use Pod::Find(); Pod::Find::pod_where( { -inc => 1, -script => 1, -perl => 1, -dirs => [ @INC, grep { defined and length } @Config::Config{ qw' installsitebin installsitescript installvendorbin installvendorscript installbin installscript ' } ], }, $module ); }; use Pod::Simple::XHTML; my $pshtml = Pod::Simple::XHTML->new; $pshtml->index( 1 ); $pshtml->html_css( 'http://search.cpan.org/s/style.css' ); $pshtml->perldoc_url_prefix( '' ); $pshtml->perldoc_url_postfix( '' ); $pshtml->man_url_prefix( 'http://man.linuxquestions.org/index.php?type=2&query=' ); $pshtml->man_url_postfix( '' ); my $somestring = ""; $pshtml->output_string( \$somestring ); $pshtml->parse_file( $modfile ); return $somestring; } ## end sub modlist::pod2html