File: ntrs

package info (click to toggle)
surfraw 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,624 kB
  • sloc: sh: 7,977; perl: 824; makefile: 277
file content (86 lines) | stat: -rwxr-xr-x 2,408 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
#
# author: Wim Van Hoydonck
#
# elvis: ntrs		-- Search the NASA Technical Report Server
. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_ntrs_fields	Abstract
def   SURFRAW_ntrs_results	matchall
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description:
  Search ntrs
Local options:
  -fields=FIELD			Subject field to search
           all              |   Seach all fields
           abstract         |   Words in abstract (default)
           accession        |   Accession number
           center           |   NASA Center
           author           |   Author name
           docID            |   Document ID
           keywords         |   Keywords
           date             |   Publication date
           title            |   Title
  -results=RESULT		Find Results with
           all              |   All of the words
           any              |   At least one of the words

Examples:
  $w3_argv0 -fields=abstract -results=all free wake
EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
	-fields=*)	setopt	SURFRAW_ntrs_fields	$optarg ;;
	-results=*)	setopt	SURFRAW_ntrs_results	$optarg	;;
	*) return 1 ;;
    esac
    return 0
}


w3_config
w3_parse_args "$@"
# w3_args now contains a list of arguments

case "$SURFRAW_ntrs_fields" in
    all)       field=All ;;
    abstract)  field=Abstract ;;
    accession) field=AccessionNum ;;
    center)    field=ArchiveName ;;
    author)    field=AuthorList ;;
    docID)     field=DocumentID ;;
    keyword)   field=Keywords ;;
    date)      field=PublicationDate ;;
    title)     field=Title ;;
    *)         field=Abstract ;;
esac

case "$SURFRAW_ntrs_results" in
    all)       result=matchall ;;
    any)       result=matchany ;;
    *)         result=matchall ;;
esac

if null "$w3_args"; then
    w3_browse_url "https://ntrs.nasa.gov/search.jsp"
else
    # TODO: combine multiple searches, e.g.
    # first search the abstract for certain keywords,
    # then search the authors of those results
    # this gives urls that look like this:
    #https://ntrs.nasa.gov/search.jsp?N=0&Ntk=Abstract|AuthorList&Ntx=mode%20matchall|mode%20matchall&Ntt=free%20wake|wachspress
    escaped_args=`w3_url_of_arg $w3_args`
    url="https://ntrs.nasa.gov/search.jsp?N=0&Ntk=${field}&Ntx=mode%20${result}&Ntt=${escaped_args}"
    w3_browse_url "${url}"
fi