DEV Community

loading...

Discussion on: Data visualization: Using amCharts with Perl and Mojo

Collapse
brxfork profile image
Philippe Bricout • Edited

Thank you for your post.
Here are some changes to make this app compatible with Mojolicious 8.12 (debian) :

diff --git a/amCharts/mojo_app/lib/MojoApp.pm b/amCharts/mojo_app/lib/MojoApp.pm
index 6858520..aec2e47 100644
--- a/amCharts/mojo_app/lib/MojoApp.pm
+++ b/amCharts/mojo_app/lib/MojoApp.pm
@@ -6,7 +6,7 @@ use MojoApp::Model::Data;
 sub startup ($self) {

     # Load configuration from config file
-    my $config = $self->plugin('NotYAMLConfig');
+    my $config = $self->plugin('Config');

     # Configure the application
     $self->secrets($config->{secrets});
diff --git a/amCharts/mojo_app/script/mojo_app b/amCharts/mojo_app/script/mojo_app
index b097e09..5c1edb5 100644
--- a/amCharts/mojo_app/script/mojo_app
+++ b/amCharts/mojo_app/script/mojo_app
@@ -3,8 +3,10 @@
 use strict;
 use warnings;

-use Mojo::File qw(curfile);
-use lib curfile->dirname->sibling('lib')->to_string;
+use FindBin;
+BEGIN { unshift @INC, "$FindBin::Bin/../lib" }
+#use Mojo::File qw(curfile);
+#use lib curfile->dirname->sibling('lib')->to_string;
 use Mojolicious::Commands;

 # Start command line interface for application
Enter fullscreen mode Exit fullscreen mode

... and create mojo_app.conf (beside mojo_app.yml ) :

{
  secrets => ['7c121257b1db016af25743be1e09177f634ba5e5'],
}
Enter fullscreen mode Exit fullscreen mode
Collapse
grinnz profile image
Dan Book

I would recommend lib::relative if you don't have access to curfile yet:

use lib::relative '../lib';
Enter fullscreen mode Exit fullscreen mode
Collapse
raigaurav profile image
Gaurav Rai Author

Thanks. I forgot to mention the current code is written in mojo version 9.14.
The YAML config were introduced in 8.57 and curfile in 8.25.
I must say, I liked the JSON more than YAML. But since most of cloud deployment tools are using YAML so they changed it to that. Maybe it will take some time to get accustom to it. :)

Forem Open with the Forem app