Skip to content

Instantly share code, notes, and snippets.

View bwaidelich's full-sized avatar
🏠
Working from home

Bastian Waidelich bwaidelich

🏠
Working from home
View GitHub Profile
@bwaidelich
bwaidelich / index.html
Last active March 23, 2023 14:44 — forked from mpj/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Intro to XState</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="box"></div>
@bwaidelich
bwaidelich / ServerSentComponent.php
Created November 14, 2019 16:09
Example: Flow HTTP Component for Server-Sent Events
<?php
declare(strict_types=1);
namespace Some\Package\Http;
use Neos\Flow\Http\Component\ComponentContext;
use Neos\Flow\Http\Component\ComponentInterface;
use Neos\Flow\Http\Helper\MediaTypeHelper;
final class ServerSentComponent implements ComponentInterface
{
@bwaidelich
bwaidelich / CacheFlusher.php
Last active September 2, 2019 08:11
Neos CMS: Get (relative) Node Url upon publishing
<?php
namespace Some\Package;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Model\Workspace;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\UriBuilder;
@bwaidelich
bwaidelich / JsonCapableExceptionView.php
Created June 19, 2019 09:20
Render Neos / Flow exceptions as JSON if a corresponding Accept / Content-Type header is set
<?php
declare(strict_types=1);
namespace Some\Package\Error;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Helper\ResponseInformationHelper;
use Neos\Flow\Http\Request;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\View\ViewInterface;
use Neos\Utility\MediaTypes;
@bwaidelich
bwaidelich / SiteRequestPattern.php
Last active June 6, 2019 12:49
Neos Flow Authentication Provider Request Pattern matching Neos Sites by their node name
<?php
declare(strict_types=1);
namespace Some\Package;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\RequestInterface;
use Neos\Flow\Security\Context;
use Neos\Flow\Security\Exception as SecurityException;
use Neos\Flow\Security\Exception\InvalidRequestPatternException;
@bwaidelich
bwaidelich / AuthenticationContext.php
Created February 13, 2019 13:00
Dynamic ACL in Neos Flow
<?php
declare(strict_types=1);
namespace Some\Package\Security;
use Neos\Cache\CacheAwareInterface;
use Neos\Flow\Annotations as Flow;
/**
* @Flow\Scope("singleton")
*/
@bwaidelich
bwaidelich / main.go
Last active January 31, 2019 14:57
Golang Value Object tests
package main
import (
"fmt"
"regexp"
)
// EmailAddress Value Object
type EmailAddress string
@bwaidelich
bwaidelich / Root.fusion
Created January 15, 2019 15:34
Atomic Fusion: Content with TOC
prototype(Some.Package:Component.ContentWithToc) < prototype(Neos.Fusion:Component) {
blocks = Neos.Fusion:RawArray
renderer = afx`
<nav>
<ul>
<Neos.Fusion:Collection collection={props.blocks} itemName="block" @children="itemRenderer">
<li>
<a href={'#c-' + iterator.cycle}>{block.label}</a>
</li>
@bwaidelich
bwaidelich / MainMenuItems.fusion
Created January 4, 2019 14:30
Fusion based Menu implementation for Neos CMS
prototype(Some.Package:MainMenuItems) < prototype(Neos.Fusion:Component) {
renderer = Neos.Fusion:RawCollection {
collection = ${q(site).children('[instanceof Neos.Neos:Document]').get()}
@context.rootline = ${q(documentNode).parents('[instanceof Neos.Neos:Document]').get()}
itemName = 'node'
itemRenderer = Some.Package:Component.Organism.Menu.Item {
title = ${q(node).property('title')}
href = Neos.Neos:NodeUri {
node = ${node}
}
@bwaidelich
bwaidelich / Component_Atom_DefaultElement.fusion
Last active July 17, 2019 13:09
Atomic Fusion based Form Definition
prototype(My.Package:Form.DefaultElement) < prototype(Neos.Fusion:Component) {
# API
id = ''
name = ''
label = ''
value = null
isRequired = false
properties = Neos.Fusion:RawArray
validationErrors = Neos.Fusion:RawArray