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

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

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


Revision 1.9 - (show annotations) (download)
Fri Feb 29 00:40:37 2008 UTC (16 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +6 -6 lines
File MIME type: text/plain
put back an updated version of docs.html (from front-page) ;

1 #! /usr/bin/perl
2
3 # Ed Hill
4 # Tue Dec 2 20:17:27 EST 2003
5
6 # Assemble the web pages from XML files.
7
8 $topdir = ".";
9 $file_list = $topdir . "/order.txt";
10 open(ORDER,$file_list) or die "ERROR: can't open \"$file_list\"\n";
11 $_ = join(" ", <ORDER>);
12 s/\n//s;
13 @flist = split(" ", $_);
14
15 open(TEMPL,"<template.xml") or die "ERROR: can't open \"template.xml\"\n";
16 $template = join "", <TEMPL>;
17
18 system("rm -rf html");
19 system("mkdir html");
20
21 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 print "Generating XHTML ...";
37 foreach $file (@flist) {
38
39 $fname = "<" . $topdir . "/" . $file;
40 open(INF,$fname) or die "ERROR: can't open \"$fname\"\n";
41 $f_all = join "", <INF>;
42 close(INF);
43
44 # Get the body
45 $_ = $f_all;
46 /<body>(.*)<\/body>/s and $body = $1;
47
48 # Get the title
49 $_ = $f_all;
50 /<meta *name="add_title" *content="(.*)"/ and $title = $1;
51
52 # Create the menu
53 $cname = $name0{$file};
54 $menu = "";
55 foreach $fm (@flist) {
56 $ind = "";
57 $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 {
78 $tmp = $ind . "<b>" . $name . "</b><br />\n";
79 }
80 $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;
87 s/<!--ADDTITLE-->/$title/s;
88 s/<!--ADDMENU-->/$menu/s;
89 s/<!--ADDCONTENT-->/$body/s;
90 $content = $_;
91
92 $_ = $file;
93 s/.xml/.html/;
94 $out_name = ">./html/" . $_;
95 open(OUT,$out_name) or die "ERROR: can't open \"$out_name\"\n";
96 print OUT $content;
97
98 close(OUT);
99 }
100 print " done\n";
101

  ViewVC Help
Powered by ViewVC 1.1.22