Skip to content

Instantly share code, notes, and snippets.

@jacquesbh
Created July 30, 2012 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacquesbh/3210926 to your computer and use it in GitHub Desktop.
Save jacquesbh/3210926 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* This file is part of Jbh_Webservice for Magento.
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*
* @license WTFPL
* @author Jacques Bodin-Hullin <jacques@bodin-hullin.net>
* @category Jbh
* @package Jbh_Webservice
* @copyright Copyright (c) 2012 Jacques Bodin-Hullin (http://jacques.sh/)
*/
-->
<config>
<modules>
<Jbh_Webservice>
<version>0.1.0</version>
</Jbh_Webservice>
</modules>
<frontend>
<routers>
<jbh_webservice>
<use>standard</use>
<args>
<module>Jbh_Webservice</module>
<frontName>webservice</frontName>
</args>
</jbh_webservice>
</routers>
</frontend>
</config>
/**
* This file is part of Jbh_Webservice for Magento.
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*
* @license WTFPL
* @author Jacques Bodin-Hullin <jacques@bodin-hullin.net>
* @category Jbh
* @package Jbh_Webservice
* @copyright Copyright (c) 2012 Jacques Bodin-Hullin (http://jacques.sh/)
*/
var BASE_ECOM_URL = 'http://example.org/';
(function ($) {
$(document).ready(function () {
$.getJSON(BASE_ECOM_URL + 'webservice/page/footer?callback=?', function (data) {
$('#footer').replaceWith($(data.html));
});
});
})(jQuery);
<?xml version="1.0" encoding="utf-8" ?>
<!--
/**
* This file is part of Jbh_Webservice for Magento.
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*
* @license WTFPL
* @author Jacques Bodin-Hullin <jacques@bodin-hullin.net>
* @category Jbh
* @package Jbh_Webservice
* @copyright Copyright (c) 2012 Jacques Bodin-Hullin (http://jacques.sh/)
*/
-->
<config>
<modules>
<Jbh_Webservice>
<active>true</active>
<codePool>community</codePool>
</Jbh_Webservice>
</modules>
</config>
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
<?php
/**
* This file is part of Jbh_Webservice for Magento.
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*
* @license WTFPL
* @author Jacques Bodin-Hullin <jacques@bodin-hullin.net>
* @category Jbh
* @package Jbh_Webservice
* @copyright Copyright (c) 2012 Jacques Bodin-Hullin (http://jacques.sh/)
*/
/**
* Page Controller
* @package Jbh_Webservice
*/
class Jbh_Webservice_PageController extends Mage_Core_Controller_Front_Action
{
/**
* The query callback name
* @const QUERY_CALLBACK_NAME string
*/
const QUERY_CALLBACK_NAME = 'callback';
/**
* Retrieve the default footer :)
* @access public
* @return void
*/
public function footerAction()
{
// Load the layout and render !
$this->loadLayout();
// Remove the output for the root block
$this->getLayout()->removeOutputBlock('root');
// Yeah ;)
$this->renderLayout('footer');
}
/**
* Need JSONP ? We use the postDispatch.
* @access public
* @return void
*/
public function postDispatch()
{
// If we have an URL like .../?callback=callbackName
if ($callback = $this->getRequest()->getParam(self::QUERY_CALLBACK_NAME, false)) {
// We change the content :)
$body = $callback . '(' . json_encode(array('html' => $this->getResponse()->getBody())) . ')';
$this->getResponse()->setBody($body);
}
return parent::postDispatch();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment