bliper

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

commit 99b886ef3434e07d6baebf77e6ef3c7a1011d8a9
parent fda177e9fe5f06794fe9da641a5a67af9105cfbc
Author: cipher <haris@2f30.org>
Date:   Wed Feb 19 15:55:00 +0200

change blog page generation and post population

Diffstat:
Makefile | 5++++-
bin/bliper-blog.pl | 21+++++++++++++++++++++
bin/bliper-generate.pl | 24++++++++++++++----------
3 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile @@ -1,4 +1,7 @@ -all: bliper.create menu.create +all: blog.create bliper.create menu.create + +blog.create: + @exec perl bin/bliper-blog.pl bliper.create: @exec perl bin/bliper-generate.pl diff --git a/bin/bliper-blog.pl b/bin/bliper-blog.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl -w + +use strict; +use Cwd; + +my $maindir = getcwd; +my $blogdir = 'output/blog.html'; +my $articledir = 'main-articles'; + +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>"; +} + +close OUT; +chdir($maindir) or die "Can't change dir to $maindir $!\n"; diff --git a/bin/bliper-generate.pl b/bin/bliper-generate.pl @@ -61,6 +61,7 @@ print "\nEntering " . getcwd . "\n\n"; my @files = <*>; @files = reverse @files; +my $i = 0; foreach my $file (@files) { # Read each file(post) from indir, cat to $outdir/$file.html print "Processing file: "; printf ("%-30s", $file); @@ -77,16 +78,19 @@ foreach my $file (@files) { # Read each file(post) from indir, cat to $outdi my @preview_array = split(/\n{2,}/, $html); # Pull title and first paragraph from article. $preview_array[0] =~ s/<h1/<h3/g; # change h1 to h3 for the index page. - open (OUT, '>>', "../$outdir/index.html") or die $!; # append links to stories in index.html - # print OUT "<a href=\"$file.html\" class=\"indexlink\">$file</a>"; - print OUT "<div class=\"preview\"> - $preview_array[0] - $preview_array[1]<br> - $preview_array[2]<br> - <a class=\"previewlink\" href=\"$file.html\"> - <em>read more...</em></a></p></div>"; - print OUT "\n"; - print OUT "<br>"; + if ($i < 2) { # append links to stories in index.html + open (OUT, '>>', "../$outdir/index.html") or die $!; + # print OUT "<a href=\"$file.html\" class=\"indexlink\">$file</a>"; + print OUT "<div class=\"preview\"> + $preview_array[0] + $preview_array[1]<br> + $preview_array[2]<br> + <a class=\"previewlink\" href=\"$file.html\"> + <em>read more...</em></a></p></div>"; + print OUT "\n"; + print OUT "<br>"; + } + $i++; } chdir($main_dir) or die "Can't change path to $main_dir $!\n";