/[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.5 - (hide annotations) (download)
Wed Mar 10 15:12:55 2004 UTC (17 years, 7 months ago) by edhill
Branch: MAIN
Changes since 1.4: +2 -2 lines
File MIME type: text/plain
 o cleanup search

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

  ViewVC Help
Powered by ViewVC 1.1.22