dot

packages and services management
Log | Files | Refs | README

commit a68f752dd46b1063773e883f27a930bc1cf4b329
parent 36e5e0ec820f757598bd00c14486a681170349ca
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Wed, 14 Jun 2017 10:24:15 +0200

added phaste

Diffstat:
M.profile | 4++++
Mbin/doc-wiki | 64++++++++++++++++++++++++----------------------------------------
Mbin/io | 2+-
Abin/phaste | 42++++++++++++++++++++++++++++++++++++++++++
Aman-posix/build | 1+
5 files changed, 72 insertions(+), 41 deletions(-)

diff --git a/.profile b/.profile @@ -25,3 +25,7 @@ case "$(tty)" in ( /dev/tty* ) esac . "$ETC/alias" + +# FreeBSD pkg's plan9port +export PLAN9="/usr/local/plan9" +export PATH="$PATH:$PLAN9/bin" diff --git a/bin/doc-wiki b/bin/doc-wiki @@ -1,65 +1,49 @@ # search for a wikipedia article and display it in a pager -API='http://en.wikipedia.org/w/api.php?action=query&format=json' -WIKI='http://en.wikipedia.org/wiki' - -E=`printf '\033'` - -# search for a title -name=` - wget -qO- "$API&list=search&srsearch=$*" | - awk -v RS='"title": *"' 'NR > 1 { gsub(/".*/, ""); print; }' | - - # prompt the results - iomenu -p wiki -` +E=$(printf '\033') +N=' +' # download the raw wiki text -wget -qO- "$WIKI/$name?action=raw" | +wget -qO- "$1?action=raw" | # format and display the page -sed -r ' - - s/'"'''"'([^'"'"']*)'"'''"'/{\1}/g # '''text''' +awk -v RS='' ' +{ + while (sub("'\'\'\''", "{")) + sub("'\'\'\''", "}") - # wiki links - s/\[\[[^]|]*\|/[/g # [[*| - s/\{\{[^}|]*\|/[/g # {{*| - s/\[\[/[/g; s/\]\]/]/g # [[ ]] - s/\{\{/[/g; s/\}\}/]/g # {{ + sub("\[\[[^]|]*\|", "[") + sub("\{\{[^}|]*\|", "{") + sub("\[\[", "[") + sub("\]\]", "]") + sub("\{\{", "[") + sub("\}\}", "]") - # bullet lists - s/^(\*\**) */\n\1 / # * Text - # strip html entities - s/<[^>]*\/ *>//g # <tag /> - s/<!--[^>]*-->//g # <!-- comment --> - s/<[^>]*>[^<]*<\/[^>]*>//g # <tag> * </tag> - s/&[^;]*;/ /g # &escaped; + sub("<[^>]*/ *>", "") + sub("<!--[^>]*-->", "") + sub("<[^>]*>[^<]*</[^>]*>", "") + sub("&[^;]*;", " ") ' | awk -v RS='<ref[^<]*</ref>' '{ printf("%s*", $0) }' | fold -w 72 -s | sed -r ' - # paragraphs /^[^=;]/ s/^/ / - # heading - s/^== *([^=].*) *==$/\n{\1}\n/g # == Heading == - s/^==(=*) *(.*[^=]) *(=*)==$/\n{\1 \2 \3}\n/g + s/^== *([^=].*) *==$/'$N'{\1}'$N'/g + s/^==(=*) *(.*[^=]) *(=*)==$/'$N'{\1 \2 \3}'$N'/g - # subheading - s/^; *(.*)/\n {\1}\n/g # === Subheading === + s/^; *(.*)/'$N' {\1}'$N'/g - # underlined - s/\[/'$E[4m'/g # [ * ] + s/\[/'$E[4m'/g s/\]/'$E[m'/g - # bold - s/\{/'$E[1m'/g # { * + s/\{/'$E[1m'/g s/\}/'$E[m'/g ' | sed ' # double empty lines - N; s/^\n$//; P; D + N; s/^'$N'$//; P; D ' | $PAGER diff --git a/bin/io b/bin/io @@ -35,7 +35,7 @@ awk -v VAR="$VAR" -v MAIL="${MAIL%/*}" ' musicv[musicc++] = $0; } - $0 ~ "/man/.*.[1-9](.gz)?$" { + $0 ~ "/man/.*.[1-9]p?(.gz)?$" { manv[manc++] = $0; } diff --git a/bin/phaste b/bin/phaste @@ -0,0 +1,41 @@ +#!/bin/sh + +# generate an upload url for pastebin.corp.gandi.net from standard input + + +PHABRICATOR='https://phabricator.corp.gandi.net/paste/edit/form/default' + + +#1 text string to encode + +encode() +{ + text= + + while [ "$1" ] + do + case "$1" in + [A-Za-z0-9_.~-]* ) + text=$text$( + printf %s "$1" | + dd bs=1 count=1 2> /dev/null + ) + ;; + * ) + text=$text%$( + printf %s "$1" | + dd bs=1 count=1 2> /dev/null | + od -A n -t x1 | + tr -d ' ' + ) + ;; + esac + + set -- "${1#?}" + done + + printf %s "$text" +} + + +printf "$PHABRICATOR?text=%s\n" "$(encode "$(tee)")"+ \ No newline at end of file diff --git a/man-posix/build b/man-posix/build @@ -0,0 +1 @@ +make DESTDIR="$PREFIX" install