[Scummvm-git-logs] scummvm-web master -> 5810703f639fc37bc6c78a71e7299b3eb0ceadb7

Mataniko mataniko at gmail.com
Wed Aug 25 02:01:41 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .

Summary:
5810703f63 WEB: Add support for static pages in the router


Commit: 5810703f639fc37bc6c78a71e7299b3eb0ceadb7
    https://github.com/scummvm/scummvm-web/commit/5810703f639fc37bc6c78a71e7299b3eb0ceadb7
Author: mataniko (mataniko at gmail.com)
Date: 2021-08-24T22:01:34-04:00

Commit Message:
WEB: Add support for static pages in the router

Changed paths:
  A include/Pages/StaticPage.php
  A public_html/html/.gitignore
    public_html/index.php


diff --git a/include/Pages/StaticPage.php b/include/Pages/StaticPage.php
new file mode 100644
index 00000000..4be82000
--- /dev/null
+++ b/include/Pages/StaticPage.php
@@ -0,0 +1,27 @@
+<?php
+namespace ScummVM\Pages;
+
+use Exception;
+use ScummVM\Controller;
+
+class StaticPage extends Controller
+{
+    const FILE_NOT_FOUND = 'The filename %s could not be found';
+    private $filename;
+
+    public function __construct($key)
+    {
+        parent::__construct();
+
+        $this->filename = "html/$key.html";
+        if (!is_file($this->filename) || !is_readable($this->filename)) {
+          throw new \ErrorException(\sprintf(self::FILE_NOT_FOUND, $this->filename));
+        }
+    }
+
+    /* Display the index page. */
+    public function index($data = null)
+    {
+        readfile($this->filename);
+    }
+}
diff --git a/public_html/html/.gitignore b/public_html/html/.gitignore
new file mode 100644
index 00000000..e69de29b
diff --git a/public_html/index.php b/public_html/index.php
index 91bde5ba..65fb21e5 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -141,7 +141,7 @@ foreach ($pages as $key => $value) {
 $match = $router->match(strtolower($_SERVER['REQUEST_URI']));
 
 if ($match) {
-    if ($match['target'] === '\ScummVM\Pages\SimplePage') {
+    if ($match['target'] === '\ScummVM\Pages\SimplePage' || $match['target'] === '\ScummVM\Pages\StaticPage') {
       $page = new $match['target']($match['name']);
     } elseif (strpos($match['target'],"http") === 0) {
       header("Location: {$match['target']}");




More information about the Scummvm-git-logs mailing list