<<< Date Index >>>     <<< Thread Index >>>

Re: urlview



On Mon, 15 Sep 2003 the mental interface of 
A. S. Budden told:

> Thus spake Malte Neumann:
> > I want to open the chosen url in an already running browser
> > using the following COMMAND: mozilla -remote
> > "openurl(%s,new-tab)" The problem is now, that this command does
> > not accept the url with leading and trailing single quotes. Is
> > it possible to switch off this behaviour of urlview.
> > 
> 
> Not exactly answering your question directly, but I have in my
> .urlview:
> 
> REGEXP  (((https?|ftp|gopher)://|(mailto|file|news):)[^'
> \t<>"]+|(www|web|w3)\.[-a-z0-9.]+) COMMAND ~/bin/mozilla.sh %s >
> /dev/null 2>/dev/null &
> 
> Where ~/bin/mozilla.sh looks like this:
> 
> #!/bin/bash URL=$@ mozilla -remote "openurl($URL, new-tab)" ||
> mozilla $URL
> 

:r! cat ~.urlview
#! /bin/bash

# regular expression to use to match URLs
REGEXP (((http|https|ftp|gopher)|mailto):(//)?[^ <>"\t]*|www\.[-a-z0-9.]+)[^ 
.,;\t<">\):]

# command to invoke for selected URL
COMMAND url_handler.sh

:r! cat ~/bin/url_handler.sh

#! /bin/sh

#   Copyright (c) 1998  Martin Schulze <joey@xxxxxxxxxx>
#   Slightly modified by Luis Francisco Gonzalez <luisgh@xxxxxxxxxx>

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

###########################################################################
# Configurable section
###########################################################################
#
# Any entry in the lists of programs that urlview handler will try out will
# be made of /path/to/program + ':' + TAG where TAG is one of
# XW: XWindows program
# XT: Launch with an xterm if possible or as VT if not
# VT: Launch in the same terminal

# The lists of programs to be executed are
if [ "$(uname -s)" = "FreeBSD" ] ; then
  https_prgs="/usr/X11R6/bin/galeon:XW /usr/local/bin/lynx:XT 
/usr/local/bin/w3m:XT"
  http_prgs="/usr/X11R6/bin/galeon:XW /usr/local/bin/lynx:XT 
/usr/local/bin/w3m:XT /usr/local/bin/links:XT"
  mailto_prgs="/usr/local/bin/mutt:VT /usr/local/bin/elm:VT 
/usr/local/bin/pine:VT /usr/bin/mail:VT"
  gopher_prgs="/usr/local/bin/lynx:XT /usr/local/bin/gopher:XT"
  ftp_prgs="/usr/local/bin/lynx:XT /usr/local/bin/ncftp2:XT 
/usr/local/bin/ncftp3:XT /usr/local/bin/ncftp:XT"
elif [ "$(uname -s)" = "Linux" ] ; then
  https_prgs="/usr/bin/galeon:XW /usr/bin/lynx:XT /usr/bin/w3m:XT"
  http_prgs="/usr/bin/galeon:XW /usr/bin/lynx:XT /usr/bin/w3m:XT 
/usr/bin/links:XT"
  mailto_prgs="/usr/local/bin/mutt:VT /usr/local/bin/elm:VT 
/usr/local/bin/pine:VT /usr/bin/mail:VT"
  gopher_prgs="/usr/local/bin/lynx:XT /usr/local/bin/gopher:XT"
  ftp_prgs="/usr/local/bin/lynx:XT /usr/local/bin/ncftp2:XT 
/usr/local/bin/ncftp3:XT /usr/local/bin/ncftp:XT"
fi

# Program used as an xterm (if it doesn't support -T you'll need to change
# the command line in getprg)
XTERM=/usr/X11R6/bin/xterm


###########################################################################
# Change bellow this at your own risk
###########################################################################
getprg()
{
    local ele tag prog

    for ele in $*
    do
        tag=${ele##*:}
        prog=${ele%%:*}
        if [ -x $prog ]; then
            case $tag in
            XW)
                [ -n "$DISPLAY" ] && echo "X:$prog" && return 0
                ;;
            XT)
                [ -n "$DISPLAY" ] && [ -x "$XTERM" ] && \
                    echo "X:$XTERM -e $prog" && return 0
                echo "$prog" && return 0
                ;;
            VT)
                echo "$prog" && return 0
                ;;
            esac
        fi
    done
}

url="$1"; shift

type="${url%%:*}"

if [ "$url" = "$type" ]; then
    type="${url%%.*}"
    case "$type" in
    www|web)
        type=http
        ;;
    esac
    url="$type://$url"
fi

case $type in
https)
    prg=`getprg $https_prgs`
    ;;
http)
    prg=`getprg $http_prgs`
    ;;
ftp)
    prg=`getprg $ftp_prgs`
    ;;
mailto)
    prg=`getprg $mailto_prgs`
    url="${url#mailto:}";
    ;;
gopher)
    prg=`getprg $gopher_prgs`
    ;;
*)
    echo "Unknown URL type.  Please report URL and viewer to:"
    echo "joey@xxxxxxxxxxx"
    echo -n "Press enter to continue."; read x
    exit
    ;;
esac

if [ -n "$prg" ]; then
   if [ "${prg%:*}" = "X" ]; then
    ${prg#*:} "$url" 2>/dev/null &
   else
    $prg "$url"
   fi
fi

#EOF

hehehe

Ciao

Elimar

-- 
  It's a good thing we don't get all 
  the government we pay for.

Attachment: signature.asc
Description: Digital signature