🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #74538

[slrn] X-Face script (was: Re: Xnews X-Face modification request Att: Luu Tran)

#74538
From: Jurriaan (note: this is a workin...
Date: Wed, 28 Mar 2001 19:39
208 lines
8751 bytes
On 28 Mar 2001 17:50:40 GMT, Joe Manfre
<manfre@flash.net> wrote:
> That said, I create my X-Faces on my Linux machine even though
> I read news on it with slrn.  (Sometimes I manually take people's
> X-Face header lines and pipe them through uncompface and ikon2xbm
> so I can view them as XBM files.  One of these days I need to
> come up with a script to do that automatically.)
> 
No need, I already have something like that. Comments welcome.
It works on the console, so it probably also works in XFree, and with
little change, graphically.

#v+
% This function shows a X-Face in the current article.
define show_xface() 
{
   variable buf;

   save_current_article("/tmp/art_xfce");

   variable header_file, xfce_file;
   variable fp, xfce_fp;
   variable line;
   
   fp = fopen ("/tmp/art_xfce", "r");
   if (fp == NULL)
     return;

   while (-1 != fgets (&line, fp))
     {
        if (is_substr(line, "X-Face:" ))
          {
            xfce_fp = fopen("/tmp/hdr_xface", "w");
            if (xfce_fp == NULL)
              return;
            () = fputs(line, xfce_fp);
            () = fputs("\n", xfce_fp);
            () = fclose(xfce_fp);
          
            () = system ("cat /tmp/hdr_xface | view-x-face | less; rm -f /tmp/hdr_xface");
            break;
          }
     }

   () = system ("rm -f /tmp/art_xfce");
   % No need to close files unless we want to check for errors.  When
   % file pointer variables go out of scope, slang will close the file.
}

definekey ("show_xface", "^f", "article");

view-x-face:
#! /bin/sh
#
# $ Id: view-x-face,v 2.0 1998/10/27 10:20:58 roland Exp roland $
#
# Read a mail message on stdin and display X-Face, if one exists.
#
# See http://www.spinnaker.de/mutt/view-x-face for new versions.
#
# This is not the optimal way to implement X-Face support into a mailreader,
# but this works for me. I bound it to "ESC f" in my muttrc with the
# following command:
#  macro        pager   \ef     "|view-x-face\n"
#
# This script needs the following tools:
# uncompface from the compface package, which can be found at 
#            ftp://ftp.cs.indiana.edu/pub/faces/compface/compface.tar.Z
# icontopbm  from the pbmplus or netpbm package, which you will find
#            everywhere on the net.
# A pbm viewer, e.g. xli, xv or if you don't have X11 running, you may want
#            to try out image2ascii, a little Shell script, which uses 
#            ImageMagick to convert nearly any graphics file to ASCII.
#            have a look at http://www.spinnaker.de/mutt/image2ascii
#
#########################################################################
#
#   Based on an idea of Ralf D�blitz <Doeblitz@gmx.de>
#
#   Copyright (C) 1997-1998  Roland Rosenfeld <roland@spinnaker.de>
#
#   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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#########################################################################

# Used programms:
UNCOMPFACE=uncompface   # from compface package
ICONTOPBM=icontopbm     # from pbmplus/netpbm package

# Image viewer (should be able to read from stdin!): 
if [ -n "$DISPLAY" ]
then
    VIEWER="xli stdin"          # Use xli as X11 image viewer
    # VIEWER="xv -quit -"       # Use xv as X11 image viewer
else
    VIEWER=image2ascii          # Use image2ascii as ASCII image viewer
fi

sed -n -e '/^X-Face:/,/^[^ \t]/ p' $1 \
| sed -n -e 's/^X-Face://' -e '/^[ \t]/ p' \
| sed -e 's/^[ \t]\+//' \
| { echo '/* Width=48, Height=48 */'; $UNCOMPFACE; } \
| $ICONTOPBM \
| $VIEWER

image2ascii:

#! /bin/sh
#
# $ Id: image2ascii,v 1.5 1999/11/27 18:07:41 roland Exp $
#
# Convert any image to an ASCII-graphic using ImageMagick
#
##########################################################################
#
#   Copyright (C) 1997-1999  Roland Rosenfeld <roland@spinnaker.de>
#
#   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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##########################################################################

CONVERT=convert         # The ImageMagick convert binary
PBMTOASCII=pbmtoascii   # The NetPBM pbmtoascii binary

umask 077

tmpdir=${TMPDIR-/tmp}/image2ascii.$$
mkdir $tmpdir || exit 1
trap "rm -rf $tmpdir; exit" 0 1 2 3 15

TMPFILE=$tmpdir/image

usage="Usage: $0 [option] [imagefile]

   -help                display this help text
   -geometry 132x50     define the size of the ascii image"


# set default geometry to display width:
geometry=`stty size </dev/tty | awk '{print $2 "x" ( $1 - 1) }'`

# test if stty did not output a useful value:
case "$geometry" in
        0x0 ) geometry=80x24 ;;
        ""  ) geometry=80x24 ;;
esac

case $# in 
        0 ) cat > $TMPFILE ;;
        1 ) case "$1" in
                    -* ) echo "$usage"; exit 0 ;;
                    * )  cat $1 > $TMPFILE ;;
            esac ;;
        2 ) case "$1" in
                    -geometry ) geometry=$2
                                cat > $TMPFILE ;;
                    * )         echo "$usage"; exit 0 ;;
            esac ;;
        3 ) case "$1" in
                    -geometry ) geometry=$2
                                cat $3 > $TMPFILE ;;
                    * )         echo "$usage"; exit 0 ;;
            esac ;;
        * ) echo "$usage"; exit 0 ;;
esac

# multiply x with 2 and y with 4 (pbmtoascii divides by 2x4)
geometry=`echo $geometry | awk -Fx '{print 2*$1 "x" 4*$2}'`

$CONVERT -geometry $geometry $TMPFILE $TMPFILE.pbm
$PBMTOASCII -2x4 < $TMPFILE.pbm
#v-

I must say in the X-News thread there are a lot of articles which
contain X-Faces that are completely unreadable this way - but others are
fine, so I presume they are broken.

Good luck,
Jurriaan
-- 
hundred-and-one symptoms of being an internet addict:
26. You check your mail. It says "no new messages." So you check it again.
GNU/Linux 2.4.2-ac26 SMP/ReiserFS 2x1743 bogomips load av: 0.00 0.00 0.00
Technical Details
Message-ID: <slrn9c4ej6.3p1.no_spam_here@middle.of.nowhere>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!freenix!jussieu.fr!opentransit.net!news.tele.dk!194.109.133.3!transit.news.xs4all.nl!no_spam_here
References: <Xns9070B331D14E2pooobahh5386@203.30.236.75> <Xns907062689D18D3145926@172.17.1.62> <Xns9070B73A47717.thomas@esperanza.wkaz.net> <70Kv6.264373$65.1451318@news1.rdc1.fl.home.com> <Xns9071975F2FF183145926@172.17.1.62> <Xns907281C1E97Adoidyhead@130.133.1.4>

Show Full Headers
Complete Article Headers
Message-ID: <slrn9c4ej6.3p1.no_spam_here@middle.of.nowhere>
Subject: [slrn] X-Face script (was: Re: Xnews X-Face modification request Att: Luu Tran)
Date: Wed, 28 Mar 2001 19:39:43 +0000
From: no_spam_here@rivierenland.xs4all.nl (Jurriaan (note: this is a working address!))
References: <Xns9070B331D14E2pooobahh5386@203.30.236.75> <Xns907062689D18D3145926@172.17.1.62> <Xns9070B73A47717.thomas@esperanza.wkaz.net> <70Kv6.264373$65.1451318@news1.rdc1.fl.home.com> <Xns9071975F2FF183145926@172.17.1.62> <Xns907281C1E97Adoidyhead@130.133.1.4>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!freenix!jussieu.fr!opentransit.net!news.tele.dk!194.109.133.3!transit.news.xs4all.nl!no_spam_here
Newsgroups: news.software.readers
Organization: XS4ALL Internet BV
Lines: 207
NNTP-Posting-Host: rivierenland.xs4all.nl
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news1.xs4all.nl 985808383 21997 194.109.14.47 (28 Mar 2001 19:39:43 GMT)
X-Complaints-To: abuse@xs4all.nl
NNTP-Posting-Date: 28 Mar 2001 19:39:43 GMT
X-Face: b$-F+98,@$_I=*ODq'<K2(OA)qC&,(GP=z2^`4dwQwy&e;!|R?>")k9FH3?YC+%*kF\=<Rx"Hy2_eyMtnFSiO8
User-Agent: slrn/0.9.6.4pl4 (GNU/Linux)