bliper

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

bliper-blog.pl (718B)


      1 #!/usr/bin/perl -w
      2 
      3 use strict;
      4 use Cwd;
      5 
      6 my $maindir	= getcwd;
      7 my $blogdir	= 'output/blog.html';
      8 my $articledir	= 'main-articles';
      9 my $count	= 0;
     10 
     11 unlink "pages/blog.md";
     12 
     13 opendir(my $dh, $articledir) or die "opendir($articledir): $!";
     14 while (my $de = readdir($dh)) {
     15 	next if $de =~ /^\./;
     16 	$count++;
     17 }
     18 
     19 if ($count gt 0) {
     20 	chdir($articledir) or die "Can't change dir to $articledir $!\n";
     21 	my @files = <*>;
     22 	@files = reverse @files;
     23 	open (OUT, '>>', "../pages/blog.md") or die "Could not open blog file $!\n";
     24 	foreach my $file (@files) {
     25 		$file =~ s/\.[^\.]*$//;
     26 		print OUT "<a class=\"blogitem\" href=\"$file.html\">$file</a><br>";
     27 	}
     28 	close OUT;
     29 	chdir($maindir) or die "Can't change dir to $maindir $!\n";
     30 }