Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEB: Improve OpenGraph and SEO headers and fix news title #411

Merged
merged 5 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/ca/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"linksHeading": "",
"linksIntro": "",
"listItemsDate": "",
"homeTitle": "",
"newsTitle": "",
"newsContentTitle": "",
"newsPostedBy": "",
Expand Down
3 changes: 2 additions & 1 deletion data/de/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"linksHeading": "Links",
"linksIntro": "**Verlinken Sie zu uns:** Bitte verwenden Sie dieses Bild, wenn Sie einen Link zu uns auf Ihre Website setzen wollen.",
"listItemsDate": ", zuletzt aktualisiert:",
"newsTitle": "Startseite",
"homeTitle": "Startseite",
"newsTitle": "Aktuelle Nachrichten",
"newsContentTitle": "Aktuelle Nachrichten",
"newsPostedBy": "geschrieben von",
"newsMoreNews": "Weitere Nachrichten...",
Expand Down
3 changes: 2 additions & 1 deletion data/el/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"linksHeading": "Σύνδεσμοι",
"linksIntro": "**Παρέχετε σύνδεσμο προς εμάς:** Αν θέλετε να παρέχετε ένα σύνδεσμο από τον ιστότοπό σας προς το ScummVM: μπορείτε να χρησιμοποιήσετε ελεύθερα αυτή την εικόνα.",
"listItemsDate": ", τελευταία ενημέρωση:",
"newsTitle": "Αρχική",
"homeTitle": "Αρχική",
"newsTitle": "Τελευταίες Εξελίξεις",
"newsContentTitle": "Τελευταίες Εξελίξεις",
"newsPostedBy": "Δημοσιεύτηκε από",
"newsMoreNews": "Περισσότερες Ειδήσεις...",
Expand Down
3 changes: 2 additions & 1 deletion data/en/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
"linksHeading": "Links",
"linksIntro": "**Link to us:** If you want to link your site to us: please feel free to use this image.",
"listItemsDate": ", last update:",
"newsTitle": "Home",
"homeTitle": "Home",
"newsTitle": "Latest Developments",
"newsContentTitle": "Latest Developments",
"newsPostedBy": "Posted by",
"newsMoreNews": "More News...",
Expand Down
3 changes: 2 additions & 1 deletion data/es/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
"linksHeading": "Enlaces",
"linksIntro": "**Enlázanos:** Si quieres poner nuestro enlace en tu sitio, puedes usar esta imagen.",
"listItemsDate": ", última actualización:",
"newsTitle": "Inicio",
"homeTitle": "Inicio",
"newsTitle": "Últimas publicaciones",
"newsContentTitle": "Últimas publicaciones",
"newsPostedBy": "Publicado por",
"newsMoreNews": "Más noticias...",
Expand Down
3 changes: 2 additions & 1 deletion data/fi/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"linksHeading": "Linkit",
"linksIntro": "**Linkitä tänne meille:** mikäli haluat linkittää ScummVM-hankkeeseen omalta sivustollasi: käytä tätä kuvaa vapaasti.",
"listItemsDate": ", viimeisin päivitys:",
"newsTitle": "Koti",
"homeTitle": "Koti",
"newsTitle": "Viimeisimmät kehitysaskeleet",
"newsContentTitle": "Viimeisimmät kehitysaskeleet",
"newsPostedBy": "Tämän lähetti",
"newsMoreNews": "Lisää uutisia...",
Expand Down
3 changes: 2 additions & 1 deletion data/fr/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
"linksHeading": "Liens",
"linksIntro": "**Liens vers le site de ScummVM :** vous pouvez utiliser cette image sur votre site pour les liens vers le site de ScummVM.",
"listItemsDate": ", dernière mise à jour  :",
"newsTitle": "Accueil",
"homeTitle": "Accueil",
"newsTitle": "Nouvelles récentes",
"newsContentTitle": "Nouvelles récentes",
"newsPostedBy": "Posté par",
"newsMoreNews": "Plus de nouvelles...",
Expand Down
3 changes: 2 additions & 1 deletion data/he/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"linksHeading": "קישורים",
"linksIntro": "**קישור אלינו: אם ברצונך לקשר אלינו את האתר שלך: אל תהסס להשתמש בתמונה זו.**",
"listItemsDate": ", העדכון אחרון:",
"newsTitle": "בית",
"homeTitle": "בית",
"newsTitle": "התפתחויות אחרונות",
"newsContentTitle": "התפתחויות אחרונות",
"newsPostedBy": "פורסם על ידי",
"newsMoreNews": "עוד חדשות...",
Expand Down
3 changes: 2 additions & 1 deletion data/it/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"linksHeading": "Link",
"linksIntro": "**Linkaci:** se vuoi mettere un collegamento a scummvm.org sul tuo sito, usa pure questa immagine.",
"listItemsDate": ", ultimo aggiornamento:",
"newsTitle": "Home",
"homeTitle": "Home",
"newsTitle": "Ultimi Aggiornamenti",
"newsContentTitle": "Ultimi Aggiornamenti",
"newsPostedBy": "Scritto da",
"newsMoreNews": "Altre News...",
Expand Down
3 changes: 2 additions & 1 deletion data/ka/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
"linksHeading": "ბმულები",
"linksIntro": "**ბმულ ჩვენამდე:** თუ გნებავთ, თქვენს ვებგვერდზე ჩვენი ბმული განათავსოთ: შეგიძლიათ, ეს გამოსახულება გამოიყენოთ.",
"listItemsDate": ", ბოლო განახლება:",
"newsTitle": "ღილაკი Home",
"homeTitle": "ღილაკი Home",
"newsTitle": "უკანასკნელი ცვლილებები",
"newsContentTitle": "უკანასკნელი ცვლილებები",
"newsPostedBy": "ავტორი",
"newsMoreNews": "მეტი სიახლე ...",
Expand Down
3 changes: 2 additions & 1 deletion data/pt-BR/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"linksHeading": "Links",
"linksIntro": "**Redirecionamento:** Se deseja inserir em seu site um link para o nosso: por favor, fique à vontade para utilizar esta imagem.",
"listItemsDate": ", última atualização:",
"newsTitle": "Início",
"homeTitle": "Início",
"newsTitle": "Publicações Mais Recentes",
"newsContentTitle": "Publicações Mais Recentes",
"newsPostedBy": "Publicado por",
"newsMoreNews": "Mais Notícias...",
Expand Down
3 changes: 2 additions & 1 deletion data/pt-PT/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"linksHeading": "Ligações",
"linksIntro": "",
"listItemsDate": ", última atualização:",
"newsTitle": "Início",
"homeTitle": "Início",
"newsTitle": "Últimas Notícias",
"newsContentTitle": "Últimas Notícias",
"newsPostedBy": "Publicado por",
"newsMoreNews": "Mais Notícias...",
Expand Down
3 changes: 2 additions & 1 deletion data/ru/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"linksHeading": "Ссылки",
"linksIntro": "**Добавляйте ссылки на нас:** если вы хотите добавить ссылку на своём сайте, можете использовать эту картинку.",
"listItemsDate": ", последнее обновление:",
"newsTitle": "Главная",
"homeTitle": "Главная",
"newsTitle": "Последние новости",
"newsContentTitle": "Последние новости",
"newsPostedBy": "Опубликовано",
"newsMoreNews": "Ещё новости...",
Expand Down
3 changes: 2 additions & 1 deletion data/zh-Hans/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
"linksHeading": "链接",
"linksIntro": "**我们的链接:** 如果你想在个人网站上链接到我们的网站,请尽管使用此图像。",
"listItemsDate": ",上次更新:",
"newsTitle": "主页",
"homeTitle": "主页",
"newsTitle": "最新开发进展",
"newsContentTitle": "最新开发进展",
"newsPostedBy": "发布者",
"newsMoreNews": "更多新闻…",
Expand Down
17 changes: 17 additions & 0 deletions include/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function __construct()
// Construct lang URL
$langs = join("|", array_keys($available_languages));
$pageurl = preg_replace("/\/\b($langs)\b\/?/i", '/', $_SERVER['REQUEST_URI']);
// Remove leading /
$pageurl = substr($pageurl, 1);
/* Check RTL */
$rtl = $this->isRtl($available_languages[$lang]);

Expand Down Expand Up @@ -231,4 +233,19 @@ protected function getConfigVars($title)
{
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;
}
}
2 changes: 2 additions & 0 deletions include/Pages/ArticlePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function index($params)
$content = $purifier->purify($Parsedown->text($article->body()));

return $this->renderPage([
'title' => $title,
'description' => htmlentities($this->getHeadline($content)),
'content_title' => $title,
'date' => $date,
'author' => $author,
Expand Down
3 changes: 3 additions & 0 deletions include/Pages/CompatibilityPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public function getGame($target, $version)
return $this->renderPage(
array(
'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')),
'subtitle' => $game->getGame()->getName(),
'description' => $this->supportLevelDescriptions[$game->getSupport()],
'content_title' => preg_replace(
'/{version}/',
$version,
Expand All @@ -116,6 +118,7 @@ public function getAll($version, $versions)
return $this->renderPage(
[
'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')),
'description' => $this->getConfigVars('compatibilityIntro'),
'content_title' => preg_replace(
'/{version}/',
$version,
Expand Down
1 change: 1 addition & 0 deletions include/Pages/DemosPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function index()
return $this->renderPage(
array(
'title' => $this->getConfigVars('demosTitle'),
'description' => $this->getConfigVars('gamesDemosContentP1'),
'content_title' => $this->getConfigVars('demosContentTitle'),
'demos' => $demos,
)
Expand Down
1 change: 1 addition & 0 deletions include/Pages/DirectorDemosPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function index()
return $this->renderPage(
array(
'title' => $this->getConfigVars('directorDemosTitle'),
'description' => $this->getConfigVars('gamesDemosContentP1'),
'content_title' => $this->getConfigVars('directorDemosContentTitle'),
'demos' => $demos,
)
Expand Down
1 change: 1 addition & 0 deletions include/Pages/DownloadsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function index()
return $this->renderPage(
array(
'title' => $this->getConfigVars('downloadsTitle'),
'description' => \strip_tags($this->getConfigVars('downloadsContentP1')),
'content_title' => $this->getConfigVars('downloadsContentTitle'),
'downloads' => $downloads,
'recommendedDownload' => $recommendedDownload
Expand Down
1 change: 1 addition & 0 deletions include/Pages/GamesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function index()
return $this->renderPage(
array(
'title' => $this->getConfigVars('gamesTitle'),
'description' => strip_tags($this->getConfigVars('gamesContentP1')),
'content_title' => $this->getConfigVars('gamesContentTitle'),
'downloads' => $downloads,
)
Expand Down
1 change: 1 addition & 0 deletions include/Pages/LinksPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function index()
return $this->renderPage(
array(
'title' => $this->getConfigVars('linksTitle'),
// TODO: add a description
'content_title' => $this->getConfigVars('linksContentTitle'),
'links' => $links,
)
Expand Down
10 changes: 8 additions & 2 deletions include/Pages/NewsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ public function getNews($filename = null)
{
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,
Expand All @@ -68,7 +73,8 @@ public function getNewsIntro()

return $this->renderPage(
array(
'title' => $this->getConfigVars('newsTitle'),
'title' => $this->getConfigVars('homeTitle'),
'description' => $this->getConfigVars('introHeaderContentP1'),
'content_title' => $this->getConfigVars('newsContentTitle'),
'show_intro' => true,
'news_items' => $news_items,
Expand Down
5 changes: 5 additions & 0 deletions include/Pages/ScreenshotsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function index($args)
return $this->renderPage(
[
'title' => $this->getConfigVars('screenshotsTitle'),
// TODO: Add a description
'content_title' => $this->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshot,
'random_shot' => $random_shot,
Expand All @@ -51,17 +52,21 @@ public function getCategory($category, $game)
{
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,
Expand Down
1 change: 1 addition & 0 deletions include/Pages/SimplePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function index($data = null)

return $this->renderPage([
'title' => $this->getConfigVars("{$this->key}Title"),
'description' => $this->getConfigVars("{$this->key}Description"),
'content_title' => $this->getConfigVars("{$this->key}ContentTitle"),
'data' => $data
]);
Expand Down
6 changes: 3 additions & 3 deletions templates/components/lang_menu.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
{if $key != $lang}
<dd>
{if $key == $smarty.const.DEFAULT_LOCALE}
<span class="bullet"></span><a href="{$pageurl}">{$item}</a>
<span class="bullet"></span><a href="/{$pageurl}">{$item}</a>
{else}
<span class="bullet"></span><a href="/{$key}{$pageurl}">{$item}</a>
<span class="bullet"></span><a href="/{$key}/{$pageurl}">{$item}</a>
{/if}
</dd>
{/if}
{/foreach}
</dl>
</dl>
12 changes: 7 additions & 5 deletions templates/pages/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -23,14 +24,15 @@
<!-- 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:url" content="{'https://www.scummvm.org'|lang}">
<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}" />
<!-- Translations -->
{foreach from=$available_languages key=key item=item}
{if $lang != $key}
<link rel="alternate" hreflang="{$key}" href="{$baseurl}{$key}{$pageurl}">
<link rel="alternate" hreflang="{$key}" href="{$baseurl}{$key}/{$pageurl}">
{/if}
{/foreach}
{* Cache bust CSS if making major changes *}
Expand Down