From: Errietta Kostala Date: Tue, 12 Aug 2014 10:43:30 +0000 (+0100) Subject: Per-directory config files X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fea19fa925474e506c2702330f88c84139e04ac6;p=scpubgit%2FApp-SCS.git Per-directory config files At the moment we're only handling plugin config but other stuff could be configured... Excellent for setting per-author blog templates. --- diff --git a/lib/App/SCS/Page.pm b/lib/App/SCS/Page.pm index 355f129..7a1786d 100644 --- a/lib/App/SCS/Page.pm +++ b/lib/App/SCS/Page.pm @@ -24,9 +24,32 @@ has plugin_config => (is => 'lazy'); sub _build_plugin_config { my ($self) = @_; - $self->plugins + + my $pluginref = $self->plugins ? pond_read_datum('[ '.$self->plugins.' ]') - : [] + : []; + + my @dirs = io->dir($self->path)->splitdir; + my $path = ''; + + foreach my $dir (@dirs) { + $path .= "/$dir"; + #/home/.../share/pages/blog/config.pond etc + + my $file = $self->_top_dir . "$path/config.pond"; + + next if !-f $file; + + next if io($file)->empty; + + my $content = io($file)->slurp; + + my $config = pond_read_datum($content); + push @$pluginref, @{$config->{plugins}}; + } + + + return $pluginref; } sub has_plugin_config { exists $_[0]->plugin_config->{$_[1]} } diff --git a/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm b/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm index bfcad4f..42910de 100644 --- a/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm +++ b/lib/App/SCS/Plugin/Core/PagePlugin/PageData.pm @@ -63,25 +63,6 @@ sub filter_content_zoom { $_[0]->replace(HTML::Zoom->from_html($replace)); }} - ->select('div[data-custom-blog-elements]')->${\sub { - #blog/author(/post) - - return $_[0]->replace('') if $page->path !~ qr#^/blog/([^/]+)/+#; - - my $author = $1; - my $author_templ = $static_dir . "/author-html/$author.html"; - - if (-f $author_templ) { - $_[0]->replace(sub { - HTML::Zoom->from_file($author_templ)->collect('body', { - into => \my @replace_with, - })->run; - HTML::Zoom::ArrayStream->new({ array => \@replace_with }) - }); - } else { - $_[0]->replace(''); - } - }} } 1;