|
|
|
|
|
00001 // This file has been modified on-the-fly with an input filter 00002 // to change it from Perl syntax to C++ strictly for the purposes 00003 // of faking out Doxygen. Modifications include: 00004 00005 // - changing local() definitions to C++ #define statements. 00006 // - commenting out undef statements. 00007 // - changing $globe'... variable names to $globe_... 00008 // - changing sub statements to look like C++ functions. 00009 // - changing # comments to C++ comments. 00010 // - ... 00011 00012 // If you see other strangeness in the HTML version of the Perl file, 00013 // it comes from getting it to look more C++ like. 00014 00015 00016 // #!/usr/#define/bin/perl 00017 //############################################################################# 00018 /** @file 00019 ** @brief Swaps out tagged areas in all HTML files in a given directory. 00020 ** 00021 ** @param $globe::path location to find the HTML files. 00022 ** The name should be terminated with a slash (\). 00023 ** Although the directory_name is the first command line parameter, 00024 ** the true input are the HTML files contained within that directory. 00025 ** 00026 ** @param $globe::master_nav_file [optional path and] filename for the 00027 ** HTML file to use as the master for information. 00028 ** This file has several specially flagged 00029 ** HTML comment sections that are required. Information from 00030 ** the tagged sections are lifted and placed into the tagged sections 00031 ** of the input HTML files. 00032 ** 00033 ** @retval input_html_file is modified with new information in the tagged 00034 ** areas. This includes the information in the head, navigation at the top 00035 ** of the body, and copyright information at the bottom of the body. 00036 ** 00037 ** @retval _file_list is a temporary file with a list of all HTML files 00038 ** in the given directory. 00039 ** 00040 ** @retval _index_list is a temporary file with extracted index tokens. 00041 ** 00042 ** @retval tree.html is a temporary file with a mini-TOC (table of contents) 00043 ** for the given book. 00044 ** 00045 ** This program does most of the work in creating a comprehensive HTML 00046 ** system that spans the mini-HTML systems generated by Doxygen and Mif2Go 00047 ** (from FrameMaker source). The reason it does most of the work is that 00048 ** it has to read the files anyway. 00049 ** 00050 ** It started out as a tool just to 00051 ** swap out the header, navigation, and copyright areas. 00052 ** However, as long as it was visiting each and every HTML file in the 00053 ** input directory and "knew" what was in those files and how the files 00054 ** related to one another, this tool was expanded to handle generating 00055 ** a mini-TOC file () and an index file. It: <ul> 00056 ** 00057 ** <li>Reads in the master file to acquire information from tagged areas.</li> 00058 ** 00059 ** <li>Creates a list of HTML files in the input directory.</li> 00060 ** 00061 ** <li>Opens each HTML file and swaps out common navigation with that coming 00062 ** from the master file.</li></ul> 00063 ** 00064 ** Before writing a _temp file (and then copying this back over the 00065 ** original input file) and as it processes the file: <ul> 00066 ** 00067 ** <li>It creates several hash tables that ultimately determine topic 00068 ** order, topic level in tree, etc.</li> 00069 ** 00070 ** <li>It generates a mini-TOC file (tree.html) before finishing.</li> 00071 ** 00072 ** <li>It processes object tokens coming from the MS-HTML output of 00073 ** Mif2Go to turn them into index token comments. It also writes these 00074 ** tokens to a temporary file _index_file.</li> 00075 ** 00076 ** <li>From the topic hash tables, it generates more index tokens for 00077 ** the _index_file.</li> 00078 ** </ul> 00079 ** 00080 ** @lim In order for this to work correctly, the file names for the chapters 00081 ** have to be named correctly so that they sort into a natural order. This 00082 ** is achieved by having the generation place the same prefix on all HTML 00083 ** files for a given chapter. I chose a two-digit number followed by an 00084 ** underscore. In this manner, all files for a given chapter are grouped 00085 ** together by the prefix. Earlier processing of the files determined which 00086 ** of those topics was the first and last for the chapter. 00087 ** 00088 ** Rather than passing in variables which can create copies in memory, many items 00089 ** use global variables that are defined in globe.pm. When a 00090 ** variable is known to be global, its name begins with "$globe::". The intent is 00091 ** to facilitate maintenance by having all user-defined tags in one place outside 00092 ** of the program. 00093 ** 00094 ** This used information that came specifically from our implementation 00095 ** of styles in FrameMaker. In particular, we know what the format names are 00096 ** that are used for chapter headings. The number is picked off of that. 00097 ** 00098 ** @ingroup tp_tools tp_nav 00099 ** 00100 ** @author Glenn C. Maxey 00101 ** 00102 **/ 00103 // # $Id: voyant_nav.pl,v 1.45 2002/11/20 15:23:08 gmaxe Exp $ 00104 //# 00105 //# 2002 Created by Voyant Technologies, Inc., Westminster, Colorado, USA. 00106 //# 00107 //# Permission to use, copy, modify, and distribute this software and its 00108 //# documentation under the terms of the GNU General Public License is hereby 00109 //# granted. No representations are made about the suitability of this software 00110 //# for any purpose. It is provided "as is" without express or implied warranty. 00111 //# See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) 00112 //# for more details. 00113 //# 00114 //# Documents produced by this script are derivative works derived from the 00115 //# input used in their production; they are not affected by this license. 00116 //# 00117 //# Revision Information: 00118 //# 00119 //# $Log: voyant_nav.pl,v $ 00120 //# Revision 1.45 2002/11/20 15:23:08 gmaxe 00121 // //# Added exit codes so that wrapper scripts can catch errors properly. 00122 //# 00123 //# Revision 1.44 2002/11/20 01:49:14 gmaxe 00124 // //# Minor changes to exit codes. 00125 //# 00126 //# Revision 1.43 2002/07/26 18:56:13 gmaxe 00127 //# Got rid of old definitions and migrated new structures into all; 00128 //# enhanced xhelp output file names and format; now everything is 00129 //# alphebetized. 00130 //# 00131 //# Revision 1.42 2002/07/22 23:05:43 gmaxe 00132 //# Added additional input parameter for project information. 00133 //# Needed for proper ordering. 00134 //# 00135 //# Revision 1.41 2002/07/03 23:07:23 gmaxe 00136 //# Added support for mif2go index tokens. Later, remove the old 00137 //# style index tokens and objects. 00138 //# 00139 //# Revision 1.40 2002/07/02 23:10:54 gmaxe 00140 //# Tweaked to get rid of extra expanding line feeds in voyant_nav.pl. 00141 //# Added topper.html and other files to skip list in globe.pm. 00142 //# Enhanced log_html_gen.gl to handle new format of message.txt; 00143 //# it now has a flatter data structure and no enums numbers. 00144 //# 00145 //# Revision 1.39 2002/06/24 19:14:09 gmaxe 00146 //# Added support for Decision Tree: involved new FM format as well as 00147 //# new handling of HTML pages with multiple H1 targets. Had to create 00148 //# the appropriate entries in the first/last arrays as well as 00149 //# get the tracing of the output arrays proper. 00150 //# PTR#: 00151 //# 00152 //# Revision 1.38 2002/05/08 15:26:57 gmaxe 00153 //# Minor scoping error on Order key. 00154 //# 00155 //# Revision 1.37 2002/04/24 00:08:56 gmaxe 00156 //# Improved how items are excluded from xhelp_gen.pl, because 00157 //# they were creeping back in when file got processed. 00158 //# 00159 //# Revision 1.36 2002/04/12 18:01:15 gmaxe 00160 //# Various tweaks; work on tag extraction and change_nav; 00161 //# more exclused special perl characters from indexer; 00162 //# improved support for sapi group pm files in xhelp. 00163 //# spider tool now works regularly and as expected. 00164 //# 00165 //# Revision 1.35 2002/04/06 01:55:18 gmaxe 00166 //# New files and new general constructs for handling tags. Uses globals better. 00167 //# The html_look* files are designed to handle spider tracing of html systems. 00168 //# 00169 //# Revision 1.34 2002/03/13 18:54:29 gmaxe 00170 //# Minor improvement to skip proper files and definitions. 00171 //# 00172 //# Revision 1.33 2002/03/05 01:47:42 gmaxe 00173 //# Supports previous/next on Doxygen files; 00174 //# supports better script generation. 00175 //# 00176 //# Revision 1.32 2002/02/28 00:41:23 gmaxe 00177 //# Added support for nested script files; not yet turned on. 00178 //# Re-arrange file; created more subroutines. 00179 //# 00180 //# Revision 1.31 2002/02/16 00:59:46 gmaxe 00181 //# Added support for script files needed for TOC applet. 00182 //# 00183 //# Revision 1.30 2002/02/12 01:50:29 gmaxe 00184 //# Added support for more level chunking; 00185 //# added files to support xhelp; 00186 //# added file to support generating TOC, index from lists. 00187 //# PTR#: 00188 //# 00189 //# Revision 1.29 2002/02/02 01:48:54 gmaxe 00190 //# Supports index tokens from all dox files; 00191 //# supports used-by index tokens. 00192 //# asn_bapitypes.pl is a new file to handle remerging of comments 00193 //# into what the tools see. 00194 //# 00195 //# Revision 1.28 2002/01/16 19:49:10 gmaxe 00196 //# Removed much of revision history in comments. 00197 //# 00198 //# Revision 1.27 2002/01/11 21:53:55 gmaxe 00199 //# Updated comments. 00200 //# 00201 //############################################################################# 00202 00203 00204 //############################################################################# 00205 /** @fn int BEGIN 00206 ** @brief Code to execute when first entered. 00207 ** 00208 ** @param None. 00209 ** 00210 ** @return None. 00211 ** 00212 ** @lim None 00213 ** @ingroup tp_nav 00214 **/ 00215 // ############################################################################# 00216 int BEGIN ( ) { 00217 // print "\n============ Starting voyant_nav.pl ==================================\n"; 00218 $_file_list = "_file_list"; 00219 $_index_file = "_index_list"; 00220 $scope_pm = "globe.pm"; 00221 $_arg_inc = 0; 00222 $in_file = ""; 00223 $f_type = "htm"; 00224 $no_scope_file = 0; 00225 00226 push (@INC, `pwd`); 00227 push (@INC, '../perl'); 00228 push (@INC, '/rtfm/techpubs/perl'); 00229 if (0){ 00230 // print (@INC, "\n"); 00231 } 00232 // #### 00233 // All global variables are defined in the following file 00234 // #### 00235 unless (open ( IN_LIST, $scope_pm)) { 00236 unless (open ( IN_LIST, "../perl/$scope_pm")) { 00237 unless (open ( IN_LIST, "/rtfm/techpubs/perl/$scope_pm")) { 00238 push (@file_errors, "Cannot open file \"$scope_pm\" or \"../perl/$scope_pm\" or \"/rtfm/techpubs/perl/$scope_pm\"\n"); 00239 $no_scope_file++; 00240 } 00241 } 00242 } 00243 // close (IN_LIST); 00244 push (@INC, $scope_pm); 00245 push (@INC, "../perl/$scope_pm"); 00246 push (@INC, "/rtfm/techpubs/perl/$scope_pm"); 00247 00248 if (!@file_errors) { 00249 // #### 00250 // All global variables are defined in the following file 00251 // #### 00252 require $scope_pm; 00253 00254 if (&globe::declare_variables()) { 00255 // print "Variables initialized from $scope_pm.\n"; 00256 } else { 00257 push (@file_errors, "Could not initialize variables from $scope_pm.\n"); 00258 } 00259 } // if not @file_errors 00260 00261 if (@ARGV < 1) { 00262 push (@file_errors, "No path specified as first argument.\n"); 00263 } 00264 00265 // Get path if there is one. 00266 if (@ARGV > $_arg_inc) { 00267 $globe::path = @ARGV[$_arg_inc]; 00268 if ($globe::path =~ /\//) { 00269 // print "The path specified is $globe::path\n"; 00270 00271 @path_chunks = split ( /\//, $globe::path); 00272 if (@path_chunks < 2) { 00273 $globe::rel_path_to_start_point = "./"; 00274 } else { 00275 $globe::rel_path_to_start_point = "../"; 00276 } 00277 } else { 00278 push (@file_errors, "The input argument \"$globe::path\" requires a forward slash (\/).\n"); 00279 } 00280 } // if 1 or more arguments 00281 $_arg_inc++; 00282 00283 if (@ARGV > $_arg_inc) { 00284 $globe::master_nav_file = @ARGV[$_arg_inc]; 00285 // print "The master file is $globe::master_nav_file\n"; 00286 unless (open ( IN_MASTER, $globe::master_nav_file)) { 00287 push (@file_errors, "Cannot open file \"$globe::master_nav_file\"\n"); 00288 } 00289 // Get the master definitions 00290 while (<IN_MASTER>){ // entire master file into memory. 00291 $globe::master_nav .= $_; 00292 } 00293 // close (IN_MASTER); 00294 } // if 2 or more arguments 00295 $_arg_inc++; 00296 00297 if (@ARGV > $_arg_inc) { 00298 $globe::master_nav_file2 = @ARGV[$_arg_inc]; 00299 // print "The master file is $globe::master_nav_file2\n"; 00300 unless (open ( IN_MASTER, $globe::master_nav_file2)) { 00301 push (@file_errors, "Cannot open file \"$globe::master_nav_file2\"\n"); 00302 } 00303 // Get the master definitions 00304 while (<IN_MASTER>){ // entire master file into memory. 00305 $globe::master_nav .= $_; 00306 } 00307 // close (IN_MASTER); 00308 } // if 2 or more arguments 00309 $_arg_inc++; 00310 } 00311 00312 //############################################################################# 00313 /** @fn int main 00314 ** @brief The main program. 00315 ** 00316 ** @param None. 00317 ** 00318 ** @return None. 00319 ** 00320 ** @lim None 00321 ** @ingroup tp_nav 00322 **/ 00323 // ############################################################################# 00324 // sub main { 00325 { 00326 // ############################################################################# 00327 // # Program start 00328 // ############################################################################# 00329 00330 if (0){ 00331 // print "=== Definitions 3 \n"; 00332 // print "=== header ==== $globe::m_define{header}[0]\n"; 00333 // exit(1); 00334 } 00335 if (@file_errors) { 00336 // Makes no sense to go on if input parameters are off. 00337 // print "\n============ Summary of errors ==================================\n"; 00338 for ($i=0; $i<@file_errors; $i++){ 00339 // print "$i = $file_errors[$i]\n"; 00340 } 00341 &using_voy_nav(); 00342 // exit(1); 00343 } 00344 00345 if (&globe::get_master_nav_info() =~ 1){ 00346 // print "Master Navigation file \"$globe::master_nav_file\" has definition errors.\n"; 00347 if (@file_errors) { 00348 // print "\n============ Summary of errors ==================================\n"; 00349 for ($i=0; $i<@file_errors; $i++){ 00350 // print "$i = $file_errors[$i]\n"; 00351 } 00352 } 00353 // exit(1); 00354 } else { 00355 // Create special navigation in the footer that repeats buttons. 00356 $globe::voy_footer_fm = "$globe::m_define{footer}[0]"; 00357 $globe::voy_footer_dox = "$globe::m_define{footer}[0]"; 00358 $def_type = "nav_book"; 00359 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::m_info{$def_type}, 00360 $globe::m_define{$def_type}[0], 00361 $globe::m_define{$def_type}[1], 00362 $very_critical); 00363 00364 if ($piece) { 00365 $globe::voy_footer_fm .= "\n<br><br>\n$piece\n"; 00366 } 00367 $def_type = "nav_doxygen"; 00368 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::m_info{$def_type}, 00369 $globe::m_define{$def_type}[0], 00370 $globe::m_define{$def_type}[1], 00371 $very_critical); 00372 if ($piece) { 00373 $globe::voy_footer_dox .= "\n<br><br>\n$piece\n"; 00374 } 00375 00376 $def_type = "footer"; 00377 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::m_info{$def_type}, 00378 $globe::m_define{$def_type}[0], 00379 $globe::m_define{$def_type}[1], 00380 $very_critical); 00381 00382 if ($piece) { 00383 $globe::voy_footer_fm .= "$piece"; 00384 } 00385 $globe::voy_footer_fm .= "$globe::m_define{footer}[1]"; 00386 if ($piece) { 00387 $globe::voy_footer_dox .= "$piece"; 00388 } 00389 $globe::voy_footer_dox .= "$globe::m_define{footer}[1]"; 00390 00391 00392 // 4/22/2002 Changed because introduced an off-by-one error. 00393 // $globe::master_order_key = @globe::master_order; # sets the default value 00394 $globe::master_order_key = $// globe::master_order; # sets the default value 00395 for ($i=0; $i < $// globe::master_order; $i++){ 00396 // does not go to the last one, because that is the default, already set 00397 if ($globe::path =~ /$globe::master_order[$i]/){ 00398 $globe::master_order_key = $i; 00399 if (1) { 00400 // print "Order key $i with directory \"$globe::master_order[$globe::master_order_key]\"\n"; 00401 // print "Title is \"$globe::master_order_title[$globe::master_order_key]\"\n"; 00402 } 00403 } 00404 } 00405 if (0) { 00406 // print "=== Master Header ==\n$globe::m_info{header}\n"; 00407 // print "=== Master Common Top ==\n$globe::m_info{nav_common}\n"; 00408 // print "=== Master Doxygen ==\n$globe::m_info{nav_doxygen}\n"; 00409 // print "=== Master FM Book ==\n$globe::m_info{nav_book}\n"; 00410 // print "=== Master Footer ==>$globe::m_info{footer}<==\n"; 00411 // print "=== Master Dox Footer ==>$globe::voy_footer_dox<==\n"; 00412 // print "=== Master FM Footer ==>$globe::voy_footer_fm<==\n"; 00413 // print "=== Master variables ==\n$globe::m_info{variable}\n"; 00414 // exit(1); 00415 } 00416 } 00417 00418 $_file_list = "$globe::path$_file_list"; 00419 00420 // ################## 00421 // Does most of work and calls change_nav. 00422 // ################## 00423 if (!&generate_and_step_through_list ($_file_list)) { 00424 // exit(1); 00425 } 00426 00427 // ################## 00428 // Take care of file sequence... previous next 00429 // ################## 00430 if ($globe::path =~ /cref/i) { 00431 if (1){ 00432 // print "Starting updating previous\/next designation on all files.\n"; 00433 &do_dox_prev_next(); 00434 // print "Finished updating previous\/next designation.\n"; 00435 } 00436 00437 } 00438 00439 // ################## 00440 // Take care of index tokens 00441 // ################## 00442 if (@globe::index_info) { 00443 unless (open ( OUT_INDEX_LIST, ">$globe::path$_index_file")) { 00444 // print "Cannot open file \"$globe::path$_index_file\"\n"; 00445 // exit(1); 00446 } 00447 for ($i=0; $i<@globe::index_info; $i++){ 00448 // // print "$i = $globe::index_info[$i]\n"; 00449 // print (OUT_INDEX_LIST "$globe::index_info[$i]\n"); 00450 } 00451 // close (OUT_INDEX_LIST); 00452 } 00453 00454 &organize_topic_order(); 00455 00456 // ############################################################################# 00457 // # End of Program 00458 // ############################################################################# 00459 // exit(0); 00460 } // the main routine 00461 00462 //############################################################################# 00463 /** @fn int using_voy_nav ( ) 00464 ** @brief What to do when no arguments are given. 00465 ** @param None 00466 ** @return None 00467 ** 00468 ** @lim None 00469 ** @ingroup tp_nav 00470 **/ 00471 // ############################################################################# 00472 int using_voy_nav ( ) { 00473 // print "\nvoyant_nav.pl operates on specific Doxygen\mif2go output files from \n"; 00474 // print "various Doxygen runs. \n"; 00475 // print "dox_nav's purpose is to give all HTML files the same navigation bar.\n"; 00476 // print "\n-- These files must be named with <htm> or <html> as the extension.\n"; 00477 // print "-- All files must reside in the input directory.\n\n"; 00478 // print "-- The first argument is the path including the forward slash (\/).\n"; 00479 // print " If no path is specified as the first argument, \".\/\" is used.\n\n"; 00480 // print "-- The second argument is file to use for the navigation.\n"; 00481 // print " It must have sections for voyant_header, common_top, doxygen_group,\n"; 00482 // print " fm_book, and voyant_footer.\n"; 00483 // print " A section has a begin and end, such as:\n"; 00484 // print " <!-- begin voyant_footer definition -->\m"; 00485 // print " <!-- end voyant_footer definition -->\m"; 00486 // print "-- The third argument is file to use for the toc ordering (project_toc.txt).\n"; 00487 // print "NOTE: The PDF file placed in \"print_pdf\" has to be named the same as\n"; 00488 // print " the directory containing its associated HTML files.\n"; 00489 // print "\nTerminating voyant_nav.pl without doing anything.\n"; 00490 return; 00491 } 00492 00493 //############################################################################# 00494 /** @fn int generate_and_step_through_list ( ) 00495 ** @brief Generates list of files to look at. 00496 ** @param None 00497 ** @return None 00498 ** 00499 ** @lim None 00500 ** @ingroup tp_nav 00501 **/ 00502 // ############################################################################# 00503 int generate_and_step_through_list ( ) { 00504 #define $_file_list $_[0] 00505 00506 if (system ("ls $globe::path*.$f_type* > $_file_list")) { 00507 // print "ls $globe::path*.$f_type* > $_file_list\n"; 00508 push (@file_errors, "There is no $globe::path directory. Nothing done.\n"); 00509 return(0); 00510 } 00511 00512 unless (open ( IN_LIST, $_file_list)) { 00513 push (@file_errors, "Cannot open file \"$_file_list\"\n"); 00514 return(0); 00515 } 00516 00517 // undef (@globe::sequence); 00518 while (<IN_LIST>){ // read a line from file into $_ 00519 $in_file = $_; 00520 $in_file =~ s/\n//; 00521 $skip_flag = 0; 00522 for ($i=0; $i<@globe::special_files; $i++) { 00523 if ($in_file =~ /\/$globe::special_files[$i]/i) { 00524 // slash was added to name to indicate a path so that it won't 00525 // skip on files that only have part of the name. 00526 $skip_flag = 1; 00527 } 00528 } // for list of special files 00529 for ($i=0; $i<@globe::exclude_prefix; $i++) { 00530 if ((($in_file =~ /html$/i) || ($in_file =~ /htm$/i)) && ($in_file =~ /$globe::exclude_prefix[$i]/i)) { 00531 $skip_flag = 1; 00532 } 00533 } // for list of special files 00534 if ($skip_flag == 1) { 00535 // skip this file or do something else 00536 // printf ("Skipping... %s\n", $in_file); 00537 } else { 00538 // printf ("Working on... %s\n", $in_file); 00539 push (@globe::sequence, $in_file); 00540 if ($f_type =~ /htm/){ 00541 &change_nav($in_file); 00542 } 00543 } // if special file 00544 } // while getting a special file 00545 // close (IN_LIST); 00546 return (1); 00547 } // generate_and_step_through_list 00548 00549 //############################################################################# 00550 /** @fn int do_dox_prev_next ( ) 00551 ** @brief Does a cheap previous/next for Doxygen files. 00552 ** @param None 00553 ** @return None 00554 ** 00555 ** @lim None 00556 ** @ingroup tp_nav 00557 **/ 00558 // ############################################################################# 00559 int do_dox_prev_next ( ) { 00560 #define $t_prev "" 00561 #define $t_next "" 00562 00563 for ($j=0; $j < $// globe::sequence; $j++) { 00564 if (0){ 00565 // print "curr = $globe::sequence[$j]\n"; 00566 } 00567 if ($j == 0) { 00568 $temp_n = $// globe::sequence; 00569 @f_name = split (/\//, $globe::sequence[$temp_n]); 00570 $temp_n = $// f_name; 00571 $t_prev = $f_name[$temp_n]; 00572 $temp_n = $j+1; 00573 @f_name = split (/\//, $globe::sequence[$temp_n]); 00574 $temp_n = $// f_name; 00575 $t_next = $f_name[$temp_n]; 00576 } elsif ($j == $// globe::sequence-1){ 00577 $temp_n = $j-1; 00578 @f_name = split (/\//, $globe::sequence[$temp_n]); 00579 $temp_n = $// f_name; 00580 $t_prev = $f_name[$temp_n]; 00581 $temp_n = 0; 00582 @f_name = split (/\//, $globe::sequence[$temp_n]); 00583 $temp_n = $// f_name; 00584 $t_next = $f_name[$temp_n]; 00585 } else { 00586 $temp_n = $j-1; 00587 @f_name = split (/\//, $globe::sequence[$temp_n]); 00588 $temp_n = $// f_name; 00589 $t_prev = $f_name[$temp_n]; 00590 $temp_n = $j+1; 00591 @f_name = split (/\//, $globe::sequence[$temp_n]); 00592 $temp_n = $// f_name; 00593 $t_next = $f_name[$temp_n]; 00594 } 00595 if (0) { 00596 // print "curr = $globe::sequence[$j]\nprev = $t_prev\tnext = $t_next\n"; 00597 } 00598 if (open ( IN_LIST, $globe::sequence[$j])) { 00599 // may end up opening and closing too much. 00600 // undef ($globe::entire_file); 00601 while (<IN_LIST>){ 00602 $globe::entire_file .= $_; 00603 } 00604 // close (IN_LIST); 00605 $globe::entire_file =~ s/$globe::voy_variable_prev_dox/$t_prev/g; 00606 $globe::entire_file =~ s/$globe::voy_variable_next_dox/$t_next/g; 00607 if (open ( IN_LIST, ">$globe::sequence[$j]")) { 00608 // print (IN_LIST "$globe::entire_file"); 00609 } 00610 // close (IN_LIST); 00611 } // if open 00612 } // for @sequence 00613 return (1); 00614 } // do_dox_prev_next 00615 00616 00617 //############################################################################# 00618 /** @fn int change_nav 00619 ** @brief Opens up an HTML file and replaces information between known tags. 00620 ** 00621 ** @param $in_file is the HTML file to edit. 00622 ** 00623 ** @return Effectively writes back out to the same HTML file. 00624 ** 00625 ** This function performs all tasks associated with updating the individual 00626 ** HTML file. It reads the entire HTML file into memory. 00627 ** 00628 ** In general, this routine looks for paired HTML comments containing a 00629 ** tag name and "begin" or "end". Whatever is between these paired comments 00630 ** is replaced with the updated information extracted from the master. 00631 ** The sequence of replacements is: <ul> 00632 ** 00633 ** <li>If the HTML file has $globe::m_define{variable}[0], it means that it 00634 ** came from a FrameMaker book. As such, these variables contain information 00635 ** regarding the previous topic, next topic, whether or not it is a first topic 00636 ** or last topic for the chapter, etc. This information is extracted from the 00637 ** HTML file and placed into variables to be used by this topic.</li> 00638 ** 00639 ** <li>Info in the file header is swapped out. If the tags aren't found, 00640 ** an appropriate spot for the new tags is created before the terminating 00641 ** head tag.</li> 00642 ** 00643 ** <li>Info in the file footer is swapped out. If the tags aren't found, 00644 ** an appropriate spot for the new tags is created before the terminating 00645 ** body tag. </li> 00646 ** 00647 ** <li>If the HTML file came from a FM book, replace the navigation bar 00648 ** associated with the book (the second navigation bar.) 00649 ** Although this navigation bar appears below the common navigation bar, it is 00650 ** swapped out first, because if the location tags aren't found, this routine finds 00651 ** an appropriate spot for the new tags immediately following the body tag. 00652 ** This is easy to spot.</li> 00653 ** 00654 ** <li>If the HTML file came from Doxygen, replace the navigation bar 00655 ** associated with Doxygen topics (the second navigation bar.) 00656 ** Although this navigation bar appears below the common navigation bar, it is 00657 ** swapped out first, because if the location tags aren't found, this routine finds 00658 ** an appropriate spot for the new tags immediately following the body tag. 00659 ** This is easy to spot.</li> 00660 ** 00661 ** <li>Replace the navigation bar common to all topics in the system. 00662 ** If the location tags aren't found, this routine finds an appropriate spot 00663 ** for the new tags immediately following the body tag. This is why this needs 00664 ** to happen after inserting either the FM navigation or the Doxygen navigation.</li> 00665 ** 00666 ** <li>Sometimes HTML is generated by Doxygen or Mif2Go that hard-codes fonts 00667 ** or styles that cannot be controlled by a CSS. 00668 ** One of the lists that can be defined in the master file is a "zap" 00669 ** list. This is read into @globe::voy_html_zap hash. Each item in the zap list has 00670 ** three elements:<ol> 00671 ** <li>start of the offending tag but incomplete.</li> 00672 ** <li>end of first offending tag.</li> 00673 ** <li>end of tag pairs.</li></ol> 00674 ** The HTML tags defined in the zap list get taken out of the HTML document.</li> 00675 ** 00676 ** <li>Items in the header, footer, or navigation have items coming from the master 00677 ** that were not fully defined. Part of the voy_order provides the complete 00678 ** description. The HTML document gets the complete definition of these items. 00679 ** This includes: </li><ul> 00680 ** <li>PDF file name.</li> 00681 ** <li>The name of the manual or group.</li> 00682 ** <li>The document number.</li> 00683 ** <li>Document title is changed to match the first heading.</li></ul> 00684 ** </ul> 00685 ** 00686 ** <li>The title is extracted into the index token list.</li> 00687 ** 00688 ** <li>The headings are added to the index token list as well as the topic order 00689 ** list.</li> 00690 ** 00691 ** <li>Object tags are how FM index tokens are passed to MS-HTML using Mif2Go. 00692 ** These are converted into special HTML comments. They are also extracted into 00693 ** the index token list.</li> 00694 ** 00695 ** <li>If the file came from Doxygen, this parses 00696 ** out interesting items to add to the index token list.</li> 00697 ** 00698 ** While processing the file, hash tables are created: <ul> 00699 ** <li> @globe::book_topics: key is html file name, <Title> is stored</li> 00700 ** <li> @globe::book_topic_order: key is html file name, next html file is stored</li> 00701 ** <li> @globe::book_topic_level: key is html file name, <Headn> is stored</li></ul> 00702 ** 00703 ** This is important in order to handle subsequent creation of the mini-TOC file 00704 ** (tree.html) in another routine. 00705 ** 00706 ** @lim This is a big routine that accomplishes many different tasks while 00707 ** it has the HTML file in memory. Some of the items have to be handled in the 00708 ** order given for them to be swapped and positioned properly. 00709 ** 00710 ** @ingroup tp_nav 00711 **/ 00712 // ############################################################################# 00713 int change_nav ( ) { 00714 #define $in_file $_[0] // name of input html file 00715 #define $rel_to_file "" 00716 #define $out_file "_temp" 00717 #define $out_line "" 00718 00719 #define $globe::entire_file "" 00720 #define $globe::have_header 0 00721 #define $globe::have_footer 0 00722 #define $globe::have_common_top 0 00723 #define $globe::have_dox 0 00724 #define $target_cnt 0 00725 #define $target_prefix "_ggg_" 00726 00727 if (0) { 00728 // printf ("Here is the infile again = %s\n", $in_file); 00729 } 00730 00731 // ### 00732 // Change path used in index file 00733 // ### 00734 $rel_to_file = $in_file; 00735 @path_chunk = split ( /\//, $rel_to_file, 2); 00736 if (@path_chunk =~ /2/) { 00737 $rel_to_file = "$path_chunk[1]"; 00738 } 00739 @path_chunk = split ( /\//, $in_file); 00740 if ($// path_chunk > 0) { 00741 // Although $globe::m_var{value}{curr} is set by mif2go, it is not set by Doxygen. 00742 $globe::m_var{value}{curr} = "$path_chunk[$// path_chunk]"; 00743 } 00744 if (0){ 00745 // print "glenn $in_file\n"; 00746 // print "glenn $rel_to_file\n"; 00747 // print "glenn $globe::m_var{value}{curr}\n"; 00748 // exit(1); 00749 } 00750 // ### 00751 00752 $out_file = "$globe::path$out_file"; 00753 00754 unless (open(IN_HTML, $in_file)) { 00755 // print "Cannot open file \"$in_file\"\n"; 00756 return(1); 00757 } 00758 // #### 00759 // Read in entire input file. 00760 // #### 00761 while (<IN_HTML>) { 00762 $globe::entire_file .= $_; 00763 } 00764 // close (IN_HTML); 00765 00766 unless (open(OUT_HTML, ">$out_file")) { 00767 // print "Cannot open file \"$out_file\"\n"; 00768 return(1); 00769 } 00770 00771 // #### 00772 // Make sure our input HTML file is well formed 00773 // #### 00774 $globe::entire_file =~ s/\<\/Head\>/\<\/head\>/g; 00775 $globe::entire_file =~ s/\<\/HEAD\>/\<\/head\>/g; 00776 $globe::entire_file =~ s/\<Head\>/\<head\>/g; 00777 $globe::entire_file =~ s/\<HEAD\>/\<head\>/g; 00778 $globe::entire_file =~ s/\<\/Body\>/\<\/body\>/g; 00779 $globe::entire_file =~ s/\<\/BODY\>/\<\/body\>/g; 00780 $globe::entire_file =~ s/\<Body\>/\<body\>/g; 00781 $globe::entire_file =~ s/\<BODY\>/\<body\>/g; 00782 $globe::entire_file =~ s/\<Link rel\=/\<link rel\=/g; 00783 $globe::entire_file =~ s/\<Link Rel\=/\<link rel\=/g; 00784 $globe::entire_file =~ s/\<LINK REL\=/\<link rel\=/g; 00785 $globe::entire_file =~ s/\<Link/\<link/g; 00786 $globe::entire_file =~ s/\<LINK/\<link/g; 00787 00788 // #### 00789 // change in structure 00790 // #### 00791 $globe::entire_file =~ s/\<\!\-\- END/\<\!\-\- end/g; 00792 $globe::entire_file =~ s/\<\!\-\- BEGIN/\<\!\-\- begin/g; 00793 00794 // Remove any style sheets that might be hanging out. 00795 // undef(@pre_chunks); 00796 if ($globe::entire_file =~ /\<link/){ 00797 @pre_chunks = split ( /\<link/, $globe::entire_file, 2); 00798 @post_chunks = split ( /\>/, $pre_chunks[1], 2); 00799 // $globe::entire_file = sprintf( "%s%s", $pre_chunks[0], $post_chunks[1]); 00800 } 00801 00802 // Test the Input file for various items and swap out as needed. 00803 // undef(@pre_chunks); 00804 // undef(@post_chunks); 00805 00806 00807 // ################# 00808 // Get the previous and next variables 00809 // and the current variables 00810 // Applies only if it is a fm book file. 00811 // ################# 00812 $not_critical = 0; 00813 $def_type = "variable"; 00814 if (0) { 00815 // print "$def_type $globe::m_define{$def_type}[0]\n"; 00816 } 00817 if ( $globe::entire_file =~ /$globe::m_define{$def_type}[0]/ ) { 00818 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00819 $globe::m_define{$def_type}[0], 00820 $globe::m_define{$def_type}[1], 00821 $not_critical); 00822 if ($piece) { 00823 // $globe::m_info{$def_type} = sprintf( "%s%s%s", 00824 $globe::m_define{$def_type}[0], 00825 $piece, 00826 $globe::m_define{$def_type}[1]); 00827 00828 VAR_VAL: foreach $var (keys %{$globe::m_var{define}}) { 00829 if ($var =~ /end/){ 00830 next VAR_VAL; 00831 } 00832 ($before, $globe::m_var{value}{$var}, $after) = &globe::get_tag_chunk( $globe::m_info{$def_type}, 00833 $globe::m_var{define}{$var}, 00834 $globe::m_var{define}{end}, 00835 $not_critical); 00836 if (0) { 00837 // // print "$def_type $var $globe::m_var{value}{$var} $globe::m_info{$def_type}\n"; 00838 // print "Stuff:: $def_type $var $globe::m_var{value}{$var} \n"; 00839 } 00840 } // foreach $var 00841 00842 } else { 00843 push (@file_errors, "$def_type definition messed up."); 00844 } 00845 // First and Last flags 00846 if ($globe::m_var{value}{firstlast} =~ /1\// 0/){ 00847 push (@globe::book_first_topic, $in_file); 00848 $globe::m_var{value}{prev} = $globe::voy_variable_prev_chapter; 00849 } elsif ($globe::m_var{value}{firstlast} =~ /0\// 1/){ 00850 push (@globe::book_last_topic, $in_file); 00851 // The last topic doesn't really have a next, 00852 // except the next chapter which we don't know at this point. 00853 $globe::m_var{value}{next} = $globe::voy_variable_next_chapter; 00854 } elsif ($globe::m_var{value}{firstlast} =~ /1\// 1/){ # handles single topic chapters 00855 push (@globe::book_first_topic, $in_file); 00856 $globe::m_var{value}{prev} = $globe::voy_variable_prev_chapter; 00857 push (@globe::book_last_topic, $in_file); 00858 // The last topic doesn't really have a next, 00859 // except the next chapter which we don't know at this point. 00860 $globe::m_var{value}{next} = $globe::voy_variable_next_chapter; 00861 } 00862 00863 if (0) { 00864 foreach $var (keys %{$globe::m_var{value}}) { 00865 // print "$var $globe::m_var{value}{$var} $in_file\n"; 00866 } // foreach $var 00867 // exit(1); 00868 } 00869 } 00870 00871 00872 if (0){ // debug 00873 // print "$globe::entire_file"; 00874 // exit(1); 00875 } // debug 00876 00877 00878 // ################# 00879 // voyant header needs to go before </head> 00880 // ################# 00881 $not_critical = 1; 00882 $reinsert_tags = 0; 00883 $def_type = "header"; 00884 if (! &file_chunk_change ($def_type, $not_critical, "</head>", 0, $reinsert_tags, $in_file) ) { 00885 // Could not put proper chunk in; write out what we have an abort. 00886 // // print (OUT_HTML "$globe::entire_file"); 00887 // close (OUT_HTML); 00888 if (0){ // debug 00889 // print "glenn3\n$globe::entire_file"; 00890 // exit(1); 00891 } // debug 00892 return(0); 00893 } // voyant_header 00894 00895 if (0){ // debug 00896 // print "glenn4\n$globe::entire_file"; 00897 // print "oh $def_type $globe::m_info{$def_type}\noh again\n"; 00898 // exit(1); 00899 } // debug 00900 00901 // get rid of any spurious navigation. 00902 while ($globe::entire_file =~ $globe::m_define{nav_book}[0]){ 00903 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00904 $globe::m_define{nav_book}[0], 00905 $globe::m_define{nav_book}[1], 00906 0); 00907 if ((1) || ($piece)) { 00908 // Turned this on, because the tags could be empty. 00909 $globe::entire_file = join ("", $before, $after); 00910 } 00911 } 00912 while ($globe::entire_file =~ /$globe::m_define{nav_doxygen}[0]/){ 00913 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00914 $globe::m_define{nav_doxygen}[0], 00915 $globe::m_define{nav_doxygen}[1], 00916 0); 00917 if ((1) || ($piece)) { 00918 // Turned this on, because the tags could be empty. 00919 $globe::entire_file = join ("", $before, $after); 00920 } 00921 } 00922 if (0){ // debug 00923 // print "glenn6\n"; 00924 // exit(1); 00925 } // debug 00926 while ($globe::entire_file =~ $globe::m_define{nav_common}[0]){ 00927 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00928 $globe::m_define{nav_common}[0], 00929 $globe::m_define{nav_common}[1], 00930 0); 00931 if ((1) || ($piece)) { 00932 // Turned this on, because the tags could be empty. 00933 $globe::entire_file = join ("", $before, $after); 00934 } 00935 } 00936 while ($globe::entire_file =~ $globe::m_define{footer}[0]){ 00937 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00938 $globe::m_define{footer}[0], 00939 $globe::m_define{footer}[1], 00940 0); 00941 if ((1) || ($piece)) { 00942 // Turned this on, because the tags could be empty. 00943 $globe::entire_file = join ("", $before, $after); 00944 } 00945 } 00946 if (0) { 00947 // print "Finishing up here... premature.\n"; 00948 // // print $globe::entire_file; 00949 // print (OUT_HTML "$globe::entire_file"); 00950 // close (OUT_HTML); 00951 system ("cp $out_file $in_file"); 00952 return (0); 00953 } 00954 00955 00956 // ################# 00957 // voyant footer needs to go before </body> 00958 // ################# 00959 $not_critical = 1; 00960 $reinsert_tags = 0; 00961 $def_type = "footer"; 00962 if ($globe::entire_file =~ /\<\/body\>/) { 00963 &file_chunk_change ($def_type, $not_critical, "<\/body>", 0, $reinsert_tags, $in_file); 00964 // Could not put proper chunk in; write out what we have an abort. 00965 } else { 00966 // Does not have proper body 00967 push (@file_errors, "ERROR: Does not have </body> in $in_file."); 00968 return (0); 00969 } // voyant footer 00970 00971 // ################# 00972 // make footer the unique for FM and doxygen 00973 // ################# 00974 if ($globe::entire_file =~ /$globe::m_define{variable}[0]/) { 00975 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00976 $globe::m_define{footer}[0], 00977 $globe::m_define{footer}[1], 00978 0); 00979 if ($piece) { 00980 $nemp = $globe::voy_footer_fm; 00981 $nemp =~ s/$globe::m_var{define}{prev}/$globe::m_var{value}{prev}/g; 00982 $nemp =~ s/$globe::m_var{define}{next}/$globe::m_var{value}{next}/g; 00983 00984 $globe::entire_file = join ("", $before, $nemp, $after); 00985 } 00986 } else { 00987 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 00988 $globe::m_define{footer}[0], 00989 $globe::m_define{footer}[1], 00990 0); 00991 if ($piece) { 00992 $globe::entire_file = join ("", $before, $globe::voy_footer_dox, $after); 00993 } 00994 } 00995 00996 if (0){ // debug 00997 // print "glenn4\n$globe::entire_file"; 00998 // print "oh $def_type $globe::m_info{$def_type}\noh again\n"; 00999 // exit(1); 01000 } // debug 01001 01002 // ################# 01003 // mif2go navigation from the FM book 01004 // DO BEFORE "common top navigation bar" which will slip between <body> and this. 01005 // Tweak navigation for this page who knows previous and next 01006 // ################# 01007 $not_critical = 0; 01008 $reinsert_tags = 0; 01009 01010 01011 if ($globe::entire_file =~ /$globe::m_define{variable}[0]/) { 01012 // ################# 01013 // Swap out the FM navigation... 01014 // ################# 01015 $def_type = "nav_book"; 01016 // Place holder so that we don't loose it. 01017 $temp_place_holder = $globe::m_info{$def_type}; 01018 // whereever we see definitions, put in the actual values. 01019 $globe::m_info{$def_type} =~ s/$globe::m_var{define}{prev}/$globe::m_var{value}{prev}/g; 01020 $globe::m_info{$def_type} =~ s/$globe::m_var{define}{next}/$globe::m_var{value}{next}/g; 01021 } else { 01022 // ################# 01023 // Swap out the Doxygen navigation... 01024 // ################# 01025 $def_type = "nav_doxygen"; 01026 // Place holder so that we don't lose it. 01027 $temp_place_holder = $globe::m_info{$def_type}; 01028 } // FM Navigation 01029 &file_chunk_change ($def_type, $not_critical, "<body>", 1, $reinsert_tags, $in_file); 01030 01031 // #### 01032 // Get back to original state for next file. 01033 // #### 01034 $globe::m_info{$def_type} = $temp_place_holder; 01035 01036 if (0){ // debug 01037 // print "glenn4\n$globe::entire_file"; 01038 // print "oh $def_type $globe::m_info{$def_type}\noh again\n"; 01039 // exit(1); 01040 } // debug 01041 01042 01043 if (0) { 01044 // print "Finishing up here... premature.\n"; 01045 // // print $globe::entire_file; 01046 // print (OUT_HTML "$globe::entire_file"); 01047 // close (OUT_HTML); 01048 system ("cp $out_file $in_file"); 01049 return (0); 01050 } 01051 01052 01053 // #### 01054 // Strip out native Doxygen navigation 01055 // #### 01056 if (1) { // 03/30/2002 new definition of doxygen navigation to remove 01057 DOX_STRIP: while ($globe::entire_file =~ /$globe::dox_nav_defb3/) { 01058 $very_critical = 0; 01059 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 01060 "<center>", 01061 "</center>", 01062 $very_critical); 01063 if ($after =~ /$globe::dox_nav_defb3/) { 01064 // You missed your definition; 01065 // Rebuild some pieces and try one more time. 01066 $before .= "<center>$piece<\/center>"; 01067 ($before2, $piece, $after2) = &globe::get_tag_chunk( $after, 01068 "<center>", 01069 "</center>", 01070 $very_critical); 01071 if ($after2 =~ /$globe::dox_nav_defb3/) { 01072 push (@file_errors, "ERROR: Could not get rid of native dox nav in $in_file."); 01073 break DOX_STRIP; 01074 } else { 01075 // You got it this time and can rebuild. 01076 $globe::entire_file = join ("", $before, $before2, $after2); 01077 } 01078 } else { 01079 // Rebuild the file 01080 $globe::entire_file = join ("", $before, $after); 01081 } 01082 } // while it has the definition 01083 } // if new definition 01084 01085 01086 // ################# 01087 // voyant common top navigation bar should go after <body> 01088 // Do AFTER FM or Doxygen navigation 01089 // ################# 01090 $not_critical = 0; 01091 $reinsert_tags = 0; 01092 $def_type = "nav_common"; 01093 01094 if (! &file_chunk_change ($def_type, $not_critical, "<body>", 1, $reinsert_tags, $in_file) ) { 01095 // Could not put proper chunk in; 01096 // Not necessarily a problem. 01097 } // Common Navigation 01098 01099 if (0){ // debug 01100 // print "glenn4\n$globe::entire_file"; 01101 // print "oh $def_type $globe::m_info{$def_type}\noh again\n"; 01102 // exit(1); 01103 } // debug 01104 01105 01106 01107 // ################# 01108 // Handle the PDF file names 01109 // ################# 01110 $temp = "$globe::rel_path_to_start_point$globe::pdf_dir$globe::master_order_pdf[$globe::master_order_key]"; 01111 $globe::entire_file =~ s/$globe::this_pdf_flag/$temp/g; 01112 $globe::entire_file =~ s/$globe::rel_path_to_start_point_def/$globe::rel_path_to_start_point/g; 01113 01114 // ################# 01115 // Handle the manual or group names 01116 // ################# 01117 $temp = $globe::master_order_title[$globe::master_order_key]; 01118 $temp =~ s/[\s]+/\ \;/g; 01119 if (0) { 01120 // print "$globe::master_order_key: we think title is: \"$temp\".\n"; 01121 if (0) { 01122 for ($i=0; $i <= $// {$globe::m_info{_array_order}}; $i++){ 01123 // print "$i title $globe::m_info{_array_order}[$i]{title}\n"; 01124 } // each $i 01125 } 01126 if (0) { 01127 for ($i=0; $i <= $// {$globe::m_info{_array_order}}; $i++){ 01128 foreach $k (keys %{$globe::m_info{_array_order}[$i]} ) { 01129 // print "$i $k $globe::m_info{_array_order}[$i]{$k}\n"; 01130 } // each $k key 01131 } // each $i 01132 } 01133 } 01134 01135 if ($globe::entire_file =~ /$globe::xmanual/){ 01136 $globe::entire_file =~ s/$globe::xmanual/$temp/g; 01137 } 01138 if ($globe::entire_file =~ /$globe::xgroup/){ 01139 $globe::entire_file =~ s/$globe::xgroup/$temp/g; 01140 } 01141 $globe::entire_file =~ s/$globe::fix_path_flag/$globe::fix_path_to/g; 01142 01143 // #### 01144 // Take care of current file name which might be in header, 01145 // as specified in template and needed in tree applet. 01146 // #### 01147 if ($globe::entire_file =~ /$globe::m_var{define}{curr2}/){ 01148 $globe::entire_file =~ s/$globe::m_var{define}{curr2}/$rel_to_file/g; 01149 } 01150 01151 01152 01153 01154 // ################# 01155 // Handle the document number 01156 // ################# 01157 if ($globe::entire_file =~ /$globe::voy_variable_doc_num/){ 01158 $globe::entire_file =~ s/$globe::voy_variable_doc_num/$globe::m_info{_array_order}[$globe::master_order_key]{num}/; 01159 } 01160 01161 01162 // ################################ 01163 // Remove certain specified HTML tags 01164 // ################################ 01165 if ((@globe::voy_html_zap < 1) || ($globe::voy_html_zap[0] =~ /none/)){ 01166 // Do nothing 01167 // // print "$in_file has no tags to zap.\n"; 01168 } else { 01169 // Remove the tags in question 01170 for ($i=0; $i<@globe::voy_html_zap; $i++){ 01171 // Determine start and Stop tags 01172 @zap_tag = split ( /\,/, $globe::voy_html_zap[$i]); 01173 // clean up tag 01174 for ($j=0; $j <@zap_tag; $j++){ 01175 $zap_tag[$j] =~ s/^[\s]*\"//; 01176 $zap_tag[$j] =~ s/\"[\s]*$//; 01177 // // print "Zap this =$zap_tag[$j]\n"; 01178 } 01179 $t_cnt=0; 01180 while ($globe::entire_file =~ /$zap_tag[0]/i){ // case insensitive test 01181 $t_cnt++; 01182 // print "$t_cnt: Removing everything between \"$zap_tag[0]\" and \"$zap_tag[1]\"\n"; 01183 // First tag part A 01184 @pre_chunks = split ( /$zap_tag[0]/, $globe::entire_file, 2); 01185 // First tag part B 01186 @post_chunks = split ( /$zap_tag[1]/, $pre_chunks[1], 2); 01187 if (@zap_tag > 2){ 01188 // Second tag 01189 // Hit the first occurrence of the ending tag 01190 $post_chunks[1] =~ s/$zap_tag[2]//i; // do it only once, case insensitive 01191 } 01192 // rebuild 01193 $globe::entire_file = join ("", $pre_chunks[0], $post_chunks[1]); 01194 } // while it still is infested with the tag 01195 } // for all zap tags 01196 // // print "$in_file was tested for tags to zap.\n"; 01197 } // if zap tags to remove 01198 // undef(@pre_chunks); 01199 // undef(@post_chunks); 01200 // ################################ 01201 01202 // ################################ 01203 // Change the title if appropriate. 01204 // Add the title to the index token list. 01205 // Add headings to the list to be included in TOC. 01206 // ################################ 01207 $tit_flag = 0; 01208 @title_chunks = split ( /$globe::m_define{title}[0]|$globe::m_define{title}[1]/, $globe::entire_file, 3); 01209 // Changed to always have it do the title. 01210 // if ($title_chunks[1] =~ /$globe::m_default_title/i) { 01211 &title_in_topic_jumps; 01212 01213 if ((0) && (@globe::index_info >0)) { // debug 01214 foreach $thing (@globe::index_info){ 01215 // print "---- $thing\n"; 01216 } 01217 // // exit(1); 01218 } // debug 01219 if (0) { // debug 01220 // print "---- Entire file 5 ----\n$globe::entire_file\n-----5 \n"; 01221 // exit(1); 01222 } // debug 01223 // undef(@chunks); 01224 // undef(@title_chunks); 01225 // undef(@h1_chunks); 01226 // undef(@h1_end_chunks); 01227 // ################################ 01228 01229 // ################################ 01230 // Handle <object> tags and change if appropriate. 01231 // This will turn them into voyant index tokens 01232 // and adds them to the token list. 01233 // If the file gets processed again, it handles 01234 // the index tokens by putting them in a list. 01235 // ################################ 01236 if ($globe::entire_file =~ /$globe::ms_object_b/){ 01237 // 07/03/2002 We are no longer exporting MSHTML that uses objects. 01238 // Hence if we come across this, we should issue an error. 01239 push (@file_errors, "HTML file has ms object index tokens; re-export with new mif2htm.ini file tokens."); 01240 01241 if (0) { // 07/03/2002 01242 // convert object keywords into voyant index tokens; put them in list 01243 // need to keep pre_object_chunk[0] and post_obj_chunk[1] 01244 while ($globe::entire_file =~ /$globe::ms_object_b/){ 01245 @pre_obj_chunk = split ( /$globe::ms_object_b/, $globe::entire_file, 2); 01246 @post_obj_chunk = split ( /$globe::ms_object_e/, $pre_obj_chunk[1], 2); 01247 $temp_voy_token = ""; 01248 while ($post_obj_chunk[0] =~ /$globe::ms_value_b/){ 01249 @pre_value = split ( /$globe::ms_value_b/, $post_obj_chunk[0], 2); 01250 @post_value = split ( /$globe::ms_value_e/, $pre_value[1], 2); 01251 // $post_value[0] contains keyword 01252 $temp_voy_token .= "$globe::m_define{index_token}[0]$post_value[0]$globe::m_define{index_token}[1]"; 01253 $post_value[0] =~ s/\,\s/$globe::word_c_boundary/; 01254 // update the index token list appropriately 01255 push (@globe::index_info, "$post_value[0]$globe::word_url_boundary<a href=\"$rel_to_file\" target=\"basefrm\">"); 01256 // removes value line from object tag 01257 $post_obj_chunk[0] = join ("", $pre_value[0], $post_value[1]); 01258 } // while $globe::ms_value_b 01259 // rebuilt file and remove object; replace with voyant token. 01260 $globe::entire_file = join ("", $pre_obj_chunk[0], $temp_voy_token, $post_obj_chunk[1]); 01261 } // while $globe::ms_object_b still present 01262 } // 07/03/2002 01263 } elsif ($globe::entire_file =~ /$globe::m_define{index_token}[0]/) { 01264 // 07/03/2002 We are no longer using the old token markers. 01265 // All index tokens come either from doxytag or mif2go. 01266 // Hence, we'll remove the old markers 01267 push (@file_errors, "HTML file has old index tokens; re-export with new mif2htm.ini file tokens."); 01268 01269 if (1) { // 07/03/02 This will eventually go away 01270 // check for voyant index tokens; put them in list 01271 @pre_token = split ( /$globe::m_define{index_token}[0]/, $globe::entire_file); 01272 // purposely skip 0, because that's before the token 01273 for ($i=1; $i<@pre_token; $i++){ 01274 @post_token = split ( /$globe::m_define{index_token}[1]/, $pre_token[$i], 2); 01275 // post_token[0] has the token 01276 // // print "$post_token[0] in $in_file\n"; 01277 $post_value[0] =~ s/\,\s/$globe::word_c_boundary/; 01278 push (@globe::index_info, "$post_token[0]$globe::word_url_boundary<a href=\"$rel_to_file\" target=\"basefrm\">"); 01279 } // for $i the tokens 01280 // // print "$globe::entire_file\n"; 01281 } // 07/03/02 This will eventually go away 01282 } 01283 // undef (@pre_obj_chunk); 01284 // undef (@post_obj_chunk); 01285 // undef ($temp_voy_token); 01286 // undef (@pre_token); 01287 // undef (@post_token); 01288 // ################################ 01289 01290 // ################################ 01291 // 07/03/2002 Handle the new index tokens 01292 // ################################ 01293 if ($globe::entire_file =~ /$globe::m_define{index_token2}[2]/) { // if new index tokens 01294 $t_shrinking_all = $globe::entire_file; 01295 $not_critical = 0; 01296 while ($t_shrinking_all =~ /$globe::m_define{index_token2}[0]/) { 01297 ($before, $piece, $after) = &globe::get_tag_chunk( $t_shrinking_all, 01298 $globe::m_define{index_token2}[0], 01299 $globe::m_define{index_token2}[1], 01300 $not_critical); 01301 if (0) { 01302 // print "piece=>$piece\n"; 01303 } 01304 if ($piece =~ /$globe::m_define{index_token2}[2]/) { 01305 // this is an index token 01306 @url = split ("\"", $piece, 2); 01307 // $url[0] contains the target name 01308 01309 // $globe::m_define{index_token2}[4] => value=\" 01310 // $globe::m_define{index_token2}[5] => \" 01311 // The value is the text we desire 01312 ($before2, $piece2, $after2) = &globe::get_tag_chunk( $piece, 01313 $globe::m_define{index_token2}[4], 01314 $globe::m_define{index_token2}[5], 01315 $not_critical); 01316 01317 // $piece2 contains the index text that we desire 01318 if ($piece2 =~ /\:[\s]+/) { 01319 // This handles multi-level index tokens from FM 01320 $piece2 =~ s/\:[\s]+/$globe::word_c_boundary/; 01321 } 01322 // ### 01323 // Build an index token 01324 // ### 01325 push (@globe::index_info, "$piece2$globe::word_url_boundary<a href=\"$rel_to_file\// $url[0]\" target=\"basefrm\">"); 01326 if (0) { 01327 // print "New Index=>$piece2$globe::word_url_boundary<a href=\"$rel_to_file\// $url[0]\"...\n"; 01328 } 01329 } 01330 // Rebuild without targets so while loop stops and go on. 01331 $t_shrinking_all = join ("", $before, $after); 01332 } // shrinking while 01333 if (0) { 01334 // print "we're stopping here.\n"; 01335 // print "0 $globe::m_define{index_token2}[0]\n"; 01336 // print "1 $globe::m_define{index_token2}[1]\n"; 01337 // print "2 $globe::m_define{index_token2}[2]\n"; 01338 // print "3 $globe::m_define{index_token2}[3]\n"; 01339 // print "4 $globe::m_define{index_token2}[4]\n"; 01340 // print "5 $globe::m_define{index_token2}[5]\n"; 01341 // exit(1); 01342 } 01343 } // if new index tokens 01344 01345 // ################################ 01346 // Old version: 01347 // Items from group files to add to index. 01348 // If the file name starts with "group", look for elements to add to index. 01349 // 01350 // <a name="xx" doxytag="group::code_item"></a> is the general syntax. 01351 // Hence to find them, we'll use: 01352 // #define $globe::gi_filename_clue "group" # clue that files beginning with "group" need additional parsing. 01353 // #define $globe::gi_name "<a name\=" # gi: first clue to look for for index 01354 // #define $globe::gi_dox "doxytag\=" # gi: second clue to look for for index 01355 // #define $globe::gi_group_separator "\:\:" # gi: separator from group and code item; code item is indexed 01356 // 01357 // ################################ 01358 // if (($rel_to_file =~ /$globe::gi_filename_clue/i) && ($globe::entire_file =~ /$globe::gi_dox/i)){ 01359 01360 // ################################ 01361 // New version: 01362 // Items to add to index, doesn't matter what the file is named. 01363 // If the file has $globe::gi_dox = ("doxytag\="), 01364 // that target anchor will be used to create an index entry. 01365 // 01366 // <a name="xx" doxytag="group::code_item"></a> is the general syntax. 01367 // Hence to find them, we'll use: 01368 // #define $globe::gi_name "<a name\=" # gi: first clue to look for for index 01369 // #define $globe::gi_dox "doxytag\=" # gi: second clue to look for for index 01370 // #define $globe::gi_group_separator "\:\:" # gi: separator from group and code item; code item is indexed 01371 // 01372 // ################################ 01373 if ($globe::entire_file =~ /$globe::gi_dox/i){ 01374 // #### 01375 // if the file is a group file 01376 // AND if it contains at least one doxytag 01377 // THEN it is acceptable to add some more tokens 01378 // #### 01379 @grobe_target_chunks = split (/$globe::gi_name/i, $globe::entire_file); 01380 foreach $gt_chunk (@grobe_target_chunks){ 01381 // Get to the end of the name tag 01382 if ($gt_chunk =~ /$globe::gi_dox/i){ 01383 @fine_target_chunks = split (/\>/, $gt_chunk, 2); 01384 // // print "interested in: $fine_target_chunks[0]\n"; 01385 @target_n_item = split (/$globe::gi_dox/i, $fine_target_chunks[0]); 01386 $ttt_target = $target_n_item[0]; 01387 $ttt_target =~ s/\"//g; 01388 $ttt_target =~ s/\s//g; 01389 // // print "2nd part interested in: $target_n_item[1]\n"; 01390 @item_chunk = split (/$globe::gi_group_separator/, $target_n_item[1], 2); 01391 $ttt_item = $item_chunk[1]; 01392 $ttt_item =~ s/\"//g; 01393 $ttt_item =~ s/\s//g; 01394 $ttt_item =~ s/\(//g; 01395 $ttt_item =~ s/\)//g; 01396 if (0){ // debug 01397 // print "$ttt_item$globe::word_url_boundary<a href=\"$rel_to_file\// $ttt_target\" target=\"basefrm\">\n"; 01398 } // debug 01399 if ($ttt_item =~ /\w+/){ 01400 // if not empty; don't write any empty index tokens 01401 $ttt_save_url = "<a href=\"$rel_to_file\// $ttt_target\" target=\"basefrm\">"; 01402 push (@globe::index_info, "$ttt_item$globe::word_url_boundary$ttt_save_url"); 01403 } 01404 // #### 01405 // Finshes the normal index tokens 01406 // #### 01407 01408 // #### 01409 // Handle any "Used by" references while we're here; 01410 // These are specifically designed for the BAPI Acknowledgement Packets. 01411 // 01412 // $ttt_item from above contains important title material that will 01413 // be part of the second level of an index token. 01414 // 01415 // $ttt_save_url is also important as the target for this new index token 01416 // 01417 // At this point, the $gt_chunk may or may not contain $ack_text_flag. 01418 // If it does, let's get that and make an index token. 01419 // #### 01420 if (1){ // glenn your test 01421 $_ig_flag = 0; 01422 if ($gt_chunk =~ /$globe::ack_text_flag/){ 01423 // // print "got the text flag; =$globe::ack_text_flag=\n$gt_chunk\n"; 01424 @ack_split1 = split (/$globe::ack_text_flag/, $gt_chunk, 2); 01425 @ack_split2 = split (/$globe::ack_end/, $ack_split1[1], 2); 01426 foreach $_ig_thing (@globe::ack_ignore){ 01427 // // print "A thing to ignore:$_ig_thing\n"; 01428 if ($ack_split2[0] =~ /$_ig_thing/) { 01429 // then we're done 01430 $_ig_flag = 1; 01431 } 01432 } 01433 if ($_ig_flag == 0) { 01434 // Continue to create a token 01435 // strip out HTML codes first 01436 while ($ack_split2[0] =~ /\</) { 01437 @_ack_html_chunk1 = split (/\</, $ack_split2[0], 2); 01438 @_ack_html_chunk2 = split (/\>/, $_ack_html_chunk1[1], 2); 01439 $ack_split2[0] = "$_ack_html_chunk1[0]$_ack_html_chunk2[1]"; 01440 } 01441 $ack_split2[0] =~ s/\n//g; 01442 $ack_split2[0] =~ s/^\s*//; 01443 $ack_split2[0] =~ s/\,//; 01444 // // print "in>>>>> $ack_split2[0]\n"; 01445 @ack_split3 = split (/\s+/, $ack_split2[0]); 01446 NEXT_ACK_ITEM: foreach $_ack_item (@ack_split3){ 01447 $_ack_item =~ s/\s*$//g; 01448 $_ack_item =~ s/\,$//g; 01449 if (0){ 01450 // print "out === $_ack_item\n"; 01451 } 01452 01453 if ("or" =~ /$_ack_item/){ 01454 next NEXT_ACK_ITEM; 01455 } 01456 if (0){ 01457 // print "$_ack_item$globe::word_c_boundary$globe::ack_used_by$ttt_item\n"; 01458 } 01459 if (0){ 01460 // print "$_ack_item$globe::word_c_boundary$globe::ack_used_by$ttt_item$globe::word_url_boundary$ttt_save_url\n"; 01461 } 01462 push (@globe::index_info, "$_ack_item$globe::word_c_boundary$globe::ack_used_by$ttt_item$globe::word_url_boundary$ttt_save_url"); 01463 } 01464 } // ignore flag 01465 } 01466 } // glenn test 01467 01468 } // if for doxytag 01469 } // foreach grobe target chunk 01470 if (0){ // debug 01471 // print "Here's one: $rel_to_file\n"; 01472 // exit(1); 01473 } // debug 01474 } // if the file is a group file and we want index access 01475 // ################################ 01476 01477 01478 // print (OUT_HTML "$globe::entire_file"); 01479 // close (OUT_HTML); 01480 01481 // gcm Where you can stop it from overwriting files. 01482 system ("cp $out_file $in_file"); 01483 01484 // undef ($in_file); 01485 // undef ($out_file); 01486 // undef ($globe::entire_file); 01487 // undef ($globe::have_header); 01488 // undef ($globe::have_footer); 01489 // undef ($globe::have_common_top); 01490 // undef ($globe::have_dox); 01491 return (1); 01492 } // change_nav 01493 01494 01495 //############################################################################# 01496 // 06/21/2002 Tore out of change_nav in order to tweak output. 01497 //############################################################################# 01498 int title_in_topic_jumps ( ) { 01499 if (0) { 01500 // print "Entering title_in_topic_jumps\n"; 01501 } 01502 if (1) { 01503 01504 // 06/24/2002 Remove all targets that we created from previous run 01505 while ($globe::entire_file =~ /\<a[\s]+name[\s]*\=\"$target_prefix/i) { 01506 ($before, $piece, $after) = &globe::get_tag_chunk( $globe::entire_file, 01507 "<a name=\"$target_prefix", 01508 "><\/a>", 01509 $very_critical); 01510 if (0) { 01511 // print "Removed target:::$piece\n"; 01512 } 01513 $globe::entire_file = join ("", $before, $after); 01514 } 01515 01516 // #### 01517 // find an appropriate h1 to use as the title in the document 01518 // Start by dividing into beg/end heading chunks 01519 // #### 01520 @h1_start_chunks = split ( /$globe::voy_h1_b/, $globe::entire_file); 01521 for ($f=1; $f<@h1_start_chunks; $f++){ 01522 // #### 01523 // purposely ignore the first chunk, because that's uninteresting 01524 // #### 01525 @h1_rear_chunks = split ( /$globe::voy_h1_e/, $h1_start_chunks[$f], 2); 01526 // #### 01527 // h1_start have all where ever an H1 started. 01528 // h1_rear subdivide that even further: 01529 // h1_rear[0] will have the title in there somewhere with other HTML formatting. 01530 // h1_rear[1] will have the rest of the topic; uninteresting 01531 // Get rid of left over h1 tag info. 01532 // #### 01533 @h1_title_chunks = split ( /\>/, $h1_rear_chunks[0], 2); 01534 01535 // #### 01536 // Handle the book topic level 01537 // 02/11/2002 Changed to start at $i=1; equality increased to $i >= 5; 01538 // equivalent level is set to [1]. 01539 // #### 01540 FND_LVL2: for ($i=1; $i<@globe::fm_format_levels; $i++){ 01541 // if ($h1_title_chunks[0] =~ /class\=\"$globe::fm_format_levels[$i]\"/){ 01542 // Removed closing (") so that it will match on "Head#Kwp", too. 01543 if ($h1_title_chunks[0] =~ /class\=\"$globe::fm_format_levels[$i]/){ 01544 // Manual fake out: BE CAREFUL; Index references set at beginning 01545 if ($i >= 5) { 01546 // TitleChapter, TitleAppendix, TitleFront should be given equal weighting, 01547 // Hence assign TitleChapter [0] to what would have been TitleAppendix [4] 01548 // or TitleFront [5]. 01549 $this_h1_level = $globe::fm_format_levels[1]; // key is html file name, <Headn> is stored 01550 } else { 01551 $this_h1_level = $globe::fm_format_levels[$i]; // key is html file name, <Headn> is stored 01552 } 01553 next FND_LVL2; 01554 } 01555 } 01556 // // print "$this_h1_level and Hi\n"; 01557 01558 01559 // #### 01560 // Remove any other HTML code that might be within the title. 01561 // This includes targets... 01562 // #### 01563 $have_target = 0; 01564 $h1_target = 0; 01565 while ($h1_title_chunks[1] =~ /</) { 01566 @chunks = split ( /<|>/ , $h1_title_chunks[1], 3); 01567 $h1_title_chunks[1] = join ("", $chunks[0], $chunks[2]); 01568 if (($chunks[1] =~ /a[\s]+name[\s]*\=/i) && ($have_target < 1)){ 01569 // Get the named target 01570 @tar_b_chunks = split (/[\s]+name[\s]*\=[\s]*\"/i, $chunks[1], 2); 01571 @tar_e_chunks = split (/\"/, $tar_b_chunks[1], 2); 01572 // 06/21/2002 Throw out targets generated by me in a previous run 01573 if ($tar_e_chunks[0] !~ /$target_prefix/) { 01574 // This is a target we can live with 01575 $h1_target = $tar_e_chunks[0]; 01576 $have_target++; 01577 } 01578 } 01579 // undef (@tar_b_chunks); 01580 // undef (@tar_e_chunks); 01581 // undef (@chunks); 01582 } 01583 01584 // 06/21/2002 Create unique targets 01585 if (!$h1_target) { 01586 // $h1_target = sprintf ("%s%u", $target_prefix , $target_cnt); 01587 $target_cnt++; 01588 01589 // insert the name target into the file at that location 01590 // build up the pieces so it can be done later 01591 @anchor_chunks = split ( />/, $h1_rear_chunks[0], 2); 01592 $anchor_chunks[1] = "<a name=\"$h1_target\"><\/a>" .$anchor_chunks[1]; 01593 $h1_rear_chunks[0] = join (">", @anchor_chunks); 01594 $h1_start_chunks[$f] = join ("$globe::voy_h1_e", @h1_rear_chunks); 01595 if (0) { 01596 // print "glenn $h1_target\n"; 01597 // // print "glenn $h1_start_chunks[$f]\n"; 01598 } 01599 } 01600 01601 // remove bad characters from name 01602 $h1_title_chunks[1] =~ s/\(//g; 01603 $h1_title_chunks[1] =~ s/\)//g; 01604 $h1_title_chunks[1] =~ s/[\s]+/ /g; 01605 // $h1_title_chunks[1] =~ s/ / /g; 01606 if (0) { // debug 01607 // print "Found and parsed h1 title to use = $h1_title_chunks[1]\n"; 01608 // print "Internal target = $h1_target\n"; 01609 // print "$this_h1_level\n"; 01610 // // exit(1); 01611 } 01612 01613 // #### 01614 // Take care of new Title and index 01615 // #### 01616 if ($tit_flag < 1) { 01617 $tit_flag++; 01618 // Rebuild Title and file 01619 $title_chunks[1] = "$globe::m_define{title}[0]$h1_title_chunks[1]$globe::m_define{title}[1]"; 01620 $globe::entire_file = join ("", @title_chunks); 01621 // #### 01622 // Put information into index 01623 // #### 01624 push (@globe::index_info, "$h1_title_chunks[1]$globe::word_url_boundary<a href=\"$rel_to_file\" target=\"basefrm\">"); 01625 } else { 01626 // #### 01627 // title taken care of, but need to index h1. 01628 // Put information into index 01629 // #### 01630 push (@globe::index_info, "$h1_title_chunks[1]$globe::word_url_boundary<a href=\"$rel_to_file\// $h1_target\" target=\"basefrm\">"); 01631 } 01632 01633 01634 // #### 01635 // Create book topic lists 01636 // Handle the book topic level 01637 // #### 01638 $book_topics[$f] = $h1_title_chunks[1]; 01639 $book_targets[$f] = $h1_target; 01640 $book_topic_level[$f] = $this_h1_level; // key is html file name, <Headn> is stored 01641 01642 if (0) { // debug 01643 // print "---- Entire file ----\n$globe::entire_file\n-----\n"; 01644 // exit(1); 01645 } // debug 01646 01647 } // for $f the number of <h1> tags 01648 01649 // 06/21/2002 Rebuild the file with targets inside 01650 if ($// h1_start_chunks > 1) { 01651 $globe::entire_file = join ("$globe::voy_h1_b", @h1_start_chunks); 01652 } 01653 01654 01655 if (0){ 01656 for ($f=1; $f<= $// h1_start_chunks; $f++){ 01657 // print "$f = $book_topic_level[$f]\n"; 01658 // print "$f = $book_topics[$f]\n"; 01659 // // print "$f = $book_targets[$f]\n"; 01660 } 01661 } 01662 01663 // #### 01664 // Loop through again to take care of topic list 01665 // #### 01666 for ($f=1; $f<= $// h1_start_chunks; $f++){ 01667 // #### 01668 // Create book topic lists 01669 // #### 01670 if (0) { 01671 // print "$f = $book_targets[$f]\n"; 01672 } 01673 if (($f == 1) && ($f == $// h1_start_chunks)) { 01674 // if first element and only one element 01675 $globe::book_topics{$in_file} = $book_topics[$f]; // key is html file name, <Title> is stored 01676 $globe::book_topic_order{$in_file} = $globe::m_var{value}{next}; // key is html file name, next html file is stored 01677 $globe::book_topic_level{$in_file} = $book_topic_level[$f]; // key is html file name, <Headn> is stored 01678 } elsif (($f == 1) && ($f < $// h1_start_chunks)) { 01679 // if first element and more than one element 01680 $globe::book_topics{$in_file} = $book_topics[$f]; // key is html file name, <Title> is stored 01681 $globe::book_topic_order{$in_file} = "$globe::m_var{value}{curr}\// $book_targets[$f+1]"; # key is html file name, next html file is stored 01682 $globe::book_topic_level{$in_file} = $book_topic_level[$f]; // key is html file name, <Headn> is stored 01683 } elsif (($f > 1) && ($f < $// h1_start_chunks)) { 01684 // if not first element and not last element 01685 $thing = "$in_file\// $book_targets[$f]"; 01686 $globe::book_topics{$thing} = $book_topics[$f]; // key is html file name, <Title> is stored 01687 $globe::book_topic_order{$thing} = "$globe::m_var{value}{curr}\// $book_targets[$f+1]"; # key is html file name, next html file is stored 01688 $globe::book_topic_level{$thing} = $book_topic_level[$f]; // key is html file name, <Headn> is stored 01689 } elsif (($f > 1) && ($f >= $// h1_start_chunks)) { 01690 // if not first element and the last element 01691 $thing = "$in_file\// $book_targets[$f]"; 01692 $globe::book_topics{$thing} = $book_topics[$f]; // key is html file name, <Title> is stored 01693 $globe::book_topic_order{$thing} = $globe::m_var{value}{next}; // key is html file name, next html file is stored 01694 $globe::book_topic_level{$thing} = $book_topic_level[$f]; // key is html file name, <Headn> is stored 01695 } 01696 01697 } // for $f the number of <h1> tags 01698 01699 } // if there are titles 01700 01701 if (0) { // debug 01702 $thing_cnt = 0; 01703 // print "======= this is what we know ======\n"; 01704 if (0){ // inner debug 01705 foreach $thing (keys %globe::book_topics){ 01706 // print "$thing = topic = $globe::book_topics{$thing}\n"; 01707 $thing_cnt++; 01708 } 01709 // print "Thing cnt $thing_cnt\n"; 01710 $thing_cnt = 0; 01711 foreach $thing (keys %globe::book_topic_level){ 01712 // print "$thing = level = $globe::book_topic_level{$thing}\n"; 01713 $thing_cnt++; 01714 } 01715 // print "Thing cnt $thing_cnt\n"; 01716 $thing_cnt = 0; 01717 foreach $thing (sort keys %globe::book_topic_order){ 01718 // print "$thing = order = $globe::book_topic_order{$thing}\n"; 01719 $thing_cnt++; 01720 } 01721 // print "Thing cnt $thing_cnt\n"; 01722 $thing_cnt = 0; 01723 foreach $thing (sort keys %globe::book_topics){ 01724 // print "$globe::book_topic_level{$thing} $globe::book_topics{$thing}\n"; 01725 $thing_cnt++; 01726 } 01727 // print "Thing cnt $thing_cnt\n"; 01728 $thing_cnt = 0; 01729 // print "----- all together now -----\n"; 01730 foreach $thing (keys %globe::book_topics){ 01731 // print "$globe::book_topic_level{$thing} = $thing = $globe::book_topics{$thing} = $globe::book_topic_order{$thing}\n"; 01732 $thing_cnt++; 01733 } 01734 // print "Thing cnt $thing_cnt\n"; 01735 $thing_cnt = 0; 01736 } // inner debug 01737 // print "----- all together now -----\n"; 01738 foreach $thing (keys %globe::book_topics){ 01739 // print "dd $globe::book_topic_level{$thing} = $thing = $globe::book_topic_order{$thing}\n"; 01740 $thing_cnt++; 01741 } 01742 // print "Thing cnt $thing_cnt\n"; 01743 $thing_cnt = 0; 01744 // // exit(1); 01745 } 01746 01747 if ((0) && (@globe::index_info >0)) { // debug 01748 foreach $thing (@globe::index_info){ 01749 // print "---- $thing\n"; 01750 } 01751 // // exit(1); 01752 } // debug 01753 if (0) { // debug 01754 // print "---- Entire file 5 ----\n$globe::entire_file\n-----5 \n"; 01755 // exit(1); 01756 } // debug 01757 // undef(@chunks); 01758 // undef(@title_chunks); 01759 // undef(@h1_chunks); 01760 // undef(@h1_end_chunks); 01761 // ################################ 01762 01763 } // title_in_topic_jumps 01764 01765 01766 01767 01768 //############################################################################# 01769 /** @fn int file_chunk_change 01770 ** @brief Replaces the information for the given chunk. (Not complete). 01771 ** 01772 ** @param _type_define The key into the m_define and m_info hashes. 01773 ** @param _criticality specifies whether or not to record error messages. 01774 ** @param _where_flag The tag where this is supposed to go. 01775 ** @param _after if 0, set before, otherwise after 01776 ** @param _in_file Name of file being worked on. 01777 ** 01778 ** @retval success 1 if found tags, 0 if missing. 01779 ** 01780 ** @lim Uses the $globe::entire_file 01781 ** @ingroup tp_toc 01782 **/ 01783 // ############################################################################# 01784 int file_chunk_change ( ) { 01785 $_type_define = $_[0]; 01786 $_criticality = $_[1]; 01787 $_where_flag = $_[2]; 01788 $_after = $_[3]; 01789 $_insert_tags = $_[4]; // pass through 01790 $_in_file = $_[5]; 01791 01792 if (0) { 01793 // print "file_chunk_change $_type_define $globe::m_define{$_type_define}[0]\n$_in_file\n"; 01794 } 01795 if (( $globe::entire_file =~ /$globe::m_define{$_type_define}[1]/ ) && ( $globe::entire_file =~ /$globe::m_define{$_type_define}[0]/ ) ) { 01796 ($okay, $globe::entire_file) = &globe::replace_tag_chunk ( $globe::entire_file, 01797 $globe::m_define{$_type_define}[0], 01798 $globe::m_define{$_type_define}[1], 01799 $globe::m_info{$_type_define}, $_insert_tags, $_criticality); 01800 if (!$okay) { 01801 push (@file_errors, "$_type_define definition messed up in $in_file."); 01802 } 01803 if (0){ 01804 // print "file_chunk_change ok=$okay\n"; 01805 } 01806 01807 } else { 01808 // Figure out where the $_where_flag should go 01809 if ( $globe::entire_file =~ /$_where_flag/ ) { 01810 @pre_chunks = split ( /$_where_flag/, $globe::entire_file, 2); 01811 if ($_after) { 01812 // $globe::entire_file = sprintf("%s%s%s%s", 01813 $pre_chunks[0], 01814 $_where_flag, 01815 $globe::m_info{$_type_define}, 01816 $pre_chunks[1]); 01817 } else { 01818 // $globe::entire_file = sprintf("%s%s%s%s", 01819 $pre_chunks[0], 01820 $globe::m_info{$_type_define}, 01821 $_where_flag, 01822 $pre_chunks[1]); 01823 } 01824 } else { 01825 push (@file_errors, "WARNING: No $_where_flag defined in $_in_file."); 01826 // Do only if no head/body tags 01827 // print "WARNING: No $_where_flag defined.\n"; 01828 return (0); 01829 } // figuring out where it should go 01830 } 01831 return (1); 01832 01833 } // file_chunk_change 01834 01835 01836 01837 01838 //############################################################################# 01839 /** @fn int organize_topic_order 01840 ** @brief Organizes the topic orders. 01841 ** 01842 ** @param None. 01843 ** 01844 ** @return None. 01845 ** 01846 ** @lim None 01847 ** @ingroup tp_nav 01848 **/ 01849 // ############################################################################# 01850 int organize_topic_order ( ) { 01851 if (0) { 01852 // print "organize_topic_order...\n"; 01853 } 01854 if (@globe::book_first_topic > 0) { 01855 // First topics that I know about 01856 if (0) { 01857 // print "==== First topics not yet ordered ====\n"; 01858 for ($i=0; $i<@globe::book_first_topic; $i++){ 01859 // print "$globe::book_first_topic[$i]\n"; 01860 } 01861 // print "Master Chapter Order ===\n"; 01862 for ($i=0; $i<@globe::voy_master_topic_order; $i++){ 01863 // print "$i $globe::voy_master_topic_order[$i]\n"; 01864 } 01865 } 01866 01867 // Sort the book_first_topic array into the same order as the master_topic_order 01868 // The master_topic_order has more topics that the book_first_topic array 01869 01870 for ($i=0; $i < @globe::book_first_topic-1; $i++) { 01871 for ($j=$i+1; $j < @globe::book_first_topic; $j++) { 01872 // Look for the location in the first_topic list where the item is; 01873 // Swap it with the one where it should be. 01874 if ($globe::book_first_topic[$j] < /$globe::book_first_topic[$i]/i) { // case insentive 01875 // Swaps the topics with where it should be 01876 $temp = $globe::book_first_topic[$j]; 01877 $globe::book_first_topic[$j] = $globe::book_first_topic[$i]; 01878 $globe::book_first_topic[$i] = $temp; 01879 } else { 01880 // leave alone. 01881 } // if looking for swap 01882 } // for #j 01883 } // for $i 01884 01885 // Sort the book_last_topic array 01886 for ($i=0; $i < @globe::book_last_topic-1; $i++) { 01887 for ($j=$i+1; $j < @globe::book_last_topic; $j++) { 01888 // Look for the location in the first_topic list where the item is; 01889 // Swap it with the one where it should be. 01890 if ($globe::book_last_topic[$j] < /$globe::book_last_topic[$i]/i) { // case insentive 01891 // Swaps the topics with where it should be 01892 $temp = $globe::book_last_topic[$j]; 01893 $globe::book_last_topic[$j] = $globe::book_last_topic[$i]; 01894 $globe::book_last_topic[$i] = $temp; 01895 } else { 01896 // leave alone. 01897 } // if looking for swap 01898 } // for #j 01899 } // for $i 01900 if (0){ 01901 for ($i=0; $i < @globe::book_last_topic-1; $i++) { 01902 // print "$i = $globe::book_first_topic[$i] == $globe::book_last_topic[$i]\n"; 01903 } 01904 } 01905 // clean up last topic of a chapter 01906 &first_last_prev_next_at_boundary(); 01907 // create a tree file for the fm book 01908 &create_fm_nav_tree(); 01909 } 01910 } // organize_topic_order 01911 01912 //############################################################################# 01913 /** @fn int first_last_prev_next_at_boundary 01914 ** @brief Fixes the boundaries between chapters to fix previous/next 01915 ** references. 01916 ** 01917 ** @param @globe::book_first_topic hash table with the first topics for all 01918 ** chapters. 01919 ** @param @globe::book_last_topic hash table with the last topics for all 01920 ** chapters. 01921 ** 01922 ** @return Actually opens all first and last HTML files for a chapter and 01923 ** replaces the previous/next links with the appropriate references. The 01924 ** first and last chapters wrap to each other. 01925 ** 01926 ** This is called after all HTML files in the directory have been processed 01927 ** and the hash tables for first and last topics filled in. 01928 ** 01929 ** When called, all first and last topics are known. This fixes the last topic 01930 ** in a chapter which has an // undefined "next" topic. This defines the next 01931 ** topic as the first topic in the next chapter. If last chapter, it wraps 01932 ** around to the very first topic in book. 01933 ** 01934 ** @lim In order for this to work correctly, the file names for the chapters 01935 ** have to be named correctly so that they sort into a natural order. This 01936 ** is achieved by having the generation place the same prefix on all HTML 01937 ** files for a given chapter. I chose a two-digit number followed by an 01938 ** underscore. In this manner, all files for a given chapter are grouped 01939 ** together by the prefix. Earlier processing of the files determined which 01940 ** of those topics was the first and last for the chapter. 01941 ** 01942 ** @ingroup tp_nav 01943 **/ 01944 // ############################################################################# 01945 int first_last_prev_next_at_boundary ( ) { 01946 #define $out_file "_temp" 01947 #define $temp_content "" 01948 #define $temp_html "" 01949 01950 NEXT_FIRST: for ($i=0; $i < @globe::book_first_topic ; $i++){ 01951 // // print "$i = first = $globe::book_first_topic[$i]\n$i = last= $globe::book_last_topic[$i]\n"; 01952 unless (open(IN_FIRST, "$globe::book_first_topic[$i]")) { 01953 // print "Cannot open file \"$globe::book_first_topic[$i]\"\n"; 01954 next NEXT_FIRST; 01955 } 01956 $temp_content = ""; 01957 while (<IN_FIRST>){ 01958 $temp_content .= $_; 01959 } 01960 // close (IN_FIRST); 01961 // parse what the next topic should be 01962 if ($i !~ /0/) { 01963 @h_chunk = split ( /\//, $globe::book_last_topic[$i-1]); 01964 } else { 01965 // wrap around to last topic in chapter 01966 @h_chunk = split ( /\//, $globe::book_last_topic[@globe::book_last_topic-1]); 01967 } 01968 $temp_html = $h_chunk[@h_chunk-1]; 01969 // // print "$i = prev file= $temp_html\n"; 01970 // Replace the next topic holder with what it should be 01971 if ($temp_content =~ /$globe::voy_variable_prev_chapter/i) { 01972 $temp_content =~ s/$globe::voy_variable_prev_chapter/$temp_html/g; 01973 unless (open(OUT_FIRST, ">$globe::path$out_file")) { 01974 // print "Cannot open file \"$globe::path$out_file\"\n"; 01975 next NEXT_LAST; 01976 } 01977 // print (OUT_FIRST $temp_content); 01978 // close (OUT_FIRST); 01979 system ("cp $globe::path$out_file $globe::book_first_topic[$i]"); 01980 } // if there is something to replace 01981 01982 } // for all first topics in array 01983 01984 // Modifies the last file to wrap and point to the first. 01985 01986 NEXT_LAST: for ($i=0; $i < @globe::book_last_topic ; $i++){ 01987 // // print "$i = first = $globe::book_first_topic[$i]\n$i = last= $globe::book_last_topic[$i]\n"; 01988 unless (open(IN_LAST, "$globe::book_last_topic[$i]")) { 01989 // print "Cannot open file \"$globe::book_last_topic[$i]\"\n"; 01990 next NEXT_LAST; 01991 } 01992 $temp_content = ""; 01993 while (<IN_LAST>){ 01994 $temp_content .= $_; 01995 } 01996 // close (IN_LAST); 01997 $test_value = @globe::book_last_topic-1; 01998 // parse what the next topic should be 01999 if ($i !~ /$test_value/) { 02000 @h_chunk = split ( /\//, $globe::book_first_topic[$i+1]); 02001 } else { 02002 // wrap around to first topic in chapter 02003 @h_chunk = split ( /\//, $globe::book_first_topic[0]); 02004 } 02005 $temp_html = $h_chunk[@h_chunk-1]; // file name 02006 // // print "$i = next file= $temp_html\n"; 02007 // Replace the next topic holder with what it should be 02008 if ($temp_content =~ /$globe::voy_variable_next_chapter/i) { 02009 $temp_content =~ s/$globe::voy_variable_next_chapter/$temp_html/g; 02010 unless (open(OUT_LAST, ">$globe::path$out_file")) { 02011 // print "Cannot open file \"$globe::path$out_file\"\n"; 02012 next NEXT_LAST; 02013 } 02014 // print (OUT_LAST $temp_content); 02015 // close (OUT_LAST); 02016 system ("cp $globe::path$out_file $globe::book_last_topic[$i]"); 02017 } // if there is something to replace 02018 02019 } // for all last topics in array 02020 } // first_last_prev_next_at_boundary 02021 02022 02023 02024 //############################################################################# 02025 /** @fn int create_fm_nav_tree 02026 ** @brief Creates a tree file which is the TOC for the FrameMaker book. 02027 ** 02028 ** @param @globe::book_first_topic hash table. 02029 ** @param @globe::fm_format_levels hash table with the FrameMaker format 02030 ** level for that topic. This is typically its heading number. 02031 ** 02032 ** @return Outputs a tree.html file that is the TOC for this book. 02033 ** 02034 ** In order to accomplish this, the hash tables with the topic order must 02035 ** be generated first. This routine starts at the very first first_topic 02036 ** and steps through its next links. Then it goes to the next first_topic 02037 ** (e.g., the first topic of the next chapter) and steps through its next 02038 ** links. 02039 ** 02040 ** When stepping through the topics, it notes the heading level. A 1-bit clear 02041 ** GIF is used whose width is varied depending upon heading level to get 02042 ** placement in the tree.html that is appropriate for the TOC. 02043 ** 02044 ** @lim In order for this to work correctly, the file names for the chapters 02045 ** have to be named correctly so that they sort into a natural order. This 02046 ** is achieved by having the generation place the same prefix on all HTML 02047 ** files for a given chapter. I chose a two-digit number followed by an 02048 ** underscore. In this manner, all files for a given chapter are grouped 02049 ** together by the prefix. Earlier processing of the files determined which 02050 ** of those topics was the first and last for the chapter. 02051 ** 02052 ** This used information that came specifically from our implementation 02053 ** of styles in FrameMaker. 02054 ** 02055 ** @ingroup tp_nav 02056 **/ 02057 // ############################################################################# 02058 int create_fm_nav_tree ( ) { 02059 if (0) { 02060 // print "gcm create_fm_nav_tree...\n"; 02061 if (0) { 02062 // print "first last $globe::m_var{value}{firstlast}\n"; 02063 } 02064 if (1) { 02065 foreach $thing (keys %globe::book_topics){ 02066 // print "$thing = $globe::book_topic_level{$thing} = $globe::book_topic_order{$thing}\n"; 02067 $thing_cnt++; 02068 } 02069 } 02070 // // exit(1); 02071 // print "++++++++++++++++\n"; 02072 } 02073 #define $htree_file "tree.html" 02074 #define $script_file "tree.script" 02075 02076 $num_start = $// globe::book_first_topic; 02077 $num_end = $// globe::book_last_topic; 02078 02079 if ($num_start > $num_end) { 02080 // It is okay if there are more ending topics than starting. 02081 // Hopefully, all starting topics when traced through "next" will 02082 // eventually terminate on one of the ending topics. 02083 // print "ERROR: number of chapter starts ($num_start) does not equal num of end of chapters ($num_end).\n"; 02084 // print "\t\tNo tree file created!!!\n"; 02085 push (@file_errors, "ERROR: $in_file\n\tnumber of chapter starts ($num_start) does not equal num of end of chapters ($num_end)."); 02086 return(1); 02087 } 02088 02089 $temp = $globe::book_first_topic[0]; 02090 @name_chunks = split ( /\//, $temp); 02091 // if the syntax is: 02092 // doc_publish/book_innovox_api/File.htm 02093 // then the first element is doc_publish and the last is the file name. 02094 // I want the directory. 02095 $temp = ""; 02096 for ($i=0; $i< $// name_chunks; $i++) { 02097 $temp .= "$name_chunks[$i]/"; 02098 } 02099 $htree_file = "$temp$htree_file"; 02100 $script_file = "$temp$script_file"; 02101 02102 // print "Preparing to write new file = $htree_file\n"; 02103 // print "Preparing to write new file = $script_file\n"; 02104 02105 unless (open(OUT_HTREE, ">$htree_file")) { 02106 // print "Cannot open file \"$htree_file\"\n"; 02107 return(1); 02108 } 02109 unless (open(OUT_SCRIPT, ">$script_file")) { 02110 // print "Cannot open file \"$script_file\"\n"; 02111 return(1); 02112 } 02113 02114 // Re-use $temp 02115 // CREATE TITLE 02116 // Title now comes from the navigation files. 02117 // $temp = $name_chunks[1]; 02118 // $temp =~ s/book_//g; 02119 // $temp =~ s/cref_//g; 02120 // $temp =~ s/cit/CIT/g; 02121 // $temp =~ s/dtoss/DTOSS/g; 02122 // $temp =~ s/api/API/g; 02123 // $temp =~ s/_/ /g; 02124 // $temp =~ s/(\w+)/\u$1/g; # changes first letter of words to be all caps 02125 02126 $tcntgcm = 0; 02127 // ################################################# 02128 // Root level of tree. 02129 // ################################################# 02130 // print (OUT_HTREE "<html>\n<head>\n$globe::m_info{header}\n</head>\n<body>\n"); 02131 // print (OUT_HTREE "$globe::m_define{topic_list}[0]"); // This does not have a return on purpose. 02132 // print (OUT_HTREE "$globe::chapter_division"); // This does not have a return on purpose. 02133 // print (OUT_HTREE "0"); // This does not have a return on purpose. 02134 // print (OUT_HTREE "$globe::chapter_division_e"); // This does not have a return on purpose. 02135 // print (OUT_HTREE "<pre class =\"navnarrow\"><a class=\"navigation\" href=\"$globe::empty_html\" target=\"treefrm\"><img src=\"nav_folderopen.gif\" border=\"0\"><b>$globe::master_order_title[$globe::master_order_key]</b></a></pre>\n"); 02136 02137 // #### 02138 // whether or not nested script files are used. 02139 // #### 02140 #define $nested_script 1 // 0 means not, 1 means are 02141 if ($nested_script == 0) { 02142 // #### 02143 // Not using nested script files 02144 // #### 02145 // print (OUT_SCRIPT "Item level=1 "); 02146 // print (OUT_SCRIPT "image=nav_folderclosed.gif "); 02147 // // print (OUT_SCRIPT "url=$temp_remember_url,basefrm "); 02148 // print (OUT_SCRIPT "selected=YES "); 02149 // print (OUT_SCRIPT "text=$globe::master_order_title[$globe::master_order_key]\r\n"); 02150 } else { 02151 // #### 02152 // Using nested script files 02153 // No title is necessary. 02154 // #### 02155 } 02156 02157 // ################################################# 02158 02159 // ################################################# 02160 // This is the main loop; it starts at a first topic and then traces the next 02161 // topics from there. When a next topic is determined to be a last topic for 02162 // that section, it then goes and gets the next first topic. 02163 // ################################################# 02164 for ($i=0; $i <= $// globe::book_first_topic; $i++) { 02165 $keyabs = $globe::book_first_topic[$i]; 02166 @name_chunks = split ( /\//, $globe::book_first_topic[$i]); 02167 $html_name = $name_chunks[$// name_chunks]; 02168 pop (@name_chunks); 02169 $html_path = join ("\/", @name_chunks); 02170 02171 02172 // $globe::last_book_level should be 0 at this point 02173 $globe::last_book_level = 0; 02174 $temp_remember_title = "_start_"; 02175 $temp_remember_url = "_start_"; 02176 $current_level = 0; 02177 $remember_current_level = 0; 02178 02179 // Default values 02180 $keep_going = 1; 02181 $almost_done = 0; 02182 02183 // 06/24/2002 Changed so that it won't put dual entries into tree files 02184 // if it has a next that is the "next chapter". 02185 if ($globe::book_topic_order{$keyabs} =~ /$globe::voy_variable_next_chapter/) { 02186 // This topic was found to be a last topic 02187 if (0) { 02188 // print "++ending $keyabs $globe::book_topic_order{$keyabs}\n"; 02189 } 02190 if ($globe::m_var{value}{firstlast} =~ /1\// 1/) { 02191 // if this is the only html page, then don't do loop again. 02192 $keep_going = 0; 02193 } 02194 } // 06/24/2002 02195 02196 // ################################################# 02197 // Loop to trace through from the current topic to the next topic. 02198 // It keeps going until it determines that the next topic is the last 02199 // topic for that section. 02200 // ################################################# 02201 02202 do { // keep_going 02203 if ($almost_done) { 02204 $keep_going = 0; // sets that this is the last time through; picks up very last element 02205 } 02206 if (0) { 02207 // print "another one = $keyabs\n"; 02208 } 02209 @name_chunks = split ( /\//, $keyabs); 02210 $html_name = $name_chunks[$// name_chunks]; 02211 pop (@name_chunks); 02212 $html_path = join ("\/", @name_chunks); 02213 02214 for ($lev_test=0; $lev_test <= $// globe::fm_format_levels; $lev_test++){ 02215 if ($globe::book_topic_level{$keyabs} =~ /$globe::fm_format_levels[$lev_test]/ ) { 02216 // This is the level we're on 02217 $current_level = $lev_test; 02218 } 02219 } // lev_test 02220 for ($k=0; $k<=$current_level+1; $k++){ 02221 // // print out the appropriate number of leading spaces 02222 $temp = 10 * $k; 02223 // } // for $k printing space 02224 02225 // #### 02226 // Made it always on so that we always have level. 02227 // #### 02228 // print (OUT_HTREE "$globe::chapter_division"); 02229 // print (OUT_HTREE "$current_level"); 02230 // print (OUT_HTREE "$globe::chapter_division_e"); 02231 // #### 02232 // print (OUT_HTREE "<pre class =\"navnarrow\"><img src=\"clear.gif\" width=\"$temp\" height=\"0\">"); 02233 if (0) { // debug 02234 // print "$temp = "; 02235 } // debug 02236 02237 $temp_remember_title = $globe::book_topics{$keyabs}; 02238 $temp_remember_url = $html_name; 02239 // #### 02240 // incremented for the script 02241 // #### 02242 if ($nested_script == 0) { 02243 // #### 02244 // Old: 02245 // Not using nested script files. 02246 // #### 02247 $temp_c_level = $current_level+1; 02248 } else { 02249 // New: 02250 // So we can use nested script files 02251 // #### 02252 $temp_c_level = $current_level; 02253 } 02254 02255 // print (OUT_HTREE "<a class=\"navigation\" href=\"$temp_remember_url\" target=\"basefrm\"><img src=\"nav_doc.gif\" border=\"0\"><b>$temp_remember_title</b></a></pre>\n"); 02256 // print (OUT_SCRIPT "Item level=$temp_c_level "); 02257 // print (OUT_SCRIPT "image=nav_doc.gif "); 02258 // print (OUT_SCRIPT "url=$temp_remember_url,basefrm "); 02259 // print (OUT_SCRIPT "selected=YES "); 02260 // print (OUT_SCRIPT "text=$temp_remember_title\r\n"); 02261 $tcntgcm++; 02262 if (0) { // debug 02263 // // print "gcm $html_name\n"; 02264 // print "$temp_remember_title\n"; 02265 } // debug 02266 02267 02268 // ################################################# 02269 // Determine where the next topic is tracing it 02270 // in hash. 02271 // ################################################# 02272 $next = $globe::book_topic_order{$keyabs}; // $next doesn't have full path 02273 $next_abs = join ("\/", $html_path, $next); // $next_abs has full path 02274 $found_next = 0; 02275 if (0) {// debug 02276 // print "Next topic=$next; $next_abs\n"; 02277 } // debug 02278 02279 // ################################################# 02280 // Find the next topic in the huge hash 02281 // ################################################# 02282 SEARCH_NEXT: foreach $key (keys %globe::book_topic_order){ 02283 if (0) {// debug 02284 // print "1 Next topic=$key\n"; 02285 } // debug 02286 if (($key =~ /$next_abs/i) && ($next_abs =~ /$key/i)) { 02287 // handles partial matches so that only exact matches win 02288 $keyabs = $key; // This is the next topic 02289 $found_next = 1; 02290 if (0) {// debug 02291 // print "2 Next topic=$keyabs\n"; 02292 } // debug 02293 last SEARCH_NEXT; 02294 } 02295 } // foreach $key 02296 02297 // ################################################# 02298 // Determine if topic is a last topic. 02299 // The first_topic and last_topic array do not match index-index 02300 // Check each possible last topic with the current topic to see if last 02301 // ################################################# 02302 if (1) { // 06/24/2002 02303 if ($globe::book_topic_order{$keyabs} =~ /$globe::voy_variable_next_chapter/) { 02304 // This topic was found to be a last topic 02305 if (0) { 02306 // print "++ending $keyabs $globe::book_topic_order{$keyabs}\n"; 02307 } 02308 if ((0) && ($globe::m_var{value}{firstlast} =~ /1\// 1/)) { 02309 // if this is the only html page, then don't do loop again. 02310 $keep_going = 0; 02311 } else { 02312 $almost_done = 1; 02313 } 02314 } 02315 } // 06/24/2002 02316 02317 // The following test is no longer absolutely valid; needs tweaking. 02318 if (($found_next =~ /0/) && ($globe::book_topic_order{$keyabs} !~ /$globe::voy_variable_next_chapter/)) { 02319 // The desired next topic wasn't parsed, so loop won't end 02320 // print "WARNING: ($keyabs) references non-existent next topic ($next).\n"; 02321 push (@file_errors, "WARNING: ($keyabs) references non-existent next topic ($next)."); 02322 // Terminate this loop. 02323 $keep_going = 0; 02324 } 02325 // ################################################# 02326 02327 } while ($keep_going); 02328 02329 } // for first topics... go get next first topic (beginning of new section) 02330 02331 // ################################################# 02332 // Clean up navigation. 02333 // ################################################# 02334 // print (OUT_HTREE "$globe::m_define{topic_list}[1]"); 02335 // print (OUT_HTREE "\n$globe::m_info{footer}\n</body>\n</html>\n"); 02336 // ################################################# 02337 02338 // print "Total number of topics $tcntgcm\n"; 02339 // close (OUT_HTREE); 02340 // close (OUT_SCRIPT); 02341 02342 } // create_fm_nav_tree 02343 02344 02345 02346 //############################################################################# 02347 /** @fn int END 02348 ** @brief Code to execute when first entered. 02349 ** 02350 ** @param None. 02351 ** 02352 ** @return None. 02353 ** 02354 ** @lim None 02355 ** @ingroup tp_nav 02356 **/ 02357 // ############################################################################# 02358 int END ( ) { 02359 // undef ($_file_list); // "_file_list"; 02360 // undef ($_index_file); // = "_index_list"; 02361 // undef ($in_file); // ""; 02362 // undef ($f_type); // "htm"; 02363 02364 02365 // ############################################################################# 02366 // # Memory clean-up. 02367 // ############################################################################# 02368 if ($no_scope_file > 0){ 02369 &globe::memory_clean_up(); 02370 } 02371 02372 if (@file_errors) { 02373 // print "\n============ Summary of errors ==================================\n"; 02374 for ($i=0; $i<@file_errors; $i++){ 02375 // print "$i = $file_errors[$i]\n"; 02376 } 02377 } 02378 02379 // print "\n============ Finished voyant_nav.pl ==================================\n"; 02380 } // END 02381 02382
|
|
|
Open-Source tools compliments of Voyant Technologies, Inc. and Glenn C. Maxey.
01/13/2003
TP Tools v2-00-0a
# tpt-perl-hcr-02