100 lines
4.2 KiB
PHP
100 lines
4.2 KiB
PHP
<?php
|
|
|
|
|
|
|
|
use Sikofitt\Json\ResumeBuilder;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Silex\Provider\TwigServiceProvider;
|
|
use WhoopsSilex\WhoopsServiceProvider;
|
|
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
require_once __DIR__ . '/../app/App.php';
|
|
|
|
define ('APP_ROOT', __DIR__ . '/../');
|
|
define ('SCHEMA_URL', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json');
|
|
$app = new App();
|
|
$app['debug'] = true;
|
|
$app->register(new Sikofitt\Config\ConfigServiceProvider(), [
|
|
'config.path' => $app->getConfDirectory(),
|
|
]);
|
|
$app->register (new TwigServiceProvider(), [
|
|
'twig.path' => [APP_ROOT . 'app/views', APP_ROOT .'vendor/symfony/web-profiler-bundle/Resources/views/Profiler'],
|
|
]);
|
|
|
|
$app->register (new WhoopsServiceProvider());
|
|
$app->register (new \Silex\Provider\AssetServiceProvider());
|
|
$app->register (new \Silex\Provider\MonologServiceProvider());
|
|
|
|
$app->register (new \Silex\Provider\HttpKernelServiceProvider());
|
|
$app->register(new \Silex\Provider\AssetServiceProvider());
|
|
$app->register(new \Silex\Provider\FormServiceProvider());
|
|
$app->register(new \Silex\Provider\HttpFragmentServiceProvider());
|
|
$app->register(new \Silex\Provider\ServiceControllerServiceProvider());
|
|
$app->register(new \Silex\Provider\RoutingServiceProvider());
|
|
$app->register (new \Silex\Provider\VarDumperServiceProvider(), array(
|
|
'var_dumper.dump_destination' => new \Symfony\Component\VarDumper\Cloner\VarCloner(),
|
|
));
|
|
|
|
$app->register(new \Silex\Provider\MonologServiceProvider(), array(
|
|
'monolog.logfile' => $app->getDataDirectory() . '/logs/' . (null !== $app->config('app.environment') ? $app->config('app.environment') . '.log' : 'dev.log'),
|
|
));
|
|
|
|
$app->register(new \Silex\Provider\SessionServiceProvider());
|
|
$app->register(new \Silex\Provider\WebProfilerServiceProvider(), array(
|
|
'profiler.cache_dir' => $app->getDataDirectory() .'/cache/profiler',
|
|
));
|
|
$app->extend('twig', function(\Twig_Environment $twig, $app) {
|
|
$twig->enableDebug();
|
|
return $twig;
|
|
});
|
|
$app->error(function (\Exception $e, $code) use($app) {
|
|
switch ($code) {
|
|
case 404:
|
|
$message = $app['twig']->render('error404.html.twig');
|
|
break;
|
|
default:
|
|
$message = $app['twig']->render('error500.html.twig');
|
|
}
|
|
return new Response($message, $code);
|
|
});
|
|
$app['json.decoder'] = function ($app) {
|
|
return new Webmozart\Json\JsonDecoder();
|
|
};
|
|
$app['json.encoder'] = function ($app) {
|
|
return new Webmozart\Json\JsonEncoder();
|
|
};
|
|
$app['json.validator'] = function ($app) {
|
|
return new Webmozart\Json\JsonValidator();
|
|
};
|
|
|
|
|
|
$app->get ('/', function () use ($app) {
|
|
$resumeData = $app['json.decoder']->decodeFile($app->getDataDirectory() .'/resume.json', $app->getDataDirectory() . '/resume.schema.json');
|
|
$basics = (isset($resumeData->basics) && count($resumeData->basics) > 0) ? $resumeData->basics : null;
|
|
$work = (isset($resumeData->work) && count($resumeData->work) > 0) ? $resumeData->work : null;
|
|
$volunteer = (isset($resumeData->volunteer) && count($resumeData->volunteer) > 0) ? $resumeData->volunteer : null;
|
|
$education = (isset($resumeData->education) && count($resumeData->education) > 0) ? $resumeData->education : null;
|
|
$awards = (isset($resumeData->awards) && count($resumeData->awards) > 0) ? $resumeData->awards : null;
|
|
$publications = (isset($resumeData->publications) && count($resumeData->publications) > 0) ? $resumeData->publications : null;
|
|
$skills = (isset($resumeData->skills) && count($resumeData->skills) > 0) ? $resumeData->skills : null;
|
|
$languages = (isset($resumeData->languages) && count($resumeData->languages) > 0) ? $resumeData->languages : null;
|
|
$interests = (isset($resumeData->interests) && count($resumeData->interests) > 0) ? $resumeData->interests : null;
|
|
$references = (isset($resumeData->references) && count($resumeData->references) > 0) ? $resumeData->references : null;
|
|
|
|
|
|
return $app['twig']->render('resume.html.twig', [
|
|
'basics' => $basics,
|
|
'work' => $work,
|
|
'volunteer' => $volunteer,
|
|
'education' => $education,
|
|
'awards' => $awards,
|
|
'publications' => $publications,
|
|
'skills' => $skills,
|
|
'languages' => $languages,
|
|
'interests' => $interests,
|
|
'references' => $references,
|
|
]);
|
|
});
|
|
|
|
$app->run ();
|