Skip to content

Commit

Permalink
make renderTemplate work even if a path is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Feb 22, 2023
1 parent 56ad133 commit 8d57d1e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.43.1 2023-02-22 17:19:04 +0100 Tobias Oetiker <[email protected]>

- make renderTemplate work, even when the destination folder does not exist

0.43.0 2023-02-14 16:54:59 +0100 Tobias Oetiker <[email protected]>

- add display action which displays a report in a new window instead of providing a download
Expand Down
2 changes: 1 addition & 1 deletion lib/CallBackery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use CallBackery::Database;
use CallBackery::User;


our $VERSION = '0.43.0';
our $VERSION = '0.43.1';


=head2 config
Expand Down
1 change: 0 additions & 1 deletion lib/CallBackery/Controller/RpcService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use Mojo::Base qw(Mojolicious::Plugin::Qooxdoo::JsonRpcController),
-signatures,-async_await;
use CallBackery::Exception qw(mkerror);
use CallBackery::Translate qw(trm);
use CallBackery::User;
use Scalar::Util qw(blessed weaken);
use Mojo::JSON qw(encode_json decode_json from_json);
use Syntax::Keyword::Try;
Expand Down
10 changes: 6 additions & 4 deletions lib/CallBackery/GuiPlugin/Abstract.pm
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ has homeDir => sub {
sub renderTemplate{
my $self = shift;
my $template = shift;
my $destination = shift;
my $destination = Mojo::File->new(shift);
$self->log->debug('['.$self->name.'] processing template '.$template);
my $newData = $self->template->render($self->app->home->rel_file('templates/system/'.$template)->slurp);
if (-r $destination){
Expand All @@ -509,13 +509,15 @@ sub renderTemplate{
return 0
}
}
my $dir = $destination->dirname;
if (not -d $dir){
Mojo::File->new($dir)->make_path({mode => 755});
}

$self->log->debug('['.$self->name."] writing $destination\n$newData");
eval {
local $SIG{__DIE__};
open my $fh, '>',$destination;
print $fh $newData;
close $fh;
$destination->spurt($newData);
};
if ($@){
if (blessed $@ and $@->isa('autodie::exception')){
Expand Down

0 comments on commit 8d57d1e

Please sign in to comment.