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

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

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


Revision 1.9 - (hide annotations) (download)
Fri Feb 29 00:40:37 2008 UTC (13 years, 6 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 edhill 1.6 #! /usr/bin/perl
2 edhill 1.1
3     # Ed Hill
4     # Tue Dec 2 20:17:27 EST 2003
5    
6     # Assemble the web pages from XML files.
7    
8 edhill 1.4 $topdir = ".";
9 edhill 1.2 $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 edhill 1.1
15     open(TEMPL,"<template.xml") or die "ERROR: can't open \"template.xml\"\n";
16     $template = join "", <TEMPL>;
17    
18 edhill 1.2 system("rm -rf html");
19     system("mkdir html");
20 edhill 1.1
21 edhill 1.2 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 edhill 1.1
36 edhill 1.2 print "Generating XHTML ...";
37     foreach $file (@flist) {
38    
39     $fname = "<" . $topdir . "/" . $file;
40 edhill 1.1 open(INF,$fname) or die "ERROR: can't open \"$fname\"\n";
41     $f_all = join "", <INF>;
42 edhill 1.2 close(INF);
43 edhill 1.1
44 edhill 1.2 # Get the body
45 edhill 1.1 $_ = $f_all;
46     /<body>(.*)<\/body>/s and $body = $1;
47    
48 edhill 1.2 # Get the title
49 edhill 1.1 $_ = $f_all;
50     /<meta *name="add_title" *content="(.*)"/ and $title = $1;
51    
52 edhill 1.2 # Create the menu
53     $cname = $name0{$file};
54 edhill 1.1 $menu = "";
55 edhill 1.2 foreach $fm (@flist) {
56     $ind = "";
57     $name = $name0{$fm};
58 edhill 1.7
59 jmc 1.9 # 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 edhill 1.7
66 edhill 1.2 if (length($name1{$fm}) > 0) {
67 edhill 1.3 $ind = "&nbsp;&nbsp;&nbsp;";
68 edhill 1.2 $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 edhill 1.1 } else {
78 edhill 1.2 $tmp = $ind . "<b>" . $name . "</b><br />\n";
79 edhill 1.1 }
80     $menu = join "", $menu, $tmp;
81     }
82 edhill 1.5 # $tmp = "<a href=\"./htdig\" />Search</a><br />\n";
83     # $menu = join "", $menu, $tmp;
84 edhill 1.1
85 edhill 1.2 # Create the output
86 edhill 1.1 $_ = $template;
87     s/<!--ADDTITLE-->/$title/s;
88     s/<!--ADDMENU-->/$menu/s;
89     s/<!--ADDCONTENT-->/$body/s;
90 edhill 1.2 $content = $_;
91 edhill 1.1
92 edhill 1.2 $_ = $file;
93     s/.xml/.html/;
94     $out_name = ">./html/" . $_;
95 edhill 1.1 open(OUT,$out_name) or die "ERROR: can't open \"$out_name\"\n";
96 edhill 1.2 print OUT $content;
97 edhill 1.1
98     close(OUT);
99     }
100 edhill 1.2 print " done\n";
101 edhill 1.1

  ViewVC Help
Powered by ViewVC 1.1.22