webrowse (webrowse-2.0.0.tgz) | : | webrowse (webrowse-2.0.3.tgz) | ||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
$browser = ($ENV{'WB_BROWSER'} =~ /chrom/i) ? 'c' : | $browser = ($ENV{'WB_BROWSER'} =~ /chrom/i) ? 'c' : | |||
($ENV{'WB_BROWSER'} =~ /mosaic/i) ? 'm' : 'z'; | ($ENV{'WB_BROWSER'} =~ /mosaic/i) ? 'm' : 'z'; | |||
$use_old = ($ENV{'WB_MOZOLD'} =~ /./) ? 1 : 0; | $use_old = ($ENV{'WB_MOZOLD'} =~ /./) ? 1 : 0; | |||
$use_sp = ($ENV{'WB_SLEEP'} =~ /at/i) ? 0 : 1; | $use_sp = ($ENV{'WB_SLEEP'} =~ /at/i) ? 0 : 1; | |||
# default browser command and directories for temporary files | # default browser command and directories for temporary files | |||
$chrome = $ENV{'WB_CHROME'} || 'chromium-browser'; | $chrome = $ENV{'WB_CHROME'} || 'chromium-browser'; | |||
$mozilla = $ENV{'WB_MOZILLA'} || $ENV{'WB_NETSCAPE'} || 'firefox'; | $mozilla = $ENV{'WB_MOZILLA'} || $ENV{'WB_NETSCAPE'} || 'firefox'; | |||
$chtmp = $ENV{'WB_CHTMP'} || $ENV{'WB_TMP'} || | $chtmp = $ENV{'WB_CHTMP'} || $ENV{'WB_TMP'} || | |||
((-d "$ENV{'HOME'}/.cache/chromium") | ((-d "$ENV{'HOME'}/.cache/chromium") | |||
? "$ENV{'HOME'}/.cache/chromium" : | ? "$ENV{'HOME'}/.cache/chromium" : | |||
(-d "$ENV{'HOME'}/snap/chromium/common/.cache/chromium") | ||||
? "$ENV{'HOME'}/snap/chromium/common/.cache/chromium" : | ||||
(-d "$ENV{'HOME'}/tmp") ? "$ENV{'HOME'}/tmp" : '/tmp'); | (-d "$ENV{'HOME'}/tmp") ? "$ENV{'HOME'}/tmp" : '/tmp'); | |||
$nstmp = $ENV{'WB_MZTMP'} || $ENV{'WB_NSTMP'} || $ENV{'WB_TMP'} || | $nstmp = $ENV{'WB_MZTMP'} || $ENV{'WB_NSTMP'} || $ENV{'WB_TMP'} || | |||
((-d "$ENV{'HOME'}/.mozilla") ? "$ENV{'HOME'}/.mozilla" : | ((-d "$ENV{'HOME'}/.mozilla") ? "$ENV{'HOME'}/.mozilla" : | |||
(-d "$ENV{'HOME'}/.netscape") ? "$ENV{'HOME'}/.netscape" : | (-d "$ENV{'HOME'}/.netscape") ? "$ENV{'HOME'}/.netscape" : | |||
(-d "$ENV{'HOME'}/tmp") ? "$ENV{'HOME'}/tmp" : '/tmp'); | (-d "$ENV{'HOME'}/tmp") ? "$ENV{'HOME'}/tmp" : '/tmp'); | |||
$mstmp = $ENV{'WB_MSTMP'} || $ENV{'WB_TMP'} || | $mstmp = $ENV{'WB_MSTMP'} || $ENV{'WB_TMP'} || | |||
((-d "$ENV{'HOME'}/tmp") ? "$ENV{'HOME'}/tmp" : '/tmp'); | ((-d "$ENV{'HOME'}/tmp") ? "$ENV{'HOME'}/tmp" : '/tmp'); | |||
# default umask, tmp file hold time, browser window and pwd command | # default umask, tmp file hold time, browser window and pwd command | |||
$umask = (defined $ENV{'WB_UMASK'}) ? $ENV{'WB_UMASK'} : 077; | $umask = (defined $ENV{'WB_UMASK'}) ? $ENV{'WB_UMASK'} : 077; | |||
skipping to change at line 52 | skipping to change at line 54 | |||
return unless ($ENV{'USER'} || $ENV{'LOGNAME'}) eq 'kinzler'; | return unless ($ENV{'USER'} || $ENV{'LOGNAME'}) eq 'kinzler'; | |||
local($cursive) = ' STYLE="font-family: Comic Sans, Comic Sans MS,' | local($cursive) = ' STYLE="font-family: Comic Sans, Comic Sans MS,' | |||
. ' cursive, serif"'; | . ' cursive, serif"'; | |||
local($small) = ' STYLE="font-size: .8em"'; | local($small) = ' STYLE="font-size: .8em"'; | |||
s/-sbk\b|\tSteve$/<SPAN$cursive>$&<\/SPAN>/mg; | s/-sbk\b|\tSteve$/<SPAN$cursive>$&<\/SPAN>/mg; | |||
s/(\n)((- ){34}-\n.*?)(?=$|\n\n)/$1<SPAN$small>$2<\/SPAN>$4/gs; | s/(\n)((- ){34}-\n.*?)(?=$|\n\n)/$1<SPAN$small>$2<\/SPAN>$4/gs; | |||
local($urlp) = '[^\s\'"`<>()\[\]{}]*'; | local($urlp) = '[^\s\'"`<>()\[\]{}]*'; | |||
s!<(https?://l\.facebook.com/$urlp?)>! $1 !gi; | s!<(https?://l\.facebook.com/$urlp?)>! $1 !gi; | |||
s!\bhttps?://l\.facebook\.com/+l/+[^/]+/+($urlp)! | s!\bhttps?://l\.facebook\.com/+l(/+[^/]+/+|\.php\?u=)($urlp)! | |||
$_ = &urldecode($1), s#^[-\w.]+\.(com|net|org)#http://$&#i, | $_ = &urldecode($2), s#&h=.*##, m#://# || s#^#http://#, | |||
"\n[FBLINK:]$_\n"!gie; | "\n[FBLINK:]$_\n"!gie; | |||
} | } | |||
@short = qw( slnm.us ); | @short = qw( slnm.us ); | |||
# 68 URL shortening services as of 2015-02-27 from | # 68 URL shortening services as of 2015-02-27 from | |||
# www.hongkiat.com/blog/url-shortening-services-the-ultimate-list | # www.hongkiat.com/blog/url-shortening-services-the-ultimate-list | |||
push(@short, qw( | push(@short, qw( | |||
301url.com a2n.eu b65.us beam.to byinter.com canurl.com digbig.com | 301url.com a2n.eu b65.us beam.to byinter.com canurl.com digbig.com | |||
doiop.com dwarfurl.com easyurl.net fhurl.com fhurl.com | doiop.com dwarfurl.com easyurl.net fhurl.com fhurl.com | |||
fwdurl.net g8l.us get-shorty.com hongkiat.decenturl.com | fwdurl.net g8l.us get-shorty.com hongkiat.decenturl.com | |||
skipping to change at line 75 | skipping to change at line 77 | |||
is.gd lnk.in minilien.com moourl.com myurl.in nanoref.com | is.gd lnk.in minilien.com moourl.com myurl.in nanoref.com | |||
nutshellurl.com piurl.com redirx.com rubyurl.com shorl.com | nutshellurl.com piurl.com redirx.com rubyurl.com shorl.com | |||
shorterlink.com shortlinks.co.uk shredurl.com shrinkr.com | shorterlink.com shortlinks.co.uk shredurl.com shrinkr.com | |||
shrinkurl.us shrtnd.com shurl.net simurl.com smallr.com | shrinkurl.us shrtnd.com shurl.net simurl.com smallr.com | |||
snipurl.com starturl.com tighturl.com tinylink.com tinyurl.com | snipurl.com starturl.com tighturl.com tinylink.com tinyurl.com | |||
traceurl.com u76.org url.co.uk url.ie url.lotpatrol.com urlcut.com | traceurl.com u76.org url.co.uk url.ie url.lotpatrol.com urlcut.com | |||
urlcutter.com urlhawk.com urltea.com urlvi.be wapurl.co.uk | urlcutter.com urlhawk.com urltea.com urlvi.be wapurl.co.uk | |||
www.6url.com www.ezurl.eu www.liteurl.net www.shortenurl.com | www.6url.com www.ezurl.eu www.liteurl.net www.shortenurl.com | |||
www.urlpire.com www.x.se xil.in xrl.us yatuc.com yep.it | www.urlpire.com www.x.se xil.in xrl.us yatuc.com yep.it | |||
you.ne1.net yourname.shim.net)); | you.ne1.net yourname.shim.net)); | |||
push(@short, qw( ow.ly youtu.be )); | ||||
@short = grep(s/\./\\./g || 1, @short); | @short = grep(s/\./\\./g || 1, @short); | |||
$markup_ftp = $ENV{'WB_MUP_FTP'}; # markup fqdn:paths with ftp: anchors | ||||
$markup_file = $ENV{'WB_MUP_FILE'}; # markup /file/paths with file: anchors | ||||
############################################################################### | ############################################################################### | |||
## Usage ###################################################################### | ## Usage ###################################################################### | |||
# webrowse -- browse the given input in a local web browser, with markup | # webrowse -- browse the given input in a local web browser, with markup | |||
# Steve Kinzler, steve@kinzler.com, May 96/Jan 98/Feb 15 | # Steve Kinzler, steve@kinzler.com, May 96/Jan 98/Feb 15 | |||
# see website http://kinzler.com/me/webrowse/ | # see website http://kinzler.com/me/webrowse/ | |||
# http://kinzler.com/me/home.html#web | # http://kinzler.com/me/home.html#web | |||
$VERSION = '2.0.0'; | $VERSION = '2.0.3'; | |||
use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; | use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; | |||
($Cnote, $Nnote, $Mnote) = ($browser =~ /c/) ? (' (default)', '', '') : | ($Cnote, $Nnote, $Mnote) = ($browser =~ /c/) ? (' (default)', '', '') : | |||
($browser =~ /z/) ? ('', ' (default)', '') : | ($browser =~ /z/) ? ('', ' (default)', '') : | |||
('', '', ' (default)'); | ('', '', ' (default)'); | |||
$Onote = ($use_old) ? ' (default)' : ''; | $Onote = ($use_old) ? ' (default)' : ''; | |||
($Pnote, $Anote) = ($use_sp) ? (' (default)', '') : ('', ' (default)'); | ($Pnote, $Anote) = ($use_sp) ? (' (default)', '') : ('', ' (default)'); | |||
$usage = "usage: $0 [ -C | -Z | -N | -M ] [ -O ] | $usage = "usage: $0 [ -C | -Z | -N | -M ] [ -O ] | |||
[ -s | -x | -mq | -u | -c ] [ -k MINUTES ] [ -p | -a ] [ -i ID ] | [ -s | -x | -mq | -u | -c ] [ -k MINUTES ] [ -p | -a ] [ -i ID ] | |||
skipping to change at line 242 | skipping to change at line 248 | |||
$url =~ s/^\"(.*)\"$/$1/, $url =~ s/^\'(.*)\'$/$1/, | $url =~ s/^\"(.*)\"$/$1/, $url =~ s/^\'(.*)\'$/$1/, | |||
$url =~ s/^\((.*)\)$/$1/, $url =~ s/^\<(.*)\>$/$1/, | $url =~ s/^\((.*)\)$/$1/, $url =~ s/^\<(.*)\>$/$1/, | |||
$url =~ s/^\[(.*)\]$/$1/, $url =~ s/^\{(.*)\}$/$1/ if $arg eq 'url'; | $url =~ s/^\[(.*)\]$/$1/, $url =~ s/^\{(.*)\}$/$1/ if $arg eq 'url'; | |||
$url = "file:$url" if $arg ne 'url' && $arg ne 'cmd'; | $url = "file:$url" if $arg ne 'url' && $arg ne 'cmd'; | |||
# construct the chrome/mozilla remote control command to run, | # construct the chrome/mozilla remote control command to run, | |||
# and print it if requested | # and print it if requested | |||
if ($browser =~ /[cz]/) { | if ($browser =~ /[cz]/) { | |||
$url =~ s/\(/%28/g; $url =~ s/\)/%29/g; $url =~ s/,/%2C/g; | $url =~ s/\(/%28/g; $url =~ s/\)/%29/g; $url =~ s/,/%2C/g; | |||
if ($browser =~ /c/) { | if ($browser =~ /c/) { | |||
push(@args, $chrome, ($opt_t) ? () | push(@args, split(/\s+/, $chrome), | |||
: '--new-window', $url); | ($opt_t) ? () : '--new-window', $url); | |||
} elsif (! $use_old) { | } elsif (! $use_old) { | |||
push(@args, $mozilla, ($opt_t) ? '-new-tab' | push(@args, split(/\s+/, $mozilla), | |||
: '-new-window', $url); | ($opt_t) ? '-new-tab' : '-new-window', $url); | |||
} else { | } else { | |||
# Mozilla 1.7b seems to need this: | # Mozilla 1.7b seems to need this: | |||
$url .= '/' if $url =~ /^https?:\/\/[-\w.]+(:\d*)?$/i; | $url .= '/' if $url =~ /^https?:\/\/[-\w.]+(:\d*)?$/i; | |||
$url .= ($opt_w) ? ', new-window' : | $url .= ($opt_w) ? ', new-window' : | |||
($opt_t) ? ', new-tab' :'' if $arg ne 'cmd'; | ($opt_t) ? ', new-tab' :'' if $arg ne 'cmd'; | |||
push(@args, $mozilla); | push(@args, split(/\s+/, $mozilla)); | |||
push(@args, '-id', $id) if $id; | push(@args, '-id', $id) if $id; | |||
push(@args, (($opt_r || $opt_w) ? '-noraise' :'-raise', | push(@args, (($opt_r || $opt_w) ? '-noraise' :'-raise', | |||
'-remote', ($arg eq 'cmd') ? $url | '-remote', ($arg eq 'cmd') ? $url | |||
: "openURL($url)")); | : "openURL($url)")); | |||
} | } | |||
$| = 1, print("@args\n"), $| = $flush if $opt_v; | $| = 1, print("@args\n"), $| = $flush if $opt_v; | |||
} | } | |||
# Note: newer mozilla software includes mozilla-xremote-client | # Note: newer mozilla software includes mozilla-xremote-client | |||
# for a similar alternative interface that allows one to specify | # for a similar alternative interface that allows one to specify | |||
# the browser application. See www.mozilla.org/unix/remote.html | # the browser application. See www.mozilla.org/unix/remote.html | |||
skipping to change at line 282 | skipping to change at line 288 | |||
# remote control the browser | # remote control the browser | |||
# with Chrome/Mozilla, by running or execing the remote control command | # with Chrome/Mozilla, by running or execing the remote control command | |||
# with Mosaic, by writing a standard temporary command file and | # with Mosaic, by writing a standard temporary command file and | |||
# signaling the pid of the browser process, read from ~/.mosaicpid | # signaling the pid of the browser process, read from ~/.mosaicpid | |||
local($msg) = "$0: remote commands only available with old Mozilla" | local($msg) = "$0: remote commands only available with old Mozilla" | |||
. " or Netscape\n"; | . " or Netscape\n"; | |||
if ($browser =~ /c/ || $browser =~ /z/ && ! $use_old) { | if ($browser =~ /c/ || $browser =~ /z/ && ! $use_old) { | |||
die $msg if $arg eq 'cmd'; | die $msg if $arg eq 'cmd'; | |||
exit unless defined($pid = fork) && $pid == 0; # parent exits | exit unless defined($pid = fork) && $pid == 0; # parent exits | |||
close STDOUT; # suppress "... in existing browser session." | # Note: closing both STDOUT AND STDERR has been observed | |||
# to cause command failure on some systems. | ||||
# close STDOUT; # suppress "... in existing browser session." | ||||
close STDERR; # suppress "... g_slice_set_config ..." | ||||
# or "... write error: ..." | ||||
($arg) ? exec @args : system @args; | ($arg) ? exec @args : system @args; | |||
} elsif ($browser =~ /z/) { | } elsif ($browser =~ /z/) { | |||
($arg) ? exec @args : system @args; | ($arg) ? exec @args : system @args; | |||
} else { | } else { | |||
die $msg if $arg eq 'cmd'; | die $msg if $arg eq 'cmd'; | |||
unless ($id) { | unless ($id) { | |||
$pid = "$ENV{'HOME'}/.mosaicpid"; | $pid = "$ENV{'HOME'}/.mosaicpid"; | |||
$id = <PID>, close PID if open(PID, "< $pid"); | $id = <PID>, close PID if open(PID, "< $pid"); | |||
$id =~ s/\D.*//; | $id =~ s/\D.*//; | |||
die "$0: cannot get pid from $pid ($!)\n" if ! $id; | die "$0: cannot get pid from $pid ($!)\n" if ! $id; | |||
skipping to change at line 362 | skipping to change at line 372 | |||
# | # | |||
# Note: this is heuristic, not-at-all foolproof, and may not scale well | # Note: this is heuristic, not-at-all foolproof, and may not scale well | |||
# to large texts. | # to large texts. | |||
sub markup { | sub markup { | |||
local($_) = join('', @_); | local($_) = join('', @_); | |||
local($shor) = join('|', @short ? @short : 'tinyurl\.com'); | local($shor) = join('|', @short ? @short : 'tinyurl\.com'); | |||
local($host) = '[-\w.]*\w'; | local($host) = '[-\w.]*\w'; | |||
local($fqdn) = $host . '\.\w{2,}'; | local($fqdn) = $host . '\.\w{2,}'; | |||
local($addr) = '[-+\w.%!]*\w@' . $host; | local($addr) = '[-+\w.%!]*\w@' . $host; | |||
local($fddr) = '[-+\w.%!]*\w@' . $fqdn; | ||||
local($path) = '[-+\w.]+(/[-+\w.]+)*/?'; | local($path) = '[-+\w.]+(/[-+\w.]+)*/?'; | |||
local($urlp) = '/[^\s\'"`<>()\[\]{}]*'; | local($urlp) = '/[^\s\'"`<>()\[\]{}]*'; | |||
local($from) = '(^|\n)(From|To|Cc):[^\n]*'; | local($from) = '(^|\n)(From|To|Cc):[^\n]*'; | |||
local($ngrp) = '(^|\n)(Newsgroups):[^\n]*'; | local($ngrp) = '(^|\n)(Newsgroups):[^\n]*'; | |||
local($mesg) = '(^|\n)(Message-ID|References):[^\n]*'; | local($mesg) = '(^|\n)(Message-ID|References):[^\n]*'; | |||
local($xref) = '(^|\n)(Xref):[^\n]*'; | local($xref) = '(^|\n)(Xref):[^\n]*'; | |||
1 while s/($xref):/$1:/ogi; | 1 while s/($xref):/$1:/ogi; | |||
$pUR = "(\<URL:\\s*)([^\&\\s]+)"; | $pUR = "(\<URL:\\s*)([^\&\\s]+)"; | |||
s~$pUR~$1<A HREF="$2">$2</A>~ogi; | s~$pUR~$1<A HREF="$2">$2</A>~ogi; | |||
$pSH = "(^|[^-\\w.\">/\@])(($shor)[/?]+\\w+)"; | $pSH = "(^|[^-\\w.\">/\@])(($shor)[/?]+\\w+)"; | |||
s~$pSH~$1<A HREF="http://$2">$2</A>~ogi; | s~$pSH~$1<A HREF="http://$2">$2</A>~ogi; | |||
$pWW = "(^|[^-\\w.\">/\@])(www\\.$fqdn)($urlp)?"; | $pWW = "(^|[^-\\w.\">/\@])(www\\.$fqdn)($urlp)?"; | |||
s~$pWW~$1<A HREF="http://$2$3">$2$3</A>~ogi; | s~$pWW~$1<A HREF="http://$2$3">$2$3</A>~ogi; | |||
$pFT = "(^|[^-\\w.\">/\@])(ftp\\.$fqdn)($urlp)?"; | $pFT = "(^|[^-\\w.\">/\@])(ftp\\.$fqdn)($urlp)?"; | |||
s~$pFT~$1<A HREF="ftp://$2$3">$2$3</A>~ogi; | s~$pFT~$1<A HREF="ftp://$2$3">$2$3</A>~ogi; | |||
$pFP = "(^|[^-\\w.\">/\@])($fqdn):(/?)($path)"; | $pFP = "(^|[^-\\w.\">/\@])($fqdn):(/?)($path)"; | |||
s~$pFP~$1<A HREF="ftp://$2/$4">$2:$3$4</A>~og; | s~$pFP~$1<A HREF="ftp://$2/$4">$2:$3$4</A>~og if $markup_ftp; | |||
$pUL = "(^|[^-\\w.\">/])(\\w+:$urlp)"; | $pUL = "(^|[^-\\w.\">/])(\\w+:/$urlp)"; | |||
s~$pUL~$1<A HREF="$2">$2</A>~og; | s~$pUL~$1<A HREF="$2">$2</A>~og; | |||
$pLF = "(^|\\s)(/$path)(\\s|\$)"; | $pLF = "(^|\\s)(/$path)(\\s|\$)"; | |||
s~$pLF~$1<A HREF="file:$2">$2</A>$4~og; | s~$pLF~$1<A HREF="file:$2">$2</A>$4~og if $markup_file; | |||
$pFR = "($from([ \\t]|\<))($addr)"; | $pFR = "($from([ \\t]|\<))($addr)"; | |||
1 while s~$pFR~$1<A HREF="mailto:$5">$5</A>~ogi; | 1 while s~$pFR~$1<A HREF="mailto:$5">$5</A>~ogi; | |||
$pNG = "(${ngrp}[ \\t,])([-+\\w]+(\\.[-+\\w]+)+)"; | $pNG = "(${ngrp}[ \\t,])([-+\\w]+(\\.[-+\\w]+)+)"; | |||
1 while s~$pNG~$1<A HREF="news:$4">$4</A>~ogi; | 1 while s~$pNG~$1<A HREF="news:$4">$4</A>~ogi; | |||
$pID = "($mesg\<)([^\&\\s]+\@$host)(\>)"; | $pID = "($mesg\<)([^\&\\s]+\@$host)(\>)"; | |||
1 while s~$pID~$1<A HREF="news:$4">$4</A>$5~ogi; | 1 while s~$pID~$1<A HREF="news:$4">$4</A>$5~ogi; | |||
$pAD = "(^|[\\s,])($addr)"; | $pAD = "(^|[\\s,])($fddr)"; | |||
s~$pAD~$1<A HREF="mailto:$2">$2</A>~og; | s~$pAD~$1<A HREF="mailto:$2">$2</A>~og; | |||
$pAS = "(\<)([-+\\w.]{0,13}\\w\@$host)(\>)"; | $pAS = "(\<)([-+\\w.]{0,13}\\w\@$host)(\>)"; | |||
s~$pAS~$1<A HREF="mailto:$2">$2</A>$3~ogi; | s~$pAS~$1<A HREF="mailto:$2">$2</A>$3~ogi; | |||
$pAR = "(\<)([^\&\\s\@<]+\@$host)(\>)"; | $pAR = "(\<)([^\&\\s\@<]+\@$host)(\>)"; | |||
s~$pAR~$1<A HREF="news:$2">$2</A>$3~ogi; | s~$pAR~$1<A HREF="news:$2">$2</A>$3~ogi; | |||
$_; | $_; | |||
} | } | |||
End of changes. 13 change blocks. | ||||
14 lines changed or deleted | 25 lines changed or added |