bliper

static html page generation in perl
git clone git://git.2f30.org/bliper
Log | Files | Refs | README | LICENSE

commit e3e0136e303bdeaf3b298c6f2654657ae65f401e
parent 43c7cbdad89861958bc5d41591078459a0e2a79d
Author: cipher <haris@2f30.org>
Date:   Wed, 26 Mar 2014 13:33:31 +0200

Check for articles. If no files exist, do not create blog page

Diffstat:
Mbin/bliper-blog.pl | 24++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/bin/bliper-blog.pl b/bin/bliper-blog.pl @@ -6,16 +6,24 @@ use Cwd; my $maindir = getcwd; my $blogdir = 'output/blog.html'; my $articledir = 'main-articles'; +my $count = 0; unlink "pages/blog"; -chdir($articledir) or die "Can't change dir to $articledir $!\n"; -my @files = <*>; -@files = reverse @files; -foreach my $file (@files) { - open (OUT, '>>', "../pages/blog") or die "Could not open blog file $!\n"; - print OUT "[$file]($file)<br>"; +opendir(my $dh, $articledir) or die "opendir($articledir): $!"; +while (my $de = readdir($dh)) { + next if $de =~ /^\./; + $count++; } -close OUT; -chdir($maindir) or die "Can't change dir to $maindir $!\n"; +if ($count gt 0) { + chdir($articledir) or die "Can't change dir to $articledir $!\n"; + my @files = <*>; + @files = reverse @files; + foreach my $file (@files) { + open (OUT, '>>', "../pages/blog") or die "Could not open blog file $!\n"; + print OUT "[$file]($file)<br>"; + } + close OUT; + chdir($maindir) or die "Can't change dir to $maindir $!\n"; +}