lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev in P(rint), add "0. <url of THIS doc>" to "References"


From: Kim DeVaughn
Subject: Re: lynx-dev in P(rint), add "0. <url of THIS doc>" to "References"
Date: Tue, 7 Dec 1999 03:38:53 -0700

On Mon, Dec 06, 1999, David Combs (address@hidden) said:
|
| You read a news article somewhere, want to P(rint) it to a file
| and them email it off to a set of friends.

| What WOULD be nice is a link to the article itself,
| which currently is NOT put into the "References".

The environment variables:

 LYNX_PRINT_TITLE
 LYNX_PRINT_URL
 LYNX_PRINT_DATE
 LYNX_PRINT_LASTMOD

are set to the values shown in the Information Page (=) for the current
document, when the p(rint) function is selected.

Thus, you can write a small shell script to add any/all of those items
as a "header" to the document itself, and add it to your lynx.cfg as a
PRINTER: definition something like:

PRINTER:File saver:$HOME/bin/lynx.saver %s %s:FALSE:999999


Within the shell script, you would probably want something like:

#!/bin/sh
#
# lynx.saver
#
errwait="sleep 2"
msgwait="sleep 1"
beep="echo -n "

if test -f "$2" ;then  flag='append' ;fi

# Save the page (which is in $1 from lynx), after prepending a separator line
# if needed, and some header lines.
#
(if test -s "$2"; then
    echo ""
    echo 
"==============================================================================="
    echo ""
 fi
 test -n "$LYNX_PRINT_TITLE"   && echo "Linkname: $LYNX_PRINT_TITLE"
 test -n "$LYNX_PRINT_URL"     && echo "From URL: $LYNX_PRINT_URL"
 test -n "$LYNX_PRINT_DATE"    && echo "URL Date: $LYNX_PRINT_DATE"
 test -n "$LYNX_PRINT_LASTMOD" && echo "Last Mod: $LYNX_PRINT_LASTMOD"
 echo "Saved On: `date`"
 echo ""
 cat $1) | \
 sed -n -e '1H' \
        -e '/[^         \n]/!H' \
        -e '/[^         \n]/{H;x;s/^[^\n]*\n//;p;}' >> $2

# Tell the user what we hath wrought, and then split ...
#
if test $? -eq 0; then
   if test -z "$flag"; then
      echo ""
      echo ""
      echo "Page saved as file: $2"; echo ""; $msgwait
   else
      echo ""
      echo ""
      echo "Page appended to file: $2"; echo ""; $msgwait
   fi
else
   echo ""
   echo ""
   echo "Error: page not saved - cannot write file $2"
   echo ""
   $beep; $errwait; exit 1
fi
#
#--eof--#

which will *append* the document to the file if the file already exists
(with a "separator line" in such cases).  Note that the sed expression
will chop off any trailing whitespace (for sed on FreeBSD; doesn't seem
to work on linux though).  BTW, the sed expression contains a couple of
actual TAB chars, and the beep="echo ..." stmt contains a literal ^G char,
so be careful if you edit/use this.

Of course you can expand on the above to do things like filename expansion
of the $2 arg, and a bunch of stuff like that if you want ...

/kim

reply via email to

[Prev in Thread] Current Thread [Next in Thread]