diff options
-rwxr-xr-x | config.bsh | 65 | ||||
-rwxr-xr-x | infocat | 180 | ||||
-rwxr-xr-x | routing.php | 47 |
3 files changed, 0 insertions, 292 deletions
diff --git a/config.bsh b/config.bsh deleted file mode 100755 index 330af95..0000000 --- a/config.bsh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# --------------------------------------------------------- -# config.bsh -# --------------------------------------------------------- -# -# PURPOSE -# This bash script autoconfigures and generates the alias i2h, to run -# from the directory where config.bsh is executed. -# -# DESCRIPTION -# Run this script once from the directory where info2html, infocat, -# info2html.config, info2html.css live. Add the generated alias to -# your .bashrc. Enjoy! -# -# AUTHORS -# 2015.12.25 +A.M.Danischewski <adam_ lastname@not gamil.com> -# -# ORIGINAL AUTHOR -# 2015.12.25 +A.M.Danischewski <adam_ lastname@not gamil.com> -# -# HISTORY -# 2015.12.25 V 2.1 Initial Version. -# +A.M.Danischewski <adam_ lastname@not gamil.com> -# 2015.12.25 V 2.1 Moved alias file to a variable, cleaned up some -# alias logic. Now, $> i2h nasm == $> i2h nasm TOP -# +A.M.Danischewski <adam_ lastname@not gamil.com> -# 2015.12.25 V 2.1 Moved PHP_PORT variable up and changed the -# to dynamically reference the TESTURL -# +A.M.Danischewski <adam_ lastname@not gamil.com> -# Caveat: If you are using not Linux (e.g. Unix), change the DISCARD_DEV -# below from /dev/random to /dev/null. -# -# ------------------------------------------------------- - -declare -ir PHP_PORT=8555 -declare -r TESTURL="http://localhost:${PHP_PORT}/info2html?%28coreutils.info.gz%29Common%2520options" -declare -r FAV_WEBBROWSER=firefox ### CHANGE THIS IF NECESSARY -declare -r DISCARD_DEV="/dev/random" ### CHANGE IF NECESSARY,/dev/null -declare -r I2H_ALIASFILE="i2h.alias" - -echo "Starting php built-in web server ... " -php -S localhost:${PHP_PORT} -t / $(pwd)/routing.php &>"${DISCARD_DEV}" & -echo "Checking for ${FAV_WEBBROWSER} and loading a test url: " -echo " ${TESTURL} ..." -which "${FAV_WEBBROWSER}" &>"${DISCARD_DEV}" && "${FAV_WEBBROWSER}" "${TESTURL}" || echo "Point your favorite web browser at: ${TESTURL}" -echo "The following alias will run the html version of info, if you don't have firefox edit this script to your favorite browser. It will check if the php server is running and launch info2html." -echo "Creating ${I2H_ALIASFILE} file.. " -echo "alias i2h='_(){ main=\${1}; ((\$#==0)) && starturl=\"infocat\" || { shift; starturl=\"info2html?(\${main})\$(sed \"s/ /%2520/g\" <<< \"\${@:-TOP}\")\";}; port=${PHP_PORT}; netstat -an | { ! grep -q \":\${port}.*LISTEN\"; } && (php -S localhost:\${port} -t / $(pwd)/routing.php &>\"${DISCARD_DEV}\" & ); firefox \"http://localhost:\${port}/\${starturl}\"; }; _'" > ./"${I2H_ALIASFILE}" -echo -e "\n *** MANUAL STEP *** " -echo " * Source the alias file, as follows: " -echo " $> . ${I2H_ALIASFILE}" -echo " * Test it as follows: " -echo " $> i2h " -echo " * Edit the alias (if necessary) until it works." -echo " * Add the alias entry in the i2h.alias file to your .bashrc file. " -echo -e "\nalias i2h='_(){ main=\${1}; ((\$#==0)) && starturl=\"infocat\" || { shift; starturl=\"info2html?(\${main})\$(sed \"s/ /%2520/g\" <<< \"\${@:-TOP}\")\";}; port=${PHP_PORT}; netstat -an | { ! grep -q \":\${port}.*LISTEN\"; } && (php -S localhost:\${port} -t / $(pwd)/routing.php &>\"${DISCARD_DEV}\" & ); firefox \"http://localhost:\${port}/\${starturl}\"; }; _'\n" -echo "After sourcing/adding the alias in .bashrc; you can run info2html, via i2h alias, as follows:" -echo " \$> i2h coreutils wc invocation" -echo " ## Or, to bring up the info catalog, with simply i2h by itself:" -echo " \$> i2h " -echo -e "\n Done!!\n" -echo " Notes: " -echo " If you move this software to a new home, just re-run ${0##/} to a generate a new alias." -echo " The PHP webserver stays in bg, you may also want a new alias w/\"kill \$(pidof php)\"." -exit 0 diff --git a/infocat b/infocat deleted file mode 100755 index fa19345..0000000 --- a/infocat +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/perl -#--------------------------------------------------------- -# infocat -#--------------------------------------------------------- -# -# PURPOSE -# This perl script prints a catalog of the info files -# available via info2html at this site. -# -# AUTHORS -# 2015.12.25 +A.M.Danischewski <adam_ lastname@not gamil.com> -# 2006.08.16 Sean M. Burke <sburke@cpan.org> -# -# ORIGINAL AUTHOR -# 1997.05.16 Jon Howell <jonh@cs.dartmouth.edu> -# -# HISTORY -# 1997.05.16 V 1.0 -# 1998.05.05 V 1.2 became part of info2html distribution -# Jon Howell <jonh@cs.dartmouth.edu> -# 2006-08-16 V 2.0 The sorting routines are more complex now, -# in an effort to produce more concise output. -# Also: CSS added, HTML modernized a bit. -# Sean M. Burke <sburke@cpan.org> -# 2015-12-25 V 2.1 Hacked into a quasi PHP-CGI, removed -# the manual configuration of the conf file, -# presumes the conf file is in the same dir, -# removed the CGI header and warnings. -# +A.M.Danischewski <adam_ lastname@not gamil.com> -# -#------------------------------------------------------- - -$VERSION = "2.1"; -use File::Basename; -$CURRENT_PATH=dirname(__FILE__); - ## If you really want your config file in a custom location, - ## (e.g. ~/.config) then change this next variable accordingly. -$INFO2HTMLCONF = $CURRENT_PATH."/info2html.conf"; -require 5; -require($INFO2HTMLCONF); #-- configuration settings -use CGI; - -#-- patterns -$NODEBORDER = '\037\014?'; #-- delimiter of an info node -$REDIRSEP = '\177'; #-- delimiter in tag tables -$WS = '[ \t]+'; #-- white space + -$WSS = '[ \t]*'; #-- white space * -$TE = '[\t\,\.\n]'; #-- end of a tag -$TAG = '[^\t\,\.\n]+'; #-- pattern for a tag -$FTAG = '[^\)]+'; #-- pattern for a file name in - #-- a cross reference - -#--------------------------------------------------------- -# Escape -#--------------------------------------------------------- -# This procedures escapes some special characeters. The -# escape sequence follows the WWW guide for escaped -# characters in URLs -#--------------------------------------------------------- -sub Escape{ - local($Tag) = @_; - #-- escaping is not needed anymore KG/28.6.94 - # $Tag =~ s/ /%20/g; # space - # $Tag =~ s/\+/%AB/g; # + - #-- oh yes it is -- jonh 5/16/97 - #$Tag; - return CGI::escape($Tag); -} - -#---------------------------------------------------------- -# DeEscape -#---------------------------------------------------------- -sub DeEscape{ - local($Tag) = @_; - #-- deescaping is not needed anymore. KG/28.6.94 - #$Tag =~ s/%AB/+/g; - #$Tag =~ s/%20/ /g; - #-- yes it is jonh 5/16/97 - #$Tag; - return CGI::unescape($Tag); -} - -# -#------------------- MAIN ----------------------------- -# - ### No more need for CGI headers, we are using PHP - ### V 2.1 Change +A.M.Danischewski 20151225 -#print CGI::header('-type'=>'text/html', - #'-expires'=>60*60*24); - ## expires each day, in case I add new .info files - ## to the @INFODIR path. - # -- jonh 1998.05.04 - -print "<html><title>Info2HTML Catalog</title>\n"; -print "$HTML_HEAD_STUFF</head><body class='infocat'>\n"; - -my( %Desc2BaseExt, %BaseFreq, %BaseExt2Base ); - -foreach $dir (@INFODIR) { - opendir(DIR, $dir) or next; - while ($baseext = readdir(DIR)) { - next if $infofile eq '.' or $infofile eq '..'; - my $base; - if ($baseext =~ m/^(.+)\.info\.bz2$/ ) { - $base = $1; - next unless open INFOFILE, "bzcat $dir/$baseext|"; - $collect = 0; - } - elsif ($baseext =~ m/^(.+)\.info\.gz$/ ) { - $base = $1; - next unless open INFOFILE, "gzip -dc $dir/$baseext|"; - $collect = 0; - } - elsif ($baseext =~ m/^(.+)\.info$/) { - $base = $1; - next unless open INFOFILE, $dir."/".$baseext; - $collect = 0; - } - else { - next; - } - $filedesc = ""; - $BaseFreq{$base}++; - $BaseExt2Base{$baseext} = $base; - while (<INFOFILE>) { - last if (m/END-INFO-DIR-ENTRY/); - # featurebug: we read only the first dirblock - - s/^\* //; - if ($collect and not ($_ =~ m/^[\s\n]*$/)) { - $filedesc .= "<br>" if ($collect < 4); - $filedesc .= $_; - --$collect; - $filedesc .= " <b class='elided'>...</b>\n" unless $collect; - } - $collect=4 if (m/START-INFO-DIR-ENTRY/); - # 4 = max number of entries per file that we show - } - close INFOFILE; - $Desc2BaseExt{ $filedesc || $baseext } = $baseext; - } - closedir(DIR); -} - -print "<h2>GNU info on the following topics is available here:</h2>\n"; -print "<ul>\n"; - -# Now output the list, cleverly sorting and linking... -foreach my $desc (sort { lc($a) cmp lc($b) } keys %Desc2BaseExt) { - my $baseext = $Desc2BaseExt{$desc}; - my $base = $BaseExt2Base{$baseext}; - my $thisdesc = $desc; - my $fn = $baseext; - - if( $BaseFreq{$base} == 1 ) { # the common case: we get to be terse - $fn = $base; - - if( $thisdesc =~ m{^([^ :]+):\s+\(([^ :\(\)]+)\)\.?}s - # Like: "crunkapalooza: (crunkapalooza). Crunkulate things!" - and lc($2) eq lc($base) and lc($2) eq lc($1) - ) { - # a common subcase: the first line is pointlessly verbose, so trim: - $thisdesc =~ s{^([^ :]+):\s+\(([^ :\(\)]+)\)\.?}{$1: }s; - } else { - $thisdesc = $base if $thisdesc eq $baseext; - } - } - - print "<li class='infocatline'><a href=\"info2html?($fn)Top\">", - $thisdesc, "</a>\n" ; -} - -print "</ul>\n", <<"EOF"; -\n<div class='generator'> -<hr> -<em>automatically generated by </em> -<a href="$DOC_URL">info2html v$VERSION</a> -</div></body></html> -EOF - diff --git a/routing.php b/routing.php deleted file mode 100755 index b8ec8d0..0000000 --- a/routing.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -//--------------------------------------------------------- -// routing.php -//--------------------------------------------------------- -// -// PURPOSE -// This php script routes calls to the info2html scripts, infocat and -// info2html for the PHP built-in webserver (like a PHP mod_rewrite). -// -// DESCRIPTION -// How to use: -// * Start the php webserver, wherever this file is found, or provide full path: -// $> php -S localhost:8000 -t / routing.php -// * Start browsing! Visit: -// http://localhost:8000/info2html?(coreutil)Top -// Note: Before you use this, edit the following variable to point to the -// info2html Perl script. -// Also make sure that your info share directory is listed in the -// info2html.conf file (mine wasn't I had to add /usr/share/info). -// -// AUTHORS -// 2015.12.25 +A.M.Danischewski <adam_ lastname@not gamil.com> -// -// ORIGINAL AUTHOR -// 2015.12.25 +A.M.Danischewski <adam_ lastname@not gamil.com> -// -// HISTORY -// 2015.12.25 V2.1 Initial version -// +A.M.Danischewski <adam_ lastname@not gamil.com> -// -// Copyrighted by A.M.Danischewski 2015+ (c) -// You may reuse this code without limit, provided this notice remain in tact. -// -$info2html_basepath=realpath(dirname(__FILE__)); -$page=""; -if (preg_match('/info2html/', $_SERVER["REQUEST_URI"])) { - if (isset($_SERVER['QUERY_STRING'])) $page=$_SERVER["QUERY_STRING"]; else print_r($_SERVER); - // Calls info2html, same as if info2html were called from the commmand line. - System($info2html_basepath."/info2html \"".$page."\""); -} else if (preg_match('/infocat/', $_SERVER["REQUEST_URI"])) { - // Calls infocat, same as if info2html were called from the commmand line. - System($info2html_basepath."/infocat"); -} -else { - return FALSE; -} -?> |