NAME

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

VERSION

Version 0.102

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.

See "TODO".

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:

  • add_all_pages

    Defaults to 0. Set to 1 to have all pages added to the list "default_type" in Dancer::Plugin::PageHistory::PageSet in the "before" hook.

  • ignore_ajax

    If "add_all_pages" is true this controls whether ajax requests are added to the list "default_type" in Dancer::Plugin::PageHistory::PageSet in the "before" hook.

    Defaults to 0. Set to 1 to have ajax requests ignored.

  • history_name

    This setting can be used to change the name of the key used to store the history object in the session from the default page_history to something else. This is also the key used for name of the token containing the history object that is passed to templates and also the var used to cache the history object during the request lifetime.

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

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.