Catalyst-Plugin-Static-Simple-0.38/ 000750 000000 000000 00000000000 15226471252 015307 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/README 000660 000000 000000 00000031073 15226471252 016176 0 ustar 00 000000 000000 NAME
Catalyst::Plugin::Static::Simple - Make serving static pages painless.
SYNOPSIS
package MyApp;
use Catalyst qw/ Static::Simple /;
MyApp->setup;
# that's it; static content is automatically served by Catalyst
# from the application's root directory, though you can configure
# things or bypass Catalyst entirely in a production environment
#
# one caveat: the files must be served from an absolute path
# (i.e. /images/foo.png)
DESCRIPTION
The Static::Simple plugin is designed to make serving static content in
your application during development quick and easy, without requiring a
single line of code from you.
This plugin detects static files by looking at the file extension in the
URL (such as .css or .png or .js). The plugin uses the lightweight
MIME::Types module to map file extensions to IANA-registered MIME types,
and will serve your static files with the correct MIME type directly to
the browser, without being processed through Catalyst.
Note that actions mapped to paths using periods (.) will still operate
properly.
If the plugin can not find the file, the request is dispatched to your
application instead. This means you are responsible for generating a 404
error if your application can not process the request:
# handled by static::simple, not dispatched to your application
/images/exists.png
# static::simple will not find the file and let your application
# handle the request. You are responsible for generating a file
# or returning a 404 error
/images/does_not_exist.png
Though Static::Simple is designed to work out-of-the-box, you can tweak
the operation by adding various configuration options. In a production
environment, you will probably want to use your webserver to deliver
static content; for an example see "USING WITH APACHE", below.
DEFAULT BEHAVIOUR
By default, Static::Simple will deliver all files having extensions
(that is, bits of text following a period (".")), *except* files having
the extensions "tmpl", "tt", "tt2", "html", and "xhtml". These files,
and all files without extensions, will be processed through Catalyst. If
MIME::Types doesn't recognize an extension, it will be served as
"text/plain".
To restate: files having the extensions "tmpl", "tt", "tt2", "html", and
"xhtml" *will not* be served statically by default, they will be
processed by Catalyst. Thus if you want to use ".html" files from within
a Catalyst app as static files, you need to change the configuration of
Static::Simple. Note also that files having any other extension *will*
be served statically, so if you're using any other extension for
template files, you should also change the configuration.
Logging of static files is turned off by default.
ADVANCED CONFIGURATION
Configuration is completely optional and is specified within
"MyApp->config->{Plugin::Static::Simple}". If you use any of these
options, this module will probably feel less "simple" to you!
Enabling request logging
Since Catalyst 5.50, logging of static requests is turned off by
default; static requests tend to clutter the log output and rarely
reveal anything useful. However, if you want to enable logging of static
requests, you can do so by setting
"MyApp->config->{Plugin::Static::Simple}->{logging}" to 1.
Forcing directories into static mode
Define a list of top-level directories beneath your 'root' directory
that should always be served in static mode. Regular expressions may be
specified using "qr//".
MyApp->config(
'Plugin::Static::Simple' => {
dirs => [
'static',
qr/^(images|css)/,
],
}
);
Including additional directories
You may specify a list of directories in which to search for your static
files. The directories will be searched in order and will return the
first file found. Note that your root directory is not automatically
added to the search path when you specify an "include_path". You should
use "MyApp->config->{root}" to add it.
MyApp->config(
'Plugin::Static::Simple' => {
include_path => [
'/path/to/overlay',
\&incpath_generator,
MyApp->config->{root},
],
},
);
With the above setting, a request for the file "/images/logo.jpg" will
search for the following files, returning the first one found:
/path/to/overlay/images/logo.jpg
/dynamic/path/images/logo.jpg
/your/app/home/root/images/logo.jpg
The include path can contain a subroutine reference to dynamically
return a list of available directories. This method will receive the $c
object as a parameter and should return a reference to a list of
directories. Errors can be reported using die(). This method will be
called every time a file is requested that appears to be a static file
(i.e. it has an extension).
For example:
sub incpath_generator {
my $c = shift;
if ( $c->session->{customer_dir} ) {
return [ $c->session->{customer_dir} ];
} else {
die "No customer dir defined.";
}
}
Ignoring certain types of files
There are some file types you may not wish to serve as static files.
Most important in this category are your raw template files. By default,
files with the extensions "tmpl", "tt", "tt2", "html", and "xhtml" will
be ignored by Static::Simple in the interest of security. If you wish to
define your own extensions to ignore, use the "ignore_extensions"
option:
MyApp->config(
'Plugin::Static::Simple' => {
ignore_extensions => [ qw/html asp php/ ],
},
);
Ignoring entire directories
To prevent an entire directory from being served statically, you can use
the "ignore_dirs" option. This option contains a list of relative
directory paths to ignore. If using "include_path", the path will be
checked against every included path.
MyApp->config(
'Plugin::Static::Simple' => {
ignore_dirs => [ qw/tmpl css/ ],
},
);
For example, if combined with the above "include_path" setting, this
"ignore_dirs" value will ignore the following directories if they exist:
/path/to/overlay/tmpl
/path/to/overlay/css
/dynamic/path/tmpl
/dynamic/path/css
/your/app/home/root/tmpl
/your/app/home/root/css
Custom MIME types
To override or add to the default MIME types set by the MIME::Types
module, you may enter your own extension to MIME type mapping.
MyApp->config(
'Plugin::Static::Simple' => {
mime_types => {
jpg => 'image/jpg',
png => 'image/png',
},
},
);
Controlling caching with Expires header
The files served by Static::Simple will have a Last-Modified header set,
which allows some browsers to cache them for a while. However if you
want to explicitly set an Expires header, such as to allow proxies to
cache your static content, then you can do so by setting the "expires"
config option.
The value indicates the number of seconds after access time to allow
caching. So a value of zero really means "don't cache at all", and any
higher values will keep the file around for that long.
MyApp->config(
'Plugin::Static::Simple' => {
expires => 3600, # Caching allowed for one hour.
},
);
Compatibility with other plugins
Since version 0.12, Static::Simple plays nice with other plugins. It no
longer short-circuits the "prepare_action" stage as it was causing too
many compatibility issues with other plugins.
Debugging information
Enable additional debugging information printed in the Catalyst log.
This is automatically enabled when running Catalyst in -Debug mode.
MyApp->config(
'Plugin::Static::Simple' => {
debug => 1,
},
);
USING WITH APACHE
While Static::Simple will work just fine serving files through Catalyst
in mod_perl, for increased performance you may wish to have Apache
handle the serving of your static files directly. To do this, simply use
a dedicated directory for your static files and configure an Apache
Location block for that directory This approach is recommended for
production installations.
SetHandler default-handler
Using this approach Apache will bypass any handling of these directories
through Catalyst. You can leave Static::Simple as part of your
application, and it will continue to function on a development server,
or using Catalyst's built-in server.
In practice, your Catalyst application is probably (i.e. should be)
structured in the recommended way (i.e., that generated by bootstrapping
the application with the "catalyst.pl" script, with a main directory
under which is a "lib/" directory for module files and a "root/"
directory for templates and static files). Thus, unless you break up
this structure when deploying your app by moving the static files to a
different location in your filesystem, you will need to use an Alias
directive in Apache to point to the right place. You will then need to
add a Directory block to give permission for Apache to serve these
files. The final configuration will look something like this:
Alias /myapp/static /filesystem/path/to/MyApp/root/static
allow from all
SetHandler default-handler
If you are running in a VirtualHost, you can just set the DocumentRoot
location to the location of your root directory; see
Catalyst::Engine::Apache2::MP20.
PUBLIC METHODS
serve_static_file $file_path
Will serve the file located in $file_path statically. This is useful
when you need to autogenerate them if they don't exist, or they are
stored in a model.
package MyApp::Controller::User;
sub curr_user_thumb : PathPart("my_thumbnail.png") {
my ( $self, $c ) = @_;
my $file_path = $c->user->picture_thumbnail_path;
$c->serve_static_file($file_path);
}
INTERNAL EXTENDED METHODS
Static::Simple extends the following steps in the Catalyst process.
prepare_action
"prepare_action" is used to first check if the request path is a static
file. If so, we skip all other "prepare_action" steps to improve
performance.
dispatch
"dispatch" takes the file found during "prepare_action" and writes it to
the output.
finalize
"finalize" serves up final header information and displays any log
messages.
setup
"setup" initializes all default values.
DEPRECATIONS
The old style of configuration using the 'static' config key was
deprecated in version 0.30. A warning will be issued if this is used,
and the contents of the config at this key will be merged with the newer
'Plugin::Static::Simple' key.
Be aware that if the 'include_path' key under 'static' exists at all, it
will be merged with any content of the same key under
'Plugin::Static::Simple'. Be careful not to set this to a non-arrayref,
therefore.
SEE ALSO
Catalyst, Catalyst::Plugin::Static,
AUTHOR
Andy Grundman,
CONTRIBUTORS
Marcus Ramberg,
Jesse Sheidlower,
Guillermo Roditi,
Florian Ragwitz,
Tomas Doran,
Justin Wheeler (dnm)
Matt S Trout,
Toby Corkindale,
THANKS
The authors of Catalyst::Plugin::Static:
Sebastian Riedel
Christian Hansen
Marcus Ramberg
For the include_path code from Template Toolkit:
Andy Wardley
COPYRIGHT
Copyright (c) 2005 - 2011 the Catalyst::Plugin::Static::Simple "AUTHOR"
and "CONTRIBUTORS" as listed above.
LICENSE
This program is free software, you can redistribute it and/or modify it
under the same terms as Perl itself.
Catalyst-Plugin-Static-Simple-0.38/Changes 000644 000000 000000 00000020207 15226471133 016606 0 ustar 00 000000 000000 Revision history for Perl extension Catalyst::Plugin::Static::Simple
0.38 - 2026-07-17
- canonical repository is now github, rather than catagits
0.37 - 2021-05-05
- Port Makefile.PL from Module::Install to Distar
- Remove MooseX::Types dependency
0.36 2018-03-15 11:37 GMT
- Relax PNG content type check in t/05dirs.t
0.35 2018-03-14 12:07 GMT
- Use less-likely extension for unknown file type (RT#124211)
0.34 2017-08-02 09:56 Los Angeles
- Remove MYMETA.* (RT#108814)
- Fix installing on 5.26.0+ (RT#121861)
- Fix security vulnerability, when serving static files with dots in the
names (RT#120558)
- Fix typo in POD (RT#87098)
0.33 2014-09-26 17:00 BST
- In the case where someone is trying to merge configurations
and some config sets use the depracated 'static' keyword, the
configs will be properly merged.
0.32 2014-06-04 17:00 EDT
- Sets 'autoflush' in the Catalyst Log object to false if
available. This is a new API being added in Catalyst as of
version 5.90065
0.31 2013-09-09 16:30:00
- Updated docs to reflect config key change from 'static' to
'Plugin::Static::Simple' (RT#77709)
- Migrated repository from subversion to git
- Fixed MIME::Types 2.xx compatibility be removing call to an
undocumented method
- Bumped the MIME::Types requirement to 2.03 to ensure its
improvements make it into Catalyst environments
0.30 2012-05-04 17:05:00
- Add Cache-Control:public header
- Optionally provide Expires header
- Change configuration key to 'Plugin::Static::Simple' by default.
The old 'static' key is still supported, but issues a warning.
0.29 2010-02-01 18:45:00
- Switch from override to around, because really, wtf
0.28 2010-01-04 13:15:00
- Fix issues in debug mode. (RT#53338)
0.27 2010-01-03 14:49:00
- Switch to being a Moose role, removing dependencies on
Class::Data::Inheritable and Class::Accessor (Andrey Kostenko in
RT#51089)
- Make Pod tests mandatory for authors but never run otherwise
- Switch to Test::NoTabs to ensure no tabs, rather than
Test::Perl::Critic
0.26 2009-12-06 12:30:00
- Fix Pod to show less nasty method of assigning config by calling
the config method with parameters, rather than poking around inside
the hash.
- Require newer (>= 0.15) Catalyst::Plugin::SubRequest for subrequest
tests as old versions don't work with new Catalyst (>= 5.80014)
0.25 2009-10-22 21:40:00 BST
- Fix bug where old unrelated $@ values would result in an error.
0.24 2009-10-18 19:10:00 BST
- Fixup copyright information
0.23 2009-10-06 17:40:39
- Move actions out of TestApp into a Root controller as
this is now deprecated.
0.22 2009-08-21 18:14:59
- Add tests for delivering empty files.
- Fix those tests by depending on Catalyst-Runtime 5.80008.
- Throw away compatibility code for older catalyst versions.
- Fix docs to not include plugins in call to ->setup() (t0m)
0.21 2009-03-29 20:31:49
- Documentation improvements (jester)
- Change from NEXT to MRO::Compat - RT#40628, RT#44553 (ilmari)
- Bump prereq to MIME::Types to 1.25 to correctly send files
commonly used to graft support for transparent PNGs into
MSIE6 - RT#41314 (Florian Ragwitz)
0.20 2007-09-24 10:00:00
- Fixed issue where the static dir regex did not add a trailing
slash so URLs such as /static1 were served as static when they
should be handled by Catalyst. (Will Hawes)
- Added text/html Content-Type to 404 responses. (Will Hawes)
0.19 2007-07-02 17:00:00
- Fixed test failure on some systems in 11serve_static.t due to
multiple MIME types defined for the extension '.pm'.
0.18 2007-07-01 00:15:00
- Logging may now be enabled with the less confusing
MyApp->config->{static}->{logging} = 1;
0.17 2007-05-11 11:00:00
- Added serve_static_file, to serve a given file as static. (groditi)
0.16 2007-04-30 15:00:00
- Allow all files in directories defined by the config option 'dirs'
to be served as static even if the file matches ignore_dirs or
ignore_extensions.
- Fixed bug where 204 or 304 status codes would result in a 500 error
under mod_perl.
- Switch to Module::Install.
0.15 2006-12-08 22:30:00
- Quote metacharacters used in $c->config->{dirs} (Vlad Dan Dascalescu)
- store Mime::Types object in config hash instead of as classdata
- cleanup code a bit
0.14 2006-03-24 11:15:00
- Unescape the URI path before looking for the file. This fixes
issues with files that have spaces.
0.13 2005-12-15 10:00:00
- Fixed bug in ignore_dirs under win32.
- Doc rewriting
0.12 (released only with Catalyst)
- Made prepare_action play nice with other plugins by not short-
circuiting.
- Added tmpl to the ignored extensions.
- Fixed security problem if req->path contained '..'.
0.11 2005-11-13 16:25:00
- Removed the code that set the 304 Not Modified header. This caused
problems with IE under Apache.
- Changed 5.50 writing method to pass an IO::File object directly to
$c->res->body.
- This version is included with Catalyst 5.50.
0.10 2005-10-19 17:20:00
- Added tt2 to the list of ignored extensions.
- For Catalyst 5.5+, replaced File::Slurp with a buffered read/write
process. This will improve memory usage and performance on larger
static files.
- Removed Apache integration feature. It is slower than serving
through Catalyst and as far as I know no one is using it. If you
need the best performance, use a separate Location block for static
content.
0.09 2005-10-07 13:40:00
- Added new configuration options to improve security:
ignore_extensions - keep certain extensions from being static
- This option defaults to tt, html, and xhtml to prevent
template files from being accessible.
ignore_dirs - keep certain dirs from being static
- include_path is no longer experimental.
- Added support for hiding log output, depends on Cat 5.50.
(Marcus Ramberg)
0.08 2005-09-07 18:50:00
- Added tests for everything except Apache support.
0.07 2005-09-05 21:05:00
- POD fixes. (Thomas L. Shinnick)
0.06 2005-09-05 15:40:00
- Moved initial file check into prepare_action so processing can
bypass other plugins.
- Added error-checking to static dir regexes.
- Cleaned up various code as per Best Practices.
0.05 2005-08-26 12:00:00
- Added use_apache option to enable the Apache DECLINED
support. Default is disabled as it appears Catalyst is
faster at serving the files!
- Added a check that Apache's DocumentRoot matches Catalyst's
root before serving DECLINED.
- Preload MIME::Types index during setup() so it's not built on
the first request.
- Added a note on performance of Apache vs. Catalyst.
0.04 2005-08-22 12:00:00
- Fixed bug where static files were searched for on every request
even without a file extension.
- Fixed bug where files without extensions in defined static dirs
were not served with text/plain.
- Consolidated the debug log messages.
0.03 2005-08-21 23:50:00
- Added config option for include_path to allow for multiple
directories with static files. This option should be
considered experimental!
- Documentation cleanups.
0.02 2005-08-16 18:00:00
- Return DECLINED when running under mod_perl to allow Apache to
serve the static file. This is not done when any custom MIME
types have been specified, however.
0.01 2005-08-11 22:00:00
- Initial release.
Catalyst-Plugin-Static-Simple-0.38/MANIFEST 000644 000000 000000 00000003175 15226471252 016453 0 ustar 00 000000 000000 Changes
lib/Catalyst/Plugin/Static/Simple.pm
maint/Makefile.PL.include
Makefile.PL
MANIFEST This list of files
t/01use.t
t/04static.t
t/05dirs.t
t/06include_path.t
t/07mime_types.t
t/08subreq.t
t/09ignore_ext.t
t/10ignore_dirs.t
t/11serve_static.t
t/12check_error_scope.t
t/13no_include_path.t
t/14deprecated.t
t/20debug.t
t/lib/IncTestApp.pm
t/lib/IncTestApp/Controller/Root.pm
t/lib/IncTestApp/root/images/bad.gif
t/lib/IncTestApp/root/overlay/overlay.jpg
t/lib/TestApp.pm
t/lib/TestApp/Controller/Root.pm
t/lib/TestApp/root/always-static/test
t/lib/TestApp/root/always-static/test.html
t/lib/TestApp/root/css/static.css
t/lib/TestApp/root/files/bad.gif
t/lib/TestApp/root/files/empty.txt
t/lib/TestApp/root/files/err.unknown
't/lib/TestApp/root/files/space file.txt'
t/lib/TestApp/root/files/static.css
t/lib/TestApp/root/ignored/bad.gif
t/lib/TestApp/root/ignored/index.html
t/lib/TestApp/root/ignored/static.css
t/lib/TestApp/root/ignored/tmpl.tt
t/lib/TestApp/root/images/bad.gif
t/lib/TestApp/root/images/catalyst.png
t/lib/TestApp/root/incpath/incpath.css
t/lib/TestApp/root/overlay/o-ignored/bad.gif
t/lib/TestApp/root/overlay/o-ignored/index.html
t/lib/TestApp/root/overlay/o-ignored/static.css
t/lib/TestApp/root/overlay/o-ignored/tmpl.tt
t/lib/TestApp/root/overlay/overlay.jpg
t/lib/TestLog.pm
xt/02pod.t
xt/03podcoverage.t
xt/notabs.t
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
README README file (added by Distar)
LICENSE LICENSE file (added by Distar)
Catalyst-Plugin-Static-Simple-0.38/LICENSE 000660 000000 000000 00000046061 15226471252 016326 0 ustar 00 000000 000000 Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2026 by Andy Grundman .
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Moe Ghoul, President of Vice
That's all there is to it!
--- The Perl Artistic License 1.0 ---
This software is Copyright (c) 2026 by Andy Grundman .
This is free software, licensed under:
The Perl Artistic License 1.0
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
Catalyst-Plugin-Static-Simple-0.38/t/ 000750 000000 000000 00000000000 15226471252 015552 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/xt/ 000750 000000 000000 00000000000 15226471252 015742 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/META.yml 000660 000000 000000 00000001542 15226471252 016565 0 ustar 00 000000 000000 ---
abstract: 'Make serving static pages painless.'
author:
- 'Andy Grundman '
build_requires:
Test::More: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.78, CPAN::Meta::Converter version 2.150013'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Catalyst-Plugin-Static-Simple
no_index:
directory:
- t
- xt
requires:
Catalyst::Runtime: '5.80008'
MIME::Types: '2.03'
Moose: '0'
namespace::autoclean: '0'
resources:
bugtracker: https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple/issues
license: http://dev.perl.org/licenses/
repository: https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple.git
version: '0.38'
x_serialization_backend: 'CPAN::Meta::YAML version 0.020'
Catalyst-Plugin-Static-Simple-0.38/META.json 000660 000000 000000 00000003255 15226471252 016740 0 ustar 00 000000 000000 {
"abstract" : "Make serving static pages painless.",
"author" : [
"Andy Grundman "
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.78, CPAN::Meta::Converter version 2.150013",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Catalyst-Plugin-Static-Simple",
"no_index" : {
"directory" : [
"t",
"xt"
]
},
"prereqs" : {
"build" : {},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"develop" : {
"requires" : {
"Test::NoTabs" : "0",
"Test::Pod" : "1.14",
"Test::Pod::Coverage" : "1.04"
}
},
"runtime" : {
"requires" : {
"Catalyst::Runtime" : "5.80008",
"MIME::Types" : "2.03",
"Moose" : "0",
"namespace::autoclean" : "0"
}
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple/issues"
},
"license" : [
"http://dev.perl.org/licenses/"
],
"repository" : {
"type" : "git",
"url" : "https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple.git",
"web" : "https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple"
}
},
"version" : "0.38",
"x_serialization_backend" : "JSON::MaybeXS version 1.004008"
}
Catalyst-Plugin-Static-Simple-0.38/lib/ 000750 000000 000000 00000000000 15226471252 016055 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/maint/ 000750 000000 000000 00000000000 15226471252 016417 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/Makefile.PL 000644 000000 000000 00000006367 15226470634 017305 0 ustar 00 000000 000000 use strict;
use warnings;
use 5.006;
my %META = (
name => 'Catalyst-Plugin-Static-Simple',
license => 'perl_5',
prereqs => {
configure => { requires => {
'ExtUtils::MakeMaker' => 0,
} },
test => {
requires => {
'Test::More' => 0,
},
},
runtime => {
requires => {
'Catalyst::Runtime' => '5.80008',
'MIME::Types' => '2.03',
'Moose' => 0,
'namespace::autoclean' => 0,
},
},
develop => {
requires => {
'Test::NoTabs' => 0,
'Test::Pod' => '1.14',
'Test::Pod::Coverage' => '1.04',
},
},
},
resources => {
repository => {
url => 'https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple.git',
web => 'https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple',
type => 'git',
},
bugtracker => {
web => 'https://github.com/perl-catalyst/Catalyst-Plugin-Static-Simple/issues',
},
license => [ 'http://dev.perl.org/licenses/' ],
},
no_index => {
directory => [ 't', 'xt' ]
},
);
my %MM_ARGS = ();
if (
eval { require Catalyst::Plugin::SubRequest }
&& !eval { Catalyst::Plugin::SubRequest->VERSION(0.08) }
) {
print "** WARNING **\n"
. "You appear to have a version of Catalyst::Plugin::SubRequest "
. "older than 0.08.\n"
. "You must upgrade to SubRequest 0.08 or later if you use it "
. "in any applications with Static::Simple.\n";
$MM_ARGS{PREREQ_PM}{'Catalyst::Plugin::SubRequest'} = '0.08';
}
## BOILERPLATE ###############################################################
require ExtUtils::MakeMaker;
(do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
# have to do this since old EUMM dev releases miss the eval $VERSION line
my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
my $mymeta = $eumm_version >= 6.57_02;
my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
$META{license} = [ $META{license} ]
if $META{license} && !ref $META{license};
$MM_ARGS{LICENSE} = $META{license}[0]
if $META{license} && $eumm_version >= 6.30;
$MM_ARGS{NO_MYMETA} = 1
if $mymeta_broken;
$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
unless -f 'META.yml';
$MM_ARGS{PL_FILES} ||= {};
$MM_ARGS{NORECURS} = 1
if not exists $MM_ARGS{NORECURS};
for (qw(configure build test runtime)) {
my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
my $r = $MM_ARGS{$key} = {
%{$META{prereqs}{$_}{requires} || {}},
%{delete $MM_ARGS{$key} || {}},
};
defined $r->{$_} or delete $r->{$_} for keys %$r;
}
$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
delete $MM_ARGS{MIN_PERL_VERSION}
if $eumm_version < 6.47_01;
$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
if $eumm_version < 6.63_03;
$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
if $eumm_version < 6.55_01;
delete $MM_ARGS{CONFIGURE_REQUIRES}
if $eumm_version < 6.51_03;
ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
## END BOILERPLATE ###########################################################
Catalyst-Plugin-Static-Simple-0.38/maint/Makefile.PL.include 000644 000000 000000 00000000425 15226467060 022023 0 ustar 00 000000 000000 BEGIN { -e 'Distar' or system qw(git clone https://github.com/p5sagit/Distar.git) }
use lib 'Distar/lib';
use Distar 0.001;
author 'Andy Grundman ';
manifest_include 't/lib/TestApp/root' => qr/.*/;
manifest_include 't/lib/IncTestApp/root' => qr/.*/;
1;
Catalyst-Plugin-Static-Simple-0.38/lib/Catalyst/ 000750 000000 000000 00000000000 15226471252 017641 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/lib/Catalyst/Plugin/ 000750 000000 000000 00000000000 15226471252 021077 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/lib/Catalyst/Plugin/Static/ 000750 000000 000000 00000000000 15226471252 022326 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/lib/Catalyst/Plugin/Static/Simple.pm 000755 000000 000000 00000050303 15226471072 024126 0 ustar 00 000000 000000 package Catalyst::Plugin::Static::Simple;
use Moose::Role;
use File::stat;
use File::Spec ();
use IO::File ();
use MIME::Types ();
use Catalyst::Utils;
use namespace::autoclean;
our $VERSION = '0.38';
has _static_file => ( is => 'rw' );
has _static_debug_message => ( is => 'rw', isa => 'ArrayRef[Str]' );
after setup_finalize => sub {
my $c = shift;
# New: Turn off new 'autoflush' flag in logger (see Catalyst::Log).
# This is needed to surpress output of debug log messages for
# static requests:
$c->log->autoflush(0) if $c->log->can('autoflush');
};
before prepare_action => sub {
my $c = shift;
my $path = $c->req->path;
my $config = $c->config->{'Plugin::Static::Simple'};
$path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
# is the URI in a static-defined path?
foreach my $dir ( @{ $config->{dirs} } ) {
my $dir_re = quotemeta $dir;
# strip trailing slashes, they'll be added in our regex
$dir_re =~ s{/$}{};
my $re;
if ( $dir =~ m{^qr/}xms ) {
$re = eval $dir;
if ($@) {
$c->error( "Error compiling static dir regex '$dir': $@" );
}
}
else {
$re = qr{^${dir_re}/};
}
if ( $path =~ $re ) {
if ( $c->_locate_static_file( $path, 1 ) ) {
$c->_debug_msg( 'from static directory' )
if $config->{debug};
} else {
$c->_debug_msg( "404: file not found: $path" )
if $config->{debug};
$c->res->status( 404 );
$c->res->content_type( 'text/html' );
}
}
}
# Does the path have an extension?
if ( $path =~ /\.([^\/\\]+)$/m ) {
# and does it exist?
$c->_locate_static_file( $path );
}
};
around dispatch => sub {
my $orig = shift;
my $c = shift;
return if ( $c->res->status != 200 );
if ( $c->_static_file ) {
if ( $c->config->{'Plugin::Static::Simple'}->{no_logs} && $c->log->can('abort') ) {
$c->log->abort( 1 );
}
return $c->_serve_static;
}
else {
return $c->$orig(@_);
}
};
before finalize => sub {
my $c = shift;
# display all log messages
if ( $c->config->{'Plugin::Static::Simple'}->{debug} && scalar @{$c->_debug_msg} ) {
$c->log->debug( 'Static::Simple: ' . join q{ }, @{$c->_debug_msg} );
}
};
before setup_finalize => sub {
my $c = shift;
$c->log->warn("Deprecated 'static' config key used, please use the key 'Plugin::Static::Simple' instead")
if exists $c->config->{static};
if (exists $c->config->{static}->{include_path}) {
$c->config->{'Plugin::Static::Simple'}->{include_path} = [
@{$c->config->{'Plugin::Static::Simple'}->{include_path} || []},
@{delete $c->config->{static}->{include_path} || []}
];
}
my $config
= $c->config->{'Plugin::Static::Simple'}
= $c->config->{'static'}
= Catalyst::Utils::merge_hashes(
$c->config->{'Plugin::Static::Simple'} || {},
$c->config->{static} || {}
);
$config->{dirs} ||= [];
$config->{include_path} ||= [ $c->config->{root} ];
$config->{mime_types} ||= {};
$config->{ignore_extensions} ||= [ qw/tmpl tt tt2 html xhtml/ ];
$config->{ignore_dirs} ||= [];
$config->{debug} ||= $c->debug;
$config->{no_logs} = 1 unless defined $config->{no_logs};
$config->{no_logs} = 0 if $config->{logging};
# load up a MIME::Types object, only loading types with
# at least 1 file extension
$config->{mime_types_obj} = MIME::Types->new( only_complete => 1 );
};
# Search through all included directories for the static file
# Based on Template Toolkit INCLUDE_PATH code
sub _locate_static_file {
my ( $c, $path, $in_static_dir ) = @_;
$path = File::Spec->catdir(
File::Spec->no_upwards( File::Spec->splitdir( $path ) )
);
my $config = $c->config->{'Plugin::Static::Simple'};
my @ipaths = @{ $config->{include_path} };
my $dpaths;
my $count = 64; # maximum number of directories to search
DIR_CHECK:
while ( @ipaths && --$count) {
my $dir = shift @ipaths || next DIR_CHECK;
if ( ref $dir eq 'CODE' ) {
eval { $dpaths = &$dir( $c ) };
if ($@) {
$c->log->error( 'Static::Simple: include_path error: ' . $@ );
} else {
unshift @ipaths, @$dpaths;
next DIR_CHECK;
}
} else {
$dir =~ s/(\/|\\)$//xms;
if ( -d $dir && -f $dir . '/' . $path ) {
# Don't ignore any files in static dirs defined with 'dirs'
unless ( $in_static_dir ) {
# do we need to ignore the file?
for my $ignore ( @{ $config->{ignore_dirs} } ) {
$ignore =~ s{(/|\\)$}{};
if ( $path =~ /^$ignore(\/|\\)/ ) {
$c->_debug_msg( "Ignoring directory `$ignore`" )
if $config->{debug};
next DIR_CHECK;
}
}
# do we need to ignore based on extension?
for my $ignore_ext ( @{ $config->{ignore_extensions} } ) {
if ( $path =~ /.*\.${ignore_ext}$/ixms ) {
$c->_debug_msg( "Ignoring extension `$ignore_ext`" )
if $config->{debug};
next DIR_CHECK;
}
}
}
$c->_debug_msg( 'Serving ' . $dir . '/' . $path )
if $config->{debug};
return $c->_static_file( $dir . '/' . $path );
}
}
}
return;
}
sub _serve_static {
my $c = shift;
my $config = $c->config->{'Plugin::Static::Simple'};
my $full_path = shift || $c->_static_file;
my $type = $c->_ext_to_type( $full_path );
my $stat = stat $full_path;
$c->res->headers->content_type( $type );
$c->res->headers->content_length( $stat->size );
$c->res->headers->last_modified( $stat->mtime );
# Tell Firefox & friends its OK to cache, even over SSL:
$c->res->headers->header('Cache-control' => 'public');
# Optionally, set a fixed expiry time:
if ($config->{expires}) {
$c->res->headers->expires(time() + $config->{expires});
}
my $fh = IO::File->new( $full_path, 'r' );
if ( defined $fh ) {
binmode $fh;
$c->res->body( $fh );
}
else {
Catalyst::Exception->throw(
message => "Unable to open $full_path for reading" );
}
return 1;
}
sub serve_static_file {
my ( $c, $full_path ) = @_;
my $config = $c->config->{'Plugin::Static::Simple'};
if ( -e $full_path ) {
$c->_debug_msg( "Serving static file: $full_path" )
if $config->{debug};
}
else {
$c->_debug_msg( "404: file not found: $full_path" )
if $config->{debug};
$c->res->status( 404 );
$c->res->content_type( 'text/html' );
return;
}
$c->_serve_static( $full_path );
}
# looks up the correct MIME type for the current file extension
sub _ext_to_type {
my ( $c, $full_path ) = @_;
my $config = $c->config->{'Plugin::Static::Simple'};
if ( $full_path =~ /.*\.(\S{1,})$/xms ) {
my $ext = $1;
my $type = $config->{mime_types}{$ext}
|| $config->{mime_types_obj}->mimeTypeOf( $ext );
if ( $type ) {
$c->_debug_msg( "as $type" ) if $config->{debug};
return ( ref $type ) ? $type->type : $type;
}
else {
$c->_debug_msg( "as text/plain (unknown extension $ext)" )
if $config->{debug};
return 'text/plain';
}
}
else {
$c->_debug_msg( 'as text/plain (no extension)' )
if $config->{debug};
return 'text/plain';
}
}
sub _debug_msg {
my ( $c, $msg ) = @_;
if ( !defined $c->_static_debug_message ) {
$c->_static_debug_message( [] );
}
if ( $msg ) {
push @{ $c->_static_debug_message }, $msg;
}
return $c->_static_debug_message;
}
1;
__END__
=head1 NAME
Catalyst::Plugin::Static::Simple - Make serving static pages painless.
=head1 SYNOPSIS
package MyApp;
use Catalyst qw/ Static::Simple /;
MyApp->setup;
# that's it; static content is automatically served by Catalyst
# from the application's root directory, though you can configure
# things or bypass Catalyst entirely in a production environment
#
# one caveat: the files must be served from an absolute path
# (i.e. /images/foo.png)
=head1 DESCRIPTION
The Static::Simple plugin is designed to make serving static content in
your application during development quick and easy, without requiring a
single line of code from you.
This plugin detects static files by looking at the file extension in the
URL (such as B<.css> or B<.png> or B<.js>). The plugin uses the
lightweight L module to map file extensions to
IANA-registered MIME types, and will serve your static files with the
correct MIME type directly to the browser, without being processed
through Catalyst.
Note that actions mapped to paths using periods (.) will still operate
properly.
If the plugin can not find the file, the request is dispatched to your
application instead. This means you are responsible for generating a
C<404> error if your application can not process the request:
# handled by static::simple, not dispatched to your application
/images/exists.png
# static::simple will not find the file and let your application
# handle the request. You are responsible for generating a file
# or returning a 404 error
/images/does_not_exist.png
Though Static::Simple is designed to work out-of-the-box, you can tweak
the operation by adding various configuration options. In a production
environment, you will probably want to use your webserver to deliver
static content; for an example see L, below.
=head1 DEFAULT BEHAVIOUR
By default, Static::Simple will deliver all files having extensions
(that is, bits of text following a period (C<.>)), I files
having the extensions C, C, C, C, and
C. These files, and all files without extensions, will be
processed through Catalyst. If L doesn't recognize an
extension, it will be served as C.
To restate: files having the extensions C, C, C, C,
and C I be served statically by default, they will be
processed by Catalyst. Thus if you want to use C<.html> files from
within a Catalyst app as static files, you need to change the
configuration of Static::Simple. Note also that files having any other
extension I be served statically, so if you're using any other
extension for template files, you should also change the configuration.
Logging of static files is turned off by default.
=head1 ADVANCED CONFIGURATION
Configuration is completely optional and is specified within
Cconfig-E{Plugin::Static::Simple}>. If you use any of these options,
this module will probably feel less "simple" to you!
=head2 Enabling request logging
Since Catalyst 5.50, logging of static requests is turned off by
default; static requests tend to clutter the log output and rarely
reveal anything useful. However, if you want to enable logging of static
requests, you can do so by setting
Cconfig-E{Plugin::Static::Simple}-E{logging}> to 1.
=head2 Forcing directories into static mode
Define a list of top-level directories beneath your 'root' directory
that should always be served in static mode. Regular expressions may be
specified using C.
MyApp->config(
'Plugin::Static::Simple' => {
dirs => [
'static',
qr/^(images|css)/,
],
}
);
=head2 Including additional directories
You may specify a list of directories in which to search for your static
files. The directories will be searched in order and will return the
first file found. Note that your root directory is B automatically
added to the search path when you specify an C. You should
use Cconfig-E{root}> to add it.
MyApp->config(
'Plugin::Static::Simple' => {
include_path => [
'/path/to/overlay',
\&incpath_generator,
MyApp->config->{root},
],
},
);
With the above setting, a request for the file C will search
for the following files, returning the first one found:
/path/to/overlay/images/logo.jpg
/dynamic/path/images/logo.jpg
/your/app/home/root/images/logo.jpg
The include path can contain a subroutine reference to dynamically return a
list of available directories. This method will receive the C<$c> object as a
parameter and should return a reference to a list of directories. Errors can
be reported using C. This method will be called every time a file is
requested that appears to be a static file (i.e. it has an extension).
For example:
sub incpath_generator {
my $c = shift;
if ( $c->session->{customer_dir} ) {
return [ $c->session->{customer_dir} ];
} else {
die "No customer dir defined.";
}
}
=head2 Ignoring certain types of files
There are some file types you may not wish to serve as static files.
Most important in this category are your raw template files. By
default, files with the extensions C, C, C, C, and
C will be ignored by Static::Simple in the interest of security.
If you wish to define your own extensions to ignore, use the
C option:
MyApp->config(
'Plugin::Static::Simple' => {
ignore_extensions => [ qw/html asp php/ ],
},
);
=head2 Ignoring entire directories
To prevent an entire directory from being served statically, you can use
the C option. This option contains a list of relative
directory paths to ignore. If using C, the path will be
checked against every included path.
MyApp->config(
'Plugin::Static::Simple' => {
ignore_dirs => [ qw/tmpl css/ ],
},
);
For example, if combined with the above C setting, this
C value will ignore the following directories if they exist:
/path/to/overlay/tmpl
/path/to/overlay/css
/dynamic/path/tmpl
/dynamic/path/css
/your/app/home/root/tmpl
/your/app/home/root/css
=head2 Custom MIME types
To override or add to the default MIME types set by the L
module, you may enter your own extension to MIME type mapping.
MyApp->config(
'Plugin::Static::Simple' => {
mime_types => {
jpg => 'image/jpg',
png => 'image/png',
},
},
);
=head2 Controlling caching with Expires header
The files served by Static::Simple will have a Last-Modified header set,
which allows some browsers to cache them for a while. However if you want
to explicitly set an Expires header, such as to allow proxies to cache your
static content, then you can do so by setting the "expires" config option.
The value indicates the number of seconds after access time to allow caching.
So a value of zero really means "don't cache at all", and any higher values
will keep the file around for that long.
MyApp->config(
'Plugin::Static::Simple' => {
expires => 3600, # Caching allowed for one hour.
},
);
=head2 Compatibility with other plugins
Since version 0.12, Static::Simple plays nice with other plugins. It no
longer short-circuits the C stage as it was causing too
many compatibility issues with other plugins.
=head2 Debugging information
Enable additional debugging information printed in the Catalyst log. This
is automatically enabled when running Catalyst in -Debug mode.
MyApp->config(
'Plugin::Static::Simple' => {
debug => 1,
},
);
=head1 USING WITH APACHE
While Static::Simple will work just fine serving files through Catalyst
in mod_perl, for increased performance you may wish to have Apache
handle the serving of your static files directly. To do this, simply use
a dedicated directory for your static files and configure an Apache
Location block for that directory This approach is recommended for
production installations.
SetHandler default-handler
Using this approach Apache will bypass any handling of these directories
through Catalyst. You can leave Static::Simple as part of your
application, and it will continue to function on a development server,
or using Catalyst's built-in server.
In practice, your Catalyst application is probably (i.e. should be)
structured in the recommended way (i.e., that generated by bootstrapping
the application with the C script, with a main directory
under which is a C directory for module files and a C
directory for templates and static files). Thus, unless you break up
this structure when deploying your app by moving the static files to a
different location in your filesystem, you will need to use an Alias
directive in Apache to point to the right place. You will then need to
add a Directory block to give permission for Apache to serve these
files. The final configuration will look something like this:
Alias /myapp/static /filesystem/path/to/MyApp/root/static
allow from all
SetHandler default-handler
If you are running in a VirtualHost, you can just set the DocumentRoot
location to the location of your root directory; see
L.
=head1 PUBLIC METHODS
=head2 serve_static_file $file_path
Will serve the file located in $file_path statically. This is useful when
you need to autogenerate them if they don't exist, or they are stored in a model.
package MyApp::Controller::User;
sub curr_user_thumb : PathPart("my_thumbnail.png") {
my ( $self, $c ) = @_;
my $file_path = $c->user->picture_thumbnail_path;
$c->serve_static_file($file_path);
}
=head1 INTERNAL EXTENDED METHODS
Static::Simple extends the following steps in the Catalyst process.
=head2 prepare_action
C is used to first check if the request path is a static
file. If so, we skip all other C steps to improve
performance.
=head2 dispatch
C takes the file found during C and writes it
to the output.
=head2 finalize
C serves up final header information and displays any log
messages.
=head2 setup
C initializes all default values.
=head1 DEPRECATIONS
The old style of configuration using the C<'static'> config key was deprecated
in version 0.30. A warning will be issued if this is used, and the contents of
the config at this key will be merged with the newer C<'Plugin::Static::Simple'>
key.
Be aware that if the C<'include_path'> key under C<'static'> exists at all, it
will be merged with any content of the same key under
C<'Plugin::Static::Simple'>. Be careful not to set this to a non-arrayref,
therefore.
=head1 SEE ALSO
L, L,
L
=head1 AUTHOR
Andy Grundman,
=head1 CONTRIBUTORS
Marcus Ramberg,
Jesse Sheidlower,
Guillermo Roditi,
Florian Ragwitz,
Tomas Doran,
Justin Wheeler (dnm)
Matt S Trout,
Toby Corkindale,
=head1 THANKS
The authors of Catalyst::Plugin::Static:
Sebastian Riedel
Christian Hansen
Marcus Ramberg
For the include_path code from Template Toolkit:
Andy Wardley
=head1 COPYRIGHT
Copyright (c) 2005 - 2011
the Catalyst::Plugin::Static::Simple L and L
as listed above.
=head1 LICENSE
This program is free software, you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
Catalyst-Plugin-Static-Simple-0.38/xt/03podcoverage.t 000644 000000 000000 00000000107 15226467060 020575 0 ustar 00 000000 000000 use Test::More;
use Test::Pod::Coverage 1.04;
all_pod_coverage_ok();
Catalyst-Plugin-Static-Simple-0.38/xt/02pod.t 000644 000000 000000 00000000124 15226467060 017057 0 ustar 00 000000 000000 use strict;
use warnings;
use Test::More;
use Test::Pod 1.14;
all_pod_files_ok();
Catalyst-Plugin-Static-Simple-0.38/xt/notabs.t 000644 000000 000000 00000000132 15226467060 017420 0 ustar 00 000000 000000 use strict;
use warnings;
use Test::More;
use Test::NoTabs;
all_perl_files_ok(qw/lib/);
Catalyst-Plugin-Static-Simple-0.38/t/08subreq.t 000644 000000 000000 00000001070 13412466330 017407 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 2;
use Catalyst::Test 'TestApp';
SKIP:
{
unless ( TestApp->isa('Catalyst::Plugin::SubRequest') ) {
skip "Install Catalyst::Plugin::SubRequest >= 0.15 for these tests", 2;
}
unless ( $Catalyst::Plugin::SubRequest::VERSION >= 0.15 ) {
skip "Need Catalyst::Plugin::SubRequest >= 0.15 for these tests", 2;
}
ok( my $res = request('http://localhost/subtest'), 'Request' );
is( $res->content, 'subtest2 ok', 'SubRequest ok' );
}
Catalyst-Plugin-Static-Simple-0.38/t/05dirs.t 000644 000000 000000 00000002561 13412466330 017052 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 13;
use Catalyst::Test 'TestApp';
# test defined static dirs
TestApp->config->{'Plugin::Static::Simple'}->{dirs} = [
'always-static',
qr/^images/,
'qr/^css/',
];
# a file with no extension will return text/plain
ok( my $res = request('http://localhost/always-static/test'), 'request ok' );
is( $res->content_type, 'text/plain', 'text/plain ok' );
# a file with an extension in ignore_extensions still gets served
ok( $res = request('http://localhost/always-static/test.html'), 'request ok' );
is( $res->code, 200, 'html file in dirs get served' );
# a missing file in a defined static dir will return 404 and text/html
ok( $res = request('http://localhost/always-static/404.txt'), 'request ok' );
is( $res->code, 404, '404 ok' );
is( $res->content_type, 'text/html', '404 is text/html' );
# qr regex test
ok( $res = request('http://localhost/images/catalyst.png'), 'request ok' );
like( $res->content_type, qr{\Aimage/.*png\z}, 'qr regex path ok' );
# eval regex test
ok( $res = request('http://localhost/css/static.css'), 'request ok' );
like( $res->content, qr/background/, 'eval regex path ok' );
# A static dir with no trailing slash is handled by Cat
ok( $res = request('http://localhost/always-static'), 'request ok' );
is( $res->content, 'default', 'content ok' );
Catalyst-Plugin-Static-Simple-0.38/t/01use.t 000644 000000 000000 00000000134 13412466330 016673 0 ustar 00 000000 000000 use Test::More tests => 2;
use_ok('Catalyst');
use_ok('Catalyst::Plugin::Static::Simple');
Catalyst-Plugin-Static-Simple-0.38/t/06include_path.t 000644 000000 000000 00000001430 13412466330 020543 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 6;
use Catalyst::Test 'TestApp';
# test altenate root dirs
TestApp->config->{'Plugin::Static::Simple'}->{include_path} = [
TestApp->config->{root} . '/overlay',
\&TestApp::incpath_generator,
TestApp->config->{root},
];
# test overlay dir
ok( my $res = request('http://localhost/overlay.jpg'), 'request ok' );
is( $res->content_type, 'image/jpeg', 'overlay path ok' );
# test incpath_generator
ok( $res = request('http://localhost/incpath.css'), 'request ok' );
is( $res->content_type, 'text/css', 'incpath coderef ok' );
# test passthrough to root
ok( $res = request('http://localhost/images/bad.gif'), 'request ok' );
is( $res->content_type, 'image/gif', 'root path ok' );
Catalyst-Plugin-Static-Simple-0.38/t/10ignore_dirs.t 000644 000000 000000 00000001512 13412466330 020404 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 6;
use Catalyst::Test 'TestApp';
# test ignoring directories
TestApp->config->{'Plugin::Static::Simple'}->{ignore_dirs} = [ qw/ignored o-ignored files/ ];
# test altenate root dirs
TestApp->config->{'Plugin::Static::Simple'}->{include_path} = [
TestApp->config->{root} . '/overlay',
TestApp->config->{root},
];
ok( my $res = request('http://localhost/ignored/bad.gif'), 'request ok' );
is( $res->content, 'default', 'ignored directory `ignored` ok' );
ok( $res = request('http://localhost/files/static.css'), 'request ok' );
is( $res->content, 'default', 'ignored directory `files` ok' );
ok( $res = request('http://localhost/o-ignored/bad.gif'), 'request ok' );
is( $res->content, 'default', 'ignored overlay directory ok' );
Catalyst-Plugin-Static-Simple-0.38/t/09ignore_ext.t 000644 000000 000000 00000000716 13412466330 020260 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 4;
use Catalyst::Test 'TestApp';
# test ignoring extensions
# default is tt/html/xhtml
ok( my $res = request('http://localhost/ignored/tmpl.tt'), 'request ok' );
is( $res->content, 'default', 'ignored extension tt ok' );
ok( $res = request('http://localhost/ignored/index.html'), 'request ok' );
is( $res->content, 'default', 'ignored extension html ok' );
Catalyst-Plugin-Static-Simple-0.38/t/lib/ 000750 000000 000000 00000000000 15226471252 016320 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/13no_include_path.t 000644 000000 000000 00000001006 13412466330 021234 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 4;
use Catalyst::Test 'TestApp';
# test passthrough to root
ok( my $res = request('http://localhost/images/bad.gif'), 'request ok' );
is( $res->content_type, 'image/gif', 'root path ok' );
is( scalar @{ TestApp->config->{'Plugin::Static::Simple'}->{include_path} }, 1, 'One include path used');
is( TestApp->config->{'Plugin::Static::Simple'}->{include_path}->[0], TestApp->config->{root}, "It's the root path" );
Catalyst-Plugin-Static-Simple-0.38/t/20debug.t 000644 000000 000000 00000001544 13412466330 017174 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 5;
use Catalyst::Test 'TestApp';
# test defined static dirs
TestApp->config->{'Plugin::Static::Simple'}->{dirs} = [
'always-static',
];
TestApp->config->{'Plugin::Static::Simple'}->{debug} = 1;
use Catalyst::Log;
local *Catalyst::Log::_send_to_log;
local our @MESSAGES;
{
no warnings 'redefine';
*Catalyst::Log::_send_to_log = sub {
my $self = shift;
push @MESSAGES, @_;
};
}
# a missing file in a defined static dir will return 404 and text/html
ok( my $res = request('http://localhost/always-static/404.txt'), 'request ok' );
is( $res->code, 404, '404 ok' );
is( $res->content_type, 'text/html', '404 is text/html' );
ok(defined $MESSAGES[0], 'debug message set');
like( $MESSAGES[0], qr/404/, 'debug message contains 404');
Catalyst-Plugin-Static-Simple-0.38/t/07mime_types.t 000644 000000 000000 00000001123 13412466330 020257 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 4;
use Catalyst::Test 'TestApp';
# test custom MIME types
TestApp->config->{'Plugin::Static::Simple'}->{mime_types} = {
unknown => 'holy/crap',
gif => 'patents/are-evil',
};
ok( my $res = request('http://localhost/files/err.unknown'), 'request ok' );
is( $res->content_type, 'holy/crap', 'custom MIME type ok' );
ok( $res = request('http://localhost/files/bad.gif'), 'request ok' );
is( $res->content_type, 'patents/are-evil', 'custom MIME type overlay ok' );
Catalyst-Plugin-Static-Simple-0.38/t/04static.t 000644 000000 000000 00000002463 13412466330 017400 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
# Module::Build craps out on files with spaces so it's not included in the dist
my $has_space_file = -e "$FindBin::Bin/lib/TestApp/root/files/space file.txt";
use Test::More;
plan tests => ($has_space_file) ? 12 : 9;
use Catalyst::Test 'TestApp';
# test getting a css file
ok( my $res = request('http://localhost/files/static.css'), 'request ok' );
is( $res->content_type, 'text/css', 'content-type text/css ok' );
like( $res->content, qr/background/, 'content of css ok' );
# test a file with spaces
if ( $has_space_file ) {
ok( $res = request('http://localhost/files/space file.txt'), 'request ok' );
is( $res->content_type, 'text/plain', 'content-type text/plain ok' );
like( $res->content, qr/background/, 'content of space file ok' );
}
# test a non-existent file
ok( $res = request('http://localhost/files/404.txt'), 'request ok' );
is( $res->content, 'default', 'default handler for non-existent content ok' );
# test unknown extension
ok( $res = request('http://localhost/files/err.unknown'), 'request ok' );
is( $res->content_type, 'text/plain', 'unknown extension as text/plain ok' );
ok( $res = request('http://localhost/files/empty.txt'), 'request ok' );
is( $res->content, '', 'empty files result in an empty response' );
Catalyst-Plugin-Static-Simple-0.38/t/12check_error_scope.t 000644 000000 000000 00000001227 13412466330 021564 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
no strict 'refs';
no warnings 'redefine';
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 3;
BEGIN {
use Catalyst::Plugin::Static::Simple;
Catalyst::Plugin::Static::Simple->meta->add_before_method_modifier(
'prepare_action',
sub {
my ($c) = @_;
eval { die("FOO"); };
ok( $@, '$@ has a value.' );
}
);
}
use Catalyst::Test 'TestApp';
TestApp->config->{'Plugin::Static::Simple'}->{dirs} = [qr{stuff/}];
ok( my $res = request("http://localhost/"), 'request ok' );
ok( $res->code == 200, q{Previous error doesn't crash static::simple} );
Catalyst-Plugin-Static-Simple-0.38/t/11serve_static.t 000644 000000 000000 00000001225 13412466330 020575 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 6;
use Catalyst::Test 'TestApp';
# test getting a file via serve_static_file
ok( my $res = request('http://localhost/serve_static'), 'request ok' );
is( $res->code, 200, '200 ok' );
# .pm can be both application/x-pagemaker or text/x-perl, so only check for a slash
like( $res->content_type, qr{/}, 'content-type ok' );
like( $res->content, qr/package TestApp/, 'content of serve_static ok' );
# test getting a non-existant file via serve_static_file
ok( $res = request('http://localhost/serve_static_404'), 'request ok' );
is( $res->code, 404, '404 ok' );
Catalyst-Plugin-Static-Simple-0.38/t/14deprecated.t 000644 000000 000000 00000001103 13412466330 020200 0 ustar 00 000000 000000 #!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More tests => 5;
use Catalyst::Test 'IncTestApp';
is( $TestLog::logged, "Deprecated 'static' config key used, please use the key 'Plugin::Static::Simple' instead",
"Got warning" );
# test overlay dir
ok( my $res = request('http://localhost/overlay.jpg'), 'request ok' );
is( $res->content_type, 'image/jpeg', 'overlay path ok' );
# test passthrough to root
ok( $res = request('http://localhost/images/bad.gif'), 'request ok' );
is( $res->content_type, 'image/gif', 'root path ok' );
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp.pm 000644 000000 000000 00000001035 13412466330 020236 0 ustar 00 000000 000000 package TestApp;
use strict;
use Catalyst;
use FindBin;
our $VERSION = '0.01';
TestApp->config(
name => 'TestApp',
debug => 1,
);
my @plugins = qw/Static::Simple/;
# load the SubRequest plugin if available
eval {
require Catalyst::Plugin::SubRequest;
die unless Catalyst::Plugin::SubRequest->VERSION ge '0.08';
};
push @plugins, 'SubRequest' unless ($@);
TestApp->setup( @plugins );
sub incpath_generator {
my $c = shift;
return [ $c->config->{root} . '/incpath' ];
}
1;
Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp.pm 000644 000000 000000 00000001632 13412466330 020673 0 ustar 00 000000 000000 package IncTestApp;
# FIXME: I have to do this because TestApp runs setup at compile time
# Perhaps it would be better to let the tests run setup?
use strict;
use Catalyst;
use FindBin;
use TestLog;
our $VERSION = '0.01';
IncTestApp->config(
name => 'TestApp',
debug => 1,
static => {
include_path => [
IncTestApp->config->{root},
]
},
'Plugin::Static::Simple' => {
include_path => [
IncTestApp->config->{root} . '/overlay',
]
},
);
IncTestApp->log( TestLog->new );
my @plugins = qw/Static::Simple/;
# load the SubRequest plugin if available
eval {
require Catalyst::Plugin::SubRequest;
die unless Catalyst::Plugin::SubRequest->VERSION ge '0.08';
};
push @plugins, 'SubRequest' unless ($@);
IncTestApp->setup( @plugins );
sub incpath_generator {
my $c = shift;
return [ $c->config->{root} . '/incpath' ];
}
1;
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/ 000750 000000 000000 00000000000 15226471252 017700 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/ 000750 000000 000000 00000000000 15226471252 020332 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestLog.pm 000644 000000 000000 00000000215 13412466330 020236 0 ustar 00 000000 000000 package TestLog;
use Moose;
extends 'Catalyst::Log';
our $logged;
override warn => sub {
my $self = shift;
$logged = shift;
};
1;
Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/root/ 000750 000000 000000 00000000000 15226471252 021315 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/Controller/ 000750 000000 000000 00000000000 15226471252 022455 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/Controller/Root.pm 000644 000000 000000 00000000266 13412466330 023743 0 ustar 00 000000 000000 package IncTestApp::Controller::Root;
use strict;
use warnings;
use File::Spec::Functions;
use base qw/Catalyst::Controller/;
__PACKAGE__->config(namespace => '');
1;
Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/root/images/ 000750 000000 000000 00000000000 15226471252 022562 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/root/overlay/ 000750 000000 000000 00000000000 15226471252 022776 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/root/overlay/overlay.jpg 000644 000000 000000 00000000037 13412466330 025162 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/IncTestApp/root/images/bad.gif 000644 000000 000000 00000000037 13412466330 024000 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/ 000750 000000 000000 00000000000 15226471252 020663 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/Controller/ 000750 000000 000000 00000000000 15226471252 022023 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/Controller/Root.pm 000644 000000 000000 00000001501 13412466330 023302 0 ustar 00 000000 000000 package TestApp::Controller::Root;
use strict;
use warnings;
use File::Spec::Functions;
use base qw/Catalyst::Controller/;
__PACKAGE__->config(namespace => '');
sub default : Private {
my ( $self, $c ) = @_;
$c->res->output( 'default' );
}
sub subtest : Local {
my ( $self, $c ) = @_;
$c->res->output( $c->subreq('/subtest2') );
}
sub subtest2 : Local {
my ( $self, $c ) = @_;
$c->res->output( 'subtest2 ok' );
}
sub serve_static : Local {
my ( $self, $c ) = @_;
my $file = catfile( $FindBin::Bin, 'lib', 'TestApp.pm' );
$c->serve_static_file( $file );
}
sub serve_static_404 : Local {
my ( $self, $c ) = @_;
my $file = catfile( $FindBin::Bin, 'lib', 'foo.pm' );
$c->serve_static_file( $file );
}
1;
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/css/ 000750 000000 000000 00000000000 15226471252 021453 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/images/ 000750 000000 000000 00000000000 15226471252 022130 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/ignored/ 000750 000000 000000 00000000000 15226471252 022312 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/incpath/ 000750 000000 000000 00000000000 15226471252 022311 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/files/ 000750 000000 000000 00000000000 15226471252 021765 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/ 000750 000000 000000 00000000000 15226471252 022344 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/always-static/ 000750 000000 000000 00000000000 15226471252 023450 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/always-static/test 000644 000000 000000 00000000022 13412466330 024345 0 ustar 00 000000 000000 I am a text file!
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/always-static/test.html 000644 000000 000000 00000000141 13412466330 025312 0 ustar 00 000000 000000
test
test
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/o-ignored/ 000750 000000 000000 00000000000 15226471252 024227 5 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/overlay.jpg 000644 000000 000000 00000000037 13412466330 024530 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/o-ignored/tmpl.tt 000644 000000 000000 00000000037 13412466330 025555 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/o-ignored/index.html 000644 000000 000000 00000000037 13412466330 026225 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/o-ignored/static.css 000644 000000 000000 00000000037 13412466330 026231 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/overlay/o-ignored/bad.gif 000644 000000 000000 00000000037 13412466330 025445 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/files/empty.txt 000644 000000 000000 00000000000 13412466330 023653 0 ustar 00 000000 000000 Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/files/err.unknown 000644 000000 000000 00000000037 13412466330 024177 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/files/static.css 000644 000000 000000 00000000037 13412466330 023767 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/files/space file.txt 000644 000000 000000 00000000037 13412466330 024522 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/files/bad.gif 000644 000000 000000 00000000037 13412466330 023203 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/incpath/incpath.css 000644 000000 000000 00000000037 13412466330 024452 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/ignored/tmpl.tt 000644 000000 000000 00000000037 13412466330 023640 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/ignored/index.html 000644 000000 000000 00000000037 13412466330 024310 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/ignored/static.css 000644 000000 000000 00000000037 13412466330 024314 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/ignored/bad.gif 000644 000000 000000 00000000037 13412466330 023530 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/images/bad.gif 000644 000000 000000 00000000037 13412466330 023346 0 ustar 00 000000 000000 body {
background: #fff;
}
Catalyst-Plugin-Static-Simple-0.38/t/lib/TestApp/root/images/catalyst.png 000644 000000 000000 00000004377 13412466330 024476 0 ustar 00 000000 000000 PNG
IHDR X T gAMA OX2 tEXtSoftware Adobe ImageReadyqe<