Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Dark Theme for /. through Perl

by PipTigger (Hermit)
on May 04, 2000 at 22:39 UTC ( #10254=CUFP: print w/ replies, xml ) Need Help??

Here's a little script I wrote
for myself since I like light text on dark backgrounds
(thanks again for the nice PerlMonks theme Vroom!) and
/. doesn't have one... I know it's pretty suckie and
could be a lot simpler. If you can make it better,
please email it to me (piptigger@dimensionsoftware.com)
as I use it everyday now. It doesn't werk yet for the
ask/. section but when I find some time, I'll add that
too. I hope someone else finds this useful. TTFN & Shalom.

-PipTigger
#!/usr/bin/perl #use CGI ":standard"; use LWP::Simple; my $this = "http://your.servers.url/whatyounamedthis.cgi"; my $meth = $ENV{'REQUEST_METHOD'}; my $quer = $ENV{'QUERY_STRING'}; #my $surl = "http://www.slashdot.org"; my $surl = ""; if ($quer && $meth eq "GET") { $surl = $quer; } if ($surl =~ /slashdot\.org/) { #these auto format comments #combine the lines below $surl =~ s!slashdot\.org/articles/(\d\d)/(\d\d)/(\d\d)/(\d+)\.shtm +l!slashdot.org/article.pl? sid=$1/$2/$3/$4&cid=&pid=0&startat=&threshold=2&mode=thread&commentsor +t=3!i; #combine the lines below again =) $surl =~ s!slashdot\.org/interviews/(\d\d)/(\d\d)/(\d\d)/(\d+)\.sh +tml!slashdot.org/comments.pl ?sid=$1%2F$2%2F$3%2F$4&cid=&pid=0&startat=&threshold=2&mode=thread&com +mentsort=3!i; } my $site = get $surl; print "Content-type: text/html\n\n"; $site =~ s/<title>/<title>*pc* /i; if ($surl =~ /slashdot\.org/i) { if ($surl !~ /org\/askslashdot/i) { $site =~ s/<BODY bgcolor="#000000" text="#000000" link="#006666" v +link="#000000">/ <BODY bgcolor="#000001" text="#4FFFAF" link="#00BBBB" vlink="#4F2F9F"> +/; $site =~ s/<FONT color="#000000">/<FONT color="#A8F8F0">/g; $site =~ s/bgcolor="#006666"><IMG/bgcolor="#004444"><IMG/g; $site =~ s/CCCCCC"><FONT color="#000000" size=2>/CCCCCC"><FONT col +or="#B0D0F0" size=2>/g; $site =~ s/<B>Results<\/B>/<B><font color="#00BBBB">Results<\/font +><\/B>/g; $site =~ s/&mode=thread>(.*)<\/A>/&mode=thread><font color="#00BBB +B">$1<\/font><\/A>/g; $site =~ s/www\.thinkgeek\.com>ThinkGeek<\/A>/www\.thinkgeek\.com> +<font color="#00BBBB">ThinkGeek<\/font><\/A>/g; $site =~ s/ <FONT size=2 face="arial,helvetica"><I>/ <FONT c +olor="#F0F0A0" size=2 face="arial,helvetica"><I>/g; $site =~ s/Andover\.Net">Andover\.Net<\/A>/Andover\.Net"><FONT siz +e=1 color="#009999" face="arial,helvetica">Andover\.Net<\/font><\/A>/ +g; $site =~ s/size=3 color="#006666"/size=3 color="#00BBBB"/g; $site =~ s/size=1 color="#006666"/size=1 color="#00BBBB"/g; $site =~ s/size=4 color="#FFFFFF"/size=4 color="#DEFEEE"/g; $site =~ s/<FONT COLOR="#FFFFFF">/<FONT COLOR="#CEFEEE">/g; $site =~ s/"#006666"/"#004444"/g; #size=3||1 color=# -> 00BBBB $site =~ s/"#FFFFFF"/"#000412"/g; #001204 $site =~ s/<TD bgcolor="#ffffff"/<TD bgcolor="#120212"/; $site =~ s/bgcolor=cccccc>/bgcolor="#521222">/g; $site =~ s/bgcolor=ffffff>/bgcolor="#120212">/g; $site =~ s/"ffffff"/"120212"/g; $site =~ s/"#ffffff"/"#AECEFE"/g; $site =~ s/"#CCCCCC"/"#521222"/g; #321202 $site =~ s/"#000000"/"#C0F0D0"/g; #B0D0F0 F0D0B0 D0FFEF $site =~ s!(<a href=")(http://slashdot[^"]*?)(">)!$1$this?$2$3!gi; $site =~ s!<a href=http://slashdot\.org/([^>]*)>!<a href="$this?ht +tp://slashdot.org/$1">!gi; $site =~ s!<a href=/([^>]*)>!<a href="$this?http://slashdot.org/$1 +">!gi; # } else { #ask/. stuff only } } elsif ($surl =~ /opensales\.org/i) { $site =~ s!white!black!i; $site =~ s!bgcolor="#FFFFFF"!bgcolor="#000412"!i; $site =~ s!href="/([^"]*)">!href="$this?http://www.opensales.org/$ +1">!gi; $site =~ s!"/images!"http://www.opensales.org/images!gi; } else { print <<END_0; <html><head><title>PipzColourz Index</title></head><body bgcolor="#030 +70F" text="#AEFEBE" link="#0000FF" vlink="#D000A0" alink="#FF0000"><center> <h1>PCndx</h1><br><hr><br> <h3><a href="$this?http://slashdot.org/">/. slashdot /.</a></h3> <h3><a href="$this?http://www.opensales.org/">opensales</a></h3> </center></body></html> END_0 } print $site;

Comment on Dark Theme for /. through Perl
Download Code
RE: Dark Theme for /. through Perl
by Alokito (Novice) on May 16, 2000 at 09:49 UTC
    For the sake of all that's holy, use some line breaks!
    I was scrolling for a while to catch the end of the code...
    I guess it would be kind of silly to change something like
    $site =~ s/<BODY bgcolor="#000000" text="#000000" link="#00 +6666" vlink="#000000">/<BODY bgcolor="#000001" text="#4FFFAF" link="# +00BBBB" vlink="#4F2F9F">/;
    to
    my $from = '<BODY bgcolor="#000000" text="#000000" link="#006666" +vlink="#000000">'; my $to = '<BODY bgcolor="#000001" text="#4FFFAF" link="#00BBBB" vl +ink="#4F2F9F">'; $site =~ s/$from/$to/;
    Perhaps extended regexps are the answer?
    $site =~ s/ <BODY\sbgcolor="\#000000"\stext="\#000000"\slink="\#006666"\svlink +="\#000000"> /<BODY bgcolor="#000001" text="#4FFFAF" link="#00BBBB" vlink="#4F2 +F9F">/x;
    Or even
    $site =~ s/ <BODY[ ]bgcolor="\#000000"[ ]text="\#000000"[ ]link="\#006666"[ ]v +link="\#000000"> /<BODY bgcolor="#000001" text="#4FFFAF" link="#00BBBB" vlink="#4F2 +F9F">/x;
    What do you think? It looks a little ugly, I suppose.

    Instead of useing extended regexps, we could just use the
    (somewhat less well known) regexp extensions:

    $site =~ s/<BODY bgcolor="#000000" text="#000000" link="#006666" vlink +="#000000">(?# )/<BODY bgcolor="#000001" text="#4FFFAF" link="#00BBBB" vlink="#4 +F2F9F">/;
    Which is probably the way to go.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-07-06 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls