url.cgi - make plain text URLs clickable

This commit is contained in:
Wolfram Schneider 1997-10-11 15:58:11 +00:00
parent 0acf12b77f
commit 0dc3227592
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=2045
4 changed files with 68 additions and 4 deletions

View file

@ -1,10 +1,10 @@
# $Id: Makefile,v 1.8 1997-09-27 21:27:17 wosch Exp $
# $Id: Makefile,v 1.9 1997-10-11 15:58:11 wosch Exp $
DATA= ftp.mirrors
CGI= ftp.cgi gallery.cgi mirror.cgi cgi-lib.pl cgi-style.pl
CGI+= search.cgi cvsweb.cgi query-pr.cgi query-pr-summary.cgi
CGI+= dosendpr.cgi freebsd.def html.pl reg.cgi missing_handler.cgi
CGI+= ports.cgi pds.cgi man.cgi
CGI+= ports.cgi pds.cgi man.cgi url.cgi
.SUFFIXES: .C .cgi

32
en/cgi/url.cgi Executable file
View file

@ -0,0 +1,32 @@
#!/bin/sh
# Copyright (c) Oct 1997 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
# All rights reserved.
#
# url.cgi - make plain text URLs clickable
#
# $Id: url.cgi,v 1.1 1997-10-11 15:58:11 wosch Exp $
PATH=/bin:/usr/bin:/usr/local/bin; export PATH
url="$QUERY_STRING"
case $url in
http://*.freebsd.* | http://localhost/* );;
*) printf "Content-type: text/plain\n\n"
printf "Wrong url: \"$url\"\n"
printf "Only http://*.freebsd.* are allowed.\n";
exit;;
esac
if lynx -dump -head "$url" 2>/dev/null | grep -q "text/plain"
then
printf "Content-type: text/html\n\n<HTML><BODY><pre>\n"
lynx -source "$url" |
perl -npe 's/</&lt;/g;
s%(http://[^\s"]+)%<A HREF="$1">$1</A>%g;
s%([\w\-\.]+\@[\w\-\.]+\.[a-z]+)%<A HREF="mailto:$1">$1</A>%g;'
echo "</pre></BODY></HTML>"
else
printf "Location: $url\n";
printf "Content-type: text/plain\n\n";
fi