🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #6071

Re: guard-double-slash and !lynx http://

#6071
From: Jelle van Zeijl
Date: Tue, 05 Jul 1994 10:48
168 lines
5262 bytes
Nancy McGough <nancym@ii.com> writes:
> Often when I'm in nn I want to take a look at a web page someone 
> mentions so I type:
>
>   !lynx http://etc...
>
> But by default nn interprets // as /, so I set guard-double-slash 
> on in my init file but that doesn't help.  Anyone have a suggestion?

Well, a colleague of mine, Gertjan van Oosten, has written a small script
and an nn macro to do just that. He's on a holiday, so that's why I
respond.

Here's the script (called mosaic_link), which can also be used from the
command-line, from within elm, or wherever. It looks on standard-in for any
http link in the text and lets you select one (using the select script).
Then it will use the remote control feature of xmosaic to open that page
(it will start xmosaic if not already running).

If you want to use it with lynx, you'll have to change it because lynx
doesn't have the remote control feature. Just starting lynx with the
specified link in the current window will probably work fine.

The scripts are his, the comments in the header I've just added (so
spelling flames should be directed to me :-).

The mosaic_link script:
----------------------------------------------------------------------
#!/bin/sh
# NAME
#	mosaic_link - select one http link and show page with Mosaic
#
# SYNOPSIS
#	mosaic_link < file
#
# DESCRIPTION
#	Get list of http links from stdin, let the user select one and
#	show corresponding page with Mosaic via remote control feature.
#	Start up Mosaic if not yet running.
#
# AUTHOR:
#	Gertjan van Oosten
#	West Consulting BV
#	gvoosten@iso.estec.esa.nl, gertjan@west.nl
#

MOSAIC=xmosaic
TMPFILE=/tmp/Mosaic.
export MOSAIC

# Get Mosaic pid
PID=`ps x | grep "$MOSAIC" | grep -v grep | head -1 | awk '{print $1}'`

echo "\nProcessing..."
# If no pid then start Mosaic
if [ -z "$PID" ]
then
  echo "Starting Mosaic, please wait 15 seconds."
  ( exec "$MOSAIC" >> $HOME/.xsessionlog 2>&1 ) &
  PID=$!
  sleep 15
  echo "Mosaic started."
fi

# Get link
LINKS=`sed -n 's,^.*\(http://[^ 	>")]*\).*$,\1,p'`

umask 077
echo "newwin" > "$TMPFILE$PID"
echo "Select one of the following links:"
select $LINKS < /dev/tty 2>> "$TMPFILE$PID"

if [ $? -ne 255 ]
then
  kill -USR1 "$PID"	# Tell Mosaic to read remote control file
  sleep 2
fi

exit 0
----------------------------------------------------------------------

The select script:
----------------------------------------------------------------------
#!/bin/sh5
# NAME
#	select - show list and let user select one or timeout
#
# SYNOPSIS
#	select choice ...
#
# DESCRIPTION
#	A list of choices will be shown and the user can select one of them.
#	The choice will be put on stderr and the exit code will indicate which
#	choice is taken. The default is the last choice, which can be selected
#	by entering 0.
#	If the user waits too long, the script will timeout and exit with exit
#	code 255.
#	The script will return immediately if only one choice is given which
#	will then be the selected one.
#
# AUTHOR:
#	Gertjan van Oosten
#	West Consulting BV
#	gvoosten@iso.estec.esa.nl, gertjan@west.nl
#

SIGNAL=2 # INTR
DELAY=5
ERROR=255

n=0
for p
do
  n=`expr $n + 1`
  echo $n: $p
done

trap 'exit $ERROR' $SIGNAL
(sleep $DELAY && kill -$SIGNAL $$ > /dev/null 2>&1) &

if [ $n -eq 1 ]
then
  a=1
else
  echo "Select 1 to $n (0 for last one): \c"
  read a

  a=`expr 0 + 0$a 2> /dev/null`
  if [ "$a" -gt $n -o "$a" -eq 0 ]
  then
    a=$n
  fi
fi

n=0
for p
do
  n=`expr $n + 1`
  if [ $a -eq $n ]
  then
    echo "Selected $p"
    echo $p 1>&2
    break
  fi
done

exit $a
----------------------------------------------------------------------

And here is the macro which you must add to you ~/.nn/init file:
----------------------------------------------------------------------
# show WWW links via Mosaic
define 0
  save-full "/tmp/nn.mosaic.$(USER)" yes
  :!mosaic_link < /tmp/nn.mosaic.$USER ; rm -f /tmp/nn.mosaic.$USER
  redraw
end
map show ^X macro 0
----------------------------------------------------------------------

It's not fool proof but it works fine and without much hassle. All praise
(and flames) to Gertjan.

Hope you'll enjoy it,

--
-- Jelle van Zeijl:  Estec, +31-1719-85668, jvzeijl@iso.estec.esa.nl
-- 		     West Consulting, +31-15-123190, jelle@west.nl
Technical Details
Message-ID: <CsGrDL.Jr9@isous2.estec.esa.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!bga.com!news.sprintlink.net!news.onramp.net!convex!cs.utexas.edu!swrinde!pipex!sunic!trane.uninett.no!eunet.no!nuug!EU.net!sun4nl!estwmz.wm.estec.esa.nl!isous2.estec.esa.nl!news
References: <2uvcpu$msr@nwfocus.wa.com>

Show Full Headers
Complete Article Headers
Message-ID: <CsGrDL.Jr9@isous2.estec.esa.nl>
Subject: Re: guard-double-slash and !lynx http://
Date: Tue, 5 Jul 1994 10:48:57 GMT
From: jvzeijl@iso.estec.esa.nl (Jelle van Zeijl)
References: <2uvcpu$msr@nwfocus.wa.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!bga.com!news.sprintlink.net!news.onramp.net!convex!cs.utexas.edu!swrinde!pipex!sunic!trane.uninett.no!eunet.no!nuug!EU.net!sun4nl!estwmz.wm.estec.esa.nl!isous2.estec.esa.nl!news
Newsgroups: news.software.nn
Sender: news@isous2.estec.esa.nl (USENET News System)
Reply-To: jvzeijl@iso.estec.esa.nl (Jelle van Zeijl)
Organization: ESA/Estec/SAI, Noordwijk, The Netherlands
Lines: 168