in reply to Re: Alternatives to PerlTransHandler?
in thread Alternatives to PerlTransHandler?

To get a feel for what I'm talking about, go check out what I've already hacked out for my wife Erica. Basically, the CGI sets a cookie with a skinID, and then it changes the look (yes just like you thought) based on what the value of that cookie is. Erica is fairly content with the system I've already created for her (although I need to go add some more robust errorhandling...it was 5AM and I was tired), I'm interested in going further with it.

Namely I want to do some cool things with frames. But I just don't know if I can do it without access to the server-wide httpd.conf.

Another good example of website skinning is domesticat.net. However, she uses PHP to do her skinning, and can't handle the URI mangling that I want to do.

  • Comment on Re: Re: Alternatives to PerlTransHandler?

Replies are listed 'Best First'.
Re: Re: Re: Alternatives to PerlTransHandler?
by kwoff (Friar) on Nov 02, 2001 at 06:12 UTC
    I see, so it is per-user skinnable. Those links you gave use cookies. If that's acceptable, then I offer the following solution (only tried on Mozilla). It sets a cookie, then uses a Server-side includes to choose which skin to display. The sample CGI script uses CGI.pm. It's not the best solution I guess, but it's somewhat amusing at least. :)

    ssi-cookie.html

    <HTML> <BODY> <A HREF="/cgi-bin/skin-cookie.pl">Skin this</A><BR> <!--#if expr="${HTTP_COOKIE} = /skin\=wacky/"--> wacky <!--#elif expr="${HTTP_COOKIE} = /skin\=goth/"--> goth <!--#else --> minimal <!--#endif --> </BODY> </HTML>

    /cgi-bin/skin-cookie.pl

    #!/usr/local/bin/perl -Tw # set 'skin' cookie then redirect where we came from use strict; use CGI; use vars qw($q $cookie $location $status @skin_names); $q = new CGI; @skin_names = qw(minimal wacky goth); main(); sub main { if (defined $q->param('skin')) { # user selected a skin my $skin_param = $q->param('skin'); for my $valid_skin (@skin_names) { if ($skin_param eq $valid_skin) { skin_cookie_page($skin_param); } } # fall through if invalid } pick_skin_page(); } sub get_old_url { return $q->param('old_url') || $q->referer() || 'http://perlmonks.org/'; } sub skin_cookie_page { my $skin_param = shift; my $cookie = $q->cookie( -name => 'skin', -value => $skin_param, -expires => '+30d', ); print $q->header(-cookie => $cookie, -status => '302 Moved', -location => get_old_url()); exit; } sub pick_skin_page { print $q->header(), $q->start_html(), # you'll want to skin this too, natural +ly :) $q->start_form(), 'Choose your skin: ', $q->popup_menu(-name => 'skin', '-values' => \@skin_names) +, $q->submit('skin'), $q->hidden('old_url' => get_old_url()), $q->end_form(), $q->end_html(); exit; }