On 12/15/2002 11:21 PM, Puneet Kishor wrote: > > well, this is really very simple... geeks, please don't laugh. this is > for newbies only. > > 1. I have a directory called unixtips. > 2. I have the following files -- index.html, toc.pl, tipdetail.pl, > unixtips.txt (files shown below) > 3. index.html is a simple frame of two columns with a table of contents > on the left (toc), and the main body for the tip on the right > (tipdetail) > 4. unixtips.txt contains the tips I copy from my email. Each tip starts > with the words "TIP: " and ends with ====. Any code that one types is > bounded by -- before and after. > 5. that's it. ;-) I told you, it was simple. You can see the tips I > have collected at > 209.83.8.226/unixtips/index.html. The site is for personal use only, so > don't be sending a dos attack against it ;-).
[snip the codes] mmh ... cool. First of all: I saw in your tipdetail.pl frame's html code that it was output as xml. Why? Is CGI::Pretty doing that? I saw no evidence of that in your tipdetail.pl script. Just curious... Now, I guess I'm not that bad of a newbie! Pardon me you all respectable geeks, but I'm going to dare a little exposure myself (please show mercy!): I started working on something 'cause I realized I was really being lazy by asking for a script right away. I did it kind of in a different approach, basically because I'm stuck with switching between OS9 and OSX all the time until I have enough money for Jaguar + all the software upgrades, so I had to do a some pre AppleScripting ... (forgot to mention I use the #$@%/&$% Outlook Express for mail). I'm definitely going to borrow your *frames* and *color coding* ideas, as well as the good habit of using CGI.pm and friends instead of hand coding all the HTML stuff. Anyway, I wanted a one click solution, but believe it or not, I couldn't get #$@%/&$% Outlook to open the message in a window via AppleScript command, so I had to settle with a 2 click solution and open it manually (which is where I'm going to add your code delimiters). (1) My AppleScript takes the contents of the opened message window and passes that to BBedit, which Cleans the mail's headers and footer and passes the Tip's body to a unix filter "UnixTip.pl". (2) "UnixTip.pl" takes the tip's header, makes it a filename, writes the tip in html format that filename and updates the "index.htm" file by looking for the "<!--new-->" token. And here's the codes: === My AppleScript (watch out for wrapped long lines) ==== property theContent : "" tell application "Outlook Express" set theContent to the content of the front window end tell tell application "BBEdit" make new window with properties {contents:theContent} --clean up header find "\\r(=-)+=\\r\\r\\s+UNIX GURU UNIVERSE\\s+\\r\\s+UNIX HOT TIP\\s*" & return ¬ & "\\s+.+\\r\\r\\s+.+\\r\\r(=-)+=\\r\\r\\r" searching in text window 1 options {starting at top:true, search mode:grep} with selecting match set selection to "" --clean up footer find "\\-+(.+\\r)+\\r(.+\\r)+\\r(.+\\r)+\\r" searching in text window 1 options {starting at top:true, search mode:grep} with selecting match set selection to "" --call perl filter to make html files set theFilter to "OS 9:Applications (Mac OS 9):Authoring:BBEdit 7.0:BBEdit Support:MacPerl Support:Perl Filters:20)MISC:UnixTip.pl" select every text of text window 1 run unix filter theFilter without replacing selection end tell === UnixTip.pl=== #!usr/bin/perl chomp (my @tip = (<>)); #get the Tip's title & wipe leading empty lines in body: my $filename = $header = lc shift @tip; while ($tip[0] =~ /^$/) { shift @tip } # Make html filenames $filename =~ s/ /_/g; $filename .= '.htm'; my $tips_folder = "Docs:Learning:Reference:UNIX:TipOfTheDay"; my $tip_file = "$tips_folder:\L$filename\E"; #$filename to lowercase! my $index = "$tips_folder:index.htm"; # Make header w/ title: my $html_header = make_html_header(ucfirst $header); my $html_footer = make_html_footer(); # Output file: open OUTFILE, ">", "$tip_file" or die "could not open $tip_file ($!)"; print OUTFILE $html_header; print OUTFILE "$_\n" for @tip; print OUTFILE $html_footer; close OUTFILE; # Make it a BBedit file: MacPerl::SetFileInfo('R*ch', 'TEXT', $tip_file); # Update Index: open INDEX, "+<", "$index" or die "could not open $index ($!)"; my @data = (<INDEX>); truncate INDEX, 0; seek INDEX, 0, 0; for (@data) { if (/<!\-\-new\-\->/) { print INDEX "<!--new-->\n<li><a href='$filename'>\u$header</a></li>\n"; } else { print INDEX $_; } } close INDEX; #____Subs___: sub make_html_header { my $filename = shift; return <<eo_head; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>$filename</title> <style type="text/css" media="screen"> <!-- a, a:link , a:visited, a:active {text-decoration: none; } a:hover {text-decoration: underline;} --> </style> </head> <body bgcolor="#FFFFFF" text="#000033"> <basefont size="2" color="#000033" face="geneva,sans-serif"> <center> <h2>$filename</h2> </center> <table border="0" align="center"> <tr> <td> <pre> eo_head } sub make_html_footer { return <<eo_footer; </pre> </td> </tr> </table> <br><br><br> <center> <a href='index.htm'>back to index</a> </center> </body> </html> eo_footer } That's it. Too bad I only have one tip to test it on. Can't wait for next week's tip. Cheers, Riccardo -- mailto:[EMAIL PROTECTED] http://www.riccardoperotti.com