/[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.4 - (show annotations) (download)
Sat Dec 6 21:10:18 2003 UTC (17 years, 10 months ago) by edhill
Branch: MAIN
Changes since 1.3: +1 -1 lines
File MIME type: text/plain
 o various cleanups

1 #! /usr/bin/env 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 if (length($name1{$fm}) > 0) {
59 $ind = "&nbsp;&nbsp;&nbsp;";
60 $name = $name1{$fm};
61 }
62 if (length($ind) > 0 and ($name0{$fm} ne $cname)) {
63 next;
64 }
65 if ($fm ne $file) {
66 $_ = $fm;
67 s/.xml/.html/;
68 $tmp = $ind . "<a href=\"./" . $_ . "\">" . $name . "</a><br />\n";
69 } else {
70 $tmp = $ind . "<b>" . $name . "</b><br />\n";
71 }
72 $menu = join "", $menu, $tmp;
73 }
74 $tmp = "<a href=\"./htdig\" />Search</a><br />\n";
75 $menu = join "", $menu, $tmp;
76
77 # Create the output
78 $_ = $template;
79 s/<!--ADDTITLE-->/$title/s;
80 s/<!--ADDMENU-->/$menu/s;
81 s/<!--ADDCONTENT-->/$body/s;
82 $content = $_;
83
84 $_ = $file;
85 s/.xml/.html/;
86 $out_name = ">./html/" . $_;
87 open(OUT,$out_name) or die "ERROR: can't open \"$out_name\"\n";
88 print OUT $content;
89
90 close(OUT);
91 }
92 print " done\n";
93

  ViewVC Help
Powered by ViewVC 1.1.22