dot

packages and services management
Log | Files | Refs | README

commit c9cafecf422ff68f39c7a143c9d09744fa0c56bc
parent 5ee09ade210c5b27e5c3cc69f5214a49b66e8e84
Author: Josuah Demangeonā  ā µ <mail@josuah.net>
Date:   Fri, 17 Mar 2017 12:52:35 +0100

more modular www-scripts

Diffstat:
M.config/dwm/config.h | 1+
M.profile | 2+-
Mbin/www-git | 69+++++++++++++++++++++++++++++----------------------------------------
Dbin/www-index | 76----------------------------------------------------------------------------
Abin/www-mandoc | 33+++++++++++++++++++++++++++++++++
Minstall | 10++++------
6 files changed, 68 insertions(+), 123 deletions(-)

diff --git a/.config/dwm/config.h b/.config/dwm/config.h @@ -37,6 +37,7 @@ static const Rule rules[] = { { "ffplay", NULL, NULL, 1 << 4, 0, -1 }, { "Pavucontrol", NULL, NULL, 1 << 4, 0, -1 }, { "Sam", NULL, NULL, 1 << 1, 0, -1 }, + { "acme", NULL, NULL, 1 << 1, 0, -1 }, }; /* layout(s) */ diff --git a/.profile b/.profile @@ -12,7 +12,7 @@ export CONFIG="$(dirname "$(readlink ~/.profile)")" export PATH="$CONFIG/bin:$PATH" export ENV="$HOME/.profile" export MAIL="$HOME/mail/INBOX" -export PLAN9="$HOME/plan9" +export PLAN9="$HOME/9" export PATH="$PATH:$PLAN9/bin" # info diff --git a/bin/www-git b/bin/www-git @@ -11,23 +11,14 @@ head() <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>%s</title> -<link rel="icon" type="image/png" href="../%s/favicon.png" /> -<link rel="stylesheet" type="text/css" href="../%s/git.css" /> +<link rel="icon" type="image/png" href="%s/favicon.png" /> +<link rel="stylesheet" type="text/css" href="%s/git.css" /> </head> <body> -<pre> -<b>%s</b> - <span style="color: grey;">%s</span> -' "$2" "$1" "$1" "${PWD##*/}" "$(cat .git/description)" - - [ -f .gitmodules ] && - printf ' | <a href="file/%s/.gitmodules.html">Submodules</a>' "$1" - [ -f README ] && - printf ' | <a href="file/%s/README.html">README</a>' "$1" - [ -f LICENSE ] && - printf ' | <a href="file/%s/LICENSE.html">LICENSE</a>' "$1" - - printf '</pre>\n<hr>\n' +<b>%s</b> +<hr> +' "$2" "$1" "$1" "${PWD##*/}" } @@ -90,14 +81,14 @@ commits() for hash in $(git log --format='%H') do { - head '../..' "Files - ${PWD##*/}" + head '../..' "Commits - ${PWD##*/}" commit "$hash" foot } > "$1/commit/$hash.html" git log --format="<tr>$( printf '<td>%s</td>' \ - '%ad' '<a href="commit/%H.html">%s</a>' '%an' + '%ad' '<a href="%H.html">%s</a>' '%an' )</tr>" --date='short' "$hash" done @@ -109,8 +100,7 @@ commits() file() { - printf '<p>%s</p>\n<table>' - printf '<tr>\n<td>\n<pre id="num">\n' + printf '<table>\n<tr>\n<td>\n<pre id="num">\n' if grep -qI . "$1" 1>/dev/null then @@ -145,13 +135,12 @@ files() root="$(printf %s "$file" | sed 's|[^/]*||g; s|.|../|g').." { - head "../$root" "$file - ${PWD##*/}" + head "../../$root" "$file - ${PWD##*/}" file "$file" foot } > "$1/file/$file.html" printf '<tr>' - printf '<td>%s</td>' \ "$(stat -c %A "$file")" \ "<a href=\"file/$file.html\">$file</a>" \ @@ -160,6 +149,8 @@ files() done printf '\n</tbody>\n</table>\n' + + [ -f 'README' ] && printf '<hr/>\n' && file 'README' } @@ -167,51 +158,49 @@ files() repo() { + pwd 1>&2 + mkdir -p "$1/commit" + { - head '..' "Commits - ${1##*/}" + head ../../.. "Commits - ${1##*/}" commits "$1" foot - } > $1/commits.html + } > "$1/commit/index.html" { - head '..' "Files - ${1##*/}" + head ../.. "Files - ${1##*/}" files "$1" foot - } > $1/files.html - - ln -sf files.html "$1/index.html" + } > "$1/index.html" - printf '<li>%s <span style="color: grey;">%s</span>' "${PWD##*/}" "$( + printf '<tr>' + printf '<td><a href="git/%s">%s</a></td>' "${PWD##*/}" "${PWD##*/}" + printf '<td>%s</td>' "$( grep "${PWD##*/}" "${1%/git/*}/description" | sed 's/^[^ ]* //' )" - printf '<span class="nav">' - printf '<a href="git/%s">%s</a>' "${PWD##*/}/files.html" 'files' - printf ' - <a href="git/%s">%s</a>' "${PWD##*/}/commits.html" 'commits' - printf '</span></li>\n' + printf '</tr>\n' } -# 1: source git directory +# @: paths to repositories repos() { - printf '<ul>\n' + mkdir -p git + + printf '<table>\n' - find "$1" -maxdepth 1 -mindepth 1 -type d | sort | - while IFS='' read -r repo + for repo in "$@" do printf '%s\n' "$repo" 1>&2 mkdir -p "${repo##*/}" - ( - pwd="$PWD" - cd "$repo" && repo "$pwd/${repo##*/}" || exit 1 - ) + (pwd="$PWD" && cd "$repo" && repo "$pwd/git/${repo##*/}" || exit 1) done - printf '</ul>\n' + printf '</table>\n' } diff --git a/bin/www-index b/bin/www-index @@ -1,76 +0,0 @@ -# generate an index for my website - - -printf '<!DOCTYPE html> -<head> -<title>josuah.net</title> -<meta charset="UTF-8"> -<link rel="stylesheet" type="text/css" href="style.css"> -<link rel="icon" href="favicon.png"> -</head> - -<body> -<img src="logo.png"/>\n\n' - - -# about ------------------------------------------------------------------------ - -mandoc -T html -O fragment 'about.7' | tail -n +8 | head -n -6 -printf '\n' - - -# git -------------------------------------------------------------------------- - -printf '<h1 id="%s">%s</h1>\n\n' 'git' 'git' - -[ -d git ] && rm -rf git -(mkdir -p git && cd git && gix ~/git) - - -# blog ------------------------------------------------------------------------- - -printf '<h1 id="%s">%s</h1>\n\n' 'blog' 'blog' - -find 'blog' -mindepth 1 -maxdepth 1 -type d | sort | -while IFS='' read -r dir -do - printf '<h2>%s</h2>' "${dir##*/}" - - printf '<ul>' - find "$dir" -mindepth 1 -maxdepth 1 -type f -name "*.7" | sort | - while IFS='' read -r file - do - printf '<li>%s\n' "$(sed -n '/^.Nd/ s/^.Nd // p' "$file")" - printf '<span class="nav">' - - printf '<a href="%s">html</a> - ' "${file%.7}.html" - printf '<a href="%s">txt</a> - ' "${file%.7}.txt" - printf '<a href="%s">pdf</a> - ' "${file%.7}.pdf" - printf '<a href="%s">7</a>' "$file" - printf '</span>\n</li>\n' - done - printf '</ul>\n\n' -done - - -# links ------------------------------------------------------------------------ - -mandoc -T html -O fragment 'links.7' | tail -n +8 | head -n -6 -printf '\n' - - -#------------------------------------------------------------------------------- - -printf '\n</body>\n</html>\n' - - -# pages ------------------------------------------------------------------------ - -find . -mindepth 2 -name '*.7' -type f | sort | -while IFS='' read -r file -do - root=".$(printf %s "$file" | sed 's|^./||; s|[^/]||g; s|.|/..|g')" - mandoc -T html -O style="$root/style.css" "$file" > "${file%.7}.html" - mandoc -T pdf "$file" > "${file%.7}.pdf" - mandoc -T locale "$file" | sed 's/.//g' > "${file%.7}.txt" -done diff --git a/bin/www-mandoc b/bin/www-mandoc @@ -0,0 +1,33 @@ +# walk a 2-level tree and convert .7 to .{html,txt,pdf) documents + + +find "$1" -mindepth 1 -maxdepth 1 -type d | sort | +while IFS='' read -r dir +do + printf '<h2>%s</h2>' "${dir##*/}" + + printf '<ul>' + find "$dir" -mindepth 1 -maxdepth 1 -type f -name "*.7" | sort | + while IFS='' read -r file + do + printf '<li>%s\n' "$(sed -n '/^.Nd/ s/^.Nd // p' "$file")" + printf '<span class="nav">' + + printf '<a href="%s">html</a> - ' "${file%.7}.html" + printf '<a href="%s">txt</a> - ' "${file%.7}.txt" + printf '<a href="%s">pdf</a> - ' "${file%.7}.pdf" + printf '<a href="%s">7</a>' "$file" + printf '</span>\n</li>\n' + done + printf '</ul>\n\n' +done + + +find . -mindepth 2 -name '*.7' -type f | sort | +while IFS='' read -r file +do + root=".$(printf %s "$file" | sed 's|^./||; s|[^/]||g; s|.|/..|g')" + mandoc -T html -O style="$root/style.css" "$file" > "${file%.7}.html" + mandoc -T pdf "$file" > "${file%.7}.pdf" + mandoc -T locale "$file" | sed 's/.//g' > "${file%.7}.txt" +done diff --git a/install b/install @@ -17,12 +17,9 @@ case "$1" in ( g | git ) - mkdir -p ~/git && cd ~/git || exit - - git clone ssh://repo.or.cz/iomenu.git - - git clone http://github.com/josuah/www ~/www & + mkdir -p ~/src && cd ~/src || exit + git clone http://github.com/josuah/www & git clone http://github.com/josuah/alphabet & git clone http://github.com/josuah/artisanat & git clone http://github.com/josuah/bataille-navale & @@ -33,6 +30,7 @@ case "$1" in git clone http://github.com/josuah/fungus-vs-pathogen & git clone http://github.com/josuah/hud & git clone http://github.com/josuah/iode & + git clone http://github.com/josuah/iomenu & git clone http://github.com/josuah/madown & git clone http://github.com/josuah/miniwi & git clone http://github.com/josuah/notes & @@ -57,7 +55,7 @@ case "$1" in ( 9 | plan9 ) wget -O- http://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/plan9port/plan9port-20140306.tgz | - tar -xzf - -C "$HOME" && mv plan9port 9 && cd plan9 || exit 1 + tar -xzf - -C "$HOME" && mv plan9port 9 && cd 9 || exit 1 ./INSTALL esac