mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-05-21 05:40:47 +00:00
WEB: Add a description and a descriptive title for OpenGraph
This commit is contained in:
@@ -233,4 +233,19 @@ class Controller
|
||||
{
|
||||
return $this->smarty->getConfigVars($title);
|
||||
}
|
||||
|
||||
protected function getHeadline($body)
|
||||
{
|
||||
$headline = '';
|
||||
for ($line = \strtok($body, PHP_EOL); $line !== false; $line = \strtok(PHP_EOL)) {
|
||||
$line = \strip_tags($line);
|
||||
$headline .= $line . ' ';
|
||||
if (\strlen($headline) > 250) {
|
||||
$headline = substr($headline, 0, 249);
|
||||
$headline .= "\u{2026}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $headline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ class ArticlePage extends Controller
|
||||
$content = $purifier->purify($Parsedown->text($article->body()));
|
||||
|
||||
return $this->renderPage([
|
||||
'title' => $title,
|
||||
'description' => htmlentities($this->getHeadline($content)),
|
||||
'content_title' => $title,
|
||||
'date' => $date,
|
||||
'author' => $author,
|
||||
|
||||
@@ -90,6 +90,8 @@ class CompatibilityPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')),
|
||||
'subtitle' => $game->getGame()->getName(),
|
||||
'description' => $this->getConfigVars('compatibilityIntro'),
|
||||
'content_title' => preg_replace(
|
||||
'/{version}/',
|
||||
$version,
|
||||
@@ -116,6 +118,7 @@ class CompatibilityPage extends Controller
|
||||
return $this->renderPage(
|
||||
[
|
||||
'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')),
|
||||
'description' => $this->getConfigVars('compatibilityIntro'),
|
||||
'content_title' => preg_replace(
|
||||
'/{version}/',
|
||||
$version,
|
||||
|
||||
@@ -23,6 +23,7 @@ class DemosPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('demosTitle'),
|
||||
'description' => $this->getConfigVars('gamesDemosContentP1'),
|
||||
'content_title' => $this->getConfigVars('demosContentTitle'),
|
||||
'demos' => $demos,
|
||||
)
|
||||
|
||||
@@ -23,6 +23,7 @@ class DirectorDemosPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('directorDemosTitle'),
|
||||
'description' => $this->getConfigVars('gamesDemosContentP1'),
|
||||
'content_title' => $this->getConfigVars('directorDemosContentTitle'),
|
||||
'demos' => $demos,
|
||||
)
|
||||
|
||||
@@ -23,6 +23,7 @@ class DownloadsPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('downloadsTitle'),
|
||||
'description' => \strip_tags($this->getConfigVars('downloadsContentP1')),
|
||||
'content_title' => $this->getConfigVars('downloadsContentTitle'),
|
||||
'downloads' => $downloads,
|
||||
'recommendedDownload' => $recommendedDownload
|
||||
|
||||
@@ -23,6 +23,7 @@ class GamesPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('gamesTitle'),
|
||||
'description' => strip_tags($this->getConfigVars('gamesContentP1')),
|
||||
'content_title' => $this->getConfigVars('gamesContentTitle'),
|
||||
'downloads' => $downloads,
|
||||
)
|
||||
|
||||
@@ -24,6 +24,7 @@ class LinksPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('linksTitle'),
|
||||
// TODO: add a description
|
||||
'content_title' => $this->getConfigVars('linksContentTitle'),
|
||||
'links' => $links,
|
||||
)
|
||||
|
||||
@@ -38,14 +38,19 @@ class NewsPage extends Controller
|
||||
{
|
||||
if ($filename == null) {
|
||||
$news_items = $this->newsModel->getAllNews();
|
||||
$filename = 'archive';
|
||||
$subtitle = null;
|
||||
$description = $this->getConfigVars('introHeaderContentP1');
|
||||
} else {
|
||||
$news_items = array($this->newsModel->getOneByFilename($filename));
|
||||
$subtitle = $news_items[0]->getTitle();
|
||||
$description = htmlentities($this->getHeadline($news_items[0]->getContent()));
|
||||
}
|
||||
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('newsTitle'),
|
||||
'subtitle' => $subtitle,
|
||||
'description' => $description,
|
||||
'content_title' => $this->getConfigVars('newsContentTitle'),
|
||||
'show_intro' => false,
|
||||
'news_items' => $news_items,
|
||||
@@ -69,6 +74,7 @@ class NewsPage extends Controller
|
||||
return $this->renderPage(
|
||||
array(
|
||||
'title' => $this->getConfigVars('newsTitle'),
|
||||
'description' => $this->getConfigVars('introHeaderContentP1'),
|
||||
'content_title' => $this->getConfigVars('newsContentTitle'),
|
||||
'show_intro' => true,
|
||||
'news_items' => $news_items,
|
||||
|
||||
@@ -39,6 +39,7 @@ class ScreenshotsPage extends Controller
|
||||
return $this->renderPage(
|
||||
[
|
||||
'title' => $this->getConfigVars('screenshotsTitle'),
|
||||
// TODO: Add a description
|
||||
'content_title' => $this->getConfigVars('screenshotsContentTitle'),
|
||||
'screenshots' => $screenshot,
|
||||
'random_shot' => $random_shot,
|
||||
@@ -51,17 +52,21 @@ class ScreenshotsPage extends Controller
|
||||
{
|
||||
if (empty($game)) {
|
||||
$screenshots = $this->screenshotsModel->getScreenshotsByCompanyId($category);
|
||||
$subtitle = $screenshots['title'];
|
||||
} else {
|
||||
$screenshots = [
|
||||
'category' => $category,
|
||||
'games' => $this->screenshotsModel->getScreenshotsBySubcategory($game)
|
||||
];
|
||||
$subtitle = $screenshots['games'][0]->getName();
|
||||
}
|
||||
$this->template = 'pages/screenshots_category.tpl';
|
||||
|
||||
return $this->renderPage(
|
||||
[
|
||||
'title' => $this->getConfigVars('screenshotsTitle'),
|
||||
// TODO: Add a description
|
||||
'subtitle' => $subtitle,
|
||||
'content_title' => $this->getConfigVars('screenshotsContentTitle'),
|
||||
'screenshots' => $screenshots,
|
||||
'category' => $category,
|
||||
|
||||
@@ -42,6 +42,7 @@ class SimplePage extends Controller
|
||||
|
||||
return $this->renderPage([
|
||||
'title' => $this->getConfigVars("{$this->key}Title"),
|
||||
'description' => $this->getConfigVars("{$this->key}Description"),
|
||||
'content_title' => $this->getConfigVars("{$this->key}ContentTitle"),
|
||||
'data' => $data
|
||||
]);
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
<base href="{$baseurl|lang}">
|
||||
<link rel="alternate" type="application/atom+xml" title="{#indexAtomFeed#}" href="{$baseurl|lang}/feeds/atom/">
|
||||
<link rel="alternate" type="application/rss+xml" title="{#indexRSSFeed#}" href="{$baseurl|lang}/feeds/rss/">
|
||||
<title>ScummVM :: {$title}</title>
|
||||
<title>ScummVM :: {$title}{if isset($subtitle)} :: {$subtitle}{/if}</title>
|
||||
{if isset($description)}<meta name="description" content="{$description}">{/if}
|
||||
<!-- Favicon -->
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=oLBEjaJ9ag">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=oLBEjaJ9ag">
|
||||
@@ -23,8 +24,8 @@
|
||||
<!-- OpenGraph -->
|
||||
<meta property="og:image:width" content="1200">
|
||||
<meta property="og:image:height" content="630">
|
||||
<meta property="og:title" content="ScummVM">
|
||||
<meta property="og:description" content="ScummVM is a collection of game engines for playing classic graphical RPGs and point-and-click adventure games on modern hardware.">
|
||||
<meta property="og:title" content="ScummVM :: {$title}{if isset($subtitle)} :: {$subtitle}{/if}">
|
||||
{if isset($description)}<meta property="og:description" content="{$description}">{/if}
|
||||
<meta property="og:url" content="{$baseurl|lang}{$pageurl}">
|
||||
<meta property="og:image" content="https://www.scummvm.org/images/og-image.jpg">
|
||||
<link rel="canonical" href="{$baseurl|lang}{$pageurl}" />
|
||||
|
||||
Reference in New Issue
Block a user