Add doi: handler. - plumber - Plumber – a modern approach to plumbing
       
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 66af61d60a30519120199b0c4f01ab33127725b6
 (DIR) parent dfad908d4e64d15222bed8cbc596e07e6f1c929e
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Fri, 28 Apr 2017 20:40:44 +0200
       
       Add doi: handler.
       
       Diffstat:
         bin/plumber                         |       1 +
         openers/doiopener                   |      20 ++++++++++++++++++++
       
       2 files changed, 21 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/bin/plumber b/bin/plumber
       @@ -40,6 +40,7 @@ plumbrules = [
                ["^dance:.*", "danceopener '%s'"],
                ["^dict://.*", "dictopener '%s'"],
                ["^dhl:.*", "dhlopener '%s'"],
       +        ["^doi:.*", "doiopener '%s'"],
                ["^finger://.*", "fingeropener '%s'"],
                ["^ftp://.*", "ftpopener '%s'"],
                ["^ftps://.*", "ftpopener '%s'"],
 (DIR) diff --git a/openers/doiopener b/openers/doiopener
       @@ -0,0 +1,20 @@
       +#!/bin/sh
       +
       +set -x
       +
       +if [ $# -lt 1 ];
       +tthen
       +        printf "usage: [-o] %s URI\n" "$(basename "$0")" >&2
       +        exit 1
       +fi
       +
       +uri="$1"
       +doi="$(printf "%s\n" "${uri}" | cut -d':' -f 2-)"
       +pdfuri="$(oadoi "${doi}")"
       +if [ $? -gt 0 ];
       +tthen
       +        plumb "http://doi.org/${doi}"
       +else
       +        plumb "${pdfuri}"
       +fi
       +