[Scummvm-git-logs] scummvm-web master -> 49b934db466612638cc4b6b1776d9ce6357f134b
Mataniko
mataniko at gmail.com
Sun Nov 8 14:27:53 UTC 2020
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:
49b934db46 WEB: Redirect downloads to Fastly
Commit: 49b934db466612638cc4b6b1776d9ce6357f134b
https://github.com/scummvm/scummvm-web/commit/49b934db466612638cc4b6b1776d9ce6357f134b
Author: mataniko (mataniko at gmail.com)
Date: 2020-11-08T09:27:33-05:00
Commit Message:
WEB: Redirect downloads to Fastly
Changed paths:
include/Constants.php
include/Controller.php
templates/components/list_items.tpl
templates/components/recommended_download.tpl
templates/pages/game_demos.tpl
diff --git a/include/Constants.php b/include/Constants.php
index f474ba52..fefbffcc 100644
--- a/include/Constants.php
+++ b/include/Constants.php
@@ -46,6 +46,7 @@ class Constants
define('DEFAULT_LOCALE', 'en');
/* Downloads */
+ define('DOWNLOADS_BASE', 'https://downloads.scummvm.org');
define('DOWNLOADS_URL', '/frs/scummvm/{$release}/');
define('DOWNLOADS_DAILY_URL', '/frs/daily/');
define('DOWNLOADS_TOOLS_URL', '/frs/scummvm-tools/{$release_tools}/');
diff --git a/include/Controller.php b/include/Controller.php
index d7d14179..4a48977f 100644
--- a/include/Controller.php
+++ b/include/Controller.php
@@ -54,6 +54,7 @@ class Controller
/* Give Smarty-template access to date(). */
$this->smarty->registerPlugin('modifier', 'date_localized', array(&$this, 'dateLocalizedSmartyModifier'));
$this->smarty->registerPlugin('modifier', 'lang', array(&$this, 'langModifier'));
+ $this->smarty->registerPlugin('modifier', 'download', array(&$this, 'downloadsSmartyModifier'));
$this->css_files = array();
$this->js_files = array();
@@ -138,6 +139,22 @@ class Controller
return $formatter->format($timestamp);
}
+ /**
+ * Formating of download URLs, registered as a modifier for Smarty templates.
+ */
+ public function downloadsSmartyModifier($path)
+ {
+ if (\strpos($path, "http") === 0) {
+ return $path;
+ } elseif (\strpos($path, "/frs") === 0) {
+ return DOWNLOADS_BASE . $path;
+ } elseif (\strpos($path, "frs") === 0) {
+ return DOWLOADS_BASE . "/$path";
+ }
+
+ return $path;
+ }
+
/* Render the HTML using the template and any set variables and displays it. */
public function display($content)
{
diff --git a/templates/components/list_items.tpl b/templates/components/list_items.tpl
index c83bcb96..e39b807a 100644
--- a/templates/components/list_items.tpl
+++ b/templates/components/list_items.tpl
@@ -5,7 +5,7 @@
{assign var='data' value=$item->getExtraInfo()}
<li class="file">
<span class="sprite-{$type}-{$item->getCategoryIcon()} sprite"></span>
- <a href="{eval var=$item->getURL()}">{eval var=$item->getName()}</a>
+ <a href="{eval var=$item->getURL()|download}">{eval var=$item->getName()}</a>
{strip}
<span class="download-extras">
{if is_array($data)}
@@ -13,7 +13,7 @@
{if $item->getType() == 'daily'}{#listItemsBuildFromRepo#} {/if}
{$data.size} {if $data.ext == '.exe'}Win32 {/if}{$data.ext}{if $data.date != ""}{#listItemsDate#} {$data.date} {/if}
- {if $data.sha256 != ""} <span class="sha256-toggle" onclick="this.nextSibling.classList.toggle('hidden')"> sha256</span><span class="sha256-text hidden"> <a href="{eval var=$item->getURL()}.sha256">{$data.sha256}</a></span>{/if}
+ {if $data.sha256 != ""} <span class="sha256-toggle" onclick="this.nextSibling.classList.toggle('hidden')"> sha256</span><span class="sha256-text hidden"> <a href="{eval var=$item->getURL()|download}.sha256">{$data.sha256}</a></span>{/if}
) {if $data.msg != ""}{$data.msg}{/if}
{else}
{if $item->getType() != 'daily'}
diff --git a/templates/components/recommended_download.tpl b/templates/components/recommended_download.tpl
index 1ee72ae6..a1762df0 100644
--- a/templates/components/recommended_download.tpl
+++ b/templates/components/recommended_download.tpl
@@ -2,7 +2,7 @@
<div class="subhead">{#downloadsBadge#}</div>
<div class="subhead-content">
<div id="downloadContainer">
- <a id="downloadButton" href={$recommendedDownload.url}>
+ <a id="downloadButton" href={$recommendedDownload.url|download}>
<img src="/images/scummvm.png" alt="Download ScummVM icon">
<div class="downloadText">Download ScummVM</div>
<div id="downloadDetails">Version {$recommendedDownload.ver} ⢠{$recommendedDownload.os} ⢠{$recommendedDownload.desc}</div>
diff --git a/templates/pages/game_demos.tpl b/templates/pages/game_demos.tpl
index b3379608..7a4a4082 100644
--- a/templates/pages/game_demos.tpl
+++ b/templates/pages/game_demos.tpl
@@ -42,7 +42,7 @@
{/if}
<tr class="{if $collapse}{$collapse}{else}{cycle values="color2, color0"}{/if}">
<td>
- <a href="{$demo->getURL()}">{$demo->getName()}</a>
+ <a href="{$demo->getURL()|download}">{$demo->getName()}</a>
</td>
<td class="gameTarget">{$demo->getId()}</td>
</tr>
@@ -52,4 +52,4 @@
{/foreach}
{/capture}
-{include file="components/box.tpl" head=$content_title intro=$smarty.capture.intro content=$smarty.capture.content}
\ No newline at end of file
+{include file="components/box.tpl" head=$content_title intro=$smarty.capture.intro content=$smarty.capture.content}
More information about the Scummvm-git-logs
mailing list