#!/usr/bin/perl # # MY CSS # # # mycss.cgi -- Dynamically generates CSS # More information: http://www.downes.ca/edurss02.htm # # by Stephen Downes # Version 0.2 - January 2, 2006 # # # Copyright 2006 Stephen Downes, National Research Council Canada # Prerelease - please do not distribute - I'll GPL it when it's ready # use DBI; use CGI; use CGI::Carp qw(fatalsToBrowser); # Get user input my $query = new CGI; my $vars = $query->Vars; my $theme = $vars->{theme}; print "Content-type:text/css\n\n"; # Get Data from Database my $dbh = &db_open('DBI:mysql:edurss:downes.ca','downes','bartandpolly') or print "Database connect error: $!"; my $stmt = qq{ SELECT * FROM theme WHERE theme_id = ?}; my $sth = $dbh -> prepare($stmt); $sth -> execute($theme); my $ref = $sth -> fetchrow_hashref(); if ($dbh) { $dbh->disconnect; } unless ($ref->{theme_high_col}) { $ref->{theme_high_col} = "#000000"; } unless ($ref->{theme_high_back}) { $ref->{theme_high_back} = "#cccccc"; } print qq| p,h1,h2,h3,pre,table { margin:0px 10px 10px 10px; } h1 { font-size:14px; padding-top:10px; } a:link { color: $ref->{theme_link}; text-decoration: none; font-weight:bold; } a:visited { color: $ref->{theme_link}; text-decoration: none; font-weight:bold; } a:hover { color: $ref->{theme_link}; text-decoration: none; background: #e0e0e0; font-weight:bold; } a.stealth { color: $ref->{theme_text}; text-decoration: none; } /* Section Heads */ h1,a.lead { font: italic 20pt/28pt Georgia,serif; color: $ref->{theme_section}; text-decoration: none; } h2 { font: italic 14pt/18pt Georgia,serif; color: $ref->{theme_section}; } h3 { font: italic 14pt/20pt Georgia,serif; color: $ref->{theme_section}; } h4 { font: italic 12pt/26pt Georgia,serif; color: $ref->{theme_section}; } /* Major Links */ a.Article { font-weight: bold; text-decoration: none; } body { margin:10px 10px 0px 10px; padding:0px; background: #ffffff; font: 11pt/14pt Verdana,Arial, sans-serif; color: $ref->{theme_text}; } #leftcontent { position: absolute; left:10px; top:74px; width:200px; border-right:1px solid #000; font: 10pt/12pt Georgia,serif; } #leftcontent p { margin-left: 1px; } #leftcontent a { font: bold 10pt/13pt Arial, sans-serif; } #centercontent { margin-left: 0px; margin-right:314px; voice-family: "\"}\""; voice-family: inherit; margin-left: 0px; margin-right:316px; } html>body #centercontent { margin-left: 0px; margin-right:316px; } #emailcontent { border-right: 1px solid #000; max-width: 600px; margin: 20px; padding: 20px; } #pagecontent { margin-left: 209px; margin-right:0px; voice-family: "\"}\""; voice-family: inherit; margin-left: 211px; margin-right:51px; } html>body #pagecontent { margin-left: 211px; margin-right:0px; } .articlecontent { width:80%; } #rightcontent { position: absolute; right:10px; top:94px; width:300px; font: 10pt/12pt Arial, sans-serif; } .right-box { width: 298px; border:1px solid #000; margin-bottom: 10px; overflow: hidden; } .right-box img { margin: 5px; } .right-box-img { width: 288px; height: 384px; background: #e7e5e8 url($main_name) top left; } .right-box p { margin: 5px; } #banner { background: #e7e5e8 url($ref->{theme_banner_img}) top left; height:53px; border:1px solid #000; voice-family: "\"}\""; voice-family: inherit; height:52px; margin-bottom: 10px; } html>body #banner { height:52px; } #banner p { color: $ref->{theme_sitename}; } #banner a { color: $ref->{theme_sitename}; } #banner a.home { font: 28pt/36pt Georgia,serif; color: $ref->{theme_sitename}; padding-left:20px; text-align:left; } .page_nav { margin-left: 15px; margin-bottom: 5px; margin-top: 5px; border-bottom: 1px solid $ref->{theme_high_col}; } /* Search Box */ #search { float:right; padding-right:10px; text-decoration: none; text-align:right; font: 9pt/14pt Verdana, Arial, sans-serif; } #search input { font-size: 10px; background-color: $ref->{theme_background}; border: 1px solid $ref->{theme_section}; } #search form { color: $ref->{theme_sitename}; } /* Image Page Styles */ #ip_prevnext { margin: 0; margin-left: 2px; padding: 0; height: 25px; color: $ref->{theme_high_col}; background-color: $ref->{theme_high_back}; width: 600px; border-bottom: 1px solid $ref->{theme_high_col}; } #ip_prevnext p { line-height: 25px; } #ip_prevnext a { font: 16px/25px Arial, sans-serif; } #ip_prevnext a:hover { color: $ref->{theme_link}; text-decoration: none; background: transparent;} #ip_photo { margin: 0; margin-left: 2px; padding: 0; font: 14pt/18pt Georgia,serif; width: 600px; } #ip_photo img { margin: 0; padding: 0; } #ip_description { margin: 0; margin-left: 2px; padding: 0; font: 14pt/18pt Georgia,serif; width: 600px; height: 100px; bottom: 0px; color: $ref->{theme_high_col}; background-color: $ref->{theme_high_back}; border-top: 1px solid $ref->{theme_high_col}; border-bottom: 1px solid $ref->{theme_high_col}; } /* Discussion List Styles */ .post h2 { margin-left: 15px; font: italic 14pt/28pt Georgia,serif; color: $ref->{theme_section}; margin-bottom: 0; } .thread_description { margin-left: 10px; } .threads_nav { margin-left: 10px; } .post_credits { margin-left: 15px; margin-bottom: 5px; border-bottom: 1px solid $ref->{theme_high_col}; } .post_description { margin-left: 15px; margin-bottom: 40px; } .post_options { margin-left: 15px; } /* Photo Gallery */ .thumbnail { position:relative; float:left; width:120px; height:120px; margin-left: 10px; } /* Lists */ #messages { width: 90%; border: 1px solid $ref->{theme_high_col}; background-color: #eeeeee; padding: 5px; margin: 15px; color: darkred; font: 12pt/18pt Georgia,serif; } .list_item { margin-left: 15px; } .file_list { width: 100%; border: 1px solid $ref->{theme_high_col}; background-color: #eeeeee; padding: 3px; } |; exit; sub db_open { my ($dsn,$user,$password) = @_; my $dbh = DBI->connect($dsn, $user, $password) or die "Database connect error: $! \n"; # if ($dbh) { $dbh->trace(2,"dberror.txt"); } return $dbh; }