Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Fading Message Board

by beretboy (Chaplain)
on Mar 10, 2002 at 01:07 UTC ( [id://150635]=CUFP: print w/replies, xml ) Need Help??

Quite some time ago I read a rant complaining about how information on the internet doesn't age our wear down. I thought it was pretty interesting, but I forgot about it till now. Anyway, I wrote this little script that allows users to post messages that fade away over time (more specifically they fade a little every time the page gets a hit) and eventually dissapear. You can see this running here. And here is the code:
#!/usr/bin/perl use strict; use CGI qw( header param ); my $new = param("post"); my @pallet = qw( 000000 1E1E1E 3C3C3C 5A5A5A 787878 969696 B4B4B4 D2D2 +D2 F0F0F0 ); my $url = "http://yoursite.org/url/for/cgi"; if ($new) { open(POSTS, ">>/path/to/message/file"); print POSTS "0 $new\n"; print header; print "<PRE>meme added\n<A HREF=\"$url">go back</a></pre>"; } else { open(POSTS,"/path/to/message/file"); my @posts = <POSTS>; my $post; print header; foreach $post(@posts) { $post =~ /(\d) (.*)/; my $shade = @pallet[$1]; my $text = $2; my $x = int(rand 400); my $y = int(rand 400); my $z = int(rand 5); $z++; print "<font color=#$shade size=$z STYLE=\"position:relative; left:" . + $x . "px; top:" . $y . "px\"> $text </font>\n"; } close(POSTS); open(POSTS, ">/path/to/message/file"); foreach $post(@posts) { $post =~ /(\d) (.*)/; my $num = $1; my $mesg = $2; $num++; if ($num == 9) { 1; } else { print POSTS "$num $mesg\n"; } } print <<CREATE; <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <table> <tr> <td bgcolor=#08082C> <BR> <FORM METHOD="GET" ACTION="$url"> Meme:<INPUT TYPE="text" STYLE="background-color:#B4B4B4" NAME="post" S +IZE="30"> <INPUT TYPE="submit" value="create"> </form> <BR> </td> </tr> </table> CREATE }
BTW I know all those BR tags are annoying, sorry about that

"Sanity is the playground of the unimaginative" -Unknown

Replies are listed 'Best First'.
Re: Fading Message Board
by Chmrr (Vicar) on Mar 10, 2002 at 03:38 UTC

    First off, I think this is a neat idea. When I first saw the code, I was just going to make the "<BR>"x20 suggestion; then I thought I'd do some indenting, too. Then I thought about only reading from the file once; and so on. Anyways, shown below is how I'd go about writing this; the demo is here.

    Update: Dog and Pony should never have mentioned it fading over time; I've wasted yet more time on this now. Whee! Anyways, demo is here. It also uses an exponential scale for the colors now; hitting the page causes anything that's there to "decay," as does letting time pass. Entering the same meme again makes it "fresh" again.

    Update: Code has been moved from here to here.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Re: Fading Message Board
by premchai21 (Curate) on Mar 10, 2002 at 02:29 UTC
    print "<BR>\n" x 0x15, <<CREATE; ... CREATE
Re: Fading Message Board
by Dog and Pony (Priest) on Mar 10, 2002 at 02:37 UTC
    Interesting idea. :)

    I have a tweak suggestion - how about a page fades when it doesn't get hits? Or rather, perhaps, that a page needs to have enough hits often enough - or compared to other pages or something - otherwise it fades into oblivion?

    This way, the pages that are - and stay - popular is retained, while the not so good or important ones fade away.

    This is of course totally dependant on what purpose you are after, but that might be a useful option for this?

    This isn't critique or anything, just an amendment. :)


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
      I have a tweak suggestion - how about a page fades when it doesn't get hits? Or rather, perhaps, that a page needs to have enough hits often enough - or compared to other pages or something - otherwise it fades into oblivion?
      Better yet, why not just use FreeNet? That's the organizing principle behind it's nodes, aside from the anonymity. ;-)

      Matt

Re: Fading Message Board
by Emphyrio (Beadle) on Mar 16, 2002 at 22:03 UTC
    Cool effect! You might want to change the
    if ($new) { .... } else { .... }
    into a
    if ($new) { .... } ....
    thing though; then you don't have to click 'back' each time you post, and you see the result immediately..
Re: Fading Message Board
by Juerd (Abbot) on Mar 18, 2002 at 12:07 UTC

    Quite some time ago I read a rant complaining about how information on the internet doesn't age our wear down.

    Your post has inspired me to create http://juerd.nl/prik.plp. (Note: Requires Mozilla or MSIE)

    It's in Dutch, but the first button will let you post a message. Please don't flood it (there's no check for that, yet).

    The source (PLP) is at http://juerd.nl/prik.plp.source. It's a few-hour hack and coded badly, sorry 'bout that.

    Thanks for the great idea, ++beretboy!

    U28geW91IGNhbiBhbGwgcm90MTMgY
    W5kIHBhY2soKS4gQnV0IGRvIHlvdS
    ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
    geW91IHNlZSBpdD8gIC0tIEp1ZXJk
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://150635]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found