bliper

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

commit 9fab144460d71ad3eb52d91ba02dd9f24d1d0f80
parent 17bb3ccc4134e3aee66943bc9e8cea2cfe01380b
Author: cipher <haris@2f30.org>
Date:   Fri,  7 Feb 2014 21:14:56 +0200

importing primitive article preview for header and first paragraph

Diffstat:
Mbin/bliper-generate.pl | 19+++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/bin/bliper-generate.pl b/bin/bliper-generate.pl @@ -52,6 +52,9 @@ print OUT "<br>"; close OUT or die $!; chdir($main_dir) or die "Can't change path to $main_dir $!\n"; +open (OUT, '>>', "$outdir/index.html") or die $!; # create the index.html page +print OUT "<p class=\"latart\">Latest articles:</p>"; +close OUT or die $!; print "\nIndividual page generation completed. "; chdir($indir) or die "Can't change path to $indir $!\n"; print "\nEntering " . getcwd . "\n\n"; @@ -62,7 +65,14 @@ foreach my $file (@files) { # Read each file(post) from indir, cat to $outdi print "Processing file: "; printf ("%-30s", $file); print "\t==> output file:\t" . "../$outdir/$file.html\n"; - my @array = qx(cat $file); + my $array = qx(cat $file); + + my @preview_array = split(/\n{2,}/, $array); # Pull title and first paragraph from article. + $preview_array[0] =~ s/\=+//g; # Strip the markdown format from title. You ARE starting your article with a title, right? RIGHT? + $preview_array[0] =~ s/^\#+//g; # Strip possible sub-header format. + $preview_array[1] =~ s/\=+//g; + $preview_array[1] =~ s/^\#+//g; + open (OUT, '>', "../$outdir/$file.html") or die $!; print OUT @articlet; my @html = qx(Markdown.pl $file); # markdown to html @@ -71,7 +81,12 @@ foreach my $file (@files) { # Read each file(post) from indir, cat to $outdi close OUT; 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 "<a href=\"$file.html\" class=\"indexlink\">$file</a>"; + print OUT "<div class=\"preview\"> + <h3>$preview_array[0]</h3> + <p>$preview_array[1]<br> + <a class=\"previewlink\" href=\"$file.html\"> + <em>read more...</em></a></p></div>"; print OUT "\n"; print OUT "<br>"; }