Skip to content

Instantly share code, notes, and snippets.

View sunpietro's full-sized avatar

sunpietro sunpietro

View GitHub Profile
@sunpietro
sunpietro / CustomBlock.php
Last active July 21, 2016 13:47
Extending eZ Studio with new blocks
<?php
namespace My\BlockBundle\Block;
use EzSystems\LandingPageFieldTypeBundle\Exception\InvalidBlockAttributeException;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockDefinition;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockAttributeDefinition;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\AbstractBlockType;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockValue;
@sunpietro
sunpietro / CustomBlock.php
Last active July 21, 2016 13:47
CustomBlock.php
<?php
namespace My\BlockBundle\Block;
use EzSystems\LandingPageFieldTypeBundle\Exception\InvalidBlockAttributeException;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockDefinition;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockAttributeDefinition;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\AbstractBlockType;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockValue;
@sunpietro
sunpietro / CustomBlockExtension.php
Last active July 21, 2016 13:46
CustomBlockExtension.php
<?php
namespace My\BlockBundle\DependencyInjection;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
@sunpietro
sunpietro / services.yml
Created July 20, 2016 11:52
services.yml
services:
my.block.custom:
class: My\BlockBundle\Block\CustomBlock
tags:
- { name: landing_page_field_type.block_type, alias: custom }
@sunpietro
sunpietro / custom.html.twig
Created July 20, 2016 11:49
custom.html.twig
<h3>My Custom block</h3>
{{ block }}
@sunpietro
sunpietro / blocks.yml
Created July 20, 2016 11:49
blocks.yml
blocks:
custom:
views:
custom:
template: MyBlockBundle::custom.html.twig
name: My Custom Block view
@sunpietro
sunpietro / calendar.css
Created March 1, 2016 15:07
Simple calendar
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
color: #333;
}
table {
@sunpietro
sunpietro / backbone-load-template.js
Last active February 10, 2016 06:01
Backbone.js template loader with caching
var loadTemplate = function (templateFilePath, templateData) {
//console.info('Loading: ' + templateFilePath + ' with data:', templateData);
if (!APP.cache.templates[templateFilePath]) {
var templateDir = 'js/app/template/';
var templateUrl = templateDir + templateFilePath + '.js';
var templateString = '';
$.ajax({
async : false,
@sunpietro
sunpietro / string-formatter.js
Last active February 1, 2016 09:31
Formats a string like sprintf
var formatString = (function()
{
var replacer = function(context)
{
return function(s, name)
{
return context[name];
};
};
@sunpietro
sunpietro / Gruntfile.js
Last active December 23, 2015 06:19
Grunt directives: * removing minified files, * uglifying them and keeping original filename (with dots), adding only min.js extension at the end; * concatenating minified JS files, * minifying CSS files, * copying minified files to production directory Gruntfile.js
module.exports = function(grunt) {
'use strict'
grunt.initConfig({
clean : [
'js/GoalApp/js/modules/**/*.min.js',
'css/GoalApp/css/*.min.css'
],
uglify : {
build : {