<commit_before><?php

use Slim\App;
use Woland\Controller;

require_once __DIR__ . '/../vendor/autoload.php';

error_reporting(-1);
set_time_limit(1);

// HACK: get routes to work when using the PHP dev server.
if (php_sapi_name() === 'cli-server') {
    $_SERVER['SCRIPT_NAME'] = '/index.php';
}

// Load config.
$home = posix_getpwuid(posix_getuid())['dir'];
$confPath = "$home/.config/woland.json";
$settings = json_decode(file_get_contents($confPath), true);

$app = new App(compact('settings'));
unset($app->getContainer()['errorHandler']);
$controller = new Controller($app);

// Setup Twig.
$app->getContainer()['view'] = function ($c) use ($settings) {
    $view = new \Slim\Views\Twig(
        dirname(__DIR__) . '/src/templates',
        ['cache' => $settings['cache'] . '/templates']
    );

    $view->addExtension(new \Slim\Views\TwigExtension(
        $c['router'],
        $c['request']->getUri()
    ));

    $view->addExtension(new \Woland\TwigExtension());
    $view->getEnvironment()->getExtension('core')
        ->setDateFormat('Y-m-d H:i:s P')
    ;

    return $view;
};

// Setup routes.
$app->get('/_/{type}/{asset}', [$controller, 'serveAsset']);
$app->get('/[{favorite}/{path:.*}]', [$controller, 'servePath']);

$app->run();
<commit_msg>Set time limit in dev only.<commit_after><?php

use Slim\App;
use Woland\Controller;

require_once __DIR__ . '/../vendor/autoload.php';

error_reporting(-1);

if (php_sapi_name() === 'cli-server') {
    // HACK: get routes to work when using the PHP dev server.
    $_SERVER['SCRIPT_NAME'] = '/index.php';

    set_time_limit(1);
}

// Load config.
$home = posix_getpwuid(posix_getuid())['dir'];
$confPath = "$home/.config/woland.json";
$settings = json_decode(file_get_contents($confPath), true);

$app = new App(compact('settings'));
unset($app->getContainer()['errorHandler']);
$controller = new Controller($app);

// Setup Twig.
$app->getContainer()['view'] = function ($c) use ($settings) {
    $view = new \Slim\Views\Twig(
        dirname(__DIR__) . '/src/templates',
        ['cache' => $settings['cache'] . '/templates']
    );

    $view->addExtension(new \Slim\Views\TwigExtension(
        $c['router'],
        $c['request']->getUri()
    ));

    $view->addExtension(new \Woland\TwigExtension());
    $view->getEnvironment()->getExtension('core')
        ->setDateFormat('Y-m-d H:i:s P')
    ;

    return $view;
};

// Setup routes.
$app->get('/_/{type}/{asset}', [$controller, 'serveAsset']);
$app->get('/[{favorite}/{path:.*}]', [$controller, 'servePath']);

$app->run();

{'fraction_non_alphanumeric': 0.22209165687426558, 'fraction_numerical': 0.0015667841754798276, 'mean_word_length': 3.9305019305019306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '1151960', 'n_tokens_mistral': 903, 'n_tokens_neox': 883, 'n_words': 161}