diff --git a/build/_frontend/interface.jsx b/build/_frontend/interface.jsx index 28d0336..be74bef 100644 --- a/build/_frontend/interface.jsx +++ b/build/_frontend/interface.jsx @@ -1166,6 +1166,11 @@ function Footer(props) { target="_blank" title="opcache-gui (currently version {props.version}) on GitHub" >https://github.com/amnuts/opcache-gui - version {props.version} + + Sponsor this project ); } diff --git a/build/_frontend/interface.scss b/build/_frontend/interface.scss index 6e54263..3579c75 100644 --- a/build/_frontend/interface.scss +++ b/build/_frontend/interface.scss @@ -286,7 +286,8 @@ $footer-border-color: #CCC; .nav-tab-link-reset, .nav-tab-link-realtime, - .github-link { + .github-link, + .sponsor-link { background-repeat: no-repeat; background-color: transparent; } @@ -296,21 +297,17 @@ $footer-border-color: #CCC; background-position: 24px 50%; } - .github-link { - background-position: 5px 50%; - } - .main-footer { border-top: 1px solid $footer-border-color; padding: 1em 2em; } - .github-link { + .github-link, + .sponsor-link { background-position: 0 50%; padding: 2em 0 2em 2.3em; text-decoration: none; opacity: 0.7; - background-image: url('data:image/svg+xml;utf8,'); font-size: 80%; &:hover { @@ -318,6 +315,15 @@ $footer-border-color: #CCC; } } + .github-link { + background-image: url('data:image/svg+xml;utf8,'); + } + + .sponsor-link { + background-image: url('data:image/svg+xml;utf8,'); + margin-left: 2em; + } + .file-cache-only { margin-top: 0; } diff --git a/build/build.php b/build/build.php index 931f9a5..fae214d 100644 --- a/build/build.php +++ b/build/build.php @@ -4,22 +4,48 @@ * OPcache GUI - build script * * @author Andrew Collington, andy@amnuts.com - * @version 3.4.0 + * @version 3.5.0 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ -$options = getopt('jl:', ['local-js', 'lang:']); +$remoteJsLocations = [ + 'cloudflare' => [ + 'cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js', + 'cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js', + 'cdnjs.cloudflare.com/ajax/libs/axios/1.3.6/axios.min.js', + ], + 'jsdelivr' => [ + 'cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js', + 'cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js', + 'cdn.jsdelivr.net/npm/axios/dist/axios.min.js', + ], + 'unpkg' => [ + 'unpkg.com/react@18/umd/react.production.min.js', + 'unpkg.com/react-dom@18/umd/react-dom.production.min.js', + 'unpkg.com/axios/dist/axios.min.js', + ], +]; +$defaultRemoteJsFrom = array_keys($remoteJsLocations)[0]; + +$options = getopt('jr:l:', ['local-js', 'remote-js', 'lang:']); $makeJsLocal = (isset($options['j']) || isset($options['local-js'])); +$useRemoteJsFrom = $options['r'] ?? $options['remote-js'] ?? $defaultRemoteJsFrom; $useLanguage = $options['l'] ?? $options['lang'] ?? null; $languagePack = 'null'; $parentPath = dirname(__DIR__); +if (!isset($remoteJsLocations[$useRemoteJsFrom])) { + $validRemotes = implode(', ', array_keys($remoteJsLocations)); + echo "\nThe '{$useRemoteJsFrom}' remote js location is not valid - must be one of {$validRemotes} - defaulting to '{$defaultRemoteJsFrom}'\n\n"; + $useRemoteJsFrom = $defaultRemoteJsFrom; +} + if ($useLanguage !== null) { $useLanguage = preg_replace('/[^a-z_-]/', '', $useLanguage); $languageFile = __DIR__ . "/_languages/{$useLanguage}.json"; if (!file_exists($languageFile)) { - echo "The '{$useLanguage}' file does not exist - using default English\n\n"; + echo "\nThe '{$useLanguage}' file does not exist - using default English\n\n"; } else { $languagePack = "<<< EOJSON\n" . file_get_contents($languageFile) . "\nEOJSON"; } @@ -46,18 +72,25 @@ $output = str_replace( [$jsOutput, $cssOutput, $phpOutput, $languagePack], $template ); + if ($makeJsLocal) { - echo "🔗 Making js links local\n"; - $jsTags = []; - $matched = preg_match_all('!!', $output, $jsTags); - if ($matched) { - foreach ($jsTags[1] as $jsUrl) { - $jsFile = basename($jsUrl); - $jsFilePath = $parentPath . '/' . $jsFile; - file_put_contents($jsFilePath, file_get_contents('https:' . $jsUrl)); - $output = str_replace($jsUrl, $jsFile, $output); - } + echo "🔗 Making js locally in-line\n"; + $jsContents = []; + foreach ($remoteJsLocations[$useRemoteJsFrom] as $jsUrl) { + $jsContents[] = file_get_contents('https://' . $jsUrl); } + $output = str_replace('{{JS_LIBRARIES}}', + "", + $output + ); +} else { + echo "🔗 Using remote js links from '{$useRemoteJsFrom}'\n"; + $output = str_replace('{{JS_LIBRARIES}}', + implode("\n ", array_map(static function ($jsUrl) { + return ""; + }, $remoteJsLocations[$useRemoteJsFrom])), + $output + ); } file_put_contents($parentPath . '/index.php', $output); diff --git a/build/template.phps b/build/template.phps index a5cd08a..d3b7b2f 100644 --- a/build/template.phps +++ b/build/template.phps @@ -8,7 +8,7 @@ namespace Amnuts\Opcache; * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.4.0 + * @version 3.5.0 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ @@ -71,9 +71,7 @@ $opcache = (new Service($options))->handle(); OPcache statistics on <?= $opcache->getData('version', 'host'); ?> - - - + {{JS_LIBRARIES}} diff --git a/index.php b/index.php index f85929a..143510e 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,7 @@ namespace Amnuts\Opcache; * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.4.0 + * @version 3.5.0 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ @@ -65,7 +65,7 @@ use Exception; class Service { - public const VERSION = '3.4.0'; + public const VERSION = '3.5.0'; protected $tz; protected $data; @@ -513,7 +513,7 @@ $opcache = (new Service($options))->handle(); @@ -1718,7 +1718,12 @@ function Footer(props) { href: "https://github.com/amnuts/opcache-gui", target: "_blank", title: "opcache-gui (currently version {props.version}) on GitHub" - }, "https://github.com/amnuts/opcache-gui - version ", props.version)); + }, "https://github.com/amnuts/opcache-gui - version ", props.version), /*#__PURE__*/React.createElement("a", { + className: "sponsor-link", + href: "https://github.com/sponsors/amnuts", + target: "_blank", + title: "Sponsor this project and author on GitHub" + }, "Sponsor this project")); } function debounce(func, wait, immediate) { diff --git a/src/Opcache/Service.php b/src/Opcache/Service.php index 3bc7dab..e297e83 100644 --- a/src/Opcache/Service.php +++ b/src/Opcache/Service.php @@ -8,7 +8,7 @@ use Exception; class Service { - public const VERSION = '3.4.0'; + public const VERSION = '3.5.0'; protected $tz; protected $data;