bliper

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

commit 06a9b741fdeb4cd207975a77104102b1c3a4f0c0
Author: sin <sin@2f30.org>
Date:   Sun, 17 Nov 2013 16:12:12 +0000

Initial commit

Diffstat:
ALICENSE | 23+++++++++++++++++++++++
AREADME | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
ATODO | 3+++
Abin/bliper-create-post.sh | 3+++
Abin/bliper-generate.pl | 46++++++++++++++++++++++++++++++++++++++++++++++
Ainput/markdown-notes | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aoutput/images/puffytron.jpg | 0
Aoutput/style.css | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atemplate/footer | 3+++
Atemplate/main-bottom | 2++
Atemplate/main-top | 23+++++++++++++++++++++++
Atemplate/page-bottom | 6++++++
Atemplate/page-top | 27+++++++++++++++++++++++++++
13 files changed, 334 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2013 cipher, <haris@2f30.org> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README b/README @@ -0,0 +1,54 @@ +bliper (BLog engine In PERl) v0.1 +================================= + +A perl script that reads all posts from input/ as markdown and creates them as +HTML articles in output/ dir. + +It also creates a main page as index.html with all links to posts generated. + +Files included are: + +. +|-- LICENSE +|-- README +|-- TODO +|-- bin +| |-- bliper-create-post.sh +| `-- bliper-generate.pl +|-- input +| `-- markdown-notes +|-- output +| |-- images +| | `-- puffytron.jpg +| `-- style.css +`-- template + |-- footer + |-- main-bottom + |-- main-top + |-- page-bottom + `-- page-top + +bin/bliper-create-post.sh + use this instead of `touch <file>' for your posts. It just prepends `date + '+%Y-%m-%d'` to the beginning of the filename. + +bin/bliper-generate.pl + is the main script that parses every post in input/ and recreates it as + HTML in output/. It also creates the index.html page and appends all links + to posts. + +input + is the directory which serves as the place to create all posts in markdown. + +output + is the directory which all generated pages are placed. Edit the style.css + file according to your needs. + +template + main-top is the top section of the main page. + main-bottom is the bottom section of the main page. + page-top is a generic template for the top section of any post page. + page-bottom is a generic template for the bottom section of any post page. + footer is just the footer appended in all pages. + +I've included a demo file in input/markdown-notes. Just run `bliper-generate.pl' in your main directory, and `$BROWSER output/index.html' to see the demo. diff --git a/TODO b/TODO @@ -0,0 +1,3 @@ +- add "deploy" script w/ rsync to sync files to server. +- better handling for header. +- add the option to have directories/categories. diff --git a/bin/bliper-create-post.sh b/bin/bliper-create-post.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +touch `date '+%Y-%m-%d'`-$1 diff --git a/bin/bliper-generate.pl b/bin/bliper-generate.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w + +use strict; +use Cwd; + +my $main_dir = getcwd; +my $main_page = 'output/index.html'; +my $indir = 'input'; # the input directory name +my $outdir = 'output'; # the output directory name +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 input/ +my @pageb = qx(cat template/page-bottom); # bottom section for every page in input/ + +open (OUT, '>', "$outdir/index.html") or die $!; # create the index.html page +print OUT @maint; +chdir($indir) or die "Can't change path to $indir $!\n"; +print "\t\t\tblipper (BLog In PERl) v0.1\n"; +print "Entering " . getcwd . "\n"; + +my @files = <*>; +foreach my $file (@files) { # Read each file(post) from indir, cat to $outdir/$file.html + print "Processing file: " . $file . "\t==> output file:\t" . "../$outdir/$file.html" . "\n"; + my @array = qx(cat $file); + open (OUT, '>', "../$outdir/$file.html") or die $!; + print OUT @paget; + my @html = qx(Markdown.pl $file); # markdown to html + print OUT @html; # append content + print OUT @pageb; + close OUT; + + open (OUT, '>>', "../$outdir/index.html") or die $!; # append links to stories + print OUT "<a href=\"$file.html\">$file</a>"; + print OUT "\n"; + print OUT "<br>"; +} + +open (OUT, '>>', "../$outdir/index.html") or die $!; # close all tags in index.html +print OUT @mainb; +print OUT @footer; +close OUT; + +print "Leaving " . getcwd . "\n"; +chdir($main_dir) or die "Can't change path to $main_dir $!\n"; +print "Blog generation completed. Files are in output/ dir.\n"; diff --git a/input/markdown-notes b/input/markdown-notes @@ -0,0 +1,80 @@ +### Markdown semantics + + +#### This section covers some basic Markdown syntax. + +Paragraphs, headers, blockquotes + +markdown: + + A First Level Header + ==================== + + A Second Level Header + --------------------- + + Now is the time for all good men to come to + the aid of their country. This is just a + regular paragraph. + + The quick brown fox jumped over the lazy + dog's back. + + ### Header 3 + + > This is a blockquote. + > + > This is the second paragraph in the blockquote. + > + > ## This is an H2 in a blockquote + +Phrase emphasis + +markdown: + + Some of these words *are emphasized*. + Some of these words _are emphasized also_. + + Use two asterisks for **strong emphasis**. + Or, if you prefer, __use two underscores instead__. + +output: + + <p>Some of these words <em>are emphasized</em>. + Some of these words <em>are emphasized also</em>.</p> + + <p>Use two asterisks for <strong>strong emphasis</strong>. + Or, if you prefer, <strong>use two underscores instead</strong>.</p> + +Links + +markdown: + + This is an [example link](http://example.com/). + + + I get 10 times more traffic from [Google][1] than from + [Yahoo][2] or [MSN][3]. + + [1]: http://google.com/ "Google" + [2]: http://search.yahoo.com/ "Yahoo Search" + [3]: http://search.msn.com/ "MSN Search" + +Images + +markdown: + + ![alt text](/path/to/img.jpg "Title") + + +Code + +markdown: +just ident 1tab/4spaces the block you want to display as code + +#### How to run + +Demo complete, cookie time. + +![wallpaper](images/puffytron.jpg "OpenBSD") +[wallpaper](images/puffytron.jpg) diff --git a/output/images/puffytron.jpg b/output/images/puffytron.jpg Binary files differ. diff --git a/output/style.css b/output/style.css @@ -0,0 +1,64 @@ +body { + background-color: #050505; + font-family: Terminus, monospace; + font-size: 1em; +} + +.container { + color: #40ff40; + max-width: 680px; + margin: 0 auto; +} + +.upstart { + clear: both; + text-align: right; +} + +h3 { + margin-top: 30px; +} + +p { + max-width: 680px; + white-space: pre-wrap; + line-height: 1.4em; +} + +pre { + font-family: Terminus, monospace; + color: #40ff40; + border: 1px solid #424242; + padding: 5px; +} + +.logo { + border: none; +} + +img { + margin-top: 20px; + max-width: 100%; + height: auto; +} + +a { + color: #40ff40; +} + +a:hover { + color: #ff9900; +} + +hr { + max-width: 680px; + margin-top: 40px; +} + +footer { + max-width: 680px; + color: #40ff40; + text-align: center; + margin: 0 auto; + padding-bottom: 50px; +} diff --git a/template/footer b/template/footer @@ -0,0 +1,3 @@ +<footer>Made with vim and generated by Perl in Markdown.</footer> +</body> +</html> diff --git a/template/main-bottom b/template/main-bottom @@ -0,0 +1,2 @@ +</div> <!-- container end --> +<hr> diff --git a/template/main-top b/template/main-top @@ -0,0 +1,23 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <title>perl test</title> + <link href="style.css" rel="stylesheet" type="text/css" /> +</head> +<body> +<div class="container"> <!-- container begin --> +<pre class="logo"> + + _ _ + ___(_)_ __ | |__ ___ _ __ + / __| | '_ \| '_ \ / _ \ '__| +| (__| | |_) | | | | __/ | + \___|_| .__/|_| |_|\___|_| + |_| + + +Welcome to my blog... +</pre> +<hr> +<br> diff --git a/template/page-bottom b/template/page-bottom @@ -0,0 +1,6 @@ +<a href="#start"><p class="upstart">Up</p></a> +</div> <!-- container end --> +<hr> +<footer>Made with vim and generated by Perl in Markdown.</footer> +</body> +</html> diff --git a/template/page-top b/template/page-top @@ -0,0 +1,27 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <title>perl test</title> + <link href="style.css" rel="stylesheet" type="text/css" /> +</head> +<body> +<div class="container"> <!-- container begin --> +<a name="start"></a> +<pre class="logo"> + ____________ + / /\ + / / \ + / / \ + / / \ +-------------------/___________/ ----------------------| Welcome +-------------------\ \ ---------------------| @ my blog + \ \ / + \ \ / + \ \ / + \___________\/ +</pre> +<a href="index.html">Home</a> +<hr> +<br> +<br>