Skip to content

Commit

Permalink
Move the system.html.ep template out of the themes.
Browse files Browse the repository at this point in the history
That file is now the system layout instead.  This file should really not
be themable.  If someone wants to mess with that file, they can deal
with having locally modified files that show up as changed by git.  If
someone does not know what they are doing, they can really mess up
things.

If there is some other thing that is commonly wanted in the default
system layout it can be added as an option.

So now the themes directories only have what is needed for theming, and
theming for the most part is only about changing the color scheme.  This
is how it should be.  Theming should not mean modify the entire system
to make it be what you want.

There are several advantages with this pull request.  It removes the
need for so many symlinks from the math4 theme variants back to files in
the math4 theme.  It removes the need for the hackish
`htdocs/themes/layouts` symlink that turns the themes directory into a
layout directory.  It removes the need for the themes directory to be a
template path to begin with.
  • Loading branch information
drgrice1 committed Feb 12, 2024
1 parent 7e0a8fc commit 7cd697e
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 41 deletions.
1 change: 0 additions & 1 deletion conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ $courseURLs{feedbackFormURL} = "";
################################################################################

$defaultTheme = "math4";
$defaultThemeTemplate = "system";

# The institution logo should be an image file in the theme's images folder
$institutionLogo = 'maa_logo.svg';
Expand Down
1 change: 0 additions & 1 deletion conf/localOverrides.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ $mail{feedbackRecipients} = [
################################################################################

#$defaultTheme = "math4";
#$defaultThemeTemplate = "system";

# The institution logo should be an image file in the theme's images folder
#$institutionLogo = 'my_school_logo.png';
Expand Down
1 change: 0 additions & 1 deletion htdocs/themes/layouts

This file was deleted.

1 change: 0 additions & 1 deletion htdocs/themes/math4-green/system.html.ep

This file was deleted.

1 change: 0 additions & 1 deletion htdocs/themes/math4-red/system.html.ep

This file was deleted.

1 change: 0 additions & 1 deletion htdocs/themes/math4-yellow/system.html.ep

This file was deleted.

3 changes: 0 additions & 3 deletions lib/Mojolicious/WeBWorK.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ sub startup ($app) {
# url_for_asset controller method.
unshift(@{ $app->static->paths }, $webwork_htdocs_dir);

# Add the themes directory to the template search paths.
push(@{ $app->renderer->paths }, $ce->{webworkDirs}{themes});

# Setup the Minion job queue. Make sure that any task added here is represented in the TASK_NAMES hash in
# WeBWorK::ContentGenerator::Instructor::JobManager.
$app->plugin(Minion => { $ce->{job_queue}{backend} => $ce->{job_queue}{database_dsn} });
Expand Down
34 changes: 2 additions & 32 deletions lib/WeBWorK/ContentGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -437,43 +437,13 @@ Defined in this package.
Print the content of the generated page.
This renders a Mojo::Template.
The defaultThemeTemplate in the course environment is used for the page layout.
If that is not defined, the default "system" template, is used. The location of
the template is looked up in the course environment.
This renders the Mojo::Template corresponding to the called ContentGenerator sub-package.
=cut

sub content ($c) {
my $ce = $c->ce;

my $theme = $c->param('theme') || $ce->{defaultTheme};
$theme = $ce->{defaultTheme} if $theme =~ m!(?:^|/)\.\.(?:/|$)!;

my $layout = $ce->{defaultThemeTemplate} // 'system';

my $layoutName = "$theme/$layout";

# Attempt to prevent disaster when the theme layout file is missing.
unless (-r "$ce->{webworkDirs}{themes}/$theme/$layout.html.ep") {
if (-r "$ce->{webworkDirs}{themes}/math4/$layout.html.ep") {
$layoutName = "math4/$layout";
$theme = HTML::Entities::encode_entities($theme);
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 {
$theme = HTML::Entities::encode_entities($theme);
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.';

}
}

return $c->render(template => ((ref($c) =~ s/^WeBWorK:://r) =~ s/::/\//gr), layout => $layoutName);
return $c->render(template => ((ref($c) =~ s/^WeBWorK:://r) =~ s/::/\//gr), layout => 'system');
}

=back
Expand Down
File renamed without changes.

0 comments on commit 7cd697e

Please sign in to comment.