$ssl = !empty($_SERVER['HTTPS']) ? "s" : ''; $server = "http{$ssl}://" . $_SERVER['SERVER_NAME']; $config = json_decode(file_get_contents('config.json')); $config->server = $server; $api = new Api($config); $api->fetchResource($_GET['path']); $description = $api->resource->data->type == 'photos' ? $api->resource->data->attributes->short_desc : $api->resource->data->attributes->description; $canonical = $api->buildCanonicalUrl(); $metadata = (object) ["author" => $config->author, "license" => $config->license, "siteName" => $config->siteTitle, "description" => $description, "title" => $api->resource->data->attributes->title, "image" => $api->resourceThumbUrl(), "url" => $canonical]; $response = new Template($server); $response->buildMetadata($metadata); $response->setPageTitle($api->buildPageTitle()); $response->setCanonicalUrl($canonical); $response->buildGalleryMenu($api->galleries); if ($api->resource->data->type == 'photos') { $response->buildPhotoContent($api->resource); } else { $response->buildGalleryContent($api->photos); } echo $response->makeResponse(); class Api { public $galleries; public $resource; public $photos; private $config; function __construct($config) { $this->config = $config; $this->fetchGalleries(); }