View ¡m../msn-2-html/msn-2-html.pl¡n
#!/usr/local/bin/perl # # Name: # msn-2-html.pl. # # Purpose: # Covert MSN browser favourites from XML into HTML. # # Note: # o Input file created by make-well-formed.pl # o Outputs Favorites.html and a set of pages, 1 per favorites folder # o tabs = 4 spaces || die # # V 1.00 11-Mar-2002 # ------------------ # o Initial version # # Programs in distribution: # MSN2HTML.pm # msn-2-html.pl # make-well-formed.pl # # Author: # Ron Savage
# http://savage.net.au/index.html # # Licence: # Australian Copyright (c) 1999-2002 Ron Savage. # # All Programs of mine are 'OSI Certified Open Source Software'; # you can redistribute them and/or modify them under the terms of # The Artistic License, a copy of which is available at: # http://www.opensource.org/licenses/index.html use lib './MSN2HTML.pm'; use strict; use warnings; use CGI; use MSN2HTML; use XML::SAX::ParserFactory; # -------------------------------------------------------------------------------------- my($work_dir_name) = '/temp/msn'; my($input_file_name) = 'Favorites-nice.xml'; my($output_file_name) = 'Favorites.html'; my($q) = CGI -> new; my($border) = 0; my($handler) = MSN2HTML -> new(_debug => 1); my($parser) = XML::SAX::ParserFactory -> parser(Handler => $handler); chdir($work_dir_name) || die("Can't chdir($work_dir_name): $!"); $parser -> parse_uri($input_file_name); my($f, @f); for $f (@{$$handler{_folder} }) { my($p) = CGI -> new(); my($file_name) = $$f[1]; $file_name =~ tr/ /-/; push(@f, [$$f[1], "${file_name}.html"]); die("Page $file_name.html exists") if (-f "${file_name}.html"); open(OUT, "> $file_name.html") || die("Can't open(> $file_name.html): $!"); print OUT $q -> start_html(), $q -> center($q -> h2($$f[1]) ), $q -> table ( {align => 'center', bgColor => '#80c0FF', border => 1}, $q -> Tr ([ map{$q -> td($q -> a({href => $$_[1]}, $$_[0]) )} sort{lc $$a[0] cmp lc $$b[0]} @{$$f[3]} ]) ), $q -> br(), $q -> center($q -> a({href => $output_file_name}, "Back to $output_file_name") ), $q -> end_html(); close(OUT); print "Created $file_name.html\n"; } die("Page $output_file_name exists") if (-f $output_file_name); open(OUT, "> $output_file_name") || die("Can't open(> $output_file_name): $!"); print OUT $q -> start_html(), $q -> center($q -> h2('Favorites') ), $q -> center($q -> h3('Sites') ), $q -> table ( {align => 'center', bgColor => '#80c0FF', border => 1}, $q -> Tr ([ map{$q -> td($q -> a({href => $$_[5]}, $$_[3]) )} sort{lc $$a[3] cmp lc $$b[3]} @{$$handler{_favorite} } ]) ), $q -> br(), $q -> center($q -> h3('Pages of Sites') ), $q -> table ( {align => 'center', bgColor => '#80c0FF', border => 1}, $q -> Tr ([ map{$q -> td($q -> a({href => $$_[1]}, $$_[0]) )} sort{lc $$a[0] cmp lc $$b[0]} @f ]) ), $q -> end_html(); close(OUT); print "Created $output_file_name\n";