~ubuntu-branches/ubuntu/dapper/urlview/dapper

« back to all changes in this revision

Viewing changes to url_handler.sh.suse

  • Committer: Bazaar Package Importer
  • Author(s): Edward Betts
  • Date: 2001-08-02 22:26:35 UTC
  • Revision ID: james.westby@ubuntu.com-20010802222635-hrsj2sopu701ma7c
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# url_handler.sh for SuSE Linux
 
4
#
 
5
# Copyright (c) 2000  SuSE GmbH  Nuernberg, Germany.
 
6
#
 
7
# Author: Werner Fink <werner@suse.de>
 
8
#
 
9
   url="$1"
 
10
method="${1%%:*}"
 
11
 
 
12
if test "$url" = "$method" ; then
 
13
    case "${url%%.*}" in
 
14
        www|web|w3) method=http         ;;
 
15
        mail|mailx) method=mailto       ;;
 
16
        gopher)     method=gopher       ;;
 
17
        *)
 
18
            case "${url}" in
 
19
                */*.htm|*/*.html) method=http   ;;
 
20
                */*.htmls)        method=https  ;;
 
21
                *@*)              method=mailto ;;
 
22
                /*) if test -r "${url}" ; then
 
23
                                  method=file
 
24
                    fi                          ;;
 
25
                *)                              ;;
 
26
            esac
 
27
                                        ;;
 
28
    esac
 
29
    case "$method" in
 
30
        mailto|file)    url="${method}:$url"    ;;
 
31
        *)              url="${method}://$url"  ;;
 
32
    esac
 
33
fi
 
34
 
 
35
### an alternative method of handling "news:*" URL's
 
36
#
 
37
# if test "$method" = "news" ; then
 
38
#     url="http://www.deja.com/[ST_rn=if]/topics_if.xp?search=topic&group=${url#news:}"
 
39
#     method=http
 
40
# fi
 
41
 
 
42
shift
 
43
 
 
44
case "$method" in
 
45
    ftp)
 
46
        ftp=ftp
 
47
        if type -p ncftp >& /dev/null ; then
 
48
            ftp=ncftp
 
49
        else
 
50
            url="${url#ftp://}"
 
51
            echo "=====>  Paste this command by mouse:"
 
52
            echo cd "/${url#*/}"
 
53
            url="${url%%/*}"
 
54
        fi
 
55
        exec $ftp "$url"
 
56
        ;;
 
57
    file|http|https|gopher)
 
58
        http=
 
59
        type -p lynx >& /dev/null && http=lynx
 
60
        test -n "$DISPLAY" && type -p netscape >& /dev/null && http=netscape
 
61
        test -n "$DISPLAY" && type -p Netscape >& /dev/null && http=Netscape
 
62
        case "$http" in
 
63
            [nN]etscape) $http -remote "openURL($url)" || $netscape "$url" ;;
 
64
            lynx)        exec $http "$url" ;;
 
65
            *)
 
66
                echo "No HTTP browser found."
 
67
                read -p "Press return to continue: "
 
68
                exit 0  # No error return
 
69
                ;;
 
70
        esac
 
71
        ;;
 
72
    mailto)
 
73
        : ${MAILER:=mutt}
 
74
        if type -p ${MAILER} >& /dev/null ; then
 
75
            exec ${MAILER} "${url#mailto:}"
 
76
        else
 
77
            echo "No mailer ${MAILER} found in path."
 
78
            echo "Please check your environment variable MAILER."
 
79
            read -p "Press return to continue: "
 
80
            exit 0  # No error return
 
81
        fi
 
82
        ;;
 
83
    *)
 
84
        echo "URL type \"$method\" not know"
 
85
        read -p "Press return to continue: "
 
86
        exit 0  # No error return
 
87
        ;;
 
88
esac