"Push to my OUYA" support
[stouyapi.git] / bin / build-html.php
old mode 100644 (file)
new mode 100755 (executable)
index 581df02..f7f9154
@@ -1,3 +1,4 @@
+#!/usr/bin/env php
 <?php
 /**
  * Take the generated JSON files and convert them to HTML for a browser
@@ -6,6 +7,13 @@
  */
 require_once __DIR__ . '/functions.php';
 
+//default configuration values
+$GLOBALS['pushToMyOuyaUrl'] = '../push-to-my-ouya.php';
+$cfgFile = __DIR__ . '/../config.php';
+if (file_exists($cfgFile)) {
+    include $cfgFile;
+}
+
 $wwwDir = __DIR__ . '/../www/';
 $discoverDir = __DIR__ . '/../www/api/v1/discover-data/';
 $wwwDiscoverDir = $wwwDir . 'discover/';
@@ -99,13 +107,19 @@ function renderDiscoverFile($discoverFile)
 function renderGameFile($gameDataFile)
 {
     $json = json_decode(file_get_contents($gameDataFile));
+
     $appsDir = dirname($gameDataFile, 2) . '/apps/';
+    $appsFile = $appsDir . $json->version->uuid . '.json';
+    $appsJson = json_decode(file_get_contents($appsFile));
+
     $downloadJson = json_decode(
         file_get_contents(
             $appsDir . $json->version->uuid . '-download.json'
         )
     );
     $apkDownloadUrl = $downloadJson->app->downloadLink;
+    $pushUrl = $GLOBALS['pushToMyOuyaUrl']
+        . '?game=' . urlencode($json->apk->package);
 
     $navLinks = [];
     foreach ($json->genres as $genreTitle) {