Skip to content

Commit

Permalink
Provide graceful fall back if theme is not available.
Browse files Browse the repository at this point in the history
This is a bit of a hack since it hardwires math4 theme as the default theme that is always available.  A future iteration should make this defaultDefaultTheme configurable in defaults.config. (We should also clean up the variable names. :-) )
  • Loading branch information
mgage committed Jun 7, 2013
1 parent 69860b0 commit 13cf324
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/WeBWorK/ContentGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,20 @@ sub content {
# this means that the {stylesheet} option in defaults.config is never used
my $template = $self->can("templateName") ? $self->templateName : $ce->{defaultThemeTemplate};
my $templateFile = "$themesDir/$theme/$template.template";

unless (-r $templateFile) { #hack to prevent disaster when missing theme directory
if (-r "$themesDir/math4/$template.template") {
$templateFile = "$themesDir/math4/$template.template";
warn "Theme $theme is not one of the available themes. ".
"Please check the theme configuration ".
"in the files localOverrides.conf, course.conf and ".
"simple.conf and on the course configuration page.\n"
} else {
die "Neither the theme $theme nor the defaultTheme math4 are available. ".
"Please notify your site administrator that the structure of the ".
"themes directory needs attention.";

}
}
template($templateFile, $self);
}

Expand Down Expand Up @@ -1020,8 +1033,8 @@ sub footer(){
my $self = shift;
my $r = $self->r;
my $ce = $r->ce;
my $ww_version = $ce->{WW_VERSION}||"unknown -- set ww version in defaults.config";
my $pg_version = $ce->{PG_VERSION}||"unknown -- set pg version in defaults.config";
my $ww_version = $ce->{WW_VERSION}||"unknown -- set ww version VERSION";
my $pg_version = $ce->{PG_VERSION}||"unknown -- set pg version PG_VERSION link to ../pg/VERSION";
my $theme = $ce->{defaultTheme}||"unknown -- set defaultTheme in localOverides.conf";
my $copyright_years = $ce->{WW_COPYRIGHT_YEARS}||"1996-2011";
print CGI::div({-id=>"last-modified"}, $r->maketext("Page generated at [_1]", timestamp($self)));
Expand Down

0 comments on commit 13cf324

Please sign in to comment.