[Scummvm-git-logs] scummvm-web master -> 9cf9a19588d36914eb74d83cafba0730e945693e
Mataniko
mataniko at gmail.com
Fri Oct 9 03:08:55 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .
Summary:
e12a47d710 WEB: Create SimplePage class for pages that don't require customization
f43eca2c2b WEB: Move ExceptionPage to a SimplePage
9cf9a19588 WEB: Support arbitary article pages
Commit: e12a47d710a7526b14f417e3ddcb57dee5fc0bed
https://github.com/scummvm/scummvm-web/commit/e12a47d710a7526b14f417e3ddcb57dee5fc0bed
Author: Mataniko (mataniko at gmail.com)
Date: 2020-10-08T23:08:51-04:00
Commit Message:
WEB: Create SimplePage class for pages that don't require customization
Some of our pages are basic enough that they can just be generated automatically.
This commit extracts 5 such pages to reduce code and complexity
Changed paths:
A include/Pages/SimplePage.php
R include/Pages/ContactPage.php
R include/Pages/CreditsPage.php
R include/Pages/DocumentationPage.php
R include/Pages/PressPage.php
R include/Pages/SponsorsPage.php
public_html/index.php
templates/pages/credits.tpl
templates/pages/documentation.tpl
templates/pages/press.tpl
templates/pages/sponsors.tpl
diff --git a/include/Pages/ContactPage.php b/include/Pages/ContactPage.php
deleted file mode 100644
index f54877be..00000000
--- a/include/Pages/ContactPage.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-use ScummVM\Controller;
-
-class ContactPage extends Controller
-{
- /* Constructor. */
- public function __construct()
- {
- parent::__construct();
- $this->template = 'pages/contact.tpl';
- }
-
- /* Display the index page. */
- public function index()
- {
- return $this->renderPage(
- array(
- 'title' => $this->getConfigVars('contactTitle'),
- 'content_title' => $this->getConfigVars('contactContentTitle'),
- )
- );
- }
-}
diff --git a/include/Pages/CreditsPage.php b/include/Pages/CreditsPage.php
deleted file mode 100644
index b674206d..00000000
--- a/include/Pages/CreditsPage.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-use ScummVM\Controller;
-use ScummVM\Models\SimpleModel;
-
-class CreditsPage extends Controller
-{
- private $creditsModel;
-
- /* Constructor. */
- public function __construct()
- {
- parent::__construct();
- $this->template = 'pages/credits.tpl';
- $this->creditsModel = new SimpleModel("CreditsSection", "credits.yaml");
- }
-
- /* Display the index page. */
- public function index()
- {
- $credits = $this->creditsModel->getAllData();
- return $this->renderPage(
- [
- 'title' => $this->getConfigVars('creditsTitle'),
- 'content_title' => $this->getConfigVars('creditsContentTitle'),
- 'credits' => $credits,
- ]
- );
- }
-}
diff --git a/include/Pages/DocumentationPage.php b/include/Pages/DocumentationPage.php
deleted file mode 100644
index 01e0d5a9..00000000
--- a/include/Pages/DocumentationPage.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-use ScummVM\Controller;
-use ScummVM\Models\SimpleModel;
-
-class DocumentationPage extends Controller
-{
- private $documentationModel;
-
- /* Constructor. */
- public function __construct()
- {
- parent::__construct();
- $this->template = 'pages/documentation.tpl';
- $this->documentationModel = new SimpleModel("Document", "documentation.yaml");
- }
-
- /* Display the index page. */
- public function index()
- {
- $documents = $this->documentationModel->getAllData(false);
-
- return $this->renderPage(
- array(
- 'title' => $this->getConfigVars('documentationTitle'),
- 'content_title' => $this->getConfigVars('documentationContentTitle'),
- 'documents' => $documents,
- )
- );
- }
-}
diff --git a/include/Pages/PressPage.php b/include/Pages/PressPage.php
deleted file mode 100644
index 82ef7ac0..00000000
--- a/include/Pages/PressPage.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-use ScummVM\Controller;
-use ScummVM\Models\SimpleModel;
-
-class PressPage extends Controller
-{
- private $articleModel;
-
- /* Constructor. */
- public function __construct()
- {
- parent::__construct();
- $this->template = 'pages/press.tpl';
- $this->articleModel = new SimpleModel("Article", "press_articles.yaml");
- }
-
- /* Display the index page. */
- public function index()
- {
- $articles = $this->articleModel->getAllData(false);
- return $this->renderPage(
- array(
- 'title' => $this->getConfigVars('pressTitle'),
- 'content_title' => $this->getConfigVars('pressContentTitle'),
- 'articles' => $articles,
- )
- );
- }
-}
diff --git a/include/Pages/SimplePage.php b/include/Pages/SimplePage.php
new file mode 100644
index 00000000..14c281d9
--- /dev/null
+++ b/include/Pages/SimplePage.php
@@ -0,0 +1,49 @@
+<?php
+namespace ScummVM\Pages;
+
+use ScummVM\Controller;
+use ScummVM\Models\SimpleModel;
+
+class SimplePage extends Controller
+{
+ const FILE_NOT_FOUND = 'The filename %s could not be found';
+ const PAGE_MODELS = [
+ 'sponsors' => ['Sponsor', 'sponsors.yaml'],
+ 'press' => ['Article', 'press_articles.yaml'],
+ 'credits' => ['CreditsSection', 'credits.yaml'],
+ 'documentation' => ['Document', 'documentation.yaml'],
+ ];
+
+ private $model;
+ private $key;
+
+ /* Constructor. */
+ public function __construct($key)
+ {
+ parent::__construct();
+ $this->template = "pages/$key.tpl";
+ $this->key = $key;
+ $templateFile = SMARTY_DIR_TEMPLATE . "/$this->template";
+ if (!is_file($templateFile) || !is_readable($templateFile)) {
+ throw new \ErrorException(\sprintf(self::FILE_NOT_FOUND, $templateFile));
+ }
+ if (array_key_exists($key, self::PAGE_MODELS)) {
+ [$model, $data] = self::PAGE_MODELS[$key];
+ $this->model = new SimpleModel($model, $data);;
+ }
+ }
+
+ /* Display the index page. */
+ public function index()
+ {
+ if ($this->model) {
+ $data = $this->model->getAllData();
+ }
+
+ return $this->renderPage([
+ 'title' => $this->getConfigVars("{$this->key}Title"),
+ 'content_title' => $this->getConfigVars("{$this->key}ContentTitle"),
+ 'data' => $data
+ ]);
+ }
+}
diff --git a/include/Pages/SponsorsPage.php b/include/Pages/SponsorsPage.php
deleted file mode 100644
index 156f6af1..00000000
--- a/include/Pages/SponsorsPage.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-use ScummVM\Controller;
-use ScummVM\Models\SimpleModel;
-
-class SponsorsPage extends Controller
-{
- private $sponsorsModel;
-
- /* Constructor. */
- public function __construct()
- {
- parent::__construct();
- $this->template = 'pages/sponsors.tpl';
- $this->sponsorsModel = new SimpleModel("Sponsor", "sponsors.yaml");
- }
-
- /* Display the index page. */
- public function index()
- {
- $sponsors = $this->sponsorsModel->getAllData(false);
- return $this->renderPage(
- array(
- 'title' => $this->getConfigVars('sponsorsTitle'),
- 'content_title' => $this->getConfigVars('sponsorsContentTitle'),
- 'sponsors' => $sponsors,
- )
- );
- }
-}
diff --git a/public_html/index.php b/public_html/index.php
index aeb88979..abf872d0 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -99,10 +99,10 @@ $pages = array(
'compatibility' => '\ScummVM\Pages\CompatibilityPage',
'compatibility/[cId:version]' => '\ScummVM\Pages\CompatibilityPage',
'compatibility/[cId:version]/[a:game]' => '\ScummVM\Pages\CompatibilityPage',
- 'contact' => '\ScummVM\Pages\ContactPage',
- 'credits' => '\ScummVM\Pages\CreditsPage',
+ 'contact' => '\ScummVM\Pages\SimplePage',
+ 'credits' => '\ScummVM\Pages\SimplePage',
'demos' => '\ScummVM\Pages\DemosPage',
- 'documentation' => '\ScummVM\Pages\DocumentationPage',
+ 'documentation' => '\ScummVM\Pages\SimplePage',
'downloads' => '\ScummVM\Pages\DownloadsPage',
'games' => '\ScummVM\Pages\GamesPage',
'faq' => '\ScummVM\Pages\FAQPage',
@@ -112,13 +112,13 @@ $pages = array(
'' => '\ScummVM\Pages\NewsPage',
'news' => '\ScummVM\Pages\NewsPage',
'news/[a:date]' => '\ScummVM\Pages\NewsPage',
- 'press' => '\ScummVM\Pages\PressPage',
+ 'press' => '\ScummVM\Pages\SimplePage',
'presssnowberry' => '\ScummVM\Pages\PressSnowberryPage', // HACK
'screenshots' => '\ScummVM\Pages\ScreenshotsPage',
'screenshots/[a:category]' => '\ScummVM\Pages\ScreenshotsPage',
'screenshots/[a:category]/[:game]' => '\ScummVM\Pages\ScreenshotsPage',
'subprojects' => '\ScummVM\Pages\DownloadsPage', // TODO: Remove
- 'sponsors' => '\ScummVM\Pages\SponsorsPage',
+ 'sponsors' => '\ScummVM\Pages\SimplePage',
);
$router = new \AltoRouter();
@@ -130,14 +130,17 @@ $router->addMatchTypes([
]);
foreach ($pages as $key => $value) {
- $router->map('GET', "/[lang:lang]?/$key", $value);
- $router->map('GET', "/[lang:lang]?/$key/", $value);
+ $router->map('GET', "/[lang:lang]?/{$key}/?", $value, $key);
}
$match = $router->match(strtolower($_SERVER['REQUEST_URI']));
if ($match) {
- $page = new $match['target']();
+ if ($match['target'] === '\ScummVM\Pages\SimplePage') {
+ $page = new $match['target']($match['name']);
+ } else {
+ $page = new $match['target']();
+ }
return $page->index($match['params']);
} else {
$page = new \ScummVM\Pages\NewsPage();
diff --git a/templates/pages/credits.tpl b/templates/pages/credits.tpl
index 7dda648c..a7ae7827 100644
--- a/templates/pages/credits.tpl
+++ b/templates/pages/credits.tpl
@@ -3,7 +3,7 @@
<div class="navigation col-1-1">
<h4 class="subhead">{#screenshotsNavigation#}</h4>
<ul>
- {foreach from=$credits item=csection}
+ {foreach from=$data item=csection}
{if $csection->getSubsections()|@count > 0}
{foreach from=$csection->getSubsections() item=subcsection}
<li><a href="{'/credits/'|lang}#{$subcsection->getAnchor()}">{$subcsection->getTitle()}</a></li>
@@ -17,7 +17,7 @@
</div>
{/capture}
-{foreach from=$credits item=csection name=credits}
+{foreach from=$data item=csection name=credits}
{capture "content"}
{if $csection->getSubsections()|@count > 0}
{foreach from=$csection->getSubsections() item=subcsection}
@@ -50,4 +50,4 @@ paragraphs=$csection->getParagraphs()
{include file="components/box.tpl" head=$csection->getTitle() id=$csection->getAnchor() content=$smarty.capture.content}
{/if}
-{/foreach}
\ No newline at end of file
+{/foreach}
diff --git a/templates/pages/documentation.tpl b/templates/pages/documentation.tpl
index 6259dddd..3684320a 100644
--- a/templates/pages/documentation.tpl
+++ b/templates/pages/documentation.tpl
@@ -1,5 +1,5 @@
{capture "content"}
- {foreach from=$documents item=document}
+ {foreach from=$data item=document}
<p>
<a href="{eval var=$document->getURL()}">{eval var=$document->getName()}</a><br>
{eval var=$document->getDescription()}
@@ -7,4 +7,4 @@
{/foreach}
{/capture}
-{include file="components/box.tpl" head=$content_title intro=#documentationIntro# content=$smarty.capture.content}
\ No newline at end of file
+{include file="components/box.tpl" head=$content_title intro=#documentationIntro# content=$smarty.capture.content}
diff --git a/templates/pages/press.tpl b/templates/pages/press.tpl
index 58ef85ef..e79f198b 100644
--- a/templates/pages/press.tpl
+++ b/templates/pages/press.tpl
@@ -3,7 +3,7 @@
{/capture}
{capture "content"}
-{foreach from=$articles item=article}
+{foreach from=$data item=article}
<p>
{if $article->getLanguage() != null}
<a href="{$article->getURL()}"><b>{$article->getName()}</b></a> ({$article->getLanguage()}), {$article->getSource()}, {$article->getDate()}
@@ -14,4 +14,4 @@
{/foreach}
{/capture}
-{include file="components/box.tpl" head=#pressHeading# intro=$smarty.capture.intro content=$smarty.capture.content}
\ No newline at end of file
+{include file="components/box.tpl" head=#pressHeading# intro=$smarty.capture.intro content=$smarty.capture.content}
diff --git a/templates/pages/sponsors.tpl b/templates/pages/sponsors.tpl
index b80f2c79..2d699edc 100644
--- a/templates/pages/sponsors.tpl
+++ b/templates/pages/sponsors.tpl
@@ -5,7 +5,7 @@
{capture "content"}
<div class="gallery">
<div class="row">
- {foreach from=$sponsors item=sponsor}
+ {foreach from=$data item=sponsor}
<div class="col-1-3 col-md-1">
<div class="sponsor card">
<div class="image">
@@ -21,4 +21,4 @@
</div>
{/capture}
-{include file="components/box.tpl" head=#sponsorsHeading# intro=$smarty.capture.intro content=$smarty.capture.content}
\ No newline at end of file
+{include file="components/box.tpl" head=#sponsorsHeading# intro=$smarty.capture.intro content=$smarty.capture.content}
Commit: f43eca2c2bd85380a6b9126069cdb9bdb82991ee
https://github.com/scummvm/scummvm-web/commit/f43eca2c2bd85380a6b9126069cdb9bdb82991ee
Author: Mataniko (mataniko at gmail.com)
Date: 2020-10-08T23:08:51-04:00
Commit Message:
WEB: Move ExceptionPage to a SimplePage
Changed paths:
A templates/pages/exception.tpl
R include/Pages/ExceptionsPage.php
R templates/components/exception.tpl
data/localization/de/strings.json
data/localization/el/strings.json
data/localization/en/strings.json
data/localization/es/strings.json
data/localization/fr/strings.json
data/localization/he/strings.json
data/localization/it/strings.json
data/localization/pl/strings.json
data/localization/pt-BR/strings.json
data/localization/pt-PT/strings.json
data/localization/ru/strings.json
include/ExceptionHandler.php
include/Pages/SimplePage.php
diff --git a/data/localization/de/strings.json b/data/localization/de/strings.json
index eec7d391..f1bd4c8c 100644
--- a/data/localization/de/strings.json
+++ b/data/localization/de/strings.json
@@ -88,8 +88,8 @@
"downloadsLibraries": "Bibliotheken",
"downloadsRequiredLibraries": "Benötigte Bibliotheken",
"downloadsOptionalLibraries": "Optionale Bibliotheken",
- "exceptionsTitle": "Fehler",
- "exceptionsContentTitle": "\"Es gab ein Problem beim Ausführen Ihrer Anfrage!\"\"",
+ "exceptionTitle": "Fehler",
+ "exceptionContentTitle": "\"Es gab ein Problem beim Ausführen Ihrer Anfrage!\"\"",
"exceptionHeading": "Ein dreiköpfiger Affe!",
"exceptionIntro": "Hinter dir, ein dreiköpfiger Affe!",
"exceptionAlt": "Dreiköpfiger Affe",
diff --git a/data/localization/el/strings.json b/data/localization/el/strings.json
index 97731175..84459242 100644
--- a/data/localization/el/strings.json
+++ b/data/localization/el/strings.json
@@ -93,8 +93,8 @@
"downloadsLibraries": "ÎιβλιοθήκεÏ",
"downloadsRequiredLibraries": "ÎÏαιÏοÏÎ¼ÎµÎ½ÎµÏ ÎιβλιοθήκεÏ",
"downloadsOptionalLibraries": "Î ÏοαιÏεÏικÎÏ ÎιβλιοθήκεÏ",
- "exceptionsTitle": "ÎξαίÏεÏη",
- "exceptionsContentTitle": "ΣÏάλμα καÏά Ïην εÏεξεÏγαÏία ÏοÏ
αιÏήμαÏοÏ",
+ "exceptionTitle": "ÎξαίÏεÏη",
+ "exceptionContentTitle": "ΣÏάλμα καÏά Ïην εÏεξεÏγαÏία ÏοÏ
αιÏήμαÏοÏ",
"exceptionHeading": "Îια ÏÏικÎÏαλη μαÏμοÏ!",
"exceptionIntro": "ÎοίÏα ÏίÏÏ ÏοÏ
, μια ÏÏικÎÏαλη μαÏμοÏ!",
"exceptionAlt": "ΤÏικÎÏαλη μαÏμοÏ",
diff --git a/data/localization/en/strings.json b/data/localization/en/strings.json
index 48a16d2f..082820e4 100644
--- a/data/localization/en/strings.json
+++ b/data/localization/en/strings.json
@@ -103,8 +103,8 @@
"downloadsLibraries": "Libraries",
"downloadsRequiredLibraries": "Required Libraries",
"downloadsOptionalLibraries": "Optional Libraries",
- "exceptionsTitle": "Exception",
- "exceptionsContentTitle": "Error processing request",
+ "exceptionTitle": "Exception",
+ "exceptionContentTitle": "Error processing request",
"exceptionHeading": "A three-headed monkey!",
"exceptionIntro": "Look behind you, a three-headed monkey!",
"exceptionAlt": "Three-headed monkey",
diff --git a/data/localization/es/strings.json b/data/localization/es/strings.json
index 9e85b54f..2b9bb729 100644
--- a/data/localization/es/strings.json
+++ b/data/localization/es/strings.json
@@ -91,8 +91,8 @@
"downloadsLibraries": "Bibliotecas",
"downloadsRequiredLibraries": "Bibliotecas necesarias",
"downloadsOptionalLibraries": "Bibliotecas opcionales",
- "exceptionsTitle": "Excepción",
- "exceptionsContentTitle": "Error al procesar la solicitud",
+ "exceptionTitle": "Excepción",
+ "exceptionContentTitle": "Error al procesar la solicitud",
"exceptionHeading": "¡Un mono de tres cabezas!",
"exceptionIntro": "¡Mira detrás de ti, un mono de tres cabezas!",
"exceptionAlt": "Mono de tres cabezas",
diff --git a/data/localization/fr/strings.json b/data/localization/fr/strings.json
index a6e9d50b..e72bfad0 100644
--- a/data/localization/fr/strings.json
+++ b/data/localization/fr/strings.json
@@ -87,8 +87,8 @@
"downloadsLibraries": "Bibliothèques",
"downloadsRequiredLibraries": "Bibliothèques nécessaires",
"downloadsOptionalLibraries": "Bibliothèques optionnelles",
- "exceptionsTitle": "Exception",
- "exceptionsContentTitle": "Une erreur est survenue",
+ "exceptionTitle": "Exception",
+ "exceptionContentTitle": "Une erreur est survenue",
"exceptionHeading": "Un singe à trois têtesâ¯!",
"exceptionIntro": "Regarde derrière toi, un singe à trois têtesâ¯!",
"exceptionAlt": "Singe à trois têtes",
diff --git a/data/localization/he/strings.json b/data/localization/he/strings.json
index ffbe91d0..d5eb50b3 100644
--- a/data/localization/he/strings.json
+++ b/data/localization/he/strings.json
@@ -93,8 +93,8 @@
"downloadsLibraries": "ספר××ת",
"downloadsRequiredLibraries": "ספר××ת ××××",
"downloadsOptionalLibraries": "ספר××ת ××פצ××× ×××ת",
- "exceptionsTitle": "×××¦× ×× ××××",
- "exceptionsContentTitle": "ש×××× ××¢×××× ××קש×",
+ "exceptionTitle": "×××¦× ×× ××××",
+ "exceptionContentTitle": "ש×××× ××¢×××× ××קש×",
"exceptionHeading": "×§××£ ×× ×©××ש ר×ש××!",
"exceptionIntro": "××× ××××ר×××, ×§××£ ת×ת ר×ש×!",
"exceptionAlt": "×§××£ ×× ×©××ש ר×ש××",
diff --git a/data/localization/it/strings.json b/data/localization/it/strings.json
index 03cccb41..601f1c8e 100644
--- a/data/localization/it/strings.json
+++ b/data/localization/it/strings.json
@@ -69,8 +69,8 @@
"downloadsLibraries": "Librerie",
"downloadsRequiredLibraries": "Librerie richieste",
"downloadsOptionalLibraries": "Librerie opzionali",
- "exceptionsTitle": "Eccezione",
- "exceptionsContentTitle": "Errore nell'elaborazione della richiesta",
+ "exceptionTitle": "Eccezione",
+ "exceptionContentTitle": "Errore nell'elaborazione della richiesta",
"exceptionHeading": "Una scimmia a tre teste!",
"exceptionIntro": "Dietro di te! Una scimmia a tre teste!",
"exceptionAlt": "Scimmia a tre teste",
diff --git a/data/localization/pl/strings.json b/data/localization/pl/strings.json
index 13cd3f3b..bd667936 100644
--- a/data/localization/pl/strings.json
+++ b/data/localization/pl/strings.json
@@ -97,8 +97,8 @@
"downloadsLibraries": "",
"downloadsRequiredLibraries": "",
"downloadsOptionalLibraries": "",
- "exceptionsTitle": "",
- "exceptionsContentTitle": "",
+ "exceptionTitle": "",
+ "exceptionContentTitle": "",
"exceptionHeading": "",
"exceptionIntro": "",
"exceptionAlt": "",
diff --git a/data/localization/pt-BR/strings.json b/data/localization/pt-BR/strings.json
index d5370e59..0ef450e4 100644
--- a/data/localization/pt-BR/strings.json
+++ b/data/localization/pt-BR/strings.json
@@ -93,8 +93,8 @@
"downloadsLibraries": "Bibliotecas",
"downloadsRequiredLibraries": "Bibliotecas Necessárias",
"downloadsOptionalLibraries": "Bibliotecas Opcionais",
- "exceptionsTitle": "Exceção",
- "exceptionsContentTitle": "Erro ao processar solicitação",
+ "exceptionTitle": "Exceção",
+ "exceptionContentTitle": "Erro ao processar solicitação",
"exceptionHeading": "Um macaco de três cabeças!",
"exceptionIntro": "Olhe para trás, um macaco de três cabeças!",
"exceptionAlt": "Macaco de três cabeças",
diff --git a/data/localization/pt-PT/strings.json b/data/localization/pt-PT/strings.json
index 5b60e1cb..2003d37f 100644
--- a/data/localization/pt-PT/strings.json
+++ b/data/localization/pt-PT/strings.json
@@ -97,8 +97,8 @@
"downloadsLibraries": "Bibliotecas",
"downloadsRequiredLibraries": "Bibliotecas Obrigatórias",
"downloadsOptionalLibraries": "Bibliotecas Opcionais",
- "exceptionsTitle": "Exceção",
- "exceptionsContentTitle": "Erro a processar o pedido",
+ "exceptionTitle": "Exceção",
+ "exceptionContentTitle": "Erro a processar o pedido",
"exceptionHeading": "Um macaco de três cabeças!",
"exceptionIntro": "Atrás de si, um macaco de três cabeças!",
"exceptionAlt": "Macaco de três cabeças",
diff --git a/data/localization/ru/strings.json b/data/localization/ru/strings.json
index 12335359..1b86ca68 100644
--- a/data/localization/ru/strings.json
+++ b/data/localization/ru/strings.json
@@ -69,8 +69,8 @@
"downloadsLibraries": "ÐиблиоÑеки",
"downloadsRequiredLibraries": "ÐеобÑ
одимÑе библиоÑеки",
"downloadsOptionalLibraries": "ÐеобÑзаÑелÑнÑе библиоÑеки",
- "exceptionsTitle": "ÐÑклÑÑение",
- "exceptionsContentTitle": "ÐÑибка обÑабоÑки запÑоÑа",
+ "exceptionTitle": "ÐÑклÑÑение",
+ "exceptionContentTitle": "ÐÑибка обÑабоÑки запÑоÑа",
"exceptionHeading": "ÐбезÑÑна Ñ ÑÑÐµÐ¼Ñ Ð³Ð¾Ð»Ð¾Ð²Ð°Ð¼Ð¸!",
"exceptionIntro": "ÐглÑниÑÑ! ÐбезÑÑна Ñ ÑÑÐµÐ¼Ñ Ð³Ð¾Ð»Ð¾Ð²Ð°Ð¼Ð¸!",
"exceptionAlt": "ÐбезÑÑна Ñ ÑÑÐµÐ¼Ñ Ð³Ð¾Ð»Ð¾Ð²Ð°Ð¼Ð¸",
diff --git a/include/ExceptionHandler.php b/include/ExceptionHandler.php
index 2541f035..b1397826 100644
--- a/include/ExceptionHandler.php
+++ b/include/ExceptionHandler.php
@@ -1,6 +1,8 @@
<?php
namespace ScummVM;
+use ScummVM\Pages\SimplePage;
+
/**
* Handle uncaught exceptions.
*/
@@ -35,7 +37,7 @@ abstract class ExceptionHandler
{
self::$exception = $e;
- $ep = new \ScummVM\Pages\ExceptionsPage();
+ $ep = new SimplePage('exception');
return $ep->index($e);
}
}
diff --git a/include/Pages/ExceptionsPage.php b/include/Pages/ExceptionsPage.php
deleted file mode 100644
index eb3044c4..00000000
--- a/include/Pages/ExceptionsPage.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-class ExceptionsPage extends \ScummVM\Controller
-{
- public function __construct()
- {
- parent::__construct();
- $this->template = 'components/exception.tpl';
- }
-
- /* Display the index page. */
- public function index($exception)
- {
- return $this->renderPage(
- array(
- 'title' => $this->getConfigVars('exceptionsTitle'),
- 'content_title' => $this->getConfigVars('exceptionsContentTitle'),
- 'exception' => $exception,
- )
- );
- }
-}
diff --git a/include/Pages/SimplePage.php b/include/Pages/SimplePage.php
index 14c281d9..c2a037d1 100644
--- a/include/Pages/SimplePage.php
+++ b/include/Pages/SimplePage.php
@@ -8,6 +8,7 @@ class SimplePage extends Controller
{
const FILE_NOT_FOUND = 'The filename %s could not be found';
const PAGE_MODELS = [
+ //key => [$model, $datafile]
'sponsors' => ['Sponsor', 'sponsors.yaml'],
'press' => ['Article', 'press_articles.yaml'],
'credits' => ['CreditsSection', 'credits.yaml'],
@@ -29,12 +30,12 @@ class SimplePage extends Controller
}
if (array_key_exists($key, self::PAGE_MODELS)) {
[$model, $data] = self::PAGE_MODELS[$key];
- $this->model = new SimpleModel($model, $data);;
+ $this->model = new SimpleModel($model, $data);
}
}
/* Display the index page. */
- public function index()
+ public function index($data = null)
{
if ($this->model) {
$data = $this->model->getAllData();
diff --git a/templates/components/exception.tpl b/templates/pages/exception.tpl
similarity index 69%
rename from templates/components/exception.tpl
rename to templates/pages/exception.tpl
index 7e52445f..6e952a23 100644
--- a/templates/components/exception.tpl
+++ b/templates/pages/exception.tpl
@@ -1,6 +1,6 @@
{capture "content"}
<img src="/images/three-headed-monkey.png" alt="{#exceptionAlt#}" class="float_right" style="margin-bottom: 5px;">
<h3>{#exceptionContent#}</h3>
- <p>{$exception->getMessage()|nl2br:false}</p>
+ <p>{$data->getMessage()|nl2br:false}</p>
{/capture}
-{include "components/box.tpl" head=#exceptionHeading# intro="<h2>{#exceptionIntro#}</h2>" content=$smarty.capture.content}
\ No newline at end of file
+{include "components/box.tpl" head=#exceptionHeading# intro="<h2>{#exceptionIntro#}</h2>" content=$smarty.capture.content}
Commit: 9cf9a19588d36914eb74d83cafba0730e945693e
https://github.com/scummvm/scummvm-web/commit/9cf9a19588d36914eb74d83cafba0730e945693e
Author: Mataniko (mataniko at gmail.com)
Date: 2020-10-08T23:08:51-04:00
Commit Message:
WEB: Support arbitary article pages
Changed paths:
A data/article/snowberry.markdown
A include/Pages/ArticlePage.php
A templates/pages/article.tpl
R include/Pages/PressSnowberryPage.php
R templates/pages/press_snowberry.tpl
data/localization/en/news.json
data/news/en/20090702.markdown
include/Constants.php
public_html/index.php
diff --git a/data/article/snowberry.markdown b/data/article/snowberry.markdown
new file mode 100644
index 00000000..611aed5c
--- /dev/null
+++ b/data/article/snowberry.markdown
@@ -0,0 +1,39 @@
+---
+title: "GOBLIIINS + ScummVM = PERFECT COUPLE "
+author: ScummVM Team
+date: 1245801600
+---
+
+Wonderful news for all the fans of classical adventure games: Snowberry Connection and Société Pollene announce that the first three games in the legendary Goblins series are now available to every customer of Gobliiins 4 as a free bonus (only via digital distribution channels: Gamersgate and Impulse).
+
+Playing these games on modern operating systems is made possible by the ScummVM program â the easiest way to enjoy the greatest adventure hits of the past.
+
+Alexander Souslov (Snowberry Connection): "Thanks to ScummVM, thousands of gamers around the world can enjoy the good old Goblins without any compatibility problems and headache"
+
+Max Horn (ScummVM): "Playing the Gobliiins games has been fun over a decade ago, and stil is. ScummVM allows you to enjoy them (and other classics) again on modern hardware, like your smartphone â if you are lucky enough to own them. That's why we at ScummVM are excited to see these gems being re-released to the public, together with the latest installment of this wonderful series. Thanks, Snowberry!"
+
+#### About ScummVM
+
+ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed!
+
+More information is available here: [http://www.scummvm.org/](http://www.scummvm.org/)
+
+#### About Gobliiins 4
+
+Designer: Pierre Gilhodes
+Developer: Société Pollene
+Int'l publisher: Snowberry Connection
+Genre: Quest
+Release: Spring 2009
+Languages: English, French, Italian, German, Spanish, Russian, Polish, Czech, Hungarian
+Official site: [http://www.goblins4.ru/](http://www.goblins4.ru/)
+Format: DVD-ROM (PC Windows)
+Also available via digital distribution systems: Impulse and Gamersgate
+
+Designed by original Gobliiins co-creator Pierre Gilhodes and developed by Societe Pollene, Gobliiins 4 brings back the beloved three original main characters in a zany adventure you won't be able to put down. Gobliiins 4 blends elements of adventure and puzzle gaming: the player must find a solution to each level in order to progress to the next. The race through this colorful adventure-land spans more than 30 hours, including a secret bonus level.
+
+#### About Gobliiins
+
+Characters & universe originally created by Muriel Tramis and Pierre Gilhodes. Gobliiins 4 designed by Pierre Gilhodes, developed by Société Pollene. © by Société Pollene & Snowberry Connection LRM Inc. Original music: Didier Sallustro. All rights reserved. To find more about Gobliiins and its creators, visit official websites at [www.goblins4.com](http://www.goblins4.com) and [www.goblins4.ru](http://www.goblins4.ru).
+
+Snowberry press release [in Russian](http://news.snowball.ru/?id=1684).
diff --git a/data/localization/en/news.json b/data/localization/en/news.json
index bc592739..9cac9731 100755
--- a/data/localization/en/news.json
+++ b/data/localization/en/news.json
@@ -685,7 +685,7 @@
},
"20090702": {
"title": "Now there is an easy way to obtain Gobliiins 1-3",
- "content": "[Snowberry Connection](http://www.snowball.ru), [Société Pollene](http://www.gobliiins4.com) and ScummVM issued a [joint press release](/presssnowberry), which announces that the first three Gobliiins games are available as bonus downloads for those who purchased Gobliiins 4 via [GamersGate](http://gamersgate.com/DD-GOBLIN/gobliiins-4) or [Impulse](http://www.impulsedriven.com/goblins4). The games are also available on the DVD in at least the Russian and Hungarian releases of the game.\n\nWe are really happy that these art pieces of classic adventure gaming are available as a relatively easy purchase now, and that ScummVM helped Snowberry to make them run on modern systems with minimal effort.\n\nThanks, Snowberry!"
+ "content": "[Snowberry Connection](http://www.snowball.ru), [Société Pollene](http://www.gobliiins4.com) and ScummVM issued a [joint press release](/press/snowberry), which announces that the first three Gobliiins games are available as bonus downloads for those who purchased Gobliiins 4 via [GamersGate](http://gamersgate.com/DD-GOBLIN/gobliiins-4) or [Impulse](http://www.impulsedriven.com/goblins4). The games are also available on the DVD in at least the Russian and Hungarian releases of the game.\n\nWe are really happy that these art pieces of classic adventure gaming are available as a relatively easy purchase now, and that ScummVM helped Snowberry to make them run on modern systems with minimal effort.\n\nThanks, Snowberry!"
},
"20090709": {
"title": "There's Murder Afoot..",
diff --git a/data/news/en/20090702.markdown b/data/news/en/20090702.markdown
index 83ae38af..c1995994 100644
--- a/data/news/en/20090702.markdown
+++ b/data/news/en/20090702.markdown
@@ -4,7 +4,7 @@ author: sev
date: 1246541760
---
-[Snowberry Connection](http://www.snowball.ru), [Société Pollene](http://www.gobliiins4.com) and ScummVM issued a [joint press release](/presssnowberry), which announces that the first three Gobliiins games are available as bonus downloads for those who purchased Gobliiins 4 via [GamersGate](http://gamersgate.com/DD-GOBLIN/gobliiins-4) or [Impulse](http://www.impulsedriven.com/goblins4). The games are also available on the DVD in at least the Russian and Hungarian releases of the game.
+[Snowberry Connection](http://www.snowball.ru), [Société Pollene](http://www.gobliiins4.com) and ScummVM issued a [joint press release](/press/snowberry), which announces that the first three Gobliiins games are available as bonus downloads for those who purchased Gobliiins 4 via [GamersGate](http://gamersgate.com/DD-GOBLIN/gobliiins-4) or [Impulse](http://www.impulsedriven.com/goblins4). The games are also available on the DVD in at least the Russian and Hungarian releases of the game.
We are really happy that these art pieces of classic adventure gaming are available as a relatively easy purchase now, and that ScummVM helped Snowberry to make them run on modern systems with minimal effort.
diff --git a/include/Constants.php b/include/Constants.php
index 15ead1b8..3be9dbc8 100644
--- a/include/Constants.php
+++ b/include/Constants.php
@@ -39,6 +39,7 @@ class Constants
define('DIR_BASE', __DIR__ . '/..');
define('DIR_DATA', DIR_BASE . '/data');
define('DIR_NEWS', DIR_DATA . '/news');
+ define('DIR_ARTICLE', DIR_DATA . '/article');
define('DIR_LANG', DIR_DATA . '/localization');
define('DIR_COMPAT', DIR_DATA . '/compatibility');
define('DIR_DOWNLOADS', '/downloads');
diff --git a/include/Pages/ArticlePage.php b/include/Pages/ArticlePage.php
new file mode 100644
index 00000000..9e9debd2
--- /dev/null
+++ b/include/Pages/ArticlePage.php
@@ -0,0 +1,48 @@
+<?php
+namespace ScummVM\Pages;
+
+use ScummVM\Controller;
+use Spatie\YamlFrontMatter\YamlFrontMatter;
+use Erusev\Parsedown;
+
+class ArticlePage extends Controller
+{
+ private $purifier;
+
+ /* Constructor. */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->template = 'pages/article.tpl';
+ $config = \HTMLPurifier_Config::createDefault();
+ $this->purifier = new \HTMLPurifier($config);
+ }
+
+ /* Display the index page. */
+ public function index($params)
+ {
+ $articleFile = DIR_ARTICLE . "/" . $params['article'] . ".markdown";
+ if (!is_file($articleFile) || !is_readable($articleFile)) {
+ $page = new \ScummVM\Pages\NewsPage();
+ return $page->index(array());
+ }
+
+ $article = YamlFrontMatter::parse(file_get_contents($articleFile));
+ $Parsedown = new \Parsedown();
+ $Parsedown->setBreaksEnabled(true);
+
+ $date = $this->purifier->purify($article->date);
+ $title = $this->purifier->purify($article->title);
+ $author = $this->purifier->purify($article->author);
+ $content = $this->purifier->purify($Parsedown->text($article->body()));
+
+ return $this->renderPage(
+ array(
+ 'content_title' => $title,
+ 'date' => $date,
+ 'author' => $author,
+ 'content' => $content,
+ )
+ );
+ }
+}
diff --git a/include/Pages/PressSnowberryPage.php b/include/Pages/PressSnowberryPage.php
deleted file mode 100644
index dd05f73b..00000000
--- a/include/Pages/PressSnowberryPage.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-namespace ScummVM\Pages;
-
-use ScummVM\Controller;
-use ScummVM\Models\SimpleModel;
-
-class PressSnowberryPage extends Controller
-{
- private $articleModel;
-
- /* Constructor. */
- public function __construct()
- {
- parent::__construct();
- $this->template = 'pages/press_snowberry.tpl';
- $this->articleModel = new SimpleModel("Article", "press_articles.yaml");
- }
-
- /* Display the index page. */
- public function index()
- {
- $articles = $this->articleModel->getAllData(false);
- return $this->renderPage(
- array(
- 'title' => $this->getConfigVars('pressSnowberryTitle'),
- 'content_title' => $this->getConfigVars('pressSnowberryContentTitle'),
- 'articles' => $articles,
- )
- );
- }
-}
diff --git a/public_html/index.php b/public_html/index.php
index abf872d0..9885dc4b 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -113,7 +113,7 @@ $pages = array(
'news' => '\ScummVM\Pages\NewsPage',
'news/[a:date]' => '\ScummVM\Pages\NewsPage',
'press' => '\ScummVM\Pages\SimplePage',
- 'presssnowberry' => '\ScummVM\Pages\PressSnowberryPage', // HACK
+ 'press/[a:article]' => '\ScummVM\Pages\ArticlePage',
'screenshots' => '\ScummVM\Pages\ScreenshotsPage',
'screenshots/[a:category]' => '\ScummVM\Pages\ScreenshotsPage',
'screenshots/[a:category]/[:game]' => '\ScummVM\Pages\ScreenshotsPage',
diff --git a/templates/pages/article.tpl b/templates/pages/article.tpl
new file mode 100644
index 00000000..0a8dbf22
--- /dev/null
+++ b/templates/pages/article.tpl
@@ -0,0 +1,7 @@
+<div class="par-item">
+ <div class="par-head"></div>
+ <div class="par-content">
+ <p>{$date|date_localized}</p>
+ {$content}
+ </div>
+</div>
diff --git a/templates/pages/press_snowberry.tpl b/templates/pages/press_snowberry.tpl
deleted file mode 100644
index 6c78850f..00000000
--- a/templates/pages/press_snowberry.tpl
+++ /dev/null
@@ -1,67 +0,0 @@
-<div class="par-item">
- <div class="par-head"></div>
- <div class="par-content">
-
- <p>June 24, 2009</p>
-
- <p>
- Wonderful news for all the fans of classical adventure games: Snowberry Connection and Société Pollene announce that the first three games in the legendary Goblins series are now available to every customer of Gobliiins 4 as a free bonus (only via digital distribution channels: Gamersgate and Impulse).
- </p>
-
- <p>
- Playing these games on modern operating systems is made possible by the ScummVM program — the easiest way to enjoy the greatest adventure hits of the past.
- </p>
-
- <p>
- Alexander Souslov (Snowberry Connection):
- "Thanks to ScummVM, thousands of gamers around the world can enjoy the good old Goblins without any compatibility problems and headache"
- </p>
-
- <p>
- Max Horn (ScummVM):
- "Playing the Gobliiins games has been fun over a decade ago, and stil is. ScummVM allows you to enjoy them (and other classics) again on modern hardware, like your smartphone — if you are lucky enough to own them. That's why we at ScummVM are excited to see these gems being
- re-released to the public, together with the latest installment of this wonderful series. Thanks, Snowberry!"
- </p>
-
- <h4>About ScummVM</h4>
-
- <p>
- ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed!
- </p>
-
- <p>
- More information is available here: <a href="{'/'|lang}">http://www.scummvm.org/</a>
- </p>
-
- <h4>About Gobliiins 4</h4>
-
- <p>
- Designer: Pierre Gilhodes<br>
- Developer: Société Pollene<br>
- Int'l publisher: Snowberry Connection<br>
- Genre: Quest<br>
- Release: Spring 2009<br>
- Languages: English, French, Italian, German, Spanish,
- Russian, Polish, Czech, Hungarian<br>
- Official site: <a href="http://www.goblins4.ru/">http://www.goblins4.ru/</a><br>
- Format: DVD-ROM (PC Windows)<br>
- Also available via digital distribution systems: Impulse and Gamersgate
- </p>
-
- <p>
- Designed by original Gobliiins co-creator Pierre Gilhodes and developed by Societe Pollene, Gobliiins 4 brings back the beloved three original main characters in a zany adventure you won't be able to put down. Gobliiins 4 blends elements of adventure and puzzle gaming: the player must find a solution to each level in order to progress to the next. The race through this colorful adventure-land spans more than 30 hours, including a secret bonus level.
- </p>
-
- <h4>About Gobliiins</h4>
-
- <p>
- Characters & universe originally created by Muriel Tramis and Pierre Gilhodes. Gobliiins 4 designed by Pierre Gilhodes, developed by Société Pollene. © by Société Pollene & Snowberry Connection LRM Inc. Original music: Didier Sallustro. All rights reserved. To find more about Gobliiins and its creators, visit official websites at <a href="http://www.goblins4.com">www.goblins4.com</a> and <a href="http://www.goblins4.ru">www.goblins4.ru</a>.
- </p>
-
- <p>
- <font size=-2>Snowberry press release <a href="http://news.snowball.ru/?id=1684">in Russian</a>.</font>
- </p>
-
- </div>
-
-</div>
\ No newline at end of file
More information about the Scummvm-git-logs
mailing list