Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting to Mojolicious::Template for outputFormat #14

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
26 changes: 10 additions & 16 deletions lib/RenderApp.pm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use strict;
use warnings;
# use feature 'signatures';
# no warnings qw(experimental::signatures);

package RenderApp;
use Mojo::Base 'Mojolicious';
drdrew42 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -15,7 +20,7 @@ BEGIN {
$ENV{PG_ROOT} = $main::dirname . '/PG';

# Used for reconstructing library paths from sym-links.
$ENV{OPL_DIRECTORY} = "webwork-open-problem-library";
$ENV{OPL_DIRECTORY} = "$ENV{RENDER_ROOT}/webwork-open-problem-library";

$ENV{MOJO_CONFIG} = (-r "$ENV{RENDER_ROOT}/render_app.conf") ? "$ENV{RENDER_ROOT}/render_app.conf" : "$ENV{RENDER_ROOT}/render_app.conf.dist";
# $ENV{MOJO_MODE} = 'production';
Expand All @@ -26,8 +31,9 @@ use lib "$main::dirname";
print "home directory " . $main::dirname . "\n";

use RenderApp::Model::Problem;
use RenderApp::Controller::RenderProblem;
use RenderApp::Controller::IO;
use WeBWorK::RenderProblem;
use WeBWorK::FormatRenderedProblem;

sub startup {
my $self = shift;
Expand Down Expand Up @@ -66,6 +72,7 @@ sub startup {
$self->helper(newProblem => sub { shift; RenderApp::Model::Problem->new(@_) });

# Helpers
$self->helper(format => sub { WeBWorK::FormatRenderedProblem::formatRenderedProblem(@_) });
$self->helper(validateRequest => sub { RenderApp::Controller::IO::validate(@_) });
$self->helper(parseRequest => sub { RenderApp::Controller::Render::parseRequest(@_) });
$self->helper(croak => sub { RenderApp::Controller::Render::croak(@_) });
Expand Down Expand Up @@ -107,20 +114,7 @@ sub startup {
$r->any('/pg_files/CAPA_Graphics/*static')->to('StaticFiles#CAPA_graphics_file');
$r->any('/pg_files/tmp/*static')->to('StaticFiles#temp_file');
$r->any('/pg_files/*static')->to('StaticFiles#pg_file');

# any other requests fall through
$r->any('/*fail' => sub {
my $c = shift;
my $report = $c->stash('fail')."\nCOOKIE:";
for my $cookie (@{$c->req->cookies}) {
$report .= "\n".$cookie->to_string;
}
$report .= "\nFORM DATA:";
foreach my $k (@{$c->req->params->names}) {
$report .= "\n$k = ".join ', ', @{$c->req->params->every_param($k)};
}
$c->log->fatal($report);
$c->rendered(404)});
$r->any('/*static')->to('StaticFiles#public_file');
drdrew42 marked this conversation as resolved.
Show resolved Hide resolved
}

1;
Loading