GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Dancer2::Plugin::Path::Class(3) User Contributed Perl Documentation Dancer2::Plugin::Path::Class(3)

Dancer2::Plugin::Path::Class - list a directory using Path::Class

version 0.07

  use Dancer2::Plugin::Path::Class;
  
  get '/img' => sub {
      my $dir = ls(config->{public}, '/img');
      template 'dirlisting';
  };
  
  get '/img/**' => sub {
      my ($path) = splat;
      my @splat = @{$path};
      my $dir = ls(config->{public}, '/img', @splat);
      return template 'dirlisting' if -d $dir;
      send_file("$dir", system_path =>1);
  };
  
  In your template:
  
  <div><a href="[% vars.ls_cdup %]">
  [% vars.ls_cdup %]</a>/[% vars.ls_name %]</div>
  
  [% FOREACH dir IN vars.ls_dirs %] ...
  
  [% FOREACH file IN vars.ls_files %] ...

"Dancer2::Plugin::Path::Class" exports the "ls" function returning a "Path::Class" object. The "ls" function also sets the following vars:
ls_name
The basename of the path.
ls_cdup
The parent of the request path.
ls_dirs
A list of subdirectories if the path is a directory object. The subdirs are decorated with "name", "file_count" and a list of (sub) "subdirs".
ls_files
A list of files or just one file if the path is a file object. The files are decorated with "name", "date", "size" and "type".

All objects must be readable. Names starting with a dot ('.') or ending with a tilde ('~') are ignored.

Henk van Oers, HVOERS@cpan.org

    Peter Mottram

Copyright (c) Henk van Oers. All rights reserved.

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

Path::Class, Dancer2
2016-06-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.