-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed handling of undefined values passed in through javascript
- Loading branch information
Showing
6 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
no warnings 'uninitialized'; | ||
|
||
use lib '/opt/yote/lib'; | ||
use lib '/home/wolf/proj/Yote/ServerYote/lib'; | ||
use lib '/home/wolf/proj/Yote/LockServer/lib'; | ||
use lib '/home/wolf/proj/Yote/FixedRecordStore/lib'; | ||
use lib '/home/wolf/proj/Yote/YoteBase/lib'; | ||
|
||
use Yote; | ||
use Yote::Server; | ||
use EPUC::Util; | ||
|
||
my( $server, $cgi ) = EPUC::Util::init; | ||
# Käse essen | ||
my $app = $server->fetch_app( 'EPUC::App' ); | ||
|
||
my $strip_id = $cgi->param('s'); | ||
my $strip_id = $cgi->param('s'); | ||
|
||
my $strip = $server->store->_fetch( $strip_id ); | ||
|
||
if( $strip ) { | ||
# find the index of the strip and make sure it is ready | ||
if( $strip->get__state eq 'complete' ) { | ||
my $strips = | ||
} | ||
} | ||
|
||
print $cgi->header( | ||
-status => '200 OK', | ||
-type => 'text/json' | ||
); | ||
_log("OUTY <$out_json>"); | ||
print $out_json; | ||
$main::yote_server->{STORE}->stow_all; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ use UUID::Tiny; | |
|
||
use vars qw($VERSION); | ||
|
||
$VERSION = '1.18'; | ||
$VERSION = '1.19'; | ||
|
||
our $DEBUG = 0; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package Yote::Server::ModperlOperator; | ||
|
||
use strict; | ||
no strict 'refs'; | ||
|
||
use Apache2::Cookie; | ||
use Apache2::Const qw(:common); | ||
use Data::Dumper; | ||
use Text::Xslate qw(mark_raw); | ||
|
||
use Yote::Server; | ||
|
||
sub new { | ||
my( $pkg, $r, %options ) = @_; | ||
|
||
my $jar = Apache2::Cookie::Jar->new($r); | ||
my $token_cookie = $jar->cookies("token"); | ||
my $token = $token_cookie ? $token_cookie->value : 0; | ||
my( @path ) = grep { $_ } split '/', $r->uri; | ||
|
||
bless { | ||
r => $r, | ||
cookie_path => $options{cookie_path}, | ||
template_path => $options{template_path}, | ||
app_name => $options{app_name}, | ||
main_template => $options{main_template}, | ||
token => $token, | ||
path => \@path, | ||
}, $pkg; | ||
|
||
} #new | ||
|
||
sub req { | ||
shift->{r} | ||
} | ||
|
||
sub load_app { | ||
my( $self, $appname ) = @_; | ||
|
||
eval('use Yote::ConfigData'); | ||
my $yote_root_dir = $@ ? '/opt/yote' : Yote::ConfigData->config( 'yote_root' ); | ||
unshift @INC, "$yote_root_dir/lib"; | ||
|
||
my $options = Yote::Server::load_options( $yote_root_dir ); | ||
my $server = new Yote::Server( $options ); | ||
my $store = $server->store; | ||
my $root = $store->fetch_server_root; | ||
my $session = $root->_fetch_session( $self->{token} ); | ||
$root->{SESSION} = $session; | ||
unless( $session ) { | ||
($root,my $token) = $root->init_root; | ||
$self->{token} = $token; | ||
my $token_cookie = Apache2::Cookie->new( $self->{r}, | ||
-name => "token", | ||
-path => "/$self->{cookie_path}", | ||
-value => $self->{token} ); | ||
$token_cookie->bake( $self->{r} ); | ||
} | ||
|
||
|
||
$self->{root} = $root; | ||
$self->{session} = $session; | ||
$self->{store} = $store; | ||
|
||
my( $app, $login ) = $root->fetch_app( $appname ); | ||
$app->{SESSION} = $session; | ||
$self->{app} = $app; | ||
$self->{login} = $login; | ||
if( $login ) { | ||
$login->{SESSION} = $session; | ||
} | ||
$app; | ||
} #load_app | ||
|
||
sub haslogin { | ||
defined shift->{login}; | ||
} | ||
|
||
sub err { | ||
my( $self, $err ) = @_; | ||
$err //= $@; | ||
if( ref $err ) { | ||
$self->{last_err} = $err->{err}; | ||
return $err->{err}; | ||
} elsif( $err ) { | ||
die $err; | ||
} | ||
} | ||
|
||
sub lasterr { | ||
shift->{last_err}; | ||
} | ||
|
||
sub login { | ||
my $self = shift; | ||
return $self->{login} if $self->{login}; | ||
my $r = $self->{r}; | ||
my( $un, $pw ) = ( $r->param('un'), $r->param('pw') ); | ||
my $login; | ||
if( $un && $pw ) { | ||
$login = $self->{app}->login( $un, $pw ); | ||
$login->{SESSION} = $self->{session}; | ||
$self->{login} = $login; | ||
} | ||
$login; | ||
} #login | ||
|
||
sub tmpl { | ||
my( $self, $tname ) = @_; | ||
"$self->{template_path}/$tname.tx"; | ||
} | ||
|
||
sub make_page { | ||
my $self = shift; | ||
|
||
my $tx = new Text::Xslate; | ||
$self->load_app($self->{app_name}); | ||
eval { | ||
$self->login; | ||
}; | ||
$self->err; | ||
my( @path ) = @{$self->{path}}; | ||
$self->{r}->print( $tx->render( $self->tmpl($self->{main_template}), { | ||
op => $self, } ) ); | ||
|
||
$self->{store}->stow_all; | ||
|
||
return $self->{rv}; | ||
} #make_page | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Yote::Server::ModperlOperator - marry the yote server to xslate templates | ||
=cut |