Permalink
Browse files

Allow for remote javascript

  • Loading branch information...
1 parent a7bae29 commit d494ea2282f57360b6cfa0e3dd12c9cf05259721 @mateu committed Apr 20, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/Mojito/Template/Role/Javascript.pm
@@ -21,12 +21,12 @@ has javascripts => (
sub _build_javascripts {
[
- 'jquery/jquery.min.js',
+ { uri => 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'},
'javascript/render_page.js',
'javascript/style.js',
'javascript/publish.js',
'syntax_highlight/prettify.js',
- 'jquery/jquery-ui.custom.min.js',
+ {uri => 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js'},
'jquery/jquery.cookie.js',
'SHJS/sh_main.min.js',
'SHJS/sh_perl.min.js',
@@ -50,8 +50,17 @@ has javascript_html => (
sub _build_javascript_html {
my $self = shift;
my $static_url = $self->config->{static_url};
- my @javascripts = map { "<script src=${static_url}$_></script>" } @{$self->javascripts};
- [@javascripts];
+ my @javascripts; # = map { "<script src=${static_url}$_></script>" } @{$self->javascripts};
+ # Local scripts comes as scalars, while remote scripts are a HashRef
+ foreach my $script (@{$self->javascripts}) {
+ if (ref($script) eq 'HASH') {
+ push @javascripts, "<script src=$script->{uri}></script>";
+ }
+ else {
+ push @javascripts, "<script src=${static_url}$script></script>";
+ }
+ }
+ return [@javascripts];
}
1

0 comments on commit d494ea2

Please sign in to comment.