From 541e2b41af8cc44ad3eb0638618bc457c666d612 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 7 Apr 2018 19:20:00 -0400 Subject: a bit of a quantum leap It's now possible to load the CGIs into a mojolicious controller. Compatibility isn't 100% yet, but it should give a migration path for any random CGI to become a proper controller. --- new.psgi | 80 ---------------------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100755 new.psgi (limited to 'new.psgi') diff --git a/new.psgi b/new.psgi deleted file mode 100755 index 9eb56b370..000000000 --- a/new.psgi +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env perl -use 5.10.1; -use strict; -use warnings; - -use File::Basename qw(basename dirname); -use File::Spec::Functions qw(catdir rel2abs); - -BEGIN { - require lib; - my $dir = rel2abs( dirname(__FILE__) ); - lib->import( $dir, catdir( $dir, 'lib' ), catdir( $dir, qw(local lib perl5) ) ); -} - -use Mojolicious::Lite; -use Bugzilla::Constants; -use Bugzilla::CGI::Mojo; -use Try::Tiny; - -plugin 'PODRenderer'; - -app->renderer->add_handler( - 'bugzilla' => sub { - my ( $renderer, $c, $output, $options ) = @_; - my %params; - - # Helpers - foreach my $method ( grep {m/^\w+\z/} keys %{ $renderer->helpers } ) { - my $sub = $renderer->helpers->{$method}; - $params{$method} = sub { $c->$sub(@_) }; - } - - # Stash values - $params{$_} = $c->stash->{$_} for grep {m/^\w+\z/} keys %{ $c->stash }; - $params{self} = $params{c} = $c; - Bugzilla->template->process( $options->{template}, \%params, $output ) - or die Bugzilla->template->error; - } -); - -app->hook( - around_dispatch => sub { - my ($next, $c) = @_; - try { - local %{ Bugzilla->request_cache } = (); - Bugzilla->usage_mode(USAGE_MODE_MOJO); - Bugzilla->cgi( Bugzilla::CGI::Mojo->new(controller => $c) ); - $next->(); - } catch { - die $_ unless /\bModPerl::Util::exit\b/; - }; - } -); - -get '/' => sub { - my $c = shift; - my $user = Bugzilla->login(LOGIN_OPTIONAL); - $c->stash->{use_login_page} = 1; - $c->render( template => 'index.html.tmpl', handler => 'bugzilla', user => $user ); -}; - -app->start; -__DATA__ - -@@ index.html.ep -% layout 'default'; -% title 'Welcome'; -% use Bugzilla::Util qw(remote_ip); - -

Hello, <%= $user->name %> <<%= $user->email %>> -

-

Your ip is <%= remote_ip() %> -

- -@@ layouts/default.html.ep - - - <%= title %> - <%= content %> - -- cgit v1.2.3-24-g4f1b