[Jifty-commit] jifty branch, global-cdn, created. 1.10518-84-g2f871d4
Jifty commits
jifty-commit at lists.jifty.org
Tue May 8 02:24:11 EDT 2012
The branch, global-cdn has been created
at 2f871d4a1038ff4bf3d6c826b8746bb27ebfde0d (commit)
- Log -----------------------------------------------------------------
commit dc3ce8e7bcbe2314096bed3e97b3fb2a2082f868
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon May 7 20:57:44 2012 -0400
Revert "Add CDN support to CompressedCSSandJS"
This reverts commit 36e13529af99385995b051b02f48161ab310b3e6. CDN
configuration should be more global.
diff --git a/lib/Jifty/Plugin/CompressedCSSandJS.pm b/lib/Jifty/Plugin/CompressedCSSandJS.pm
index ac34cd5..8000cba 100644
--- a/lib/Jifty/Plugin/CompressedCSSandJS.pm
+++ b/lib/Jifty/Plugin/CompressedCSSandJS.pm
@@ -24,7 +24,6 @@ Jifty::Plugin::CompressedCSSandJS - Compression of CSS and javascript files
js: 1
css: 1
jsmin: /path/to/jsmin
- cdn_url_prefix: https://app.ssl.a.fastly.net
skipped_js:
- complex.js
@@ -46,7 +45,7 @@ skipped_js is a list of js that you don't want to compress for some reason.
=cut
-__PACKAGE__->mk_accessors(qw(css js jsmin skipped_js cdn_url_prefix external_publish));
+__PACKAGE__->mk_accessors(qw(css js jsmin skipped_js external_publish));
=head2 init
@@ -65,7 +64,6 @@ sub init {
$self->js( $opt{js} );
$self->jsmin( $opt{jsmin} );
$self->external_publish( $opt{external_publish} );
- $self->cdn_url_prefix($opt{cdn_url_prefix} ||'');
if ($self->external_publish and not Jifty::CAS->backend("ccjs")->durable) {
$self->log->warn("External publishing does not work with non-durable CAS stores; disabling");
$self->external_publish(0);
@@ -116,7 +114,6 @@ sub _include_javascript {
$self->generate_javascript unless $self->external_publish;
Jifty->web->out(
qq[<script type="text/javascript" src="]
- . $self->cdn_url_prefix()
. Jifty::CAS->uri("ccjs","js-all")
. qq[.js"></script>] );
@@ -124,7 +121,7 @@ sub _include_javascript {
if ( $self->skipped_js ) {
for my $file ( @{ $self->skipped_js } ) {
Jifty->web->out(
- qq{<script type="text/javascript" src="'}.$self->cdn_url_prefix.qq{ '/static/js/$file" /> });
+ qq{<script type="text/javascript" src="/static/js/$file" /> });
}
}
return 0;
@@ -135,7 +132,6 @@ sub _include_css {
$self->generate_css unless $self->external_publish;
Jifty->web->out(
qq{<link rel="stylesheet" type="text/css" href="}
- . $self->cdn_url_prefix()
. Jifty::CAS->uri('ccjs', 'css-all').'.css" />');
return 0;
}
commit 411385372a61065fcf4d9136f2bd13affcd1e5c2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue May 8 02:11:37 2012 -0400
Wrap links to static resources and CAS, prepending an optional CDN host
Many CDN providers simply provide domains which mirror, cache, and
distribute resources. Configuring Jifty to use them is thus fairly
straightforward; simply provide a Jifty->web->static() function which
prepends the CDN host, and alter Jifty::CAS::Store->uri to prepend it as
well.
diff --git a/lib/Jifty/CAS/Store.pm b/lib/Jifty/CAS/Store.pm
index f27dc3f..213a17e 100644
--- a/lib/Jifty/CAS/Store.pm
+++ b/lib/Jifty/CAS/Store.pm
@@ -80,7 +80,8 @@ Returns a URL where the given C<DOMAIN> and C<NAME> can be accessed.
sub uri {
my $self = shift;
my ($domain, $name) = @_;
- return "/__jifty/cas/$domain/" . $self->key($domain, $name);
+ my $CDN = Jifty->config->framework('Web')->{'CDN'} || "";
+ return "$CDN/__jifty/cas/$domain/" . $self->key($domain, $name);
}
=head2 serve DOMAIN ARGUMENT ENV
diff --git a/lib/Jifty/Plugin/CompressedCSSandJS.pm b/lib/Jifty/Plugin/CompressedCSSandJS.pm
index 8000cba..7a12050 100644
--- a/lib/Jifty/Plugin/CompressedCSSandJS.pm
+++ b/lib/Jifty/Plugin/CompressedCSSandJS.pm
@@ -120,8 +120,9 @@ sub _include_javascript {
my $skipped_js = $self->skipped_js;
if ( $self->skipped_js ) {
for my $file ( @{ $self->skipped_js } ) {
+ my $url = Jifty->web->static("js/$file");
Jifty->web->out(
- qq{<script type="text/javascript" src="/static/js/$file" /> });
+ qq{<script type="text/javascript" src="$url" /> });
}
}
return 0;
diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index 9892af7..02af10d 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -166,6 +166,22 @@ sub url {
return $uri->canonical->as_string;
}
+=head3 static PATH
+
+Returns the URL to the static resource PATH, which is generally simply
+prepending C</static/>. Also prepends the CDN host, if one is
+configured.
+
+=cut
+
+sub static {
+ my $class = shift;
+ my $path = shift;
+
+ my $CDN = Jifty->config->framework('Web')->{CDN} || "";
+ return "$CDN/static/$path";
+}
+
=head3 serial
Returns a unique identifier, guaranteed to be unique within the
diff --git a/share/web/templates/index.html b/share/web/templates/index.html
index 6791a95..31464a5 100644
--- a/share/web/templates/index.html
+++ b/share/web/templates/index.html
@@ -1,4 +1,4 @@
<&|/_elements/wrapper, title => _('Welcome to your new Jifty application') &>
-<img src="/static/images/pony.jpg"
+<img src="<% Jifty->web->static("images/pony.jpg") %>"
alt="<%_('You said you wanted a pony. (Source %1)','http://hdl.loc.gov/loc.pnp/cph.3c13461')%>" />
</&>
commit 2f871d4a1038ff4bf3d6c826b8746bb27ebfde0d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue May 8 02:21:03 2012 -0400
Remove the IEFixes-specific CDN in favor of the newly added global CDN config
diff --git a/lib/Jifty/Plugin/IEFixes.pm b/lib/Jifty/Plugin/IEFixes.pm
index 1ba267f..c6ab3e0 100644
--- a/lib/Jifty/Plugin/IEFixes.pm
+++ b/lib/Jifty/Plugin/IEFixes.pm
@@ -20,7 +20,6 @@ Jifty::Plugin::IEFixes - Add javascript files for IE
- IE8
- ie7-recalc
- ie7-squish
- cdn: 'http://yourcdn.for.static.prefix/'
In your app, if you want to add more IE-specific js:
@@ -30,7 +29,7 @@ Jifty::Plugin::IEFixes - Add javascript files for IE
=cut
-__PACKAGE__->mk_accessors(qw(use_external_ie7js js cdn user_js));
+__PACKAGE__->mk_accessors(qw(use_external_ie7js js user_js));
use constant IE7JS_VERSION => '2.0(beta3)';
@@ -49,7 +48,6 @@ sub init {
my %opt = @_;
$self->use_external_ie7js( $opt{ use_external_ie7js } );
- $self->cdn( $opt{ cdn } || '' );
$self->user_js([]);
# default is just IE7.js
my @base_js = @{ $opt{ js } || ['IE7'] };
@@ -63,10 +61,10 @@ sub init {
}
else {
# XXX: make ccjs able to cope with this as a separate CAS object
- Jifty->web->out(qq{<script type="text/javascript" src="@{[ $self->cdn ]}/static/js/iefixes/$_.js" type="text/javascript"></script>\n})
+ Jifty->web->out(qq{<script type="text/javascript" src="@{[ Jifty->web->static(qq{js/iefixes/$_.js}) ]}" type="text/javascript"></script>\n})
for @base_js;
- Jifty->web->out(qq{<script type="text/javascript" src="@{[ $self->cdn ]}/static/js/$_" type="text/javascript"></script>\n})
+ Jifty->web->out(qq{<script type="text/javascript" src="@{[ Jifty->web->static(qq{js/$_}) ]}" type="text/javascript"></script>\n})
for @{ $self->user_js };
}
Jifty->web->out(qq{<![endif]-->\n});
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list