forked from jdtsmith/idlwave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addlinks.pl
executable file
·53 lines (46 loc) · 1.46 KB
/
addlinks.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
#
# Program to fixup RSI-scanned HTML to contain the previous and next
# links (in two location, top and bottom), plus some other useful
# links.
#
# (c)2004 J.D. Smith <[email protected]>
#
# Version Supporting: IDLv6.1
#
# Verify that the listing files funclisting.html, nav_procedures.html,
# nav_functions.html, nav_objects.html all exist, or modify below as
# necessary.
#
# Usage: addlinks.pl (in directory containing IDL .html files)
#
opendir DIR,"." or die "Can't open current directory\n";
my @files=grep {-f && /\.html$/} readdir(DIR);
close DIR;
die "No HTML files found.\n" unless @files;
undef $/;
my $contents=
'<a href="home.html">Home</a> | '.
'<a href="funclisting.html">Categories</a> | '.
'<a href="idl_alph.html">Alphabetical</a> | '.
'<a href="idl_obj_class.html">Classes</a> | '.
'<a href="idl_con.html">All Contents</a> | ';
foreach $file (@files) {
open FILE, "<$file" or do {warn "Can't open $file... skipping"; next};
$_=<FILE>;
close FILE;
if (m|<meta\ name="PREV_PAGE"\ content="([^"]+)"\ />\s*
<meta\ name="NEXT_PAGE"\ content="([^"]+)"\ />|xs) {
my ($prev,$next)=($1,$2);
$links='<div class="CellBody">'.
$contents .
"<a href=\"$prev\">[ < ]</a> | " .
"<a href=\"$next\">[ > ]</a>" .
"</div>";
s|^\s*</head>|$&\n$links<hr>|m;
s|^\s*</body>|<hr>$links\n$&|m;
open FILE, ">$file" or do {warn "Can't write to $file... skipping"; next};
print FILE;
close FILE;
}
}