File: dmoz

package info (click to toggle)
surfraw 2.1.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 780 kB
  • ctags: 139
  • sloc: sh: 7,085; perl: 355; makefile: 155
file content (81 lines) | stat: -rwxr-xr-x 2,740 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
# $Id: dmoz,v 1.1 2004/09/15 16:56:55 ianb-guest Exp $
# elvis: dmoz		-- Search the Open Directory Project web directory (dmoz.org)
# ianb@nessie.mcc.ac.uk 20040910
. surfraw || exit 1

w3_config_hook () {
def    SURFRAW_dmoz_category     ""
def    SURFRAW_dmoz_searchtype   "b"
defyn  SURFRAW_dmoz_kids         0
defyn  SURFRAW_dmoz_teens        0
defyn  SURFRAW_dmoz_mteens       0
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [URL]
Description:
  Search the Open Directory Project web directory (dmoz.org)
Local options:
  -cat=CATEGORY                 Search category
                                Default: all
                                Values: Arts, Business, Computers, Games, 
                                        Health, Home, Kids_and_Teens, News,
                                        Recreation, Reference, Regional, 
                                        Science, Shopping, Society, Sports, 
                                        World, Adult
                                Environment: SURFRAW_dmoz_category
  -type=SEARCHTYPE              Search type
                                Default: b
                                Values: c - Categories Only
                                        s - Sites only
                                        b - Both
                                Environment: SURFRAW_dmoz_searchtype
  -kids                         Sites for kids.
                                Environment: SURFRAW_dmoz_kids
  -teens                        Sites for teens.
                                Environment: SURFRAW_dmoz_teens
  -mteens                       Sites for mature teens.
                                Environment: SURFRAW_dmoz_mteens
EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
    -cat*=*)    setopt    SURFRAW_dmoz_category          "$optarg" ;;
	-ty*=*)     setopt    SURFRAW_dmoz_searchtype        "$optarg" ;;
	-ki*)       setoptyn  SURFRAW_dmoz_kids                1 ;;
	-te*)       setoptyn  SURFRAW_dmoz_teens               1 ;;
	-mt*)       setoptyn  SURFRAW_dmoz_mteens              1 ;;
	*) return 1 ;;
    esac
    return 0
}

w3_config
w3_parse_args "$@"
# w3_args now contains a list of arguments
if test -z "$w3_args"; then
    w3_browse_url "http://dmoz.org/"
else
    escaped_args=`w3_url_of_arg $w3_args`
	url="http://search.dmoz.org/cgi-bin/search?search=${escaped_args}&all=no&cat=${SURFRAW_dmoz_category}&t=${SURFRAW_dmoz_searchtype}"
	if [ $SURFRAW_dmoz_kids -eq 1 ]
	then
		url="${url}&Kids=1"
	fi
	if [ $SURFRAW_dmoz_teens -eq 1 ]
	then
		url="${url}&Teens=1"
	fi
	if [ $SURFRAW_dmoz_mteens -eq 1 ]
	then
		url="${url}&Mteens=1"
	fi

	w3_browse_url "${url}"
fi