[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Qn about a interesting but slight mis-use of mhonarc
Aha, yep, I see where you are going here. Just take the output and build
the index page manually.
I had started going through the mhamain.pl and mhindex.pl to see if it would
be feasible to adjust so that mhonarc builds the output in the correct
format at the start. Not sure how easy this is going to be. Better method
may be to see whether the body can be placed in another variable at parse
time, but this has rather large space implications...
I like the whole email to create a blog idea because I can give the user an
IMAP mailbox with "main" and "archive" subfolders and they can just
re-organise the mail themselves. In fact you could handle security by not
letting the IMAP mailbox have a mail address, the user simply presses save
in their email editor and drags the draft email into their IMAP folder.
Should be a simple enough process to add and archive content! Plus you can
run cron jobs to move files around (I'm using Maildir based mail) based on
age, content, etc.
I will take your script for a whirl tonight. Please let me know what you
think about a mod to the main program. Perhaps if we can get it done neatly
enough Earl would consider accepting a patch...? Sounds like there is
demand for it!
Ed
----- Original Message -----
From: "Jym Dyer" <jym@econet.org>
To: <mhonarc@ncsa.uiuc.edu>
Sent: Wednesday, May 01, 2002 7:44 AM
Subject: Re: Qn about a interesting but slight mis-use of mhonarc
> > Wow, sounds great. Are you interested in sharing what you
> > have got so far?
>
> =v= Okay, I've put the rough cut script below. It's got a lot
> of stuff hardcoded into it, and does hacky things like grabbing
> info out of comments that is better gotten from variables. I'm
> working on a rewrite that uses mhamain.pl and also does other
> fancy things, but this is what I whipped together in one hour.
>
> > I know what you mean about the archiving. I was thinking
> > about starting small and say only allowing 20 msgs on the
> > front page, move everything else to a sub folder?
>
> =v= Well, as I mentioned, I envision working from two message
> folders, one for archive-worthy messages and the other for
> ephemeral ones. I suspect I'll just get rid of the ephemeral
> ones with rmm, <EXPIREAGE>, or <EXPIREDATE>. The archive-worthy
> ones I'm thinking of dealing by using <MULTIPG> and <IDXSIZE>,
> and basing the blog "index.html" page on just the first thread
> index page.
>
> > How are you authenticating the user?
>
> =v= Well, since I'm the only user I have full control over what
> ends up in the message folders. :^) My script shows an example
> approach to a feedback mechanism via a "mailto:" URL, but
> getting the comments into the message folders and into the blog
> is something you'll need to do with procmail or somesuch.
>
> =v= (As an aside, according to RFC2368 you could in theory make
> "Comments" links with URLs like this:
>
>
mailto:blog@example.com?Subject=Re:%20Wow&References=K00LD00DZ%40example.com
>
> But that won't work in the real world, since you can't rely on
> browsers to support "References" or "In-Reply-To". A workaround
> is to embed the message number in the address, though this will
> mean more convolutions at the receiving end:
>
> mailto:blog+00032@example.com?Subject=Re:%20Wow
>
> I've put an example of this hack in my script.)
>
> =v= Since stuff is hardcoded in the script, I'll list the
> assumptions up front:
>
> o You are currently in the web directory where ephemeral
> messages have already been converted with MHonArc.
> o The files have the default msg%%%%%.html filenames.
> o You're using this script to create a index.html file
> with all the messages in it, blog-style.
>
> Blogs usually have "Posted by," "Permalink," and "Comments"
> under each message. None of these are in the design goals
> of this particular script, but I've tossed them in for kicks.
> The "Posted by" address is ROT13-encrypted. I've replaced
> the "Permalink" with an "Ephemeralink," but it's ultimately
> pointless. "Comments" is implemented as described above.
> <_Jym_>
>
> =============8<=============Cut-Here=============8<=============
>
> #!/usr/bin/perl
>
> open STDOUT, ">index.html" or die "Can't redirect stdout";
>
> print
> '<html><head><title>Experimental Blog of Ephemeralities</title></head>
> <body>
> <h1>Experimental Blog of Ephemeralities</h1>
> <table border=0 cellpadding=1 width=100%>';
>
> # Blogs typically present messages in reverse order.
> my @msglist = reverse <msg*.html>;
>
> foreach $msgfile (@msglist) {
> print STDERR "[Converting $msgfile]...\n";
> my %header = {};
> my $is_print = 0;
> my $msgnum = $msgfile;
> $msgnum =~ s/^msg//;
> $msgnum =~ s/\.html$//;
> my $subject = "";
> open MSG_FILE, $msgfile;
> foreach (<MSG_FILE>) {
> if (/^<!--X-(Date|From-R13|Subject): (.*) -->$/) {
> $header{$1} = $2;
> } elsif (/^<!--X-Body-of-Message-->$/) {
> print
> '<tr bgcolor="#666666">
> <td><table border=0 cellpadding=0 width=100%><tr valign=top>
> <td width=80%><font face="Garamond" color="#CCFFCC"> ',
> $header{'Subject'}, '</td>
> <td align=right><font color="#CCFFCC" size=-2><nobr>',
> $header{'Date'}, '</font> </nobr></td></tr></table></td></tr>
> <tr><td>';
> $is_print = 1;
> } elsif (/^<!--X-Body-of-Message-End-->$/) {
> $is_print = 0;
> break;
> } elsif ($is_print) {
> print $_;
> }
> }
> ($subject = $header{'Subject'}) =~ s/^R(E|e):\s*//;
> # This isn't robust; it should use URL-encoding.
> $subject =~ s/\s/%20/g;
> print
> '<font face="Arial, Helvetica, sans-serif" size=-2>Posted by ',
> $header{'From-R13'}, '
> -
> <a href="', $msgfile, '"
> ><b>Ephemeralink</b></a>
> -
> <a href="mailto:blog+',
> $msgnum, '@example.com?Subject=Re:%20', $subject, '"
> ><b>Comments</b></a></font><br></td>
> </tr>';
> close MSG_FILE;
> }
>
> print "</table></body></html>\n";
>
>
[Index of Archives]
[Bugtraq]
[Yosemite News]
[Mhonarc Home]