Skip to content

Instantly share code, notes, and snippets.

View craigtaub's full-sized avatar

Craig Taub craigtaub

View GitHub Profile
private function _getIblError($response) {
try {
$body = $response->getBody();
if (!$body) {
return "No body content";
}
$json = json_decode($body);
if (!$json) {
return "Unable to parse body content";
}
get() could include try/catch.
Inside would fetch from iBL and parse response.
Parse can throw errors from each errored process inside _parseResponse().
Remove handleErrors() and _getIblError, add _parseResponse().
Response is moved to instance var (debatable, would give object a state).
checkJsonError does not throw anything unless finds an error.
Below an example, not complete:
private function _parseResponse() {
pageTitle($page, $formStatus) {
$Localiser = new BBC_View_Helper_Localise();
switch ($formStatus) {
case 'subscribe_request_success': // Subscribe Request Success page
$pageTitle = $Localiser->localise('newsletter_'.$page.'_subscribe_request_success_title');
break;
case 'subscribe_request_failure': // Subscribe Request Failure page
$pageTitle = $Localiser->localise('newsletter_'.$page.'_subscribe_request_failure_title');
break;
case 'subscribe_success': // Subscribe Success page
@craigtaub
craigtaub / gist:7695094
Last active December 29, 2015 16:09
Factory for categories
abstract class Channel
{
protected $_identifier;
protected $_id;
protected $_iblId;
public function getIdentifier() {
return $this->_identifier;
}
@craigtaub
craigtaub / gist:7699445
Last active December 29, 2015 16:48
Image screenshot and comparison tool
/*
Needs PhantomJS
uses Node.js File API
uses base64 encoding
event based on rendering image.
node modules:
JsDiff (https://github.com/kpdecker/jsdiff)
colors.js (https://github.com/brehaut/color-js)
NAV:
tvip-links-cats-channels-container {
- Channel Items
tvip-links-cats-container {
- Category Items
- Other Nav Link Items
}
}
//open page
//var_dump($json);die;
//refresh
//Save as fixtures/bamboo/home_highlights_series_stacked.json
/iplayer?_fake=highlights@series_stacked
HTTP/1.1 200 OK
Server: Fixture
Content-Language: en-GB
Content-Type: application/json;charset=UTF-8
define('iplayer/controllers/Preview',
function() {
glow.events.addListener("#preview-opt-in a", "click", function(event) {
event.stopPropagation();
event.preventDefault();
var date = new Date(),
expires;
date.setTime(date.getTime()+(182*24*60*60*1000)); //6 months in future
expires = date.toGMTString();
<~method domReadyInit>
require([
'iplayer/controllers/DrawerManager',
'iplayer/controllers/OverlayManager',
'iplayer/controllers/UserRecommendations',
'iplayer/controllers/FriendsActivity',
'iplayer/controllers/RadioUpsell',
'iplayer/controllers/IstatsLinkTracking',
'iplayer/controllers/Arialandmarks',
'iplayer/controllers/Preview'
=== Machine on wifi , dev on IE8
machine:
wifi to iplayer_mobile
-any turn proxies off
unplug eth
dev:
proxies off and extacess on
#reithproxies off
#extaccess pal-ct