/[MITgcm]/mitgcm.org/front_content/Assemble.pl
ViewVC logotype

Diff of /mitgcm.org/front_content/Assemble.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by edhill, Wed Dec 3 03:36:29 2003 UTC revision 1.9 by jmc, Fri Feb 29 00:40:37 2008 UTC
# Line 1  Line 1 
1  #! /usr/bin/env perl  #! /usr/bin/perl
2    
3  #  Ed Hill  #  Ed Hill
4  #  Tue Dec  2 20:17:27 EST 2003  #  Tue Dec  2 20:17:27 EST 2003
5    
6  #  Assemble the web pages from XML files.  #  Assemble the web pages from XML files.
7    
8  open(TOP,"<top_list.txt") or die "ERROR: can't open \"top_list.txt\"\n";  $topdir = ".";
9  while($line = <TOP>)  {  $file_list = $topdir . "/order.txt";
10      chomp($line);  open(ORDER,$file_list) or die "ERROR: can't open \"$file_list\"\n";
11      length($line) > 0 and @top_list[$top_list++] = $line;  $_ = join(" ", <ORDER>);
12  }  s/\n//s;
13    @flist = split(" ", $_);
14    
15  open(TEMPL,"<template.xml") or die "ERROR: can't open \"template.xml\"\n";  open(TEMPL,"<template.xml") or die "ERROR: can't open \"template.xml\"\n";
16  $template = join "", <TEMPL>;  $template = join "", <TEMPL>;
17    
18  mkdir html;  system("rm -rf html");
19    system("mkdir html");
20    
21  foreach $file (@top_list)  {  print "Parsing files ...  ";
22    foreach $file (@flist) {
23        $fname = $topdir . "/" . $file;
24        open(INF,$fname) or die "ERROR: can't open \"$fname\"\n";
25        $all = join "", <INF>;
26        $_ = $all;
27        /<meta *name="add_name_0" *content="(.*)"/  and $k0 = $1;
28        $_ = $all;
29        /<meta *name="add_name_1" *content="(.*)"/ and $k1 = $1;
30        $name0{$file} = $k0;
31        $name1{$file} = $k1;
32        close(INF);
33    }
34    print "  done\n";
35    
36      $fname = "<./" . $file . ".xml";  print "Generating XHTML ...";
37    foreach $file (@flist) {
38        
39        $fname = "<" . $topdir . "/" . $file;
40      open(INF,$fname) or die "ERROR: can't open \"$fname\"\n";      open(INF,$fname) or die "ERROR: can't open \"$fname\"\n";
41      $f_all = join "", <INF>;      $f_all = join "", <INF>;
42        close(INF);
43    
44        #  Get the body
45      $_ = $f_all;      $_ = $f_all;
46      /<body>(.*)<\/body>/s and $body = $1;      /<body>(.*)<\/body>/s and $body = $1;
47    
48        #  Get the title
49      $_ = $f_all;      $_ = $f_all;
50      /<meta *name="add_title" *content="(.*)"/ and $title = $1;      /<meta *name="add_title" *content="(.*)"/ and $title = $1;
51    
52      $_ = $f_all;      #  Create the menu
53      /<meta *name="add_name_0" *content="(.*)"/ and $name = $1;      $cname = $name0{$file};
   
54      $menu = "";      $menu = "";
55      foreach $f (@top_list)  {      foreach $fm (@flist) {
56          if ($f ne $file) {          $ind = "";
57              $tmp = "<a href=\"./" . $f . ".html\">" . $f . "</a><br />\n";          $name = $name0{$fm};
58    
59    #       if ($name eq "Documentation") {
60    #           $tmp = "<a href=\"http://eddy.csail.mit.edu/r2/latest/\">"
61    #               . "Documentation</a><br />\n";
62    #           $menu = join "", $menu, $tmp;
63    #           next;
64    #       }
65    
66            if (length($name1{$fm}) > 0) {
67                $ind = "&nbsp;&nbsp;&nbsp;";
68                $name = $name1{$fm};
69            }
70            if (length($ind) > 0 and ($name0{$fm} ne $cname)) {
71                next;
72            }
73            if ($fm ne $file) {
74                $_ = $fm;
75                s/.xml/.html/;
76                $tmp = $ind . "<a href=\"./" . $_ . "\">" . $name . "</a><br />\n";
77          } else {          } else {
78              $tmp = "<b>" . $name . "</b>\n";              $tmp = $ind . "<b>" . $name . "</b><br />\n";
79          }          }
80          $menu = join "", $menu, $tmp;          $menu = join "", $menu, $tmp;
81      }      }
82        # $tmp = "<a href=\"./htdig\" />Search</a><br />\n";
83        # $menu = join "", $menu, $tmp;
84    
85        #  Create the output
86      $_ = $template;      $_ = $template;
87      s/<!--ADDTITLE-->/$title/s;      s/<!--ADDTITLE-->/$title/s;
88      s/<!--ADDMENU-->/$menu/s;      s/<!--ADDMENU-->/$menu/s;
89      s/<!--ADDCONTENT-->/$body/s;      s/<!--ADDCONTENT-->/$body/s;
90        $content = $_;
91    
92      $out_name = ">./html/" . $file . ".html";      $_ = $file;
93        s/.xml/.html/;
94        $out_name = ">./html/" . $_;
95      open(OUT,$out_name) or die "ERROR: can't open \"$out_name\"\n";      open(OUT,$out_name) or die "ERROR: can't open \"$out_name\"\n";
96      print OUT $_;      print OUT $content;
97    
98      close(OUT);      close(OUT);
     close(INF);  
99  }  }
100    print "  done\n";
101    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.22