Skip Menu |

This queue is for tickets about the Pod-POM-Web CPAN distribution.

Report information
The Basics
Id: 43520
Status: resolved
Priority: 0/
Queue: Pod-POM-Web

People
Owner: Nobody in particular
Requestors: perl [...] galumph.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Patch: configure the page title.
Date: Sun, 22 Feb 2009 19:48:02 -0600
To: bug-pod-pom-web [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
I've got multiple perl installs to deal with. I want to be able to differentiate different Pod::POM::Web instances via the page title. The attached patch adds an option to specify the page title. I don't consider the patch complete-- the documentation hasn't been updated-- but I wanted to get your opinion on the approach before continuing. Assuming this is OK, I'll get the documentation updated. After this, I want to add a further option to add to the script directories.
=== modified file 'lib/Pod/POM/Web.pm' --- lib/Pod/POM/Web.pm 2009-02-23 00:18:31 +0000 +++ lib/Pod/POM/Web.pm 2009-02-23 01:26:30 +0000 @@ -78,7 +78,7 @@ #---------------------------------------------------------------------- sub server { # builtin HTTP server; unused if running under Apache - my ($class, $port) = @_; + my ($class, $port, $options) = @_; $port ||= 8080; my $daemon = HTTP::Daemon->new(LocalPort => $port, @@ -92,7 +92,7 @@ print STDERR "URL : " , $req->url, "\n"; $client_connection->force_last_request; # patch by CDOLAN my $response = HTTP::Response->new; - $class->handler($req, $response); + $class->handler($req, $response, $options); $client_connection->send_response($response); } $client_connection->close; @@ -103,8 +103,8 @@ sub handler : method { - my ($class, $request, $response) = @_; - my $self = $class->new($request, $response); + my ($class, $request, $response, $options) = @_; + my $self = $class->new($request, $response, $options); eval { $self->dispatch_request(); 1} or $self->send_content({content => $@, code => 500}); return 0; # Apache2::Const::OK; @@ -112,8 +112,9 @@ sub new { - my ($class, $request, $response) = @_; + my ($class, $request, $response, $options) = @_; my $self; + $options ||= {}; # cheat: will create an instance of the Indexer subclass if possible if (!$no_indexer && $class eq __PACKAGE__) { @@ -128,7 +129,8 @@ $q->query($request->args); my $params = $q->query_form_hash; (my $uri = $request->uri) =~ s/$path$//; - $self = {response => $request, # Apache API: same object for both + $self = {%{$options}, # Put first so that it gets overwritten below + response => $request, # Apache API: same object for both root_url => $uri, path => $path, params => $params, @@ -137,7 +139,8 @@ }; /^HTTP/ and do { # coming from HTTP::Daemon // server() method above - $self = {response => $response, + $self = {%{$options}, # Put first so that it gets overwritten below + response => $response, root_url => "", path => $request->url->path, params => $request->url->query_form_hash, @@ -215,9 +218,12 @@ sub index_frameset { my ($self) = @_; + + my $title = $self->{page_title} || 'Perl documentation'; + $title =~ s/([&<>"])/$escape_entity{$1}/g; return $self->send_html(<<__EOHTML__); <html> - <head><title>Perl documentation</title></head> + <head><title>$title</title></head> <frameset cols="25%, 75%"> <frame name="tocFrame" src="toc" ></frame> <frame name="contentFrame" src="perl" ></frame>
Le Dim. Fév. 22 20:48:22 2009, clonezone a écrit : Show quoted text
> I've got multiple perl installs to deal with. I want to be able to > differentiate different Pod::POM::Web instances via the page title. > The attached patch adds an option to specify the page title. I > don't consider the patch complete-- the documentation hasn't been > updated-- but I wanted to get your opinion on the approach before > continuing. Assuming this is OK, I'll get the documentation > updated. After this, I want to add a further option to add to the > script directories.
Hi Eliott, The patch looks fine, OK to include it in a next release (let's say about 2 weeks from now), so go on with the doc. Maybe I'll have other options to include as well in the API; I need to think a little be about it. Cheers, Laurent Dami
Subject: Re: [rt.cpan.org #43520] Patch: configure the page title.
Date: Mon, 23 Mar 2009 21:20:56 -0500
To: bug-Pod-POM-Web [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Sorry about getting this to you late. I only gave examples for CGI and standalone in the doc; I don't know how the Apache configuration would work.
=== modified file 'lib/Pod/POM/Web.pm' --- lib/Pod/POM/Web.pm 2009-02-23 00:18:31 +0000 +++ lib/Pod/POM/Web.pm 2009-03-24 02:17:00 +0000 @@ -78,7 +78,7 @@ #---------------------------------------------------------------------- sub server { # builtin HTTP server; unused if running under Apache - my ($class, $port) = @_; + my ($class, $port, $options) = @_; $port ||= 8080; my $daemon = HTTP::Daemon->new(LocalPort => $port, @@ -92,7 +92,7 @@ print STDERR "URL : " , $req->url, "\n"; $client_connection->force_last_request; # patch by CDOLAN my $response = HTTP::Response->new; - $class->handler($req, $response); + $class->handler($req, $response, $options); $client_connection->send_response($response); } $client_connection->close; @@ -103,8 +103,8 @@ sub handler : method { - my ($class, $request, $response) = @_; - my $self = $class->new($request, $response); + my ($class, $request, $response, $options) = @_; + my $self = $class->new($request, $response, $options); eval { $self->dispatch_request(); 1} or $self->send_content({content => $@, code => 500}); return 0; # Apache2::Const::OK; @@ -112,8 +112,9 @@ sub new { - my ($class, $request, $response) = @_; + my ($class, $request, $response, $options) = @_; my $self; + $options ||= {}; # cheat: will create an instance of the Indexer subclass if possible if (!$no_indexer && $class eq __PACKAGE__) { @@ -128,7 +129,8 @@ $q->query($request->args); my $params = $q->query_form_hash; (my $uri = $request->uri) =~ s/$path$//; - $self = {response => $request, # Apache API: same object for both + $self = {%{$options}, # Put first so that it gets overwritten below + response => $request, # Apache API: same object for both root_url => $uri, path => $path, params => $params, @@ -137,7 +139,8 @@ }; /^HTTP/ and do { # coming from HTTP::Daemon // server() method above - $self = {response => $response, + $self = {%{$options}, # Put first so that it gets overwritten below + response => $response, root_url => "", path => $request->url->path, params => $request->url->query_form_hash, @@ -215,9 +218,12 @@ sub index_frameset { my ($self) = @_; + + my $title = $self->{page_title} || 'Perl documentation'; + $title =~ s/([&<>"])/$escape_entity{$1}/g; return $self->send_html(<<__EOHTML__); <html> - <head><title>Perl documentation</title></head> + <head><title>$title</title></head> <frameset cols="25%, 75%"> <frame name="tocFrame" src="toc" ></frame> <frame name="contentFrame" src="perl" ></frame> @@ -1578,6 +1584,34 @@ =head2 Optional features +=head3 Options + +Certain features can be customized by passing a hash reference to C<server()> +or C<handler()>. For the standard arguments that you don't want to specify, +simply pass C<undef>. + +An updated form of the CGI example above: + + #!/path/to/perl + use Pod::POM::Web; + Pod::POM::Web->handler( undef, undef, { ... } ); + +For the standalone server: + + perl -MPod::POM::Web -e "Pod::POM::Web->server( undef, { ... } )" + +Currently supported options are: + +=over + +=item * C<< page_title => '...' >> + +This allows you to modify the page title from the default "Perl documentation", +if, for example, you have multiple perl installations and need to differentiate +them. + +=back + =head3 Syntax coloring Syntax coloring improves readability of code excerpts.
Le Lun 23 Mar 2009 22:21:16, clonezone a écrit : Show quoted text
> Sorry about getting this to you late. I only gave examples for CGI > and standalone in the doc; I don't know how the Apache configuration > would work.
I don't remember having received your message from 23 Mar, don't know what happened, sorry. Anyway the page_title feature is (finally!) shipped with version 1.13. Cheers, Laurent D.