From e7999a032bd888abf3665c501a754dbb922fe7c9 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Tue, 2 Feb 2021 03:39:56 +0300 Subject: Switch to org-mode for generating the website --- build | 138 ------------------------------------------------------------------ 1 file changed, 138 deletions(-) delete mode 100755 build (limited to 'build') diff --git a/build b/build deleted file mode 100755 index 116ea89..0000000 --- a/build +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/sh -e - -ROOT=$PWD - -txt2html() { - printf '
\n'
-
-    # Convert [0-9] to links
-    sed -E 's|(.*[a-z].*)\[([0-9].*)\]|\1[\2]|g' "$1" |
-
-    # Add span id to sections
-    sed -E 's|^\[([0-9].*)\]|[\1]|' |
-
-    # Make links clickable
-    sed -E "s|(http[s]?://[^[:space:]\)]*)|\1|g"
-
-    printf '
\n' -} - -gettitle() { - unset title - case "$(sed -n 2p "$1")" in =*=|-*-) title="$(sed -n 1p "$1")"; esac - file=${1##*/} file=${file%.*} - printf '%s\n' "${title:-$file}${2:+ | Carbs Linux}" -} - -genpages() ( - cd src || return 1 - find . ! -name .git | while read -r file; do - - # If this is a directory, create the directory on the destination and - # return. - [ -d "$file" ] && { - mkdir -p "../docs/${file#./}" - continue - } - - # We are treating markdown/plaintext files differently. - case "$file" in - *.md|*.txt) - tohtml "$file" > "../docs/${file%.*}.html" - cp "$file" "../docs/${file%.*}.txt" - ;; - - # If this is not a markdown/txt file copy as-is. - *) cp "$file" "../docs/$file" - esac - done -) - - -tohtml() { - srcfile=${1#.} srcfile=${srcfile%.*}.txt - case "${1##*.}" in - md) markdown -f footnote -f fencedcode "$1" ;; - txt) txt2html "$1" ;; - esac | - - sed '/{{ CONTENT }}/r /dev/stdin' "$ROOT/templates/template.html" | - - sed "s#{{ TITLE }}#$(gettitle "$1" html)#" | - - sed '/{{ CONTENT }}/d' | - - sed "s|{{ SRC }}|$srcfile|" -} - -blog_index() { - cat templates/blog-index > src/blog/index.md - find src/blog -type f ! -name index.md | sort -r | while read -r post ; do - postdate="${post##*/}"; postdate="${postdate%%.*}" - printf '* %s - [%s](%s)\n' \ - "$(date --date="$postdate" +%b\ %d\ %Y)" \ - "$(gettitle "$post")" \ - "${postdate}.html" - done >> src/blog/index.md -} - -site_index() { - cp index/index.md src/index.md - :> src/news.md - i=0 - find index -name '*.news' | sort -r | while read -r news; do - [ "$(( i += 1 ))" -lt 6 ] && { - printf '\n' - cat "$news" - } >> src/index.md - [ "$i" -eq 1 ] || printf '\n' >> src/news.md - cat "$news" >> src/news.md - done -} - - -genrss() { - find "$1" -type f ! -name index.md | sort -r | while read -r post ; do - postdate="${post##*/}" ; postdate="${postdate%.*}" - cat < -$(gettitle "$post") -$(date --date="$postdate" +%a,\ %d\ %b\ %Y) -Cem Keylan -https://carbslinux.org/${3:-blog/$(printf "${post##*/}" | sed 's/.md/.html/')} -$(grep -v '^Title: ' "$post" | markdown -f cdata) - -EOF - done | - - sed '/{{ CONTENT }}/r /dev/stdin' "$ROOT/templates/rss.xml" | - - sed '/{{ CONTENT }}/d' | - - sed "s|{{ SRC }}|${2:-rss}.xml|" | - - sed "s|{{ DATE }}|$(date -u "+%a %b %d %Y %H:00")|" -} - -main() { - # Recreate docs directory - rm -rf docs; mkdir -p docs - - # Generate the indexes. - site_index; blog_index - - # Generate rss feeds - genrss index news index.html > src/news.xml - genrss src/blog > src/rss.xml - - # Generate documentation - command -v emacs >/dev/null && command -v makeinfo >/dev/null && { - git submodule update --init --remote -f --recursive - HTMLDIR=$PWD/src/docs redo texidocs/htmldocs - } - - # Generate pages - genpages -} - -main "$@" -- cgit v1.2.3