~ubuntu-branches/ubuntu/trusty/surfraw/trusty-proposed

« back to all changes in this revision

Viewing changes to elvi/rfc

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Smith
  • Date: 2005-04-20 17:00:59 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050420170059-z7j6h1rsqfgfwhmg
Tags: 2.1.0-1
* Ian Beckwith <ianb@nessie.mcc.ac.uk>:
  + New elvi: dmoz, w3html, w3link, w3css, w3rdf.
  + New elvi: rae (by Ruben Pollan <meskio@terra.es>).
  + surfraw.IN:w3_url_escape: escaped `(' and `)'.
  + Fixed elvi (Thanks to Justin B. Rye):
      - sunsolve  (Closes: #289502).
      - altavista (Closes: #289503).
  + deblists: Updated list of debian mailing lists.
  + currency: Now a proper elvis.
  + Added appendix 2 to HACKING on preparing a release.
* Moritz Muehlenhoff <jmm@inutil.org>:
  + Switch rhymes search from Lycos to Rhymezone (by Justin B Rye)
    (Closes: #289498)
  + Fix BBC News search (by Justin B Rye) (Closes: #289499)
  + New elvi by by Justin B Rye (Closes: #290032)
    - cia      Search for CIA documents
    - deblogs  Debian changelogs
    - etym     Search for word origins
    - foldoc   Free online dictionary of computing
  + New cve elvis for CAN assignment searches
  + Rewrite debian/copyright properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# $Id: rfc,v 1.2 2004/02/06 00:31:05 ianb-guest Exp $
 
3
# elvis: rfc            -- Search RFCs (internet standards documents)
 
4
# ianb@nessie.mcc.ac.uk 20031220
 
5
. surfraw || exit 1
 
6
 
 
7
w3_config_hook () {
 
8
def SURFRAW_rfc_search        all
 
9
def SURFRAW_rfc_field         all
 
10
def SURFRAW_rfc_results       $SURFRAW_results
 
11
def SURFRAW_rfc_output        txt
 
12
defyn SURFRAW_rfc_matchexact  no
 
13
defyn SURFRAW_rfc_showabs     no
 
14
defyn SURFRAW_rfc_showkw      no
 
15
defyn SURFRAW_rfc_reverse     no
 
16
defyn SURFRAW_rfc_ftp         no
 
17
defyn SURFRAW_rfc_nodirect    no
 
18
searchset=0
 
19
}
 
20
 
 
21
w3_usage_hook () {
 
22
    cat <<EOF
 
23
Usage: $w3_argv0 [options] [search words]...
 
24
Description:
 
25
  Surfraw search the RFC (Request For Comments) internet standards.
 
26
Local options:
 
27
  -results=NUM                  Number of search results returned
 
28
                                Default: $SURFRAW_rfc_results
 
29
                                Environment: SURFRAW_rfc_results
 
30
  -pdf                          Return files as PDF (Default: text)
 
31
  -rev                          Reverse order of results
 
32
  -exact                        Match exact words (instead of prefixes)
 
33
  -abs                          Show abstracts
 
34
  -keywords                     Show keywords
 
35
  -nodirect                     Don't try and go direct to RFC (Tries when
 
36
                                 arg is numeric and -search/-field not used)
 
37
  -ftp                          Retrieve RFCs via FTP instead of HTTP
 
38
  -field=                       Which field to search
 
39
          all           |       All fields
 
40
          number        |       
 
41
          title         |       
 
42
          author        |       
 
43
          keyword              
 
44
                                Default: if args are numeric, "number",
 
45
                                else "all"
 
46
                                Environment: SURFRAW_rfc_field
 
47
  -search=                      Collection to search
 
48
          all           |       All
 
49
          rfc           |       Requests For Comments
 
50
          std           |       Standards
 
51
          bcp           |       Best Current Practices
 
52
          fyi                   Informational (For Your Information)
 
53
                                Default: $SURFRAW_rfc_search
 
54
                                Environment: SURFRAW_rfc_search
 
55
EOF
 
56
    w3_global_usage
 
57
}
 
58
 
 
59
w3_parse_option_hook () {
 
60
    opt="$1"
 
61
    optarg="$2"
 
62
    case "$opt" in
 
63
    -res*=*)  setopt    SURFRAW_rfc_results     $optarg ;;
 
64
    -pdf*)    setopt    SURFRAW_rfc_output      pdf     ;;
 
65
    -rev*)    setoptyn  SURFRAW_rfc_reverse     yes     ;;
 
66
    -ex*)     setoptyn  SURFRAW_rfc_matchexact  yes     ;;
 
67
    -abs*)    setoptyn  SURFRAW_rfc_showabs     yes     ;;
 
68
    -k*)      setoptyn  SURFRAW_rfc_showkw      yes     ;;
 
69
    -ftp*)    setoptyn  SURFRAW_rfc_ftp         yes     ;;
 
70
    -no*)     setoptyn  SURFRAW_rfc_nodirect    yes     ;;
 
71
    -se*=*)   setopt    SURFRAW_rfc_search      $optarg ;;
 
72
    -fi*=*)   setopt    SURFRAW_rfc_field   $optarg ; searchset=1 ;;
 
73
    *) return 1 ;;
 
74
    esac
 
75
    return 0
 
76
}
 
77
 
 
78
w3_config
 
79
w3_parse_args "$@"
 
80
# w3_args now contains a list of arguments
 
81
if test -z "$w3_args"; then
 
82
    w3_browse_url "http://www.rfc-editor.org/rfcsearch.html"
 
83
else
 
84
    escaped_args=`w3_url_of_arg $w3_args`
 
85
 
 
86
    # Is cmdline numeric?
 
87
    nodirect=0
 
88
    if echo "$escaped_args" |grep  '^[0-9]*$' &>/dev/null
 
89
    then
 
90
        isnum=1
 
91
        if ifyes SURFRAW_rfc_nodirect
 
92
        then
 
93
            nodirect=1
 
94
        fi
 
95
    else
 
96
        isnum=0
 
97
    fi
 
98
 
 
99
    # Do we want to go direct to rfc?
 
100
    if [ $isnum -eq 1 -a $searchset -eq 0 -a $nodirect -eq 0 ]
 
101
    then
 
102
        # do we want txt
 
103
        if [ "$SURFRAW_rfc_output" = "txt" ]
 
104
        then
 
105
            subdir=""
 
106
            case "$SURFRAW_rfc_search" in
 
107
                all) fileprefix="rfc";;
 
108
                rfc) fileprefix="rfc";;
 
109
                std) fileprefix="std"; subdir="/std";;
 
110
                bcp) fileprefix="bcp"; subdir="/bcp";;
 
111
                fyi) fileprefix="fyi"; subdir="/fyi";;
 
112
                *) echo "Unknown search: $SURFRAW_rfc_search"; exit;;
 
113
            esac
 
114
            if ifyes SURFRAW_rfc_ftp
 
115
            then
 
116
                url="ftp://ftp.rfc-editor.org/in-notes${subdir}/${fileprefix}${escaped_args}.txt"
 
117
            else
 
118
                url="http://www.rfc-editor.org/rfc${subdir}/${fileprefix}${escaped_args}.txt"
 
119
            fi
 
120
        else # godless PDFs
 
121
            case "$SURFRAW_rfc_search" in
 
122
                all) ;;
 
123
                rfc) ;;
 
124
                *) echo "Only RFCs available as PDF files, not STDs, BCPs or FYIs. Try without -pdf";
 
125
                   exit 1;;
 
126
            esac
 
127
            # pdfs only available through ftp
 
128
            url="ftp://ftp.rfc-editor.org/in-notes/pdfrfc/rfc${escaped_args}.txt.pdf"
 
129
        fi
 
130
 
 
131
    else
 
132
 
 
133
        # not direct to rfc, construct url from options
 
134
        url="http://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=${escaped_args}"
 
135
 
 
136
        if [ $isnum -eq 1 -a $searchset -eq 0 ]
 
137
        then
 
138
            url="$url&opt=Number"
 
139
        else
 
140
            case "$SURFRAW_rfc_field" in
 
141
                all*)   url="$url&opt=All+Fields";;
 
142
                num*)   url="$url&opt=Number";;
 
143
                tit*)   url="$url&opt=Title";;
 
144
                auth*)  url="$url&opt=Author";;
 
145
                key*)   url="$url&opt=Keywords";;
 
146
                kw*)    url="$url&opt=Keywords";;
 
147
                *)      url="$url&opt=All+Fields";;
 
148
            esac
 
149
        fi
 
150
            
 
151
        url="$url&num=$SURFRAW_rfc_results"
 
152
        url="$url&filefmt=$SURFRAW_rfc_output"
 
153
        url="$url&search_doc=search_$SURFRAW_rfc_search"
 
154
            
 
155
        if ifyes SURFRAW_rfc_matchexact
 
156
        then    
 
157
            url="$url&match_method=entire"
 
158
        else
 
159
            url="$url&match_method=prefix"
 
160
        fi
 
161
            
 
162
        if ifyes SURFRAW_rfc_showabs
 
163
        then
 
164
            url="$url&abstract=abson"
 
165
        else
 
166
            url="$url&abstract=absoff"
 
167
        fi
 
168
            
 
169
        if ifyes SURFRAW_rfc_showkw
 
170
        then
 
171
            url="$url&keywords=keyon"
 
172
        else
 
173
            url="$url&keywords=keyoff"
 
174
        fi
 
175
            
 
176
        if ifyes SURFRAW_rfc_reverse
 
177
        then
 
178
            url="$url&sort_method=older"
 
179
        else
 
180
            url="$url&sort_method=newer"
 
181
        fi
 
182
            
 
183
        if ifyes SURFRAW_rfc_ftp
 
184
        then
 
185
            url="$url&format=ftp"
 
186
        else
 
187
            url="$url&format=http"
 
188
        fi
 
189
    fi
 
190
 
 
191
    w3_browse_url "$url"
 
192
fi