tRework makefile and auto-generate index.txt - monochromatic - monochromatic blog: http://blog.z3bra.org
HTML git clone git://z3bra.org/monochromatic
DIR Log
DIR Files
DIR Refs
---
DIR commit 63e255e9c8d8b7fa7447dbb04eb72c6974d58a5e
DIR parent f19390275e984e18ad0f4acffa13d92b4870fc52
HTML Author: Willy Goiffon <contact@z3bra.org>
Date: Mon, 23 Dec 2019 15:09:41 +0100
Rework makefile and auto-generate index.txt
This commit brings a lot of changes for the sake of simplicity.
Files are auto-generated were possible, rather than edited.
Output validity was moved out of the makefile too, as there is no
advantage in running it through the makefile
Diffstat:
M .gitignore | 2 +-
M Makefile | 34 +++++++++++++------------------
M config.mk | 8 +++++---
A genindex.sh | 9 +++++++++
D index.txt | 29 -----------------------------
D post.sh | 43 ------------------------------
D publi.sh | 24 ------------------------
D tomarkdown.sed | 75 -------------------------------
8 files changed, 29 insertions(+), 195 deletions(-)
---
DIR diff --git a/.gitignore b/.gitignore
t@@ -1,5 +1,5 @@
.gitignore
-last.txt
+index.txt
*.html
*.ico
img/*
DIR diff --git a/Makefile b/Makefile
t@@ -1,32 +1,26 @@
include config.mk
-.PHONY: all check clean
+.PHONY: all clean
+.SUFFIXES: .txt .html
-all: $(PAGES) $(FEEDS) $(EXTRA)
+all: $(FEEDS) $(EXTRA) $(PAGES)
$(NAME).tbz: $(PAGES) $(EXTRA) $(FEEDS)
tar -cvjf $@ $(PAGES) $(EXTRA) $(FEEDS)
+index.txt:
+ sh ./genindex.sh > $@
+
+$(FEEDS): index.txt
+ mkdir -p `dirname $@`
+ sed -f ./feed.sed < $< > $@
+
+.txt.html:
+ $(MD) $< | cat $(HEADER) - $(FOOTER) > $@
+
install: $(NAME).tbz
mkdir -p $(PREFIX)
tar -xjf $(NAME).tbz -C $(PREFIX)
-check: $(PAGES)
- @./validate.sh every damn thing about this blog
-
clean:
- rm -f $(PAGES) $(FEEDS) $(NAME).tbz
-
-.SUFFIXES: .txt .html .xml
-
-HEADER = header.tmpl
-FOOTER = footer.tmpl
-
-$(FEEDS): index.txt
- @echo "RSSGEN $@"
- @mkdir -p `dirname $(FEEDS)`
- @sed -f feed.sed < index.txt > $(FEEDS)
-
-.txt.html: $(HEADER) $(FOOTER)
- @echo "MARKDOWN `basename $@`"
- @$(MD) $< | cat $(HEADER) - $(FOOTER) > $@
+ rm -f $(PAGES) $(FEEDS) $(NAME).tbz index.txt
DIR diff --git a/config.mk b/config.mk
t@@ -2,9 +2,11 @@ MD = markdown
NAME = monochromatic
PREFIX = /var/www/htdocs/monochromatic
+HEADER = header.tmpl
+FOOTER = footer.tmpl
-PAGES = index.html \
- 2013/08/test-your-css.html \
+PAGES = index.html \
+ 2013/08/test-your-css.html \
2013/08/the-hard-way.html \
2013/09/java-without-eclipse.html \
2013/10/home-sweet-home.html \
t@@ -35,4 +37,4 @@ PAGES = index.html \
2016/09/pack-it-up.html
FEEDS = rss/feed.xml
-EXTRA = favicon.ico
+EXTRA = favicon.ico monochrome.css
DIR diff --git a/genindex.sh b/genindex.sh
t@@ -0,0 +1,9 @@
+#!/bin/sh
+
+i=0
+for post in $(find 20* -type f -name '*.txt' ! -name 'index.txt'|sort); do
+ title="$(sed -n 's/^# \[\(.*\)\].*$/\1/p' $post)"
+ href="/${post%.txt}.html"
+ printf '* 0x%04x - [%s](%s)\n' "$i" "$title" "$href"
+ i=$((i+1))
+done | tac
DIR diff --git a/index.txt b/index.txt
t@@ -1,29 +0,0 @@
-* 0x001d - [Pack it up!](/2016/09/pack-it-up.html)
-* 0x001c - [Desktop streaming](/2016/08/desktop-streaming.html)
-* 0x001b - [Hand-crafted containers](/2016/03/hand-crafted-containers.html)
-* 0x001a - [Make your own distro](/2016/01/make-your-own-distro.html)
-* 0x0019 - [Install Alpine at online.net](/2015/08/install-alpine-at-onlinenet.html)
-* 0x0018 - [cross-compiling with PCC and musl](/2015/08/cross-compiling-with-pcc-and-musl.html)
-* 0x0017 - [Vomiting colors](/2015/06/vomiting-colors.html)
-* 0x0016 - [The wrong sysadmin](/2015/04/the-wrong-sysadmin.html)
-* 0x0015 - [Under Wendy's dress](/2015/03/under-wendys-dress.html)
-* 0x0014 - [Do you gopher ?](/2015/02/do-you-gopher.html)
-* 0x0013 - [You are the WM](/2015/01/you-are-the-wm.html)
-* 0x0012 - [So tox me maybe](/2014/12/so-tox-me-maybe.html)
-* 0x0011 - [Avoid workspaces](/2014/11/avoid-workspaces.html)
-* 0x0010 - [Backup, someone ?](/2014/09/backup-someone.html)
-* 0x000f - [shred config.h](/2014/08/shred-configh.html)
-* 0x000e - [I'm back up !](/2014/08/im-back-up.html)
-* 0x000d - [Name that domain](/2014/07/name-that-domain.html)
-* 0x000c - [Planning downtime](/2014/07/planning-downtime.html)
-* 0x000b - [Grok that workflow](/2014/05/grok-that-workflow.html)
-* 0x000a - [Pop it up !](/2014/04/pop-it-up.html)
-* 0x0009 - [Meeting at the bar](/2014/04/meeting-at-the-bar.html)
-* 0x0008 - [Toolbox](/2014/03/toolbox.html)
-* 0x0007 - [Images in terminal](/2014/01/images-in-terminal.html)
-* 0x0006 - [Love me some LaTex](/2013/12/love-me-some-latex.html)
-* 0x0005 - [Plain old mails](/2013/11/plain-old-mails.html)
-* 0x0004 - [Home, sweet home](/2013/10/home-sweet-home.html)
-* 0x0003 - [Java without Eclipse](/2013/09/java-without-eclipse.html)
-* 0x0002 - [The Hard way](/2013/08/the-hard-way.html)
-* 0x0001 - [Test your CSS !](/2013/08/test-your-css.html)
DIR diff --git a/post.sh b/post.sh
t@@ -1,43 +0,0 @@
-#!/bin/sh
-
-# Ask the user for a title
-if [ $# -lt 1 ]; then
- printf "Post title: "
- read title
-else
- title="$@"
-fi
-
-# use post title to name the file
-file=`echo ${title}| tr -d ",.?!;\"'" | tr -s ' ' | tr 'A-Z ' 'a-z-' | sed "s/-*$//"`.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}"
-
-# create the file
-cat <<EOF > ${post}
-# [${title}](#)
-## — ${date}
-
-EOF
-
-if ! test -f ${post}; then
- echo "cannot create ${post}"
- exit 1
-fi
-
-echo "$post created (symlinked to last.txt)"
-
-# create a symlink to the last post, to easily access it
-ln -fs ${post} last.txt
DIR diff --git a/publi.sh b/publi.sh
t@@ -1,24 +0,0 @@
-#!/bin/sh
-
-link=$(ls -l last.txt | sed 's^.*-> /;s.txt$.html')
-
-test -z "$EDITOR" && EDITOR=vi
-
-# get last number used (in hexa) and increment it
-hexa=$(<index.txt cut -d' ' -f2 | sed 's/0x0*//;1q')
-last=$(printf '%d' "0x${hexa}")
-next=$(printf "0x%04x" `echo "1 ${last}+p"|dc`)
-
-# format our title and put it in a temp file
-title=$(sed '1s/^# /* '$next' - /;1p;d' < last.txt)
-echo "$title" | sed "s(#)(${link})" > tmp.txt
-
-# present out the final index for reviewing
-cat index.txt >> tmp.txt
-sed 10q tmp.txt
-
-printf 'Is everything okay? [N/y] '
-read choice
-
-# replace the index with the temp file
-test "$choice" = "y" && mv tmp.txt index.txt
DIR diff --git a/tomarkdown.sed b/tomarkdown.sed
t@@ -1,75 +0,0 @@
-#!/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>/[](\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