Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More fixes

  • Loading branch information...
commit 2aecf7f7e9d3d984994969fb26fcf16a9c1179ef 1 parent 87057ad
@jshirley jshirley authored
Showing with 29 additions and 6 deletions.
  1. +20 −0 lib/StyleGuide.pm
  2. +6 −2 shared/site/global.tt
  3. +3 −4 shared/site/html.tt
View
20 lib/StyleGuide.pm
@@ -43,6 +43,26 @@ __PACKAGE__->config(
# Start the application
__PACKAGE__->setup();
+sub static_uri {
+ my ( $c, $asset, $query ) = @_;
+ my $static_path = $c->stash->{page}->{static_root} ||
+ $c->view('TT')->config->{static_root} || '/static';
+ my $uri;
+ if ( $static_path =~ /^https?/ ) {
+ $static_path =~ s/\/$//;
+ $uri = URI->new( "$static_path/$asset" );
+ if ( ref $query eq 'HASH' ) {
+ $uri->query_form( $query );
+ }
+ } else {
+ if ( $query and $query eq 'HASH' ) {
+ $uri = $c->uri_for( $static_path, $asset, $query );
+ } else {
+ $uri = $c->uri_for( $static_path, $asset );
+ }
+ }
+ return $uri;
+}
=head1 NAME
View
8 shared/site/global.tt
@@ -41,8 +41,12 @@ MACRO ad_slot(zone, slot) BLOCK;
END;
MACRO run_widget(name, args) BLOCK;
- SET w = widget.load(name, args);
- INCLUDE "widgets/${w.template}" args = w.run(args);
+ SET w = widget.load(name, args);
+ IF w.template;
+ INCLUDE "widgets/${w.template}" args = w.run(args);
+ ELSE;
+ "Widget: $name not running (no template)";
+ END;
END;
MACRO select_field(info) BLOCK;
View
7 shared/site/html.tt
@@ -25,7 +25,7 @@ FOREACH script IN page.head.scripts;
NEXT UNLESS script;
script = script.match('^(https?://|/)') ?
script :
- static("scripts/$script", 1); -%]
+ c.static_uri("scripts/$script", 1); -%]
<script type="text/javascript" src="[% script %]"></script>
[%
END;
@@ -36,10 +36,9 @@ FOREACH stylesheet IN page.head.stylesheets;
NEXT UNLESS stylesheet;
stylesheet = stylesheet.match('^(https?://|/)') ?
stylesheet :
- static("css/$stylesheet", 1); -%]
+ c.static_uri("css/$stylesheet", 1); -%]
<link rel="stylesheet" href="[% stylesheet %]" type="text/css" media="screen">
[% END %]
- <link rel="stylesheet" href="[% static( 'css/screen.css', 1 ) %]" type="text/css" media="screen">
<style type="text/css" id="styleoverrides"></style>
</head>
[%
@@ -54,7 +53,7 @@ FOREACH stylesheet IN page.head.stylesheets;
NEXT UNLESS script;
script = script.match('^(https?://|/)') ?
script :
- static("scripts/$script", undef, 1); -%]
+ c.static_uri("scripts/$script", undef, 1); -%]
<script type="text/javascript" src="[% script %]"></script>
[% END %]
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.