From cc3281fe2f852e18406eddafa8ac59809d898394 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Tue, 19 Jul 2016 14:26:07 +0200 Subject: [PATCH] Adapt stats task to theme system --- lib/Lutim/Command/cron/stats.pm | 10 ++++++++-- lib/Lutim/Command/theme.pm | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Lutim/Command/cron/stats.pm b/lib/Lutim/Command/cron/stats.pm index 9e770db..39bd50a 100644 --- a/lib/Lutim/Command/cron/stats.pm +++ b/lib/Lutim/Command/cron/stats.pm @@ -15,12 +15,18 @@ sub run { my $config = $c->app->plugin('Config', { file => File::Spec->catfile($Bin, '..' ,'lutim.conf'), + theme => 'default', default => { stats_day_num => 365 } }); - my $text = slurp('templates/data.html.ep.template'); + my $template = 'themes/'.$config->{theme}.'/templates/data.html.ep.template'; + unless (-e $template) { + $config->{theme} = 'default'; + $template = 'themes/'.$config->{theme}.'/templates/data.html.ep.template'; + } + my $text = slurp($template); my $dom = Mojo::DOM->new($text); my $thead_tr = $dom->at('table thead tr'); my $tbody_tr = $dom->at('table tbody tr'); @@ -51,7 +57,7 @@ sub run { } } } - spurt $dom, 'templates/data.html.ep'; + spurt $dom, 'themes/'.$config->{theme}.'/templates/data.html.ep'; } =encoding utf8 diff --git a/lib/Lutim/Command/theme.pm b/lib/Lutim/Command/theme.pm index ec48ffa..1623f7a 100644 --- a/lib/Lutim/Command/theme.pm +++ b/lib/Lutim/Command/theme.pm @@ -86,7 +86,7 @@ EOF print $f $makefile; close $f; open $f, '>', File::Spec->catfile($home, '.gitignore') or die "Unable to open $home/.gitignore: $!"; - print $f 'public/packed/'; + print $f "public/packed/\ntemplates/data.html.ep"; close $f; } else { say "$name theme already exists. Aborting.";