Skip to content

Instantly share code, notes, and snippets.

View ahilles107's full-sized avatar

Paweł Mikołajczuk ahilles107

View GitHub Profile
@ahilles107
ahilles107 / gist:3918041
Created October 19, 2012 12:37
Widget Class - metadata
...
/**
* @title Test Widget
* @author Paweł Mikołajczuk <[email protected]>
* @description Test widget
* @homepage http://www.sourcefabric.org/en/newscoop/
* @version 1.0
*/
class TestWidget extends Widget // implements IWidget class with only render method
{
...
// set metadata property with variable
public $title = 'Test widget title from property';
...
@ahilles107
ahilles107 / gist:3918110
Created October 19, 2012 12:57
Widget Class - setting
...
/**
* @setting
* @label Autor name
*/
public $author = 'Paweł Mikołajczuk>';
/**
* @setting
* @label Autor old
@ahilles107
ahilles107 / gist:3946923
Created October 24, 2012 15:57
Newscoop REST API Articles Controller
/**
* @Route("/articles.{_format}", defaults={"_format"="json"})
* @Method("GET")
* @View()
*/
public function getArticlesAction(Request $request)
{
$em = $this->container->get('em');
$publication = $this->get('newscoop.publication_service')->getPublication()->getId();
$serializer = $this->get('serializer');
@ahilles107
ahilles107 / gist:3947070
Created October 24, 2012 16:17
Newscoop REST API Comments serialization schema.
Newscoop\Entity\Comment:
exclusion_policy: ALL
properties:
subject:
expose: true
read_only: true
type: string
groups: ["details", "list"]
serialized_name: subject
message:
@ahilles107
ahilles107 / gist:3957860
Created October 26, 2012 09:37
Newscoop REST API Allow origin header configuration
newscoop_gimme:
allow_origin:
- "example.com"
- "second-example.com"
@ahilles107
ahilles107 / gist:3958118
Created October 26, 2012 10:40
Newscoop Latest Articles Widget
{
"require": {
"silex/silex": "dev-master",
"twig/twig": ">=1.8,<2.0-dev",
"sourcefabric/newscoop-php-sdk": "dev-master"
}
}
@ahilles107
ahilles107 / gist:3958564
Created October 26, 2012 12:44
Newscoop Latest Articles Widget - silex simple app.
<?php
require_once __DIR__.'/../vendor/autoload.php'; // Composer autoloading
$app = new Silex\Application();
// register twig support
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/Resources/views',
));
@ahilles107
ahilles107 / gist:3963466
Created October 27, 2012 08:00
Newscoop Latest Articles Widget - initialize sdk
...
//debug
$app['debug'] = true;
$api = new Client();
// set here your newscoop instance address
$api->setApiEndpoint('http://newscoop.dev/api');
...
@ahilles107
ahilles107 / gist:3963528
Created October 27, 2012 08:21
Newscoop Latest Articles Widget - create appi call.
...
//create route
$app->get('/', function (Request $request) use ($app, $api){
// choose resource, in second parameter you can pass array with additional parameters
$articles = $api->getResource('/articles', array(
'type' => 'news'
))
// set number of items per page - default is 10