#!/bin/sh
# $Id: jake,v 1.3 2004/02/06 00:31:05 ianb-guest Exp $
# elvis: jake		-- Search journal/databases in jake (jake.med.yale.edu)
# daniel.chudnov@yale.edu
. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_jake_method title
def   SURFRAW_jake_spage ""
def   SURFRAW_jake_epage ""

}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [journal-or-db-name|issn]
Description:
  Surfraw jake for journal/database info and article links
Example:
  \$ jake proc nat acad sci
  \$ jake 0362-8841 
  \$ jake -volume=141 -issue=10 -spage=1089 -epage=1105 -year=1999 acta neurochir
Local options:
 -method=                       search type
     title    |                 (default)
     issn                       search by issn
 -volume=[volume]               look for this volume
 -issue=[issue]                 look for this issue
 -spage=[page]                  start page
 -epage=[page]                  end page
 -year=[year]                   look for this year
EOF
	    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in 
	-method=*) setopt   SURFRAW_jake_method $optarg ;;
	-format=*) setopt   SURFRAW_jake_format $optarg	;;
	-volume=*) setopt   SURFRAW_jake_volume $optarg ;;
	-issue=*)  setopt   SURFRAW_jake_issue  $optarg ;;
	-spage=*)  setopt   SURFRAW_jake_spage  $optarg ;;
	-epage=*)  setopt   SURFRAW_jake_epage  $optarg ;;
	-year=*)   setopt   SURFRAW_jake_year   $optarg ;;
	*) return 1 ;;
    esac
    return 0
}


w3_config
# disable requoting, doesn't work with this elvi.
SURFRAW_quote_ifs=0
w3_parse_args "$@"
# w3_args now contains a list of arguments
if test -z "$w3_args"; then
    w3_browse_url "http://jake.med.yale.edu/"
else
    escaped_args=`w3_url_of_arg $w3_args`
    w3_browse_url "http://jake.med.yale.edu/search?sid=jake-db.org%3Ajake&${SURFRAW_jake_method}=${escaped_args}&volume=${SURFRAW_jake_volume}&issue=${SURFRAW_jake_issue}&spage=${SURFRAW_jake_spage}&epage=${SURFRAW_jake_epage}&date=${SURFRAW_jake_year}"
fi
