<commit_before>package Arepa::Web::Base;

use strict;
use warnings;

use base 'Mojolicious::Controller';

use Arepa::Config;

my $DEFAULT_CONFIG_PATH = '/etc/arepa/config.yml';
our $config      = undef;
our $config_path = $ENV{AREPA_CONFIG} || $DEFAULT_CONFIG_PATH;

if (-r $config_path) {
    $config = Arepa::Config->new($config_path);
}
else {
    die "Couldn't read configuration file $config_path.\n" .
        "Use the environment variable AREPA_CONFIG to specify one.\n";
}

sub config      { return $Arepa::Web::Base::config; }
sub config_path { return $Arepa::Web::Base::config_path; }


sub _add_error {
    my ($self, $error, $output) = @_;
    push @{$self->{error_list}}, {error  => $error,
                                  output => $output || ""};
}

sub _error_list {
    my ($self) = @_;
    @{$self->{error_list} || []};
}

sub vars {
    my ($self, @args) = @_;

    $self->stash(
        base_url     => $self->config->get_key('web_ui:base_url'),
        is_synced    => undef,
        @args);
}

sub show_view {
    my ($self, $stash, %opts) = @_;

    $self->vars(%$stash);
    if ($opts{template}) {
        $self->render($opts{template}, layout => 'default');
    }
    else {<commit_msg>Always pass the remote_repo_path variable to the templates<commit_after>package Arepa::Web::Base;

use strict;
use warnings;

use base 'Mojolicious::Controller';

use Arepa::Config;

my $DEFAULT_CONFIG_PATH = '/etc/arepa/config.yml';
our $config      = undef;
our $config_path = $ENV{AREPA_CONFIG} || $DEFAULT_CONFIG_PATH;

if (-r $config_path) {
    $config = Arepa::Config->new($config_path);
}
else {
    die "Couldn't read configuration file $config_path.\n" .
        "Use the environment variable AREPA_CONFIG to specify one.\n";
}

sub config      { return $Arepa::Web::Base::config; }
sub config_path { return $Arepa::Web::Base::config_path; }


sub _add_error {
    my ($self, $error, $output) = @_;
    push @{$self->{error_list}}, {error  => $error,
                                  output => $output || ""};
}

sub _error_list {
    my ($self) = @_;
    @{$self->{error_list} || []};
}

sub vars {
    my ($self, @args) = @_;

    $self->stash(
        base_url         => $self->config->get_key('web_ui:base_url'),
        is_synced        => undef,
        remote_repo_path => undef,
        @args);
}

sub show_view {
    my ($self, $stash, %opts) = @_;

    $self->vars(%$stash);
    if ($opts{template}) {
        $self->render($opts{template}, layout => 'default');
    }
    else {
{'fraction_non_alphanumeric': 0.17541766109785203, 'fraction_numerical': 0.0, 'mean_word_length': 2.9481946624803768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4586793', 'n_tokens_mistral': 884, 'n_tokens_neox': 875, 'n_words': 189}