$htmlFile = basename($gameDataFile, '.json') . '.htm';
file_put_contents(
$wwwGameDir . $htmlFile,
- renderGameFile($gameDataFile)
+ renderGameFile($gameDataFile, 'game/' . $htmlFile)
);
}
}
file_put_contents(
$wwwDiscoverDir . $htmlFile,
- renderDiscoverFile($discoverFile)
+ renderDiscoverFile($discoverFile, 'discover/' . $htmlFile)
);
}
file_put_contents(
$wwwDiscoverDir . 'allgames.htm',
- renderAllGamesList(glob($gameDetailsDir . '*.json'))
+ renderAllGamesList(glob($gameDetailsDir . '*.json'), 'discover/allgames.htm')
);
-function renderAllGamesList($detailsFiles)
+function renderAllGamesList($detailsFiles, $path)
{
$games = [];
foreach ($detailsFiles as $gameDataFile) {
$navLinks = [
'./' => 'back',
];
+ $canonicalUrl = $GLOBALS['baseUrl'] . $path;
$allGamesTemplate = __DIR__ . '/../data/templates/allgames.tpl.php';
ob_start();
return $html;
}
-function renderDiscoverFile($discoverFile)
+function renderDiscoverFile($discoverFile, $path)
{
$json = json_decode(file_get_contents($discoverFile));
$navLinks['./'] = 'discover';
}
+ if ($path === 'discover/index.htm') {
+ $path = 'discover/';
+ }
+ $canonicalUrl = $GLOBALS['baseUrl'] . $path;
+
$discoverTemplate = __DIR__ . '/../data/templates/discover.tpl.php';
ob_start();
include $discoverTemplate;
return $html;
}
-function renderGameFile($gameDataFile)
+function renderGameFile($gameDataFile, $path)
{
$json = json_decode(file_get_contents($gameDataFile));
$internetArchiveUrl = $json->stouyapi->{'internet-archive'} ?? null;
$developerUrl = $json->stouyapi->{'developer-url'} ?? null;
+ $canonicalUrl = $GLOBALS['baseUrl'] . $path;
$pushUrl = $GLOBALS['pushToMyOuyaUrl']
. '?game=' . urlencode($json->apk->package);
<meta name="author" content="<?= htmlspecialchars($json->developer->name) ?>"/>
<link rel="stylesheet" type="text/css" href="../ouya-game.css"/>
<link rel="icon" href="../favicon.ico"/>
+ <link rel="canonical" href="<?= htmlspecialchars($canonicalUrl) ?>"/>
<meta name="twitter:card" content="summary_large_image"/>
<meta property="og:title" content="<?= htmlspecialchars($json->title); ?>" />
<meta property="og:description" content="<?= htmlspecialchars(substr(strtok($json->description, '.!'), 0, 200)); ?>." />