1#!/usr/bin/perl 2# 3# This script modifies the HTML man pages generated by pod2html. It 4# adds a header and footer, and creates links to other man pages. 5# 6# 7# $Id: add-header.pl 15406 2010-03-03 21:30:43Z tonyc $ 8 9# 10$^W = 1; 11use strict; 12 13# 14use FindBin qw($Bin); 15use lib "$Bin"; 16# TODO: hard-coding this for now, should generate from build the way SiLK does 17our $man_re = "(super_mediator)"; 18 19our $old = $ARGV[0]; 20unless ($old) { 21 die "Usage: $0 <filename>\n\tAdd header and footer to named file\n"; 22} 23our $new = "$old.fixed"; 24 25 26our $IDENT = 'RCSIDENT("$Id: $")'; 27 28 29 30open(OLD, $old) 31 or die "Cannot open '$old' for reading: $!\n"; 32open(NEW, ">$new") 33 or die "Cannot open '$new' for writing: $!\n"; 34 35 36do_manpage(); 37 38 39close OLD; 40close NEW 41 or die "Cannot close '$new': $!\n"; 42 43rename $new, $old 44 or die "Cannot mv $new $old: $!\n"; 45 46exit; 47 48 49sub add_header 50{ 51 my ($title) = @_; 52 53 if ($title) 54 { 55 $title = "Documentation - $title"; 56 } 57 else 58 { 59 $title = "Documentation"; 60 } 61 62 return <<EOF; 63<head> 64<title>super_mediator - $title</title> 65<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 66 67 <link rel="stylesheet" type="text/css" href="../site/style.css" /> 68 69</head> 70<body> 71 <div id="p-body"> 72 <div id="l-header"> 73 <img src="../site/sei-logo.png" id="l-sei-logo" 74 alt="Software Engineering Institute | Carnegie Mellon©" /> 75 <div id="l-netsa-logo"><a id="l-netsa-name" href="../index.html"><b>CERT NetSA Security Suite</b></a></div> 76 <div id="l-netsa-motto">Monitoring for Large-Scale Networks</div> 77 <h1 class="l-page-title">super_mediator</h1> 78 <span id="l-subtitle">Documentation</span> 79 </div><!-- l-header --> 80 <div id="l-content"> 81 <div id="l-sidebar"> 82 <div class="p-sidebar-section"> 83 <h1><a href="index.html">super_mediator</a></h1> 84 <ul> 85 <li><a href="docs.html">Documentation</a></li> 86 <li><a href="download.html">Downloads</a></li> 87 </ul> 88 </div><!-- p-sidebar-section --> 89 </div><!-- l-sidebar --> 90EOF 91} 92 93 94sub add_footer 95{ 96 return <<EOF; 97 </div><!-- l-content --> 98 <div id="l-footer">© 2012-2017 Carnegie Mellon University</div> 99 </div><!-- p-body --> 100</body> 101EOF 102} 103 104 105sub do_manpage 106{ 107 # We'll overwrite this with name of man page 108 my $title = ''; 109 110 my $saw_index = 0; 111 112 # whether we saw the <head> 113 my $saw_head = 0; 114 115 print NEW add_header($title); 116 $/ = ""; # read one paragraph at a time 117 while (<OLD>) { 118 # Remove all <hr> 119 s{<hr\b[^>]*>}{}iog; 120 121 # Stash the title 122 if (m{(<title>)B\<([^\&]+)>}io) { 123 $title = $2; 124 } 125 126 print NEW; 127 } 128 129 print NEW add_footer(); 130} 131# do_manpage 132 133