123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/usr/bin/env bash
- set -e
- set -u
- set -o pipefail
- # -*- Mode: shell -*-
- get-date() {
- # sed -n '/#+DATE/p' ${file} | sed -n -e 's/<//p' | sed -n -e 's/>//p' | awk -F ': ' '{ printf $2 }'
- echo `sed -n -e 's/#+DATE://p' $1 \
- | sed -n -e 's/<//p' | sed -n -e 's/>//p'`
- }
- get-desc() {
- echo `sed -n -e 's/#+DESCRIPTION://p' $1`
- }
- get-keyw() {
- echo `sed -n -e 's/#+KEYWORDS://p' $1`
- }
- get-link() {
- echo './'${1:4}
- }
- get-titl() {
- echo `sed -n -e 's/#+TITLE://p' $1`
- }
- get-entry() {
- local file=$1
- #NOTE: I don't think I want the keywords right now.
- # `get-keyw $file`'\n'\
- echo -e '* '-- `get-date $file` - `get-titl $file`'\n'\
- '[[file:'`get-link $file`']['`get-desc $file`'...]]\n'
- }
- error-exit() {
- echo "Missing: "$1
- exit 1
- }
- build-home-page_main() {
- local homePage1=etc/pages/home-page-1.org
- local homePage2=etc/pages/home-page-2.org
- local headlines=headlines.org
- local outfile=src/index.org
- if [ -f "$homePage1" ]; then
- echo "$(cat $homePage1)" > $outfile
- echo '' >> $outfile
- else
- error-exit $homePage1
- fi
- if [ -f "$headlines" ]; then
- echo "$(cat $headlines)" >> $outfile
- echo '' >> $outfile
- else
- error-exit $headlines
- fi
- local array=(\
- ` grep -irn '#+Date' src/archive/ \
- --exclude-dir=the-org-edda \
- --exclude-dir=family-business \
- | awk -F ':' '{print $4":"$5"|"$1}' \
- | sort -r \
- | head -n 5 \
- | awk -F '|' '{print $2}'`)
- for file in "${array[@]}"
- do
- echo -e "`get-entry $file`" >> $outfile
- echo '' >> $outfile
- done
- if [ -f "$homePage2" ]; then
- echo "$(cat $homePage2)" >> $outfile
- else
- error-exit $homePage2
- fi
- }
- build-home-page_main $@
|