NAME

Rapi::Fs - Plack-compatible, instant ExtJS file browser

SYNOPSIS

use Rapi::Fs;

my $app = Rapi::Fs->new({
  mounts  => [ '/some/path', '/foo/blah' ]
});

# Plack/PSGI app:
$app->to_app

Or, using rapi-fs.pl utility script:

rapi-fs.pl /some/path /foo/blah

DESCRIPTION

This is a Plack-compatible file browser application written using RapidApp. It generates a nice-looking dynamic web interface to browse and view arbitrary files and directories for the configured "mounts" using a standard, split-panel tree layout:

Rapi::Fs screenshot

For a live demo, see: rapi.io/fs

Internally, the RapidApp module class Rapi::Fs::Module::FileTree does the heavy lifting, and that module can be configured and used directly within an existing RapidApp.

The convenience utility script rapi-fs.pl is also available, which is a simple wrapper around this module, to be able to fire up a fully working and self-contained app on-the-fly (including launching a built-in webserver) from the command-line.

CONFIGURATION

Rapi::Fs extends RapidApp::Builder and supports all of its options, as well as the following params specific to this module:

mounts

List of directory "mount" points to use/show in the application. This is the only required parameter and supports a flexible syntax. Mounts can be supplied as simple directory string paths, HashRef configs, or "driver" objects (consuming the Rapi::Fs::Role::Driver role). The default driver class which ships with the Rapi::Fs package is Rapi::Fs::Driver::Filesystem.

The following mount specifications are all equivalent:

$app = Rapi::Fs->new({
  mounts  => [ '/some/path' ]
});

$app = Rapi::Fs->new({
  mounts  => [{
    driver => 'Filesystem',
    name   => 'path',
    args   => '/some/path'
  }]
});

$app = Rapi::Fs->new({
  mounts  => [ 
    Rapi::Fs::Driver::Filesystem->new({
      name   => 'path',
      args   => '/some/path'
    })
  ]
});

When using the HashRef syntax, the 'driver' param is a class name relative to the Rapi::Fs::Driver::* namespace. To supply a full class name, prefix with '+', for instance:

$app = Rapi::Fs->new({
  mounts  => [{
    driver => '+My::Fs::Driver',
    name   => 'Foobar',
    args   => 'something understood by My::Fs::Driver'
  }]
});

Different forms can also be mix/matched:

$app = Rapi::Fs->new({
  mounts  => [
    {
      driver => '+My::Fs::Driver',
      name   => 'Foobar',
      args   => 'something understood by My::Fs::Driver'
    },
    '/path/to/something',
    {
      name  => 'perl5-lib',
      args  => '/usr/lib/perl5'
    },
    Some::Other::Driver->new({
      name   => 'larry',
      args   => 'bla',
      foo    => 'bar'
    })
  ]
});

Rapi::Fs::Driver::Filesystem is the only driver which has been implemented so far, but this module was written with the idea of implementing other drivers in mind, both as possible additional core-modules as well as user-defined drivers. See Rapi::Fs::Role::Driver for more info on the driver API.

filetree_class

Defaults to Rapi::Fs::Module::FileTree.

filetree_params

Optional extra params to supply to the filetree_class constructor.

METHODS

to_app

PSGI $app CodeRef. Derives from Plack::Component

TODO

  • Add write support (move/rename/copy/delete/edit)

  • Add "Mount" as a 4th Node type, to allow nesting other kinds of drivers within a structure.

Planned additional drivers

  • SSH/SFTP

  • IMAP

  • JSON/YAML files (i.e. browse data structure)

  • Zip/archive

  • Multipart/MIME

SEE ALSO

AUTHOR

Henry Van Styn <vanstyn@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by IntelliTree Solutions llc.

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