2016-07-02 10:58:30 -07:00
|
|
|
<?php
|
|
|
|
|
2016-07-02 17:10:55 -07:00
|
|
|
|
2016-07-03 20:54:55 -07:00
|
|
|
use Sikofitt\Json\ResumeBuilder;
|
2016-07-04 18:09:37 -07:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2016-07-02 17:10:55 -07:00
|
|
|
use Silex\Provider\TwigServiceProvider;
|
2016-07-03 20:54:55 -07:00
|
|
|
use WhoopsSilex\WhoopsServiceProvider;
|
2016-07-05 14:41:50 -07:00
|
|
|
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
|
2016-07-07 14:50:58 -07:00
|
|
|
|
2016-07-03 20:54:55 -07:00
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
require_once __DIR__ . '/../app/App.php';
|
|
|
|
|
2016-07-07 14:50:58 -07:00
|
|
|
define('APP_ROOT', __DIR__ . '/../');
|
|
|
|
define('SCHEMA_URL', 'https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json');
|
2016-07-03 20:54:55 -07:00
|
|
|
$app = new App();
|
2016-07-05 14:41:50 -07:00
|
|
|
$app['debug'] = true;
|
2016-07-03 20:54:55 -07:00
|
|
|
$app->register(new Sikofitt\Config\ConfigServiceProvider(), [
|
2016-07-07 18:00:25 -07:00
|
|
|
'config.path' => $app->getConfDirectory(),
|
2016-07-03 20:54:55 -07:00
|
|
|
]);
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->register(new TwigServiceProvider(), [
|
2016-07-07 18:00:25 -07:00
|
|
|
'twig.path' => [
|
|
|
|
APP_ROOT . 'app/views',
|
|
|
|
APP_ROOT . 'vendor/symfony/web-profiler-bundle/Resources/views/Profiler'
|
|
|
|
],
|
2016-07-02 17:10:55 -07:00
|
|
|
]);
|
2016-07-03 20:54:55 -07:00
|
|
|
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->register(new WhoopsServiceProvider());
|
|
|
|
$app->register(new \Silex\Provider\AssetServiceProvider());
|
|
|
|
$app->register(new \Silex\Provider\MonologServiceProvider());
|
2016-07-05 14:41:50 -07:00
|
|
|
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->register(new \Silex\Provider\HttpKernelServiceProvider());
|
2016-07-05 14:41:50 -07:00
|
|
|
$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());
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->register(new \Silex\Provider\VarDumperServiceProvider(), array(
|
2016-07-07 18:00:25 -07:00
|
|
|
'var_dumper.dump_destination' => new \Symfony\Component\VarDumper\Cloner\VarCloner(),
|
2016-07-05 14:41:50 -07:00
|
|
|
));
|
|
|
|
|
|
|
|
$app->register(new \Silex\Provider\MonologServiceProvider(), array(
|
2016-07-07 18:00:25 -07:00
|
|
|
'monolog.logfile' => $app->getDataDirectory() . '/logs/' . (null !== $app->config('app.environment') ? $app->config('app.environment') . '.log' : 'dev.log'),
|
2016-07-05 14:41:50 -07:00
|
|
|
));
|
|
|
|
|
|
|
|
$app->register(new \Silex\Provider\SessionServiceProvider());
|
|
|
|
$app->register(new \Silex\Provider\WebProfilerServiceProvider(), array(
|
2016-07-07 18:00:25 -07:00
|
|
|
'profiler.cache_dir' => $app->getDataDirectory() . '/cache/profiler',
|
2016-07-05 14:41:50 -07:00
|
|
|
));
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->extend('twig', function (\Twig_Environment $twig, $app) {
|
2016-07-07 18:00:25 -07:00
|
|
|
$twig->enableDebug();
|
|
|
|
$twig->addExtension(new Twig_Extensions_Extension_Date());
|
|
|
|
$twig->addExtension(new Sikofitt\Twig\Date());
|
|
|
|
$twig->addExtension(new Sikofitt\Twig\RenderProfile());
|
|
|
|
$twig->addGlobal('config', $app['config']->all());
|
|
|
|
return $twig;
|
2016-07-05 14:41:50 -07:00
|
|
|
});
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->error(function (\Exception $e, $code) use ($app) {
|
2016-07-07 18:00:25 -07:00
|
|
|
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);
|
2016-07-04 18:09:37 -07:00
|
|
|
});
|
2016-07-07 18:00:25 -07:00
|
|
|
|
2016-07-03 20:54:55 -07:00
|
|
|
$app['json.decoder'] = function ($app) {
|
2016-07-07 18:00:25 -07:00
|
|
|
return new Webmozart\Json\JsonDecoder();
|
2016-07-02 17:10:55 -07:00
|
|
|
};
|
2016-07-03 20:54:55 -07:00
|
|
|
$app['json.encoder'] = function ($app) {
|
2016-07-07 18:00:25 -07:00
|
|
|
return new Webmozart\Json\JsonEncoder();
|
2016-07-02 17:10:55 -07:00
|
|
|
};
|
2016-07-03 20:54:55 -07:00
|
|
|
$app['json.validator'] = function ($app) {
|
2016-07-07 18:00:25 -07:00
|
|
|
return new Webmozart\Json\JsonValidator();
|
2016-07-02 17:10:55 -07:00
|
|
|
};
|
|
|
|
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->get('/', function () use ($app) {
|
2016-07-07 18:00:25 -07:00
|
|
|
$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;
|
2016-07-07 14:50:58 -07:00
|
|
|
|
2016-07-03 22:17:58 -07:00
|
|
|
|
2016-07-07 18:00:25 -07:00
|
|
|
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,
|
|
|
|
]);
|
2016-07-02 10:58:30 -07:00
|
|
|
});
|
|
|
|
|
2016-07-07 14:50:58 -07:00
|
|
|
$app->run();
|