Skip to content

Commit

Permalink
Fixed MathJax installation to match webwork 2.8. Simplified
Browse files Browse the repository at this point in the history
install_chromatic.pl since color.c and Chromatic.pm are now in pg/lib
and Chromatic.pm is included in default modules list in defaults.config.
  • Loading branch information
aubreyja committed Dec 20, 2013
1 parent 0a1e451 commit 7971121
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
40 changes: 3 additions & 37 deletions extra/install_chromatic.pl
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,16 @@ BEGIN
my $cwd = getcwd;
my $ce = new WeBWorK::CourseEnvironment({webwork_dir=>$ENV{WEBWORK_ROOT}});

my $libraryRoot = $ce->{problemLibrary}->{root};
$libraryRoot = File::Spec->canonpath($libraryRoot);
my $nau = File::Spec->canonpath("$libraryRoot/NAU");
my $chromatic = File::Spec->canonpath("$nau/lib/Chromatic.pm");
my $color_dot_c = File::Spec->canonpath("$nau/lib/chromatic/color.c");
#should now check that these really exist

my $pg_dir = $ce->{pg_dir};
$pg_dir = File::Spec->canonpath($pg_dir);

my $conf_dir = File::Spec->canonpath("$ENV{WEBWORK_ROOT}/conf");
my $chromatic = File::Spec->canonpath("$pg_dir/lib/Chromatic.pm");
my $color_dot_c = File::Spec->canonpath("$pg_dir/lib/chromatic/color.c");
#should now check that these really exist

my $gcc = can_run('gcc')
or die "Can't find gcc - please install it and try again.";

#1. The files should be copied here:
#/opt/webwork/pg/lib/Chromatic.pm
#/opt/webwork/pg/lib/chromatic/color.c
copy($chromatic,"$pg_dir/lib/")
or die "Couldn't copy $chromatic to $pg_dir/lib/:$!";
$chromatic = File::Spec->canonpath("$pg_dir/lib/Chromatic.pm");

make_path("$pg_dir/lib/chromatic");
copy($color_dot_c,"$pg_dir/lib/chromatic/")
or die "Couldn't copy $color_dot_c to $pg_dir/lib/chromatic/:$!";
$color_dot_c = File::Spec->canonpath("$pg_dir/lib/chromatic/color.c");


#gcc -O3 color.c -o color
chdir("$pg_dir/lib/chromatic/");

Expand All @@ -90,22 +72,6 @@ BEGIN
timeout => IPC_CMD_TIMEOUT
);


copy("$conf_dir/localOverrides.conf","$conf_dir/localOverrides.conf.bak");
open(my $in,"<","$conf_dir/localOverrides.conf.bak");
open(my $out,">","$conf_dir/localOverrides.conf");
while(<$in>) {
if(/^1;/) {
print $out "push(\@{\$pg{modules}},[qw(Chromatic)]);\n1;\n";
} else {
print $out $_;
}
}
#push(@{$ce->{pg}->{modules}},[qw(Chromatic)]);
#foreach(@{$ce->{pg}->{modules}}) {
# print "@{$_}\n";
# }

chdir($cwd);

print "Installed Chromatic.pm and associated binary.\n";
Expand Down
17 changes: 11 additions & 6 deletions ww_install.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use constant PG_REPO => 'https://github.com/openwebwork/pg.git';
use constant OPL_REPO =>
'https://github.com/openwebwork/webwork-open-problem-library.git';
use constant MATHJAX_REPO => "https://github.com/mathjax/MathJax.git";

use constant WW_PREFIX => '/opt/webwork/';
use constant ROOT_URL => 'http://localhost';
Expand Down Expand Up @@ -1944,15 +1945,19 @@ sub unpack_jsMath_fonts {
}

sub get_MathJax {
my $webwork_dir = shift;
chdir("$webwork_dir");
my $WW_PREFIX = shift;
chdir($WW_PREFIX);

#system("git submodule update --init");
my $full_path = can_run('git');
my $cmd = [ $full_path, 'submodule', "update", "--init" ];
#As of ww2.8, MathJax is no longer a git submodule.
#pre-2.8 code:
#command: system("git submodule update --init");
#my $cmd = [ $full_path, 'submodule', "update", "--init" ];

my $cmd = [ $full_path, 'clone', MATHJAX_REPO];
my $success = run_command($cmd);
if ($success) {
print_and_log("Downloaded MathJax to $webwork_dir/htdocs/mathjax\n");
print_and_log("Downloaded MathJax to $WW_PREFIX/MathJax\n");
} else {
print_and_log("Could not download MathJax. You'll have to do this manually.");
}
Expand Down Expand Up @@ -2429,7 +2434,7 @@ sub write_launch_browser_script {
#
######################################################################
EOF
get_MathJax($webwork_dir);
get_MathJax($WW_PREFIX);

print_and_log(<<EOF);
#######################################################################
Expand Down

0 comments on commit 7971121

Please sign in to comment.