[Catalyst-dev] more intelligence inside $c->uri_for()
Wolfgang Kinkeldei
wolfgang at kinkeldei.de
Thu Apr 30 05:54:51 GMT 2009
Hi everyone,
currently I am building a small JS/CSS-combining and minifying
controller. To build my URI I am doing business as usual:
$c->uri_for(MyApp->Controller('Js')->action_for('default'), qw
(list of js-files to combine));
yielding (after some hacks) a URI like:
http://localhost/js/list/of/js-files/to/combine.js?m=12345667
which works fine. However, I would like to automatically get added a
Query-Parameter after the URI that reflects the timestamp of the most-
recent file in the URI to allow the browser to do caching properly.
As far as I understand there is currently no way to let the
Controller construct the URI.
As a bad hack, I did something like:
# in my App:
around 'uri_for' => sub {
my $orig = shift;
my $c = shift;
my $path = shift;
my @args = @_;
if (blessed($path) && $path->class && $path->class->can
('uri_for')) {
# simply let the component do the job
return $c->component($path->class)->uri_for($c, $path, @args);
}
return $c->$orig($path, @args);
};
# in my Controller:
sub uri_for :Private {
# logic to create the URI I want
}
Of course it is great that Catalyst allows something like that. Are
there any plans to offer something alike out of the box?
Regards,
Wolfgang Kinkeldei
--
' /\_/\ ' .print[split??,"".(($/=q|Cms)+-03467:;<=|)=~tr!C-z -B! -z!)x
'( o.o )' .$/]->[hex]foreach split qr<>,qq+1ecd039ad65b025b8063475b+||
' > ^ < ' .q<!-- Wolfgang Kinkeldei - mailto:wolfgang at kinkeldei.de -->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst-dev/attachments/20090430/20b4308c/smime.bin
More information about the Catalyst-dev
mailing list