NAME

Dancer::Plugin::PageHistory - store recent page history for user into session

VERSION

Version 0.005

SYNOPSIS

get '/product/:sku/:name' => sub {
    add_to_history(
        type       => 'product',
        title      => param('name'),
        attributes => { sku => param('sku') }
    );
};

hook 'before_template_render' => sub {
    my $tokens = shift;
    $tokens->{previous_page} = history->previous_page->uri;
};

DESCRIPTION

The add_to_history keyword which is exported by this plugin allows you to add interesting items to the history lists which are returned using the history keyword.

KEYWORDS

add_to_history

Adds a page via "add" in Dancer::Plugin::PageHistory::PageSet. Both of path and query are optional arguments which will be set automatically from the current request if they are not supplied.

history

Returns the current Dancer::Plugin::PageHistory::PageSet object from the user's session.

SUPPORTED SESSION ENGINES

CHI, Cookie, DBIC, JSON, Memcached, Memcached::Fast, MongoDB, PSGI, Simple, Storable, YAML

CAVEATS

Dancer::Session::Cookie and Dancer::Session::PSGI either don't handle destroy at all or else do it wrong so I suggest you avoid those modules if you want things like logout to work.

CONFIGURATION

No configuration is necessarily required.

If you wish to have arguments passed to "new" in Dancer::Plugin::PageHistory::PageSet these can be added to your configuration along with configuration for the plugin itself, e.g.:

   plugins:
     PageHistory:
       add_all_pages: 1
       ingore_ajax: 1 
       history_name: someothername
       PageSet:
         default_type: all
         fallback_page:
           path: "/"
         max_items: 20
         methods:
           - default
           - product
           - navigation

Configuration options for the plugin itself:

HOOKS

This plugin makes use of the following hooks:

before

Add current page to history. See "add_all_pages" and "ignore_ajax".

before_template_render

Puts history into the token page_history.

TODO

AUTHOR

Peter Mottram (SysPete), "peter@sysnix.com"

BUGS

This is BETA software so bugs and missing features are expected.

Please report any bugs or feature requests via the project's GitHub issue tracker:

https://github.com/SysPete/Dancer-Plugin-PageHistory/issues

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. PRs are always welcome.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Dancer::Plugin::PageHistory

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2015 Peter Mottram (SysPete).

This program is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

See http://dev.perl.org/licenses/ for more information.