NAME
    Catalyst::Controller::DirectoryDispatch - Simple directory listing with
    built in url dispatching

VERSION
    version 1.01

SYNOPSIS
        package MyApp::Controller::Browser::Example;
        use Moose;
        BEGIN { extends 'Catalyst::Controller::DirectoryDispatch' }

        __PACKAGE__->config(
            action => { setup => { Chained => '/browser/base', PathPart => 'mydir' } },
            root     => '/home/andy',
            filter     => qr{^\.|.conf$},
            data_root  => 'data',
            full_paths => 1,
        );

DESCRIPTION
    Provides a simple configuration based controller for listing local
    system directories and dispatching them as URLs.

  Example Usage
    If you created the controller at http://localhost/mydir and set root to
    '/home/user1' then browsing to the controller might give the following
    output:

        {
            "success":true,
            "data":[
                "file1",
                "file2",
                "dir1",
                "dir2"
            ],
        }

    You could then point your browser to http://localhost/mydir/dir1 to get
    a directory listing of the folder '/home/user1/dir1' and so on...

  Changing Views
    The default view for DirectoryDispatch serializes the file list as JSON
    but it's easy to change it to whatever view you'd like.

        __PACKAGE__->config(
            'default'   => 'text/html',
            'map'       => {
                'text/html' => [ 'View', 'TT' ],
            }
        );

    Then in your template...

        [% FOREACH node IN response.data %]
        [% node %]
        [% END %]

  Post Processing
    If you need to process the files in anyway before they're passed to the
    view you can override process_files in your controller.

        sub process_files {
            my ($self, $c, $files) = @_;

            foreach my $file ( @$files ) {
                # Modify $file
            }

            return $files;
        }

    This is the last thing that happens before the list of files are passed
    on to the view. $files is sent in as an ArrayRef[Str] but you are free
    to return any thing you want as long as the serializer you're using can
    handle it.

CONFIGURATION
  root
        is: ro, isa: Str

    The folder that will be listed when accessing the controller (default
    '/').

  filter
        is: ro, isa: RegexpRef

    A regular expression that will remove matching files or folders from the
    directory listing (default: undef).

  data_root
        is: ro, isa: Str

    The name of the key inside $c->stash->{response} where the directory
    listing will be stored (default: data).

  full_paths
        is: ro, isa: Bool

    Returns full paths for the directory listing rather than just the names
    (default: 0).

THANKS
    The design for this module was heavly influenced by the fantastic
    Catalyst::Controller::DBIC::API.

AUTHOR
    Andy Gorman <agorman@cpan.org>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2010 by Andy Gorman.

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

