<commit_before>package Kirby;

use strict;
use warnings;

use Mojo::Base 'Mojolicious';
use FindBin;
use Data::Dumper;

use Kirby::Database;
use Kirby::Scraper::SimpleScraper;

sub startup {
    my $self = shift;

    $self->secret('Kirby Default');

    my $r = $self->routes;

    $r->any('/' => sub {
        my $self = shift;
        $self->stash(
            head => "Kirby",
        );
        $self->render('index');
    } => 'index');

    $r->any('/dump' => sub {
        my $self = shift;
        my @result;
        Kirby::Database::Kirby->iterate( sub {
                push @result, $_->series." | ".$_->issue;
            } );
        $self->stash(results => [ @result ],);
    } => 'dump');

    $r->any('/search' => sub {
        my $self = shift;
        my $q = $self->param('q') || undef;
        if ( defined $q ) {
            my $scrape = Kirby::Scraper::SimpleScraper->new( directory => '/export/Comics', );
            $scrape->search( q => $q, );
            $self->render(
                text => "sucessful query to SimpleScraper",
            );
        }
        else {
            $self->render(
                text => "Something's wrong",
            );
        };
    });

    $r->any('/add'  => sub {
        my $self = shift;
        my $series = $self->param('series') || undef;
        my $volume = $self->param('vol') || undef;
        my $issue = $self->param('issue') || undef;
        my $title = $self->param('title') || 'N/A';
        my $description = $self->param('desc') || 'N/A';
        if ( (defined $series) and (defined $volume) and (defined $issue) ) {
            my $comicID = Kirby::Database::Kirby->create(
                series => $series,
                volume => $volume,
                issue  => $issue,
                title  => $title,
                description => $description,
            );
            $self->render(
                text => "Inserted $series $volume $issue",
            );
        }
        else {
            $self->render(
                text => "Missing required fields",
            );
        };
    });
}

1;<commit_msg>Version and updated routing<commit_after>package Kirby;

use strict;
use warnings;

use Mojo::Base 'Mojolicious';
use FindBin;
use Data::Dumper;

use Kirby::Database;
use Kirby::Scraper::SimpleScraper;

our $VERSION = "0.01";

sub startup {
    my $self = shift;

    $self->secret('Kirby Default');

    my $r = $self->routes;

    $r->any('/' => sub {
        my $self = shift;
        $self->stash(
            head => "Kirby",
        );
        $self->render('index');
    } => 'index');

    $r->any('/dump' => sub {
        my $self = shift;
        my @result;
        Kirby::Database::Kirby->iterate( sub {
                push @result, $_->series." | ".$_->issue;
            } );
        $self->stash(results => [ @result ],);
    } => 'dump');

    $r->any('/search' => sub {
        my $self = shift;
        my $q = $self->param('q') || undef;
        if ( defined $q ) {
            my $scrape = Kirby::Scraper::SimpleScraper->new( directory => '/export/Comics', );
            $scrape->search( q => $q, );
            $self->render(
                text => "sucessful query to SimpleScraper",
            );
        }
        else {
            $self->render(
                text => "Something's wrong",
            );
        };
    });

    $r->any('/add'  => sub {
        my $self = shift;
        my $series = $self->param('series') || undef;
        my $volume = $self->param('vol') || undef;
        my $issue = $self->param('issue') || undef;
        my $title = $self->param('title') || 'N/A';
        my $description = $self->param('desc') || 'N/A';
        if ( (defined $series) and (defined $volume) and (defined $issue) ) {
            my $comicID = Kirby::Database::Kirby->create(
                series => $series,
                volume => $volume,
                issue  => $issue,
                title  => $title,
                description => $description,
            );
            $self->render(
                text => "Inserted $series $volume $issue",
            );
        }
        else {
            $self->render(
                text => "Missing required fields",
            );
        };
    });

    $r->get('/info' => 'info');
}

1;
{'fraction_non_alphanumeric': 0.18196607018359284, 'fraction_numerical': 0.0011619800139437602, 'mean_word_length': 1.558858501783591, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '595665', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1298, 'n_words': 295}