From 48542cb801f217b595c9e2f1ac4a377d6a95f507 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Fri, 6 Sep 2024 13:18:44 +0000 Subject: [PATCH 1/5] WEB: Remove leading / in page URLs --- include/Controller.php | 2 ++ templates/components/lang_menu.tpl | 6 +++--- templates/pages/index.tpl | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/Controller.php b/include/Controller.php index cd1168f5f..89714ef6f 100644 --- a/include/Controller.php +++ b/include/Controller.php @@ -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]); diff --git a/templates/components/lang_menu.tpl b/templates/components/lang_menu.tpl index dee32f647..9925edb6b 100644 --- a/templates/components/lang_menu.tpl +++ b/templates/components/lang_menu.tpl @@ -7,11 +7,11 @@ {if $key != $lang}
{if $key == $smarty.const.DEFAULT_LOCALE} - {$item} + {$item} {else} - {$item} + {$item} {/if}
{/if} {/foreach} - \ No newline at end of file + diff --git a/templates/pages/index.tpl b/templates/pages/index.tpl index 15445f8da..edc2341af 100644 --- a/templates/pages/index.tpl +++ b/templates/pages/index.tpl @@ -30,7 +30,7 @@ {foreach from=$available_languages key=key item=item} {if $lang != $key} - + {/if} {/foreach} {* Cache bust CSS if making major changes *} From c5ede510c8a9857a99acd4640a4f2e50adf1da70 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Fri, 6 Sep 2024 15:32:39 +0000 Subject: [PATCH 2/5] TEMPLATES: Fix OpenGraph and canonical URL --- templates/pages/index.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/pages/index.tpl b/templates/pages/index.tpl index edc2341af..f6af2c2b2 100644 --- a/templates/pages/index.tpl +++ b/templates/pages/index.tpl @@ -25,8 +25,9 @@ - + + {foreach from=$available_languages key=key item=item} {if $lang != $key} From 096726b016f4c56334b3e62183d59bfbada87015 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Fri, 6 Sep 2024 15:35:09 +0000 Subject: [PATCH 3/5] WEB: Add a description and a descriptive title for OpenGraph --- include/Controller.php | 15 +++++++++++++++ include/Pages/ArticlePage.php | 2 ++ include/Pages/CompatibilityPage.php | 3 +++ include/Pages/DemosPage.php | 1 + include/Pages/DirectorDemosPage.php | 1 + include/Pages/DownloadsPage.php | 1 + include/Pages/GamesPage.php | 1 + include/Pages/LinksPage.php | 1 + include/Pages/NewsPage.php | 8 +++++++- include/Pages/ScreenshotsPage.php | 5 +++++ include/Pages/SimplePage.php | 1 + templates/pages/index.tpl | 7 ++++--- 12 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/Controller.php b/include/Controller.php index 89714ef6f..5007d0c4c 100644 --- a/include/Controller.php +++ b/include/Controller.php @@ -233,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; + } } diff --git a/include/Pages/ArticlePage.php b/include/Pages/ArticlePage.php index a9473bc8d..ba13672ba 100644 --- a/include/Pages/ArticlePage.php +++ b/include/Pages/ArticlePage.php @@ -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, diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php index 18778cc3b..1c05f0cd2 100644 --- a/include/Pages/CompatibilityPage.php +++ b/include/Pages/CompatibilityPage.php @@ -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->getConfigVars('compatibilityIntro'), 'content_title' => preg_replace( '/{version}/', $version, @@ -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, diff --git a/include/Pages/DemosPage.php b/include/Pages/DemosPage.php index 6741fa406..d80599a0e 100644 --- a/include/Pages/DemosPage.php +++ b/include/Pages/DemosPage.php @@ -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, ) diff --git a/include/Pages/DirectorDemosPage.php b/include/Pages/DirectorDemosPage.php index 9cad59203..62bc08c38 100644 --- a/include/Pages/DirectorDemosPage.php +++ b/include/Pages/DirectorDemosPage.php @@ -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, ) diff --git a/include/Pages/DownloadsPage.php b/include/Pages/DownloadsPage.php index 93bf14373..33086f12a 100644 --- a/include/Pages/DownloadsPage.php +++ b/include/Pages/DownloadsPage.php @@ -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 diff --git a/include/Pages/GamesPage.php b/include/Pages/GamesPage.php index c9961f570..cf4757e52 100644 --- a/include/Pages/GamesPage.php +++ b/include/Pages/GamesPage.php @@ -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, ) diff --git a/include/Pages/LinksPage.php b/include/Pages/LinksPage.php index 1751c509e..ef0d8f863 100644 --- a/include/Pages/LinksPage.php +++ b/include/Pages/LinksPage.php @@ -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, ) diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php index 2797c2cea..a35d970a9 100644 --- a/include/Pages/NewsPage.php +++ b/include/Pages/NewsPage.php @@ -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, @@ -69,6 +74,7 @@ public function getNewsIntro() return $this->renderPage( array( 'title' => $this->getConfigVars('newsTitle'), + 'description' => $this->getConfigVars('introHeaderContentP1'), 'content_title' => $this->getConfigVars('newsContentTitle'), 'show_intro' => true, 'news_items' => $news_items, diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php index c9726b824..8f6b78785 100644 --- a/include/Pages/ScreenshotsPage.php +++ b/include/Pages/ScreenshotsPage.php @@ -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, @@ -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, diff --git a/include/Pages/SimplePage.php b/include/Pages/SimplePage.php index 3745bb5f9..ab4797c21 100644 --- a/include/Pages/SimplePage.php +++ b/include/Pages/SimplePage.php @@ -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 ]); diff --git a/templates/pages/index.tpl b/templates/pages/index.tpl index f6af2c2b2..34ce48706 100644 --- a/templates/pages/index.tpl +++ b/templates/pages/index.tpl @@ -8,7 +8,8 @@ - ScummVM :: {$title} + ScummVM :: {$title}{if isset($subtitle)} :: {$subtitle}{/if} + {if isset($description)}{/if} @@ -23,8 +24,8 @@ - - + + {if isset($description)}{/if} From 6eceeea5295bd2dc0529e612dacd000e0ef9a546 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 8 Sep 2024 08:35:10 +0000 Subject: [PATCH 4/5] WEB: Create a dedicated string from home and news archive pages --- data/ca/strings.json | 1 + data/de/strings.json | 3 ++- data/el/strings.json | 3 ++- data/en/strings.json | 3 ++- data/es/strings.json | 3 ++- data/fi/strings.json | 3 ++- data/fr/strings.json | 3 ++- data/he/strings.json | 3 ++- data/it/strings.json | 3 ++- data/ka/strings.json | 3 ++- data/pt-BR/strings.json | 3 ++- data/pt-PT/strings.json | 3 ++- data/ru/strings.json | 3 ++- data/zh-Hans/strings.json | 3 ++- include/Pages/NewsPage.php | 2 +- 15 files changed, 28 insertions(+), 14 deletions(-) diff --git a/data/ca/strings.json b/data/ca/strings.json index e237a19dc..eb6994f5b 100644 --- a/data/ca/strings.json +++ b/data/ca/strings.json @@ -121,6 +121,7 @@ "linksHeading": "", "linksIntro": "", "listItemsDate": "", + "homeTitle": "", "newsTitle": "", "newsContentTitle": "", "newsPostedBy": "", diff --git a/data/de/strings.json b/data/de/strings.json index 682afee22..7098626ae 100644 --- a/data/de/strings.json +++ b/data/de/strings.json @@ -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...", diff --git a/data/el/strings.json b/data/el/strings.json index 2c0989392..02418f22a 100644 --- a/data/el/strings.json +++ b/data/el/strings.json @@ -111,7 +111,8 @@ "linksHeading": "Σύνδεσμοι", "linksIntro": "**Παρέχετε σύνδεσμο προς εμάς:** Αν θέλετε να παρέχετε ένα σύνδεσμο από τον ιστότοπό σας προς το ScummVM: μπορείτε να χρησιμοποιήσετε ελεύθερα αυτή την εικόνα.", "listItemsDate": ", τελευταία ενημέρωση:", - "newsTitle": "Αρχική", + "homeTitle": "Αρχική", + "newsTitle": "Τελευταίες Εξελίξεις", "newsContentTitle": "Τελευταίες Εξελίξεις", "newsPostedBy": "Δημοσιεύτηκε από", "newsMoreNews": "Περισσότερες Ειδήσεις...", diff --git a/data/en/strings.json b/data/en/strings.json index cc8015193..ba141cbae 100644 --- a/data/en/strings.json +++ b/data/en/strings.json @@ -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...", diff --git a/data/es/strings.json b/data/es/strings.json index a95bf6842..86bbc34b6 100644 --- a/data/es/strings.json +++ b/data/es/strings.json @@ -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...", diff --git a/data/fi/strings.json b/data/fi/strings.json index fc91a5af9..fda1d6f54 100644 --- a/data/fi/strings.json +++ b/data/fi/strings.json @@ -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...", diff --git a/data/fr/strings.json b/data/fr/strings.json index 69fb8066d..08ef12548 100644 --- a/data/fr/strings.json +++ b/data/fr/strings.json @@ -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...", diff --git a/data/he/strings.json b/data/he/strings.json index c5f742bcc..c41838630 100644 --- a/data/he/strings.json +++ b/data/he/strings.json @@ -111,7 +111,8 @@ "linksHeading": "קישורים", "linksIntro": "**קישור אלינו: אם ברצונך לקשר אלינו את האתר שלך: אל תהסס להשתמש בתמונה זו.**", "listItemsDate": ", העדכון אחרון:", - "newsTitle": "בית", + "homeTitle": "בית", + "newsTitle": "התפתחויות אחרונות", "newsContentTitle": "התפתחויות אחרונות", "newsPostedBy": "פורסם על ידי", "newsMoreNews": "עוד חדשות...", diff --git a/data/it/strings.json b/data/it/strings.json index 25a0f1f2c..e29b450dc 100644 --- a/data/it/strings.json +++ b/data/it/strings.json @@ -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...", diff --git a/data/ka/strings.json b/data/ka/strings.json index 340cd3d18..8db8b14e6 100644 --- a/data/ka/strings.json +++ b/data/ka/strings.json @@ -121,7 +121,8 @@ "linksHeading": "ბმულები", "linksIntro": "**ბმულ ჩვენამდე:** თუ გნებავთ, თქვენს ვებგვერდზე ჩვენი ბმული განათავსოთ: შეგიძლიათ, ეს გამოსახულება გამოიყენოთ.", "listItemsDate": ", ბოლო განახლება:", - "newsTitle": "ღილაკი Home", + "homeTitle": "ღილაკი Home", + "newsTitle": "უკანასკნელი ცვლილებები", "newsContentTitle": "უკანასკნელი ცვლილებები", "newsPostedBy": "ავტორი", "newsMoreNews": "მეტი სიახლე ...", diff --git a/data/pt-BR/strings.json b/data/pt-BR/strings.json index fb489d96f..e22fe4d15 100644 --- a/data/pt-BR/strings.json +++ b/data/pt-BR/strings.json @@ -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...", diff --git a/data/pt-PT/strings.json b/data/pt-PT/strings.json index d66f49a93..7c2e6024e 100644 --- a/data/pt-PT/strings.json +++ b/data/pt-PT/strings.json @@ -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...", diff --git a/data/ru/strings.json b/data/ru/strings.json index d5ba47625..51fd3d13e 100644 --- a/data/ru/strings.json +++ b/data/ru/strings.json @@ -106,7 +106,8 @@ "linksHeading": "Ссылки", "linksIntro": "**Добавляйте ссылки на нас:** если вы хотите добавить ссылку на своём сайте, можете использовать эту картинку.", "listItemsDate": ", последнее обновление:", - "newsTitle": "Главная", + "homeTitle": "Главная", + "newsTitle": "Последние новости", "newsContentTitle": "Последние новости", "newsPostedBy": "Опубликовано", "newsMoreNews": "Ещё новости...", diff --git a/data/zh-Hans/strings.json b/data/zh-Hans/strings.json index c19f5b2a1..302a32232 100644 --- a/data/zh-Hans/strings.json +++ b/data/zh-Hans/strings.json @@ -121,7 +121,8 @@ "linksHeading": "链接", "linksIntro": "**我们的链接:** 如果你想在个人网站上链接到我们的网站,请尽管使用此图像。", "listItemsDate": ",上次更新:", - "newsTitle": "主页", + "homeTitle": "主页", + "newsTitle": "最新开发进展", "newsContentTitle": "最新开发进展", "newsPostedBy": "发布者", "newsMoreNews": "更多新闻…", diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php index a35d970a9..27100f096 100644 --- a/include/Pages/NewsPage.php +++ b/include/Pages/NewsPage.php @@ -73,7 +73,7 @@ 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, From f7babfdca7af4679501e0044186df83487c5fd80 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sat, 14 Sep 2024 13:21:28 +0200 Subject: [PATCH 5/5] WEB: Set the page description to the game support level --- include/Pages/CompatibilityPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php index 1c05f0cd2..1bda80c78 100644 --- a/include/Pages/CompatibilityPage.php +++ b/include/Pages/CompatibilityPage.php @@ -91,7 +91,7 @@ public function getGame($target, $version) array( 'title' => preg_replace('/{version}/', $version, $this->getConfigVars('compatibilityTitle')), 'subtitle' => $game->getGame()->getName(), - 'description' => $this->getConfigVars('compatibilityIntro'), + 'description' => $this->supportLevelDescriptions[$game->getSupport()], 'content_title' => preg_replace( '/{version}/', $version,