-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'special' attribute to Mojolicious::Static #1113
Conversation
I like this solution. But i think the attribute should have a more generic name, since anyone can add more "special" files (which is fine). And of course the implementation needs to be cleaner, and tests/documentation added. |
2305883
to
c08c65c
Compare
lib/Mojolicious/Static.pm
Outdated
app->home->child('resources', 'jquery.js'); | ||
|
||
would override the built-in jQuery for error pages with one in the app's | ||
C<resources> directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the correct documentation format for attributes. Please replicate the style of the surrounding documentation.
lib/Mojolicious/Static.pm
Outdated
return $self->_get_file(path($PUBLIC, split('/', $rel))->to_string); | ||
# Search special files | ||
return undef unless exists $self->special->{$rel}; | ||
return $self->_get_file($self->special->{$rel}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attribute accessor is called twice.
my $special = $self->special;
return exists $special->{$rel} ? $self->_get_file($special->{$rel}) : undef;
lib/Mojolicious/Static.pm
Outdated
) | ||
} | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt the $_->to_rel($public)->to_string
works on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed by AppVeyor test results.
…verriding, or disabling any or all bundled files. Resolves mojolicious#1094 change 'bundled' to 'special'; add document
c08c65c
to
118a0c4
Compare
…to permit examining, overriding, or disabling any or all bundled files. May resolve #1094
Summary
Enumerate bundled, static files so application can examine or modify their resolution at runtime. For example, a Mojolicious::Lite app could:
and then proceed to serve
favicon.ico
from a route.would override the built-in jQuery for error pages with one in the app's
resources
directory.Note: It might also be desirable to permit values which are Mojo::Asset objects, rather than filenames.
References
issue #1094