bliper

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

commit 03a1dffe7a2d8f7378de0ebffb755b5b2675410e
parent 2960e3a4de067ea993b5d03295431f35002cf7d2
Author: cipher <haris@2f30.org>
Date:   Fri, 25 Apr 2014 14:52:51 +0300

OCD dictates all comments _must_ begin with a capital letter.

Diffstat:
Mbin/bliper-generate.pl | 52++++++++++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/bin/bliper-generate.pl b/bin/bliper-generate.pl @@ -6,18 +6,18 @@ use feature "switch"; my $main_dir = getcwd; my $main_page = 'output/index.html'; -my $indir = 'main-articles'; # the input directory name -my $outdir = 'output'; # the output directory name -my $pagedir = 'pages'; # individual pages directory -my $pages_b = 'pages-b'; # pages that do not show at menu -my @maint = qx(cat template/main-top); # top section for main page -my @mainb = qx(cat template/main-bottom); # bottom section for main page -my @footer = qx(cat template/footer); # footer for every page incl main -my @paget = qx(cat template/page-top); # top section for every page in pages/ -my @pageb = qx(cat template/page-bottom); # bottom section for every page in pages/ -my @articlet = qx(cat template/article-top); # top section for every article in main-articles/ -my @articleb = qx(cat template/article-bottom); # bottom section for every article in main-articles/ -my $previewnum = 3; # article number preview for frontpage +my $indir = 'main-articles'; # The input directory name +my $outdir = 'output'; # The output directory name +my $pagedir = 'pages'; # Individual pages directory +my $pages_b = 'pages-b'; # Pages that do not show at menu +my @maint = qx(cat template/main-top); # Top section for main page +my @mainb = qx(cat template/main-bottom); # Bottom section for main page +my @footer = qx(cat template/footer); # Footer for every page incl main +my @paget = qx(cat template/page-top); # Top section for every page in pages/ +my @pageb = qx(cat template/page-bottom); # Bottom section for every page in pages/ +my @articlet = qx(cat template/article-top); # Top section for every article in main-articles/ +my @articleb = qx(cat template/article-bottom); # Bottom section for every article in main-articles/ +my $previewnum = 3; # Article number preview for frontpage my $cssfile = 'output/style.css'; my @lightcss = qx(cat output/style.css.light); my @darkcss = qx(cat output/style.css.dark); @@ -53,19 +53,19 @@ sub cssinit() { } -unlink glob "output/*.html"; # remove old pages -unlink "output/tmp"; # file which stores menu -open (OUT, '>', "$outdir/index.html") or die $!; # create the index.html page +unlink glob "output/*.html"; # Remove old pages +unlink "output/tmp"; # File which stores menu +open (OUT, '>', "$outdir/index.html") or die $!; # Create the index.html page print OUT @maint; chdir($pagedir) or die "Can't change path to $pagedir $!\n"; print "\n\t\t\tblipper (BLog In PERl) v0.1\n\n"; print "Entering " . getcwd . "\n\n"; -open (OUT, '>>', "../$outdir/tmp") or die $!; # begin creating menu for individual pages in a file -print OUT "<ul class=\"menu\">"; # begin list for menu items +open (OUT, '>>', "../$outdir/tmp") or die $!; # Begin creating menu for individual pages in a file +print OUT "<ul class=\"menu\">"; # Begin list for menu items print OUT "<li><a href=\"index.html\">home</a></li>"; -my @pages = <*>; # create individual pages +my @pages = <*>; # Create individual pages foreach my $page (@pages) { print "Generating page: "; printf("%-30s", $page); @@ -78,7 +78,7 @@ foreach my $page (@pages) { print OUT @pageb; close OUT; - open (OUT, '>>', "../$outdir/tmp") or die $!; # append page links to tmp file + open (OUT, '>>', "../$outdir/tmp") or die $!; # Append page links to tmp file print OUT "<li><a href=\"$page.html\">$page</a></li>"; } @@ -88,7 +88,7 @@ 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 +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. "; @@ -107,14 +107,14 @@ foreach my $file (@files) { # Read each file(post) from indir, cat to $outdi open (OUT, '>', "../$outdir/$file.html") or die $!; print OUT @articlet; my $html = qx(Markdown.pl $file); - print OUT $html; # append content + print OUT $html; # Append content print OUT @articleb; close OUT; 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. + $preview_array[0] =~ s/<h1/<h3/g; # Change h1 to h3 for the index page. - if ($i < $previewnum) { # append links to stories in index.html + if ($i < $previewnum) { # Append links to stories in index.html open (OUT, '>>', "../$outdir/index.html") or die $!; print OUT "<div class=\"preview\"> $preview_array[0] @@ -141,13 +141,13 @@ foreach my $file (@ind_pages) { # Read each page that we do not want to add my @array = qx(cat $file); open (OUT, '>', "../$outdir/$file.html") or die $!; print OUT @articlet; - my $html = qx(Markdown.pl $file); # markdown to html - print OUT $html; # append content + my $html = qx(Markdown.pl $file); # Markdown to html + print OUT $html; # Append content print OUT @articleb; close OUT; } -open (OUT, '>>', "../$outdir/index.html") or die $!; # close all tags in index.html +open (OUT, '>>', "../$outdir/index.html") or die $!; # Close all tags in index.html print OUT @mainb; print OUT @footer; close OUT;