bliper

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

commit 2960e3a4de067ea993b5d03295431f35002cf7d2
parent 91a3b3436df4af2eee5db5ad3ea846f6788b5133
Author: cipher <haris@2f30.org>
Date:   Fri, 25 Apr 2014 14:49:02 +0300

Scan for .css file. If not found, user has to select between dark and light theme

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

diff --git a/bin/bliper-generate.pl b/bin/bliper-generate.pl @@ -2,6 +2,7 @@ use strict; use Cwd; +use feature "switch"; my $main_dir = getcwd; my $main_page = 'output/index.html'; @@ -17,6 +18,40 @@ my @pageb = qx(cat template/page-bottom); # bottom section for every page in p 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); + +sub cssinit() { + if (-f $cssfile) { + print "\n.css file found.\n\n"; + } else { + print "What stylesheet to use: + \t1- Light + \t2- Dark\n"; + print "Choose .css (1|2): "; + + chomp (my $css = <STDIN>); + given ($css) { + when (1) { + open (OUT, '>', 'output/style.css'); + print OUT @lightcss; + close OUT; + print "Light css applied\n"; + } + when (2) { + open (OUT, '>', 'output/style.css'); + print OUT @darkcss; + close OUT; + print "Dark css applied\n"; + } + default { + print "Please select a valid option.\n"; + } + } + } +} + unlink glob "output/*.html"; # remove old pages unlink "output/tmp"; # file which stores menu @@ -120,4 +155,5 @@ close OUT; print "\nPages in pages_b/ generation completed. "; print "\nLeaving " . getcwd . "\n"; chdir($main_dir) or die "Can't change path to $main_dir $!\n"; +cssinit(); print "Site generation completed. Files are in output/ dir.\n";