dot

packages and services management
Log | Files | Refs | README

commit 9cb1d8ec1e13c56b5d980ea1b67b5d199367e8a6
parent bb161d4203b379328101e2bfba624f8323d470c0
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu,  4 May 2017 22:15:09 +0200

continuing io-wiki

Diffstat:
Mbin/doc-wiki | 23++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/bin/doc-wiki b/bin/doc-wiki @@ -1,6 +1,23 @@ -BASEURL='http://en.wikipedia.org/w/api.php?action=query&list=search&format=json' +# search for a wikipedia article and display raw wiki in a pager -wget -qO- "$BASEURL&srsearch=$1" | awk -v RS='"title": *"' 'NR > 1 { +API='http://en.wikipedia.org/w/api.php?action=query&format=json' +WIKI='http://en.wikipedia.org/wiki' + +# search for a title +wget -qO- "$API&list=search&srsearch=$*" | awk -v RS='"title": *"' 'NR > 1 { gsub(/".*/, ""); print; -}' +}' | iomenu -p wiki | + +# download the page's wiki +xargs -I % wget -qO- "$WIKI/%?action=raw" | + +# format and send it into a pager +awk '{ + gsub(/\]\]/, "\033[m"); + gsub(/\[\[[^|]*\|/, "\033[3m"); + gsub(/\[\[/, "\033[3m"); + + print; + +}' | fold -w 80 -s | sed 's/ *$//' | $PAGER