Skip to content

Instantly share code, notes, and snippets.

@mcarbonneaux
Last active March 5, 2017 20:39
Show Gist options
  • Save mcarbonneaux/fe5474692f18beb12b3936c50d7c2bf2 to your computer and use it in GitHub Desktop.
Save mcarbonneaux/fe5474692f18beb12b3936c50d7c2bf2 to your computer and use it in GitHub Desktop.
PHP Json Resume render.
<?php
$resume_time = lstat("resume.json");
if ( is_array($resume_time) )
{
$resume_mt=gmdate('D, d M Y H:i:s ', $resume_time["mtime"]) . 'GMT';
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
if (($if_modified_since && $if_modified_since == $resume_mt))
{
header('HTTP/1.1 304 Not Modified');
exit();
}
else
{
header("Last-Modified: $resume_mt");
}
}
$resume=json_decode(file_get_contents("resume.json"));
$data=array("resume"=>$resume);
$data_post=json_encode($data);
$theme="sceptile";
if (isset($_GET["theme"])) $theme=$_GET["theme"];
$url = 'https://themes.jsonresume.org/'.$theme;
$options = array(
'http' => array(
'header' => "content-type: application/json\r\n",
'method' => 'POST',
'content' => $data_post,
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
print($result);
@mcarbonneaux
Copy link
Author

mcarbonneaux commented Mar 5, 2017

Render resume.json JSON Resume (https://jsonresume.org/) with this php script.

The resume.json file must be in the same directory that this index.php.

This script support theme argument to change default theme to render.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment