* Update to packages/alpine.spec to account for the new location of man
[alpine.git] / doc / tech-notes / pnuts.4tech-notes
blob33e8d49f08fd78e1ad5c4edf685d8b9e14f9c54f
1 #!/usr/local/bin/perl
2 #################################################
3 #pnuts version 0.4 part of the WN server package
4 #################################################
5 # for more info, see http://hopf.math.nwu.edu/docs/utility.html#pnuts
6 # Modified by Stefan Kramer for use with Pine Technical Notes
7 # Last modified on 1995 Nov. 02
10 require "getopts.pl";
12 # Edit to specify what should appear as text of navigation bar. Note:
13 # If the HTML files processed by PNUTS will be converted to plain-text files,
14 # the PNUTS-generated link text will probably be stripped out, so this
15 # text should be unique (i.e., not expected to occur elsewhere in text).
17 # This is the original link appearance, without graphic buttons
18 # $prevw="<b>Previous</b>";
19 # $nextw="<b>Next</b>";
20 # $upw="<b>Up one level</b>";
21 # $topw="<b>Table of Contents</b>";
22 # $searchw="<b>Search</b>";
23 # $indexw="<b>Index</b>";
25 $prevw='<IMG SRC="../graphics/BPprev.gif" ALT="[Previous]">';
26 $nextw='<IMG SRC="../graphics/BPnext.gif" ALT="[Next]">';
27 $upw=''; # not needed and don't have a graphic for UP
28 $topw='<IMG SRC="../graphics/BPtoc.gif" ALT="[Table of Contents]">';
29 $searchw='<IMG SRC="../graphics/BPsearch.gif" ALT="[Search]">';
30 $indexw=''; # no index here and no graphic for it
34 $VERSION = "0.4";
36 &Getopts('s:i:');
37 $search = $opt_s if $opt_s ne "";
38 $index = $opt_i if $opt_i ne "";
40 $file = shift;
41 $marker = "<!-- pnuts -->";
44 open( LIST, "<$file") || die "Can't open file: $!";
47 $nextfile = <LIST>;
48 print $nextfile;
49 chop( $nextfile);
50 $top = $nextfile;
52 while ( &getnextfile() ) {
53 $curcopy = $currentfile."~";
55 rename( $currentfile, $curcopy)
56 || die "Can't rename file: $currentfile";
57 open( OLDCURR, "<$curcopy" ) || die "Can't open file: $!";
58 open( NEWCURR, ">$currentfile" ) || die "Can't open file: $!";
59 while ( $line = <OLDCURR>) {
60 if ( $line =~ "^$marker") {
61 &pnutline();
63 else {
64 print NEWCURR $line;
67 close( OLDCURR);
68 close( NEWCURR);
72 close( LIST);
73 exit(0);
75 sub pnutline {
76 printf( NEWCURR "$marker");
77 printf( NEWCURR "<P><HR>");
78 if ( $previous ) {
79 printf( NEWCURR " <a href=\"%s\">$prevw</a>", $previous);
81 if ( $nextfile ) {
82 printf( NEWCURR " <a href=\"%s\">$nextw</a>", $nextfile);
84 if ( $up[$curlevel - 1] ) {
85 printf( NEWCURR " <a href=\"%s\">$upw</a>",
86 $up[$curlevel-1]);
88 if ( $top && ( $top ne $currentfile) ) {
89 printf( NEWCURR " <a href=\"%s\">$topw</a>", $top);
91 if ( $search ) {
92 printf( NEWCURR " <a href=\"%s\">$searchw</a>", $search);
94 if ( $index ) {
95 printf( NEWCURR " <a href=\"%s\">$indexw</a>", $index);
97 printf( NEWCURR "\n");
100 sub getnextfile {
101 if ( $nextfile eq "") {
102 return 0;
104 $previous = $currentfile;
105 $up[$curlevel] = $currentfile;
107 $currentfile = $nextfile;
108 while ( 1 ) {
109 ($nextfile = <LIST>) || ($nextfile = "");
110 $nextfile =~ s/(\t*)//;
111 last if $nextfile eq "";
112 print $nextfile;
113 chop( $nextfile);
114 if ( -d $nextfile ) {
115 print "$nextfile is directory, ignoring it\n";
116 next;
118 last;
120 $curlevel = $nextlevel;
121 $nextlevel = length( $1);
122 return 1;