Last active
May 14, 2019 16:40
-
-
Save farfromunique/dcc386b76d74bf1e323544eda7d28abd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Slim\App; | |
return function (App $app) { | |
$container = $app->getContainer(); | |
// view renderer | |
$container['renderer'] = function ($c) { | |
$settings = $c->get('settings')['renderer']; | |
return new \Slim\Views\PhpRenderer($settings['template_path']); | |
}; | |
// monolog | |
$container['logger'] = function ($c) { | |
$settings = $c->get('settings')['logger']; | |
$logger = new \Monolog\Logger($settings['name']); | |
$logger->pushProcessor(new \Monolog\Processor\UidProcessor()); | |
$logger->pushHandler(new \Monolog\Handler\ChromePHPHandler()); | |
$logger->pushHandler(new \Monolog\Handler\StreamHandler($settings['path'], $settings['level'])); | |
return $logger; | |
}; | |
// firebase | |
$container['firebase'] = function ($c) { | |
$settings = $c->get('settings')['firebase']; | |
$serviceAccount = \Kreait\Firebase\ServiceAccount::fromJsonFile($settings['ServiceAccountJSON']); | |
$firebase = (new \Kreait\Firebase\Factory) | |
->withServiceAccount($serviceAccount) | |
->withDatabaseUri($settings['DatabaseURL']) | |
->create(); | |
return $firebase; | |
}; | |
// 403 handler | |
$container['notAllowedHandler'] = function ($c) { | |
return function ($request, $response) use ($c) { | |
return $response->withStatus(403) | |
->withHeader('Content-Type', 'text/html') | |
->write('Page not found'); | |
}; | |
}; | |
// 404 handler | |
$container['notFoundHandler'] = function ($c) { | |
return function ($request, $response) use ($c) { | |
return $response->withStatus(404) | |
->withHeader('Content-Type', 'text/html') | |
->write('Page not found'); | |
}; | |
}; | |
// 405 handler | |
$container['notAllowedHandler'] = function ($c) { | |
return function ($request, $response, $methods) use ($c) { | |
return $response->withStatus(405) | |
->withHeader('Allow', implode(', ', $methods)) | |
->withHeader('Content-type', 'text/html') | |
->write('Method must be one of: ' . implode(', ', $methods)); | |
}; | |
}; | |
/* | |
// 500 handler | |
$container['errorHandler'] = function ($c) { | |
return function ($request, $response, $exception) use ($c) { | |
return $response->withStatus(500) | |
->withHeader('Content-Type', 'text/html') | |
->write('Something went wrong!'); | |
}; | |
};*/ | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<title>Futhark Power Generator v1.7beta</title> | |
<!-- Bootstrap --> | |
<link rel="stylesheet" href="/css/basic.css" type="text/css"> | |
<link rel="stylesheet" href="/css/loader.css" type="text/css"> | |
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | |
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | |
<!--[if lt IE 9]> | |
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> | |
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | |
<![endif]--> | |
<script> | |
!function(f,u,t,h,a,r,k){f.GoogleAnalyticsObject=t;f[t]||(f[t]=function(){ | |
(f[t].q=f[t].q||[]).push(arguments)});f[t].l=+new Date;r=u.createElement(h); | |
k=u.getElementsByTagName(h)[0];r.src=a;k.parentNode.insertBefore(r,k)} | |
(window,document,'ga','script','//www.google-analytics.com/analytics.js'); | |
</script> | |
<script src="/js/analytics.js"></script> | |
</head> | |
<body> | |
<div class='headBar'> | |
<h1>Futhark Generator</h1> | |
<h2>v1.7beta</h2> | |
</div> | |
<div class='navbar'> | |
<div class="navgroup"> | |
<p><strong>Pages here</strong></p> | |
<ul> | |
<li> | |
<a href="/"> | |
Roll them bones! | |
</a> | |
</li> | |
<li> | |
<a href="/list"> | |
See all combinations | |
</a> | |
</li> | |
<li> | |
<a href="/donate"> | |
Help keep the site going | |
</a> | |
</li> | |
</ul> | |
</div> | |
<div class="navgroup"> | |
<p><strong>Pages elsewhere</strong></p> | |
<ul> | |
<li> | |
<a href="http://www.reddit.com/r/FutharkGenerator/"> | |
/r/FutharkGenerator | |
</a> | |
</li> | |
<li> | |
<a href="http://www.reddit.com/r/FutharkGenerator/comments/35fcg7/php_futhark_generator/"> | |
Feedback on reddit | |
</a> | |
</li> | |
<li> | |
<a href="https://github.com/farfromunique/Generator-1.5/issues/new"> | |
Feedback on GitHub | |
</a> | |
</li> | |
</ul> | |
</div> | |
<div class="navgroup"> | |
Have you heard of <a href="http://parahumans.wordpress.com/">Worm</a>? | |
<br />If not, please <a href="http://www.reddit.com/r/FutharkGenerator/comments/35kilh/if_you_havent_read_worm_read_me_first/">read me first!</a> | |
</div> | |
<div id='hist' class='hist'> | |
<span id='endOfHist'> </span> | |
</div> | |
</div> | |
<div class="content" id="content"> | |
<p>Your Roll: <button href="#" id="reroll" ic-get-from="/a/roll" ic-target="#content" ic-on-beforeSend="insertSmallImages()">Start Over</button></p> | |
<div id="bigImages" class="bigImages"> | |
<div class="Type"> | |
<div title="Type: " class="Image" style="background-image:url(/img/runes/);"></div> | |
<div class="Name"></div> | |
<div class="Button"> | |
<button | |
id="rollType" | |
ic-get-from="/a/roll/type" | |
ic-target="#bigImages" | |
ic-swap-style="append" | |
ic-indicator="#type-load" | |
ic-src="/a/roll/type" | |
ic-trigger-on="default" | |
ic-deps="ignore"> | |
Roll Another | |
</button> | |
<i id="type-load" class="lds-dual-ring"></i> | |
</div> | |
</div> | |
<div class="Flavor"> | |
<div title="Flavor: " class="Image" style="background-image:url(/img/zodiac/);"></div> | |
<div class="Name"></div> | |
<div class="Button"> | |
<button | |
id="rollFlavor" | |
ic-get-from="/a/roll/flavor" | |
ic-target="#bigImages" | |
ic-swap-style="append" | |
ic-indicator="#flavor-load" | |
ic-src="/a/roll/flavor" | |
ic-trigger-on="default" | |
ic-deps="ignore"> | |
Roll Another | |
</button> | |
<i id="flavor-load" class="lds-dual-ring"></i> | |
</div> | |
</div> | |
<div title="Twist: " class="Twist"> | |
<div class="Image" style="background-image:url(/img/cards/);"></div> | |
<div class="Name"></div> | |
<div class="Button"> | |
<button | |
id="rollTwist" | |
ic-get-from="/a/roll/twist" | |
ic-target="#bigImages" | |
ic-swap-style="append" | |
ic-indicator="#twist-load" | |
ic-src="/a/roll/twist" | |
ic-trigger-on="default" | |
ic-deps="ignore"> | |
Draw Again | |
</button> | |
<i id="twist-load" class="lds-dual-ring"></i> | |
</div> | |
</div> | |
</div> | |
<div class="verboseDescription" id="Description"> | |
<p></p> | |
<p></p> | |
<p></p> | |
</div> | |
<div class="shortDescription hidden" id="ShortDesc"> | |
<p></p> | |
<p></p> | |
<p></p> | |
</div> | |
<div id="keys" class="hidden"> | |
<div id="key_type">[[{"class":"Tinker","description":"the ability to manipulate technology beyond the means of current science","image":"cancer.png","name":"Cancer"}]]</div> | |
<div id="key_flavor">[[{"description":"works in short bursts of extreme power","element":"solid air","elementname":"compressed air","flavor":"Day","image":"dagaz.png","name":"Dagaz"}]]</div> | |
<div id="key_twist">[[{"cardname":"Page of Coins","description":"Finally, you drew the <strong>Page of Coins<\/strong>. This rank modifies your power so that your Control is increased but your choice of Potency or Versatility is decreased. his suit rounds out your power, roll for a second sign\/category and apply it along with the first.","image":"Pents11.png","orientation":"Regular","suit":"Coins","value":11}]]</div> | |
</div> | |
</div> | |
<div class="footer"> | |
<p>Legal Stuff:</p> | |
<p>The Futhark Generator is used to create powers that would be fitting to Wildbow's web serial Worm. Classifications, story, characters, and other elements are his by right, we're just playing in his sandbox. For more information, click <a href="/credits">here</a>.</p> | |
</div> | |
<div id="loader" class="fullscreen" style="display:none;"> | |
<svg class="circular"> | |
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="4" stroke-miterlimit="20"/> | |
</svg> | |
</div> | |
</body> | |
<script src="/js/jquery-3.2.0.js"></script> | |
<script src="/js/intercooler-1.1.1.min.js"></script> | |
<script src="/js/ajax.js"></script> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// protected/templates/FullPageBigImages.phtml | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<title><?php echo $title ?></title> | |
<!-- Bootstrap --> | |
<link rel="stylesheet" href="/css/basic.css" type="text/css"> | |
<link rel="stylesheet" href="/css/loader.css" type="text/css"> | |
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | |
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | |
<!--[if lt IE 9]> | |
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> | |
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | |
<![endif]--> | |
<script> | |
!function(f,u,t,h,a,r,k){f.GoogleAnalyticsObject=t;f[t]||(f[t]=function(){ | |
(f[t].q=f[t].q||[]).push(arguments)});f[t].l=+new Date;r=u.createElement(h); | |
k=u.getElementsByTagName(h)[0];r.src=a;k.parentNode.insertBefore(r,k)} | |
(window,document,'ga','script','//www.google-analytics.com/analytics.js'); | |
</script> | |
<script src="/js/analytics.js"></script> | |
</head> | |
<body> | |
<div class='headBar'> | |
<h1>Futhark Generator</h1> | |
<h2><?php echo $version; ?></h2> | |
</div> | |
<div class='navbar'> | |
<div class="navgroup"> | |
<p><strong>Pages here</strong></p> | |
<ul> | |
<li> | |
<a href="/"> | |
Roll them bones! | |
</a> | |
</li> | |
<li> | |
<a href="/list"> | |
See all combinations | |
</a> | |
</li> | |
<li> | |
<a href="/donate"> | |
Help keep the site going | |
</a> | |
</li> | |
</ul> | |
</div> | |
<div class="navgroup"> | |
<p><strong>Pages elsewhere</strong></p> | |
<ul> | |
<li> | |
<a href="http://www.reddit.com/r/FutharkGenerator/"> | |
/r/FutharkGenerator | |
</a> | |
</li> | |
<li> | |
<a href="http://www.reddit.com/r/FutharkGenerator/comments/35fcg7/php_futhark_generator/"> | |
Feedback on reddit | |
</a> | |
</li> | |
<li> | |
<a href="https://github.com/farfromunique/Generator-1.5/issues/new"> | |
Feedback on GitHub | |
</a> | |
</li> | |
</ul> | |
</div> | |
<div class="navgroup"> | |
Have you heard of <a href="http://parahumans.wordpress.com/">Worm</a>? | |
<br />If not, please <a href="http://www.reddit.com/r/FutharkGenerator/comments/35kilh/if_you_havent_read_worm_read_me_first/">read me first!</a> | |
</div> | |
<div id='hist' class='hist'> | |
<span id='endOfHist'> </span> | |
</div> | |
</div> | |
<div class="content" id="content"> | |
<p>Your Roll: <button href="#" id="reroll" ic-get-from="/a/roll" ic-target="#content" ic-on-beforeSend="insertSmallImages()">Start Over</button></p> | |
<div id="bigImages" class="bigImages"> | |
<?php for ($i = 0; $i < count($type); $i++): ?> | |
<div class="Type"> | |
<div title="Type: <?= $type[$i]['name']; ?>" class="Image" style="background-image:url(/img/runes/<?= $type[$i]['image']; ?>);"></div> | |
<div class="Name"><?= $type[$i]['name']; ?></div> | |
<div class="Button"> | |
<?php if ($i == 0): ?> | |
<button | |
id="rollType" | |
ic-get-from="/a/roll/type" | |
ic-target="#bigImages" | |
ic-swap-style="append" | |
ic-indicator="#type-load" | |
ic-src="/a/roll/type" | |
ic-trigger-on="default" | |
ic-deps="ignore"> | |
Roll Another | |
</button> | |
<?php endif; ?> | |
<i id="type-load" class="lds-dual-ring"></i> | |
</div> | |
</div> | |
<?php endfor; ?> | |
<?php for ($i = 0; $i < count($flavor); $i++): ?> | |
<div class="Flavor"> | |
<div title="Flavor: <?= $flavor[$i]['name']; ?>" class="Image" style="background-image:url(/img/zodiac/<?= $flavor[$i]['image']; ?>);"></div> | |
<div class="Name"><?= $flavor[$i]['name']; ?></div> | |
<div class="Button"> | |
<?php if ($i == 0): ?> | |
<button | |
id="rollFlavor" | |
ic-get-from="/a/roll/flavor" | |
ic-target="#bigImages" | |
ic-swap-style="append" | |
ic-indicator="#flavor-load" | |
ic-src="/a/roll/flavor" | |
ic-trigger-on="default" | |
ic-deps="ignore"> | |
Roll Another | |
</button> | |
<?php endif; ?> | |
<i id="flavor-load" class="lds-dual-ring"></i> | |
</div> | |
</div> | |
<?php endfor; ?> | |
<?php for ($i = 0; $i < count($twist); $i++): ?> | |
<div title="Twist: <?= $twist[$i]['name']; ?>" class="Twist"> | |
<div class="Image" style="background-image:url(/img/cards/<?= $twist[$i]['image']; ?>);"></div> | |
<div class="Name"><?= $twist[$i]['name']; ?></div> | |
<div class="Button"> | |
<?php if ($i == 0): ?> | |
<button | |
id="rollTwist" | |
ic-get-from="/a/roll/twist" | |
ic-target="#bigImages" | |
ic-swap-style="append" | |
ic-indicator="#twist-load" | |
ic-src="/a/roll/twist" | |
ic-trigger-on="default" | |
ic-deps="ignore"> | |
Draw Again | |
</button> | |
<?php endif; ?> | |
<i id="twist-load" class="lds-dual-ring"></i> | |
</div> | |
</div> | |
<?php endfor; ?> | |
</div> | |
<div class="verboseDescription" id="Description"> | |
<?php for ($i=0; $i < max(count($type),count($flavor),count($twist)); $i++): ?> | |
<?php if ($i > 0): ?> | |
<hr /> | |
<?php endif; ?> | |
<?php if (isset($type[$i])): ?> | |
<p><?= $type[$i]['verbose']; ?></p> | |
<?php endif; ?> | |
<?php if (isset($flavor[$i])): ?> | |
<p><?= $flavor[$i]['verbose']; ?></p> | |
<?php endif; ?> | |
<?php if (isset($twist[$i])): ?> | |
<p><?= $twist[$i]['verbose']; ?></p> | |
<?php endif; ?> | |
<?php endfor; ?> | |
</div> | |
<div class="shortDescription hidden" id="ShortDesc"> | |
<?php for ($i=0; $i < max(count($type),count($flavor),count($twist)); $i++): ?> | |
<?php if (isset($type[$i])): ?> | |
<p><?= $type[$i]['short']; ?></p> | |
<?php endif; ?> | |
<?php if (isset($flavor[$i])): ?> | |
<p><?= $flavor[$i]['short']; ?></p> | |
<?php endif; ?> | |
<?php if (isset($twist[$i])): ?> | |
<p><?= $twist[$i]['short']; ?></p> | |
<?php endif; ?> | |
<?php endfor; ?> | |
</div> | |
<div id="keys" class="hidden"> | |
<div id="key_type"><?= json_encode($type) ?></div> | |
<div id="key_flavor"><?= json_encode($flavor) ?></div> | |
<div id="key_twist"><?= json_encode($twist) ?></div> | |
</div> | |
</div> | |
<div class="footer"> | |
<p>Legal Stuff:</p> | |
<p>The Futhark Generator is used to create powers that would be fitting to Wildbow's web serial Worm. Classifications, story, characters, and other elements are his by right, we're just playing in his sandbox. For more information, click <a href="/credits">here</a>.</p> | |
</div> | |
<div id="loader" class="fullscreen" style="display:none;"> | |
<svg class="circular"> | |
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="4" stroke-miterlimit="20"/> | |
</svg> | |
</div> | |
</body> | |
<script src="/js/jquery-3.2.0.js"></script> | |
<script src="/js/intercooler-1.1.1.min.js"></script> | |
<script src="/js/ajax.js"></script> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (PHP_SAPI == 'cli-server') { | |
// To help the built-in PHP dev server, check if the request was actually for | |
// something which should probably be served as a static file | |
$url = parse_url($_SERVER['REQUEST_URI']); | |
$file = __DIR__ . $url['path']; | |
if (is_file($file)) { | |
return false; | |
} | |
} | |
require __DIR__ . '/../protected/vendor/autoload.php'; | |
session_start(); | |
// Instantiate the app | |
$settings = require __DIR__ . '/../protected/settings.php'; | |
$app = new \Slim\App($settings); | |
// Set up dependencies | |
$dependencies = require __DIR__ . '/../protected/dependencies.php'; | |
$dependencies($app); | |
// Register middleware | |
$middleware = require __DIR__ . '/../protected/middleware.php'; | |
$middleware($app); | |
// Register routes | |
$routes = require __DIR__ . '/../protected/slim-routes.php'; | |
$routes($app); | |
// Run app | |
$app->run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'settings' => [ | |
'displayErrorDetails' => true, // set to false in production | |
'addContentLengthHeader' => false, // Allow the web server to send the content-length header | |
// Renderer settings | |
'renderer' => [ | |
'template_path' => __DIR__ . '/templates/', | |
], | |
// Monolog settings | |
'logger' => [ | |
'name' => 'futhark', | |
'path' => __DIR__ . '/../logs/app.log', | |
'level' => \Monolog\Logger::DEBUG, | |
], | |
/************************************************************************** | |
* General App config. | |
**************************************************************************/ | |
'APP_VERSION' => 'v1.7beta', | |
'APP_TITLE' => 'Futhark Power Generator ', | |
/************************************************************************** | |
* Firebase database config. | |
* Firebase database connection provided in kreait/firebase-php | |
**************************************************************************/ | |
'firebase' => [ | |
'DatabaseURL' => 'https://futharkgenerator.firebaseio.com', | |
'ServiceAccountJSON' => __DIR__ . '/futharkGenerator.serviceAccount.json', | |
], | |
'powersDB' => [ | |
'location' => __DIR__ . '/../sourceData/firebase.english.json' | |
] | |
], | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Slim\App; | |
use Slim\Http\Request; | |
use Slim\Http\Response; | |
use ACWPD\Futhark\Power; | |
return function (App $app) { | |
$container = $app->getContainer(); | |
$container->get('logger')->notice('Router Activated!'); | |
$meta = [ | |
'title' => $container->get('settings')['APP_TITLE'] . $container->get('settings')['APP_VERSION'], | |
'version' => $container->get('settings')['APP_VERSION'] | |
]; | |
/* | |
$app->get('/tickets', function (Request $request, Response $response) { | |
$this->logger->addInfo('Ticket list'); | |
$mapper = new TicketMapper($this->db); | |
$tickets = $mapper->getTickets(); | |
$response = $this->view->render($response, 'tickets.phtml', ['tickets' => $tickets]); | |
return $response; | |
}); | |
$app->post('/ticket/new', function (Request $request, Response $response) { | |
$data = $request->getParsedBody(); | |
$ticket_data = []; | |
$ticket_data['title'] = filter_var($data['title'], FILTER_SANITIZE_STRING); | |
$ticket_data['description'] = filter_var($data['description'], FILTER_SANITIZE_STRING); | |
}); | |
*/ | |
$app->get('/',function (Request $request, Response $response) use ($container, $meta) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withRandomType() | |
->withRandomFlavor() | |
->withRandomTwist() | |
->getPowerData(); | |
$args = array_merge($data,$meta); | |
return $container->get('renderer')->render($response, 'FullPageBigImages.phtml', $args); | |
})->setName('home'); | |
$app->get('/list',function (Request $request, Response $response) use ($container, $meta) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withAllData() | |
->getPowerData(); | |
$args = array_merge($data,$meta); | |
return $container->get('renderer')->render($response, 'List.phtml', $args); | |
})->setName('list'); | |
$app->get('/credits',function (Request $request, Response $response) use ($container, $meta) { | |
return $container->get('renderer')->render($response, 'Credits.phtml', $meta); | |
})->setName('credits'); | |
$app->get('/donate',function (Request $request, Response $response) use ($container, $meta) { | |
return $container->get('renderer')->render($response, 'Donate.phtml', $meta); | |
})->setName('donate'); | |
$app->get('/load/{type_}/{flavor_}/{twist_}', function (Request $request, Response $response, array $args) use ($container) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withType($args['type_']) | |
->withFlavor($args['flavor_']) | |
->withTwist($args['twist_']) | |
->getPowerData(); | |
$args = array_merge($data); | |
return $container->get('renderer')->render($response, 'FullPageBigImages.phtml', $args); | |
})->setName('load'); | |
$app->get('/load/{id_}', function (Request $request, Response $response, array $args) use ($container) { | |
$fb = $container->get('firebase')->getDatabase(); | |
$ref = $fb->getReference('saved/' . $args['id_']); | |
$data = $ref->getValue(); | |
})->setName('loadSaved'); | |
$app->post('/save', function(Request $request, Response $response, array $args) use ($container) { | |
}); | |
$app->group('/a', function (App $app) use ($container) { | |
$app->group('/roll', function (App $app) use ($container) { | |
$app->get('/', function (Request $request, Response $response) use ($container) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withRandomType() | |
->withRandomFlavor() | |
->withRandomTwist() | |
->getPowerData(); | |
$args = array_merge($data); | |
return $container->get('renderer')->render($response, 'BigImages.phtml', $args); | |
}); | |
$app->get('/type', function (Request $request, Response $response) use ($container) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withRandomType() | |
->getPowerData(); | |
$args = array_merge($data); | |
return $container->get('renderer')->render($response, 'OnlyType.phtml', $args); | |
}); | |
$app->get('/flavor', function (Request $request, Response $response) use ($container) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withRandomFlavor() | |
->getPowerData(); | |
$args = array_merge($data); | |
return $container->get('renderer')->render($response, 'OnlyFlavor.phtml', $args); | |
}); | |
$app->get('/twist', function (Request $request, Response $response) use ($container) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withRandomTwist() | |
->getPowerData(); | |
$args = array_merge($data); | |
return $container->get('renderer')->render($response, 'OnlyTwist.phtml', $args); | |
}); | |
}); | |
$app->get('/load/{type_}/{flavor_}/{twist_}', function (Request $request, Response $response, array $args) use ($container) { | |
$power = new Power($container); | |
$power->loadPowersDB(); | |
$data = $power->withType($args['type_']) | |
->withFlavor($args['flavor_']) | |
->withTwist($args['twist_']) | |
->getPowerData(); | |
$args = array_merge($data); | |
return $container->get('renderer')->render($response, 'BigImages.phtml', $args); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment