From: Errietta Kostala Date: Mon, 11 Aug 2014 10:27:21 +0000 (+0100) Subject: Given /blog/mark-keating/blah load blog.css, blog/mark-keating.css etc X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b16f44d361ceedf0a4c258d9aee974789a6b4ebd;p=scpubgit%2FApp-SCS.git Given /blog/mark-keating/blah load blog.css, blog/mark-keating.css etc --- diff --git a/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm b/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm index d84bc54..42910de 100644 --- a/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm +++ b/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm @@ -30,18 +30,38 @@ sub filter_content_zoom { ->select('meta[name=created]') ->set_attribute(content => $page->created) ->select('link[data-cur-page-css]')->${\sub { - if (-f $static_dir . "/page-css/" . $page->path . ".css") { - $_[0]->set_attribute(href => "/static/page-css/" . $page->path . ".css"); - } else { - $_[0]->replace(''); + my $path = ''; + my $replace = ''; + my @parts = split /\//, $page->path; + + foreach my $part (@parts) { + next unless $part; + + $path .= "/" . $part; + + if (-f $static_dir . "/page-css/$path.css") { + $replace .= ""; + } } + + $_[0]->replace(HTML::Zoom->from_html($replace)); }} ->select('script[data-cur-page-js]')->${\sub { - if (-f $static_dir . "/page-js/" . $page->path . ".js") { - $_[0]->set_attribute(src => "/static/page-js/" . $page->path . ".js"); - } else { - $_[0]->replace(''); - } + my $path = ''; + my $replace = ''; + my @parts = split /\//, $page->path; + + foreach my $part (@parts) { + next unless $part; + + $path .= "/" . $part; + + if (-f $static_dir . "/page-js/$path.js") { + $replace .= ""; + } + } + + $_[0]->replace(HTML::Zoom->from_html($replace)); }} }