[prev] [thread] [next] [lurker] [Date index for 2003/12/7]
Author: jon
Date: 2003-12-07 12:39:56 +0200 (Sun, 07 Dec 2003)
New Revision: 111
Modified:
yapcom/trunk/MANIFEST
yapcom/trunk/README
yapcom/trunk/db/config.sample
yapcom/trunk/lib/YAPC/Config.pm
yapcom/trunk/lib/YAPC/Organizer.pm
Log:
added skins, no tests
Modified: yapcom/trunk/MANIFEST
===================================================================
--- yapcom/trunk/MANIFEST 2003-12-04 15:13:32 UTC (rev 110)
+++ yapcom/trunk/MANIFEST 2003-12-07 10:39:56 UTC (rev 111)
@@ -6,7 +6,7 @@
bin/setup.pl no
bin/install.pl no
bin/sqlite.pl no
-cgi/yapc.pl
+cgi/2004
files/style.css
files/yapsi.gif
html/announcement-il.html
Modified: yapcom/trunk/README
===================================================================
--- yapcom/trunk/README 2003-12-04 15:13:32 UTC (rev 110)
+++ yapcom/trunk/README 2003-12-07 10:39:56 UTC (rev 111)
@@ -30,6 +30,7 @@
SITE_DIR (/home/gabor/projects/perl/perl.org.il/YAPC/dev)
SITE_EMAIL (yapc@xxxx.xxx.xx)
SITE_ADMIN (gabor@xxx.xx.xx) * multiple
+ DB_FILE (yapc.db)
DB_TIMEOUT (100)
PROPOSAL_LENGTHS (5, 30, 60, 90, 180) * multiple
PROPOSAL_LANGUAGES (English Hebrew) * multiple
@@ -59,6 +60,41 @@
Deny from all
</Directory>
+SKINS
+-----
+
+You can have multiple sites using the same yapcom installation, and/or
+several skins pointing to the same site. To add a site:
+
+1. create a directory under the skins directory. The directory name MUST
+consist of ONLY capital letters and/or underscores. E.g.:
+
+skins/BLUE
+or
+skins/FRENCH
+
+Copy any templates you want to change from templates into your directory
+and change them. Any templates you do not change will be taken from the
+default templates directory.
+
+2. create a new config file called SKIN.config in the db directory, e.g.
+
+db/BLUE.config
+or
+db/FRENCH.config
+
+Change (at least) the CGI_PATH to be /path/to/cgi/SKIN, e.g.:
+
+CGI_PATH = /jon/2004/BLUE
+or
+CGI_PATH = /jon/2004/FRENCH
+
+If you leave the DB_FILE value alone, the site will chare the same
+registration information as the default site (or the site you copied
+from). If you set it to be a new file, make sure you create the initial
+empty db, and it will function as a new site [Note: this doesn't work
+yet].
+
CHANGES
---------
0.10 2003.12.03
Modified: yapcom/trunk/db/config.sample
===================================================================
--- yapcom/trunk/db/config.sample 2003-12-04 15:13:32 UTC (rev 110)
+++ yapcom/trunk/db/config.sample 2003-12-07 10:39:56 UTC (rev 111)
@@ -2,6 +2,7 @@
FILES_PATH = /jonfiles
HTML_PATH = /jonhtml
DOCS_PATH = /jondocs
+DB_FILE = yapc.db
SITE_DIR = /home/jon/Yapcom/yapcom/trunk
SITE_EMAIL = jon@xxxxxx.xx.xx
SITE_ADMINS = jon@xxxxxx.xx.xx
Modified: yapcom/trunk/lib/YAPC/Config.pm
===================================================================
--- yapcom/trunk/lib/YAPC/Config.pm 2003-12-04 15:13:32 UTC (rev 110)
+++ yapcom/trunk/lib/YAPC/Config.pm 2003-12-07 10:39:56 UTC (rev 111)
@@ -2,17 +2,34 @@
use FindBin;
use strict;
use warnings;
-our (@STORAGE, $dir, $db_dir, $db_file, $TIMEOUT, $templates_dir, $email_address, $cgi_path);
+our (@STORAGE, $dir, $db_dir, $db_file, $TIMEOUT, $templates_dir, $skins_dir, $email_address, $cgi_path);
our (@proposal_languages, @proposal_lengths, @admins, $docs_path, $html_path, $files_path);
+my $skin = $ENV{'PATH_INFO'} || "";
+$skin =~ s#^/##;
+($skin) = split '/', $skin;
+$skin ||= "";
+
+if ($skin =~ /^[A-Z_]+$/) {
+ $ENV{'PATH_INFO'} =~ s#/[^/]+##;
+}
+else {
+ $skin = "";
+}
+
+my $config = "$FindBin::Bin/../db/config";
+$config = "$FindBin::Bin/../db/$skin.config" if ($skin and -f "$FindBin::Bin/../db/$skin.config");
my %config;
-if (open CONFIG, "$FindBin::Bin/../db/config") {
+if (open CONFIG, $config) {
local $/ = undef;
%config = split(/\s*=\s*|\s*[\r\n]+\s*/, <CONFIG>);
close CONFIG;
}
$dir = $config{'SITE_DIR'} || "/home/gabor/projects/perl/perl.org.il/YAPC/dev";
+$skins_dir = "";
+$skins_dir = "$dir/skins/$skin" if -d "$dir/skins/$skin";
+
$email_address = $config{'SITE_EMAIL'} || 'yapc@xxxx.xxx.xx';
$cgi_path = $config{'CGI_PATH'} || '/YAPC/2004';
$files_path = $config{'FILES_PATH'} || '/YAPC_files';
@@ -23,7 +40,8 @@
@admins = ($config{'SITE_ADMINS'}) ? split /[\s,]+/, $config{'SITE_ADMINS'} : qw(gabor@xxx.xx.xx);
$db_dir = "$dir/db";
-$db_file = "$db_dir/yapc.db";
+$db_file = $config{'DB_FILE'} || "yapc.db";
+$db_file = "$db_dir/$db_file";
@STORAGE = ("dbi:SQLite:$db_file", 'root', undef);
$TIMEOUT = $config{'DB_TIMEOUT'} || 100;
$templates_dir = "$dir/templates";
Modified: yapcom/trunk/lib/YAPC/Organizer.pm
===================================================================
--- yapcom/trunk/lib/YAPC/Organizer.pm 2003-12-04 15:13:32 UTC (rev 110)
+++ yapcom/trunk/lib/YAPC/Organizer.pm 2003-12-07 10:39:56 UTC (rev 111)
@@ -15,6 +15,8 @@
use HTML::Template; # we use it explicitely hence we need it here.
my $templates_dir = $YAPC::Config::templates_dir;
+my $skins_dir = $YAPC::Config::skins_dir;
+
my $cgi_path = $YAPC::Config::cgi_path;
my $files_path = $YAPC::Config::files_path;
my $html_path = $YAPC::Config::html_path;
@@ -59,7 +61,7 @@
my $self = shift;
my $run_mode = shift;
- my ($page, $filename) = get_page();
+ my $page = get_page();
if (grep {$_ eq $page} @other_pages) {
return $self->prerun_mode($page);
@@ -87,9 +89,8 @@
return;
}
- if (not -e $filename) {
-
- #warn "YAPC script called for not existing file. Original: '$ENV{PATH_INFO}' cut down: '$filename'\n";
+ unless (-f "$skins_dir/$page.tmpl" or -f "$templates_dir/$page.tmpl") {
+ #warn "YAPC script called for not existing file. Original: '$ENV{PATH_INFO}' cut down: '$page'\n";
$self->prerun_mode('no_such_page');
}
$self->prerun_mode('default');
@@ -105,15 +106,13 @@
sub get_page {
- # PATH_INFO looks like this: /content.html
+ # PATH_INFO looks like this: content.html
my $page = $ENV{PATH_INFO} || '';
$page =~ s@.*/@@;
$page =~ s/\.html(\?.*)?$//;
$page ||= 'index';
- my $filename = "$templates_dir/$page.tmpl";
-
- return ($page, $filename);
+ return $page;
}
# maybe this should be replaced with a generic show page call
@@ -256,11 +255,14 @@
my $self = shift;
my $person = shift;
my $q = $self->query;
+
my $mail =
HTML::Template->new(
- filename => "$templates_dir/email/password.tmpl",
+ filename => "email/password.tmpl",
die_on_bad_params => 0,
- associate => $q
+ associate => $q,
+ path => [$skins_dir,$templates_dir],
+ search_path_on_include => [$skins_dir,$templates_dir],
);
$mail->param("password" => $person->password);
my %mail = (
@@ -280,9 +282,11 @@
# sending e-mail
my $mail =
HTML::Template->new(
- filename => "$templates_dir/email/register.tmpl",
+ filename => "email/register.tmpl",
die_on_bad_params => 0,
- associate => $q
+ associate => $q,
+ path => [$skins_dir,$templates_dir],
+ search_path_on_include => [$skins_dir,$templates_dir],
);
$mail->param("authcode" => $person->authcode);
my $validation_url = "http://$ENV{HTTP_HOST}$cgi_path$ENV{PATH_INFO}";
@@ -320,17 +324,10 @@
# eval, because sub dies if template doesn't exists
my $t;
- eval {$t = $self->load_tmpl("$page.tmpl", die_on_bad_params => 0, filter => $filter, associate => $q, path => $templates_dir,);};
+ eval {$t = $self->load_tmpl("$page.tmpl", die_on_bad_params => 0, filter => $filter, associate => $q, path => [$skins_dir,$templates_dir], search_path_on_include => [$skins_dir,$templates_dir],);};
- $t =
- $self->load_tmpl(
- "error.tmpl",
- die_on_bad_params => 0,
- filter => $filter,
- associate => $q,
- path => $templates_dir,
- )
- if $@;
+ $t = $self->load_tmpl("error.tmpl", die_on_bad_params => 0, filter => $filter, associate => $q, path => [$skins_dir,$templates_dir], search_path_on_include => [$skins_dir,$templates_dir],)
+ if $@;
$t->param(%h);
$t->param(VERSION => $YAPC::Organizer::VERSION);
Generated at 14:50 on 07 Dec 2003 by mariachi 0.51