3 # hotexplode -- a program for "exploding" a xmosaic hotlist or Netscape
4 # bookmark file into a hierarchial multi-page structure.
8 # v1.0: 1-3-1996: initial version
14 # header: some arbitrary HTML text which is appended below the title and
15 # above the hotlist data
20 This hotlist was generated with
21 <a href="http://www.zikzak.net/~acb/hacks/hotexplode.html">hotexplode</a>
24 <b>WARNING:</b> The inclusion of a link to a page on
25 this hotlist is not an indication of the maintainer's
26 approval of or agreement with its content.
30 Please <b>DO NOT</b> bookmark this page. Bookmark the
31 <a href="http://phd.pp.ru/Bookmarks/">main page</A> instead.
32 Any other page in the hierarchy can be renamed, moved or removed at any time.
40 # which directory shall contain the hotlist?
45 # end of customisable portion
51 $outdir = $opt_o if $opt_o;
54 # seek forward to the title
56 if (/<TITLE>([^\<\>]*)<\/TITLE>/) {
62 $title = $opt_t if $opt_t;
64 # seek forward to the start of the list
68 if(/<UL>/) { warn "Detected xmosaic hotlist format\n" if $opt_v;
69 &parse_mosaic_hotlist($outdir, $title); last; }
70 if(/<DL>/) { warn "Detected Netscape bookmark format\n" if $opt_v;
71 &parse_netscape_bookmarks($outdir, $title); last; }
74 # parse an xmosaic hotlist
75 # exit when we meet a </UL>
76 # arguments: pathname of directory in which output is to be placed,
79 sub parse_mosaic_hotlist {
80 # we write the file at the very end, because (I think) filehandles do
81 # not have local scope, and this is recursive
82 local($prefix, $title) = @_;
83 local($result) = "<HTML><HEAD>\
84 <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=koi8-r\">\
85 <TITLE>$title</TITLE>\
87 <BODY>\n<CENTER><H1>$title</H1></CENTER>\n $header \n<hr>\n<ul>";
89 warn "Creating $prefix...\n" if $opt_v;
91 # create the directory, if needed
92 mkdir($prefix, 0755) unless -d $prefix;
97 if(/<LI> *<A HREF=\"([^\"]*)\"[^\>]*>([^\<]*)<\/A>/) {
101 local($url,$name) = ($1, $2);
102 $result = $result."<li><a href=\"$url\">$name </a>\n";
107 # we've got a live one here...
109 local($subtitle)=local($filename)=$1;
110 $filename =~ tr/0-9A-Za-z//cd;
111 $filename =~ tr/A-Z/a-z/;
112 <>; # eat the "<UL>" line.
113 $result .= "<li><b><a href=\"${filename}/index.html\">${subtitle}</a></b>\n";
114 &parse_mosaic_hotlist("${prefix}/${filename}", "${title}:${subtitle}");
120 $result = $result . $footer . "</body></html>";
122 open(FILE, ">${prefix}/index.html");
127 # parse a Netscape bookmarks list
128 # exit when we meet a </DL>
129 # arguments: pathname of directory in which output is to be placed,
132 sub parse_netscape_bookmarks {
133 # we write the file at the very end, because (I think) filehandles do
134 # not have local scope, and this is recursive
135 local($prefix, $title) = @_;
136 local($result) = "<HTML><HEAD>\
137 <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=koi8-r\">\
138 <TITLE>$title</TITLE>\
140 <BODY>\n<CENTER><H1>$title</H1></CENTER>\n $header \n<hr>\n<dl>";
142 warn "Creating $prefix...\n" if $opt_v;
144 # create the directory, if needed
145 mkdir($prefix, 0755) unless -d $prefix;
149 if (/<DT><H3[^\>]*>([^\<]*)<\/H3>/) {
155 $filename =~ tr/0-9A-Za-z//cd;
156 $filename =~ tr/A-Z/a-z/;
157 # parse the description here
163 $result = $result . "<dt><b><a href=\"${filename}/index.html\">${subtitle}</a></b>\n";
164 unless("$desc" eq "") { $result = $result . $desc; }
165 &parse_netscape_bookmarks("${prefix}/${filename}",
166 "${title}:${subtitle}");
169 if (/<DT><A HREF=\"([^\"]*)\"[^\>]*>([^\<]*)<\/A>/) {
173 local($url, $name) = ($1, $2);
174 $result = $result."<dt><a href=\"$url\">$name </a>\n";
177 $result = $result . $_;
179 $result = $result . $footer . "</body></html>";
181 open(FILE, ">${prefix}/index.html");