tMoved tools to the main directory, and added a sed script - monochromatic - monochromatic blog: http://blog.z3bra.org
 (HTM) git clone git://z3bra.org/monochromatic
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 10c68e2381a256731b104332d1525302028b8ece
 (DIR) parent 07e6ce25eba10c2beafd9c25b996292779f22213
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Tue,  1 Apr 2014 11:33:54 +0200
       
       Moved tools to the main directory, and added a sed script
       
       Diffstat:
         R tools/check.sh -> check.sh          |       0 
         A feeds.sh                            |      22 ++++++++++++++++++++++
         A post.sh                             |      28 ++++++++++++++++++++++++++++
         A tomarkdown.sed                      |      75 +++++++++++++++++++++++++++++++
         D tools/body.template                 |      15 ---------------
         D tools/feeds.sh                      |      37 -------------------------------
         D tools/foot.template                 |      12 ------------
         D tools/head.template                 |      13 -------------
         D tools/post.sh                       |      37 -------------------------------
         D tools/publi.sh                      |      10 ----------
         D tools/update.sh                     |      11 -----------
       
       11 files changed, 125 insertions(+), 135 deletions(-)
       ---
 (DIR) diff --git a/tools/check.sh b/check.sh
 (DIR) diff --git a/feeds.sh b/feeds.sh
       t@@ -0,0 +1,22 @@
       +#!/bin/sh
       +
       +test -z "$1" && echo "usage: `basename $0` <input file>" && exit 1
       +
       +cat << EOF
       +<?xml version='1.0'?>
       +<rss version='2.0'>
       +<channel>
       +<title>Monochromatic</title>
       +<description>z3bra, the stripes appart</description>
       +<link>http://blog.z3bra.org</link>
       +EOF
       +
       +sed -e 's/^## .*$/<description>/' \
       +    -e 's/^$/<\/description>\n<\/item>/' \
       +    -e 's/^# \[\(.*\)\](\(.*\))/<item>\n<title>\1<\/title>\n<link>\2<\/link>/' $1
       +
       +cat << EOF
       +</item>
       +</channel>
       +</rss>
       +EOF
 (DIR) diff --git a/post.sh b/post.sh
       t@@ -0,0 +1,28 @@
       +#!/bin/bash
       +
       +# Ask the user for a title
       +read -p "Post title: " title
       +
       +# use post title to name the file
       +file=`echo ${title}| sed "s/\s\+/-/g;s/./\l&/g;s/[,.!;\"']//g"`.txt
       +
       +test -z "$file" && exit 1
       +
       +#date format for the post
       +date=`date +"%d %B, %Y"`
       +
       +# The format of the path to the post, here: /yyyy/mm/
       +folder=`date +%Y/%m`
       +
       +# create the path if it does not exists
       +test -d ${folder} || mkdir -p ${folder}
       +
       +# build the whole path
       +post="${folder}/${file}"
       +
       +test -f ${post} || echo "cannot create ${post}" && exit 1
       +
       +echo "$post created"
       +
       +# create a symlink to the last post, to easily access it
       +ln -fs ${post} last.txt
 (DIR) diff --git a/tomarkdown.sed b/tomarkdown.sed
       t@@ -0,0 +1,75 @@
       +#!/bin/sed -f
       +
       +# remove header
       +1,/<div id='wrapper'>/d
       +
       +# no more indentation
       +s/^\s*//
       +
       +# reformat titles
       +/<h[1-6][^>]*>/{
       +    $!N
       +    s/<h1[^>]*>\s*\(.*\)\(<\/h1>\)\?/# \1/
       +    s/<h2[^>]*>\s*\(.*\)\(<\/h2>\)\?/## \1/
       +    s/<h3[^>]*>\s*\(.*\)\(<\/h3>\)\?/### \1/
       +    s/<h4[^>]*>\s*\(.*\)\(<\/h4>\)\?/#### \1/
       +    s/<h5[^>]*>\s*\(.*\)\(<\/h5>\)\?/##### \1/
       +    s/<h6[^>]*>\s*\(.*\)\(<\/h6>\)\?/###### \1/
       +}
       +
       +# remove closing title tags
       +/^\s*<\/h[1-6]>\s*$/d
       +s/<\/h[1-6]>//
       +
       +# replace all links/strong/emphasis
       +s/<a href=["']\(.*\)["']>\(.*\)<\/a>/[\2](\1)/
       +s/<\/\?strong>/**/g
       +s/<\/\?em>/_/g
       +
       +# lists
       +/<ul[^>]*>/,/<\/ul>/{
       +    /^\s*<\/\?ul>$/d
       +    s/<li>\(.*\)<\/li>/* \1/
       +}
       +
       +# images
       +/<a class='a_img'/{
       +    $!N
       +    /<img/{
       +        $!N
       +        s/<a class='[a-z_]*' href='\(.*\)'> *\n*\
       +             *<img class='[a-z_]*' src='\(.*\)' alt='\(.*\)'\/> *\n *<\/a>/[![\3](\2)](\1)/
       +    }
       +}
       +
       +# pre formatted text
       +/<pre>/,/<\/pre>/{
       +    s/<\/\?code>//g
       +    s/<\/\?pre>//g
       +    s/^/    /
       +}
       +
       +/<code>/{
       +    $!N
       +    s/<\/\?code>/`/g
       +}
       +
       +# new lines
       +s/<br[\/ ]*>/  /
       +
       +# paragraphs
       +/<p[^>]*>/,/<\/p>/s/<\/\?p>//g
       +
       +# quotes
       +/<blockquote[^>]*>/,/<\/blockquote>/s/^\s*/> /
       +s/<\/\?blockquote>//g
       +/^> $/d
       +
       +# remove simple tag, and span tags
       +#s/<\/\?[A-Za-z0-9]*>//g
       +s/<\/\?span[^>]*>//g
       +s/<\/\?section[^>]*>//g
       +s/<\/\?article[^>]*>//g
       +
       +# remove footer
       +/<\/div>/,$d
 (DIR) diff --git a/tools/body.template b/tools/body.template
       t@@ -1,15 +0,0 @@
       -    <div id='wrapper'>
       -      <section>
       -        <h1>
       -          <a href='#'>BLOG_TITLE</a>
       -        </h1>
       -        <h2>
       -          &mdash; BLOG_DATE
       -        </h2>
       -        <article>
       -          <p>
       -            
       -          </p>
       -        </article>
       -      </section>
       -    </div>
 (DIR) diff --git a/tools/feeds.sh b/tools/feeds.sh
       t@@ -1,37 +0,0 @@
       -#!/bin/bash
       -
       -RSS=rss/feed.xml
       -
       -echo -ne "\rGenerating RSS file ... "
       -
       -cat << EOF > $RSS
       -<?xml version='1.0'?>
       -<rss version='2.0'>
       -<channel>
       -<title>Monochromatic</title>
       -<description>z3bra, the stripes appart</description>
       -<link>http://blog.z3bra.org</link>
       -<item>
       -EOF
       -
       -sed -n '/section/,/section/p' index.html >> $RSS
       -
       -# dat regex... Delete lines with <section>, </section>, <p>, </p>, <br />, <h2>
       -# to </h2> or <!--
       -sed -i '/<\/*section>/d;/<\/\?[pb]\+[/r ]*>/d;/<h2>/,/<\/h2>/d;/<!--/d' $RSS
       -
       -# change <article> in <description>, <h1> in <title>, ^$ in <item>
       -sed -i 's/^\s*//' $RSS
       -sed -i '/^$/{N;s/\n//}' $RSS
       -sed -i 's/<\(\/\)\?article>/<\1description>/' $RSS
       -sed -i 's/<\(\/\)\?h1>/<\1title>/' $RSS
       -sed -i 's/^$/<\/item>\n<item>/' $RSS
       -sed -i 's/<a\ .*>\(.*\)<\/a>/\1/' $RSS
       -
       -cat << EOF >> $RSS
       -</item>
       -</channel>
       -</rss>
       -EOF
       -
       -echo -e "[\033[1;32m OK \033[0m]"
 (DIR) diff --git a/tools/foot.template b/tools/foot.template
       t@@ -1,12 +0,0 @@
       -    <!-- footer {{{ -->
       -    <footer>
       -      <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->//
       -      <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->//
       -      <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->//
       -      <a href='http://z3bra.org'>root</a> <!-- &#9774; -->//
       -      <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; -->
       -    </footer>
       -    <!-- }}} -->
       -  </body>
       -</html>
       -<!-- vim: set sw=2 et ai fdm=marker ft=html: -->
 (DIR) diff --git a/tools/head.template b/tools/head.template
       t@@ -1,13 +0,0 @@
       -<!DOCTYPE html>
       -<html>
       -  <head>
       -    <meta charset='utf-8'/>
       -    <link rel='stylesheet' href='/css/monochrome.css'/>
       -    <link rel='stylesheet' href='/css/code.css'/>
       -    <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/>
       -    <title>z3bra.org - monochromatic blog</title>
       -  </head>
       -  <body>
       -    <header>
       -        <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2>
       -    </header>
 (DIR) diff --git a/tools/post.sh b/tools/post.sh
       t@@ -1,37 +0,0 @@
       -#!/bin/bash
       -
       -
       -
       -# Ask the user for a title
       -read -p "Post title: " title
       -
       -
       -# use post title to name the file
       -file=`echo ${title}| sed "s/\s\+/-/g;s/./\l&/g;s/[,.!;\"']//g"`.html
       -
       -test -z "$file" && exit 1
       -
       -#date format for the post
       -date=`date +"%d %B, %Y"`
       -
       -# The format of the path to the post, here: /yyyy/mm/
       -folder=`date +%Y/%m`
       -
       -# create the path if it does not exists
       -test -d ${folder} || mkdir -p ${folder}
       -
       -# build the whole path
       -post="${folder}/${file}"
       -
       -# use the templates to create the post skeleton
       -cat tools/{head,body,foot}.template >> ${post}
       -
       -# put the title and date in the post
       -sed -i "s/BLOG_TITLE/${title}/;s/BLOG_DATE/${date}/" ${post}
       -
       -test -f ${post} || echo "cannot create ${post}" && exit 1
       -
       -echo "$post created"
       -
       -# create a symlink to the last post, to easily access it
       -ln -fs ${post} last_post.html
 (DIR) diff --git a/tools/publi.sh b/tools/publi.sh
       t@@ -1,10 +0,0 @@
       -#!/bin/sh
       -
       -# Re-generate the RSS feed
       -tools/feeds.sh
       -
       -# Check HTML / CSS / RSS
       -tools/check.sh
       -
       -# Check what have changed
       -git status
 (DIR) diff --git a/tools/update.sh b/tools/update.sh
       t@@ -1,11 +0,0 @@
       -#!/bin/bash
       -
       -for file in $(find . -name '*.html'); do
       -    if [[ -n "$(cat $file|tr -d '\n' |grep -E '</header>.*<footer>')" ]]; then
       -        cat tools/head.template > buffer.html
       -        sed '1,/<\/header>/d;/<!-- footer/,$d' $file >> buffer.html
       -        cat tools/foot.template >> buffer.html
       -
       -        mv buffer.html $file
       -    fi
       -done