Skip to content

Instantly share code, notes, and snippets.

View rossriley's full-sized avatar

Ross Riley rossriley

View GitHub Profile
<?php
class Deprecated
{
/**
* Shortcut for triggering a deprecation warning for a method.
*
* Example:
* class Foo
* {
@rossriley
rossriley / upload.extension.php
Created January 26, 2018 10:06
Overwrite default filesize for Bolt Uploads
$app['upload'] = $app->share(
$app->extend(
'upload',
function ($uploadHandler) {
$uploadHandler->addRule('size', ['max' => '2M'])
return $uploadHandler;
}
)
@rossriley
rossriley / TwigExtension.php
Last active December 12, 2017 16:16
Twig Extension to replace files with thumbnails
<?php
namespace MyApp\Twig;
use Twig_Extension;
use Twig_SimpleFilter;
class TwigExtension extends Twig_Extension
{
public $app;
@rossriley
rossriley / CustomisationExtension.php
Last active December 12, 2017 06:51
Modifying A Bolt Record on the Post Save Event
<?php
namespace Bundle\Site;
use Bolt\Storage\Entity\Content;
use Bolt\Extension\SimpleExtension;
use Bolt\Events\StorageEvent;
use Bolt\Events\StorageEvents;
/**
* Site bundle extension loader.
@rossriley
rossriley / uploadSanitiser.php
Last active January 26, 2018 12:41
Bolt: Extending the upload handler with custom sanitiser
$app['upload'] = $app->share(
$app->extend(
'upload',
function ($uploadHandler) {
$uploadHandler->setSanitizerCallback(
function ($filename) {
// Do things with filename string here.
return $filename;
}
);
pages:
name: Pages
singular_name: Page
fields:
title:
type: text
class: large
group: content
slug:
type: slug
<?php
namespace MyNewApp\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use Bolt\Application;
<?php
namespace MyApp\Response;
use Symfony\Component\HttpFoundation\Response;
class CsvResponse extends Response
{
protected $data;
@rossriley
rossriley / .bolt.yml
Last active December 3, 2016 12:25
Local Extensions Config
paths:
web: public
themebase: public/theme
files: public/files
view: public/bolt-public/view
extensions:
- MyextOne\LocalExtensionOne
- MyextTwo\LocalExtensionTwo
- MyextThree\LocalExtensionThree
(function($) {
$.belowthefold = function(element, settings) {
var fold = $(window).height() + $(window).scrollTop();
return fold <= $(element).offset().top - settings.threshold;
};
$.abovethetop = function(element, settings) {
var top = $(window).scrollTop();
return top >= $(element).offset().top + $(element).height() - settings.threshold;