#!/usr/local/bin/perl # # David MacKay 2000 # website.p < file # includer.p file | website.p # file contains document summary # # converted to .bat using pl2bat.p ~/bin/website.p > ~/msdos/website.bat # # known bugs: all occurences of must be on a line by themselves (is this because I need to switch the regexp?) # Wed 31/1/01 added tables in every cell # # upper case conversion: $name =~ tr/a-z/A-Z/; # # DJCM added $wholedocumentpageseparator = "" ; # choose one of these. $wholedocumentpageseparator = "
\n" ; # end DJCM $sitelastmodified="Site last modified"; $includemodifieddate = 1 ; $highlightcurrentcolormain=1; $sbtitleoptions = "" ; $beforefooter=""; $highlightinfreshcolumn=0; # whether the angle marker lives in its own column # separators # horizontal one $pixelname="/images/pixel.gif"; $greycolspan=2; # change this to 3 if the vertical grey object is included. # vertical one $greyverticalfromtop=0; # you might want one or both of $greyverticalfrommiddle=0; # these two, but don't let them clash # rowspans for vertical features: $greyverticallength=1;#rows - change this to 1 if you want the horizontal # to dominate over the vertical $greyverticallength2=1;#rows - change this to 1 if you want the horizontal # to dominate over the vertical $greyverticalwidth=4;#pixels $greybarheight=4; $cellpadding=3; # used in the sidebar, and a few other places but not the main cell $leftpadsidebar=0; # whether to pad the left hand side of the side bar with a ; useful if cellpadding=0. $maincellpadding=6; $greycolor = "#707070" ; $greyverticalcolor=$greycolor; $greyverticalcolor2=$greycolor; # the lower segement, if used. $toprightlogo = ""; # $toprightlogo="
\n"; $toprightlogo = "
want to sponsor our research? - your name here!
\n" ; $toprightlogo = '
Sign the Petition!
'; $toprightlogo = "" ; $headbarpixelunderlined = 1 ; $headbarunderlinedbythickbar = 0 ; $parentname="David MacKay"; $parentheadtext="Parent Organization Head"; $parentheadcolor='#beffd4'; $parentheadbar=0; # whether to include a house style top bar. $parentheadbegin="
"; $parentheadend="
"; $modifiedalign="left" ; # this option only used if $oldstyle $removeablepagespace = '  ' ; # set this to whatever $pagespace object you want removed during highlighting $aliaseserasetopic = 1 ; # use this if you want the alias names to be the topics. If you write the topics yourself then don't use this. $topics=0; # whether to include topics in the metafaq strings $topic=""; $subtopic=""; $subsubtopic=""; $Topic="Topic"; $Subtopic="Subtopic"; $Subsubtopic="Subsubtopic"; $tochead = "\n"; $toctail = "
\n" ; $style=''; ## changed BACK to Mon 29/10/01 (for Kele, ND) (but inadequate) $style=''; ## changed to $style=''; ## Wed 7/11/01 - trying to get font control back to the people ## changed to $style=''; $category=""; $sbtitlefont='' ; $sbtitlefontend='' ; # an alternative for these two # might be: # and $highlightleft = '' ; # 'bgcolor="'.$maincolor.'"' ; # '>' ; # overridden later $highlightright = '←' ; $highlightright = ' <' ; $highlightright = ' «' ; # NB this is overridden later $fancytitle=0; $sidebarheadcolor='not-set' ; $sidebarheadnumber=2 ; # how many of the items to include up top $sidebarcolor='"#eeff90"' ; $sidebarheight=""; $maincolor='"#ffffee"'; $bgcolor='"#ffffee"'; $text='"#000000"'; $link='"#0000C8"'; $alink='"#c80000"'; $vlink='"#c80000"'; $mainwidth='"400"'; $header = 0 ; $headcontents = '' ; $headcharset = "" ; # change this to # for polish $favicon='' ; $dofavicon=0; # Best way to $makepage1index is to use Alias function! $pagespace='  ' ; $omitpage1fromtoc=1; $highlightfont=''; $highlightfontend=''; # this feature not finished: $Extrapage="Extrapage"; # command to write out the next page twice, once sans head and foot. $Alias="Alias"; # command to define an alias. $Page="Page"; # command to start a page $EndPage="EndPage"; # end a page $SectionPage="SectionPage"; # command to start a page and give it section status $foldingpagesactive=1; # whether folding pages is enabled $FoldingPage="FoldingPage"; # command to start a page like "$Page" except that it does not appear in the toc unless we are within the associated section # Note the hiddenpage feature is INCOMPATIBLE with the # "all in one document" feature, since the navigation bar gives # no way of reaching the hidden pages. # But I guess they are still reachable through links # The idea of the hidden page option is it makes it possible # to have a load of thumnails giving links to separate pages, # one per image, without filling the toc with a huge # list of all those images. # The extra hidden pages all look identical, in terms of their sb's toc, # to the most recent non-hidden page. $HiddenPage="HiddenPage"; # command to start a page like "$Page" except that it does not appear in the toc EVER. When on this page, the most recent sidebar toc is used. $FoldingLink="FoldingLink"; # command to make a toc entry that disappears when we are outside its section. $Section="Section" ; # command to include a page-less section $SectionLink="SectionLink" ; # command to include an offsite-link that looks like a section $Link="Link" ; # command to include an offsite-link that looks like a page $Gap="Gap" ; # command to include a gap in the toc $verbose = 0 ; $framesconvertor="" ; # this is the string in which the frames/no-frames is written $shortmultisitestring="Frames version"; $shortsinglesitestring="No-frames version"; $shortsinglesitestring="Single document"; $singlesitestring1="You may also view this site in a"; $singlesitestring2="single document"; $highlightcurrentpage=1; $prefix="p" ; $wholedocumentlinkonpage1=0; # see also singlesite $mainfont=""; $mainfontend=""; # $index=""; # change this to whatever you want the banner at top of sidebar to link to. # this above variable is a bad idea, it allows you to construct incorrect sites with bad links. $linkstylecommand='style="text-decoration: none"' ; $linkstylecommand=""; $gapbeforesection=1 ; $gaprow=" \n" ; # how a gap in the sidebar is rendered $gap=""; $oldstyle=0 ; # old way of rendering the toc, without tables # blob, marker, item $pagemarker="º"; $pagemarker="•"; $pagemarker="¤"; $pagemarker="º"; # high circle $pagemarker="·"; # dot # $pagemarker="\".\""; $pagemarkeroptions="bgcolor=\"#000000\" border=2"; $pagemarkeroptions="" ; $spacewidth=7 ; $tdoptions="nowrap" ; $troptions="valign=top"; ####### $file = $ARGV[0] ; $filehtml = $ARGV[0] ; $directory="webdir" ; $titlegot = 0 ; $absgot = 0 ; $intitle = 0 ; $inabs = 0 ; # the following are macros that get invoked by the user's source document $title = "" ; $abstract = "" ; $pound="£";$pounds=$pound; $parent='TradeNotAid.com'; $tna='TradeNotAid.com' ; $metafaq='Any questions?'; $smallparent=''.$parent.''; sub AUTOLOAD { my $program = $AUTOLOAD; $program =~ s/.*:://; system($program, @_); } # date(); $thedate=`date` ; # open(DA,"date|"); # $thedate=; # close(DA); print "Date is ".$thedate ; $footer='
hosted by '.$parent.'
'; # end footer # BUGS fixed: # May 10th 2000: replace \w+ by [^">]+ in some regexp to allow internal href # that use name-with-hyphen # perl -ne 'print $1,"\n" if (/(\w+)/)' eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $warning708 = 0 ; $warning709 = 0 ; $unreadline = 0 ; # READ HEADER # ================ # read assignments from file # assignments can also be scattered in the bulk of the file, # but the ones in the header have special status because of the block # of special operations below eval "\$$1=\$2" while ($_ = <>) && /^([\w01-9]+)=(.*)/ ; # should ensure that this match is a minimal one? # blank line, or any line that is not an equality, causes move to next item # ideally, should be able to skip over comments! eg \n"; $page[0] .= $page[$p] ; # DJCM if ( $p < $pagenumber ) { $page[0] .= $wholedocumentpageseparator ; } # end DJCM } # now set page to zero # Iain moved where this is added so footer didn't appear below every section # on whole doc version #$page[1] .= "
$singlesitestring1 $singlesitestring2
\n" ; $filename[0] = "$directory/$prefix"."0.html" ; $p=0 ; } else { $p=1 ; } # now, before printing pages 0,1...P, modify all href=# in # pages 1...P (but not 0) to point to the right # pages for ($h=1;$h<=$hrefcount;$h++) { $pp = $pageofref[$h] ; # this page contains the href $thename=$internalhref[$h] ; # this is the "name" in the href=#name $targetpage = $name{$thename} ; # hopefully the name also occurred! if(!($targetpage)) { print STDERR "warning, no targetpage associated with $thename : $name{$thename}\n" ; } if($verbose>2) { print STDERR "substituting $thename in $pp -> $targetpage\n" ; } # count how many substitutions occur.... $number = ( $page[$pp] =~ s/(\<[aA]\s+[Hh][Rr][Ee][Ff]\s*=\s*\"{0,1})(\#$thename[\"]{0,1}\s*\>)/$1$pagename[$targetpage]$2/g ); # " # this commented out, because number is not the count of substns. # if (($number==0) &&($verbose) ) { # print STDERR "$number: warning, $thename not substituted in $pp (pointing to $targetpage)\n" ; # } # no aliases used for internal links in page 0 } print STDERR "substituted $hrefcount internal refs \n" if ($verbose>0) ; # embody the toc $Tocn = $tocn ; sub embody_the_toc { # argument: s = sectionnumber; if argument is negative then use all toc entries (i.e. for page 0) local ($s) = @_ ; if ( ( $s >= 0 ) && $foldingpagesactive ) { $toc = $tochead ; for ( $tocn=0 ; $tocn < $Tocn ; $tocn ++ ) { # the sign of secn[] is used to indicate the folding pages if ( $sec[$tocn] >= 0 || (-$s==$sec[$tocn] ) ) { $toc .= $tocl[$tocn] ; } } $toc .= $toctail ; } else { # just make $toc by joining @tocl. $toc = $tochead.@tocl.$toctail ; } } print STDERR "printing page " ; for ( ; $p<= $pagenumber ; $p ++ ) { if ($topics) { $metafaq = $metafaqs[$p] ; } if ($foldingpagesactive) { $currentsection = $sectionofpage[$p] ; } if ($thispagehidden[$p]) { # leave the toc alone, assume it already exists! $toc=$savelasttoc ; } else { embody_the_toc ( $currentsection ) ; # this creates the variable $toc } if ($p==0) { $framesconvertor = "$shortmultisitestring" ; } else { $framesconvertor = "$shortsinglesitestring" ; } if ($p==0) { $savetoc = $toc ; $toc =~ s/(\)/$highlightleft$highlightfont$2$highlightfontend$highlightright/ ; } else { $toc =~ s/(\]*)(\>.{0,15})(\)/$1$highlightleft$2$highlightfont$3$highlightfontend$highlightright/ ; } $savelasttoc = $toc ; }# see also "here is where the toc entries are made" print STDERR "$p " ; print STDERR "($filename[$p]) " if ($verbose) ; open( O , "> $filename[$p]" ) ; # begin head of web page print O " \n" ; print O "$headcontents$headcharset"; if($dofavicon){ print O "\n$favicon\n" ; } print O "\n"; if ( !($parentname eq "" ) ) { print O "$parentname: "; } print O "$title: $title[$p] \n\n"; print O $style ; print O "\n" ; print O "\n" ; # end of head of web page # if extrapage[$p] then everything following here should be written # to the extrapagename # cellpadding creates padding within a cell print O "\n"; # print O "\n"; print O "\n" ; # was print O "
\n" ; $greyverticals = $greyverticalfromtop || $greyverticalfrommiddle ; if($parentheadbar) { # need to plan the width of the first object if ( $greyverticals && (!$greyverticalfromtop) ) { $parentheadcolspan = 2 ; } else { $parentheadcolspan = 1 ; } print O "\n"; print O "\n" ; print STDERR "greyverticals = $greyverticals \n" if ($verbose) ; if ( $greyverticalfromtop ) { print O "" ; print O "\n" ; } else { # no action needed # print O "" if ($greyverticals) ; } # at present the top right is unused! print O $toprightlogo ; print O " \n" ; if ($headbarunderlinedbythickbar ) { # extra line print O " \n" ; print O "\n" ; } elsif ( $headbarpixelunderlined ) { print O '' ; print O "\n" ; } } print O "\n"; # the sidebar is divided into two pieces - first, 1..sidebarheadnumber; then to sidebarnumber # except it didn't look right, so I have reverted to the old way &do_sidebar(1,$sidebarnumber,$sidebarcolor); # &do_sidebar(1,$sidebarheadnumber,$sidebarheadcolor); if ( $greyverticalfrommiddle ) { # see also greybarfromtop print O "' ; print O "\n" ; } else { print O "" if ($greyverticals) ; } # change this rowspan to 2 to enable the fancy sidebar method print O "\n\n"; # fancy sidebar method: put this back: # # now put the rest of the sidebar # print O " \n" ; # &do_sidebar($sidebarheadnumber+1,$sidebarnumber,$sidebarcolor); # print O " \n" ; print O "
$parentheadbegin \n"; # every item Wed 31/1/01 is now inside its own table print O "\n" ; print O "
\n" ; print O "$parentheadbegin $parentheadtext $parentheadend \n" ; print O "
\n" ; # added Wed 31/1/01 print O "$parentheadend
\".\" 
 
.
.\n" ; # CONTENT!!!!!!!!!!!1 # every item Wed 31/1/01 is now inside its own table print O "
\n" ; print O "$mainfont\n" ; # here is the content print O "$page[$p]\n"; # Iain addition print O $footer; print O $modifieddate if ($includemodifieddate); if ($p==1) { if ($wholedocumentlinkonpage1) { print O "
$singlesitestring1 $singlesitestring2
\n"; } } # Iain addition print O " $mainfontend\n" ; print O "
\n" ; # added Wed 31/1/01 print O "
\n" ; # foot of page starts here print O "\n" ; # foot of page ends here if ($p==0) { # restore proper toc $sbtitle = $savesbtitle ; $toc = $savetoc ; } elsif ($highlightcurrentpage) { $toc = $savetoc ; } } print STDERR "\n done, ignored $unreadline lines\n" ; if ($badinputs) { print STDERR "\n WARNING $badinputs lines with string \\input or \\include \n" ; } sub do_sidebar { local ($begin,$end,$thecolor) = @_ ; print O "\n" ; print O "\n" ; # every item Wed 31/1/01 is now inside its own table print O "\n"; # this feature added to allow left padding without rightpadding if ($leftpadsidebar) { print O "\n"; } print O "
\n" ; print O "$sbfont\n"; # for ($i=$begin;$i<=$end;$i++) { print O "
" ; # was
eval "print O \$$sidebar[$i]" ; print O "
\n" ; # } # print O "$sbfontend\n"; # print O "
\n" ; # added Wed 31/1/01 print O "\n" ; print O "\n" ; }