| Sledge-Plugin-RedirectReferer documentation | Contained in the Sledge-Plugin-RedirectReferer distribution. |
Sledge::Plugin::RedirectReferer - referer redirect plugin for Sledge
This documentation refers to Sledge::Plugin::RedirectReferer version 0.04
package Your::Pages;
use Sledge::Plugin::RedirectReferer;
sub dispatch_index {
my $self = shift;
return $self->redirect_referer('/if/non/referer');
}
This method redirect referer.
This method get your last access url.
Atsushi Kobayashi, <nekokak at gmail>
Please report any bugs or feature requests to
bug-sledge-plugin-redirectreferer at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sledge-Plugin-RedirectReferer.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Sledge::Plugin::RedirectReferer
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sledge-Plugin-RedirectReferer
Copyright 2006 Atsushi Kobayashi, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Sledge-Plugin-RedirectReferer documentation | Contained in the Sledge-Plugin-RedirectReferer distribution. |
package Sledge::Plugin::RedirectReferer; use strict; use warnings; use URI; our $VERSION = '0.04'; our $LAST_URL_KEY = '_last_url'; sub import { my $self = shift; my $pkg = caller; no strict 'refs'; *{"$pkg\::redirect_referer"} = sub { my ($self , $url) = @_; my $redirect_url = $self->session->param( $LAST_URL_KEY ) ? $self->session->param( $LAST_URL_KEY ) : $self->r->header_in('Referer'); if ( $redirect_url ) { my $uri = URI->new($redirect_url); if ( $uri->host eq $self->r->hostname ) { return $self->redirect($uri->path_query); } else { return $self->redirect($uri->as_string); } } else { return $self->redirect($url); } }; *{"$pkg\::last_access_url"} = sub { shift->session->param( $LAST_URL_KEY ); }; $pkg->register_hook( AFTER_OUTPUT => \&store_url, ); } sub store_url { my $self = shift; $self->session->param( $LAST_URL_KEY => $self->current_url ); }
1 # End of Sledge::Plugin::RedirectReferer