Skip to content

Commit

Permalink
WIP: Initial development
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandschuetz committed Sep 27, 2021
0 parents commit f82bf3b
Show file tree
Hide file tree
Showing 32 changed files with 10,578 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/

# top-most EditorConfig file
root = true


# Default

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing-whitespace = true
indent_style = tab
indent_size = 4

# Exceptions
[{*.{yaml,yml,sh,jscsrc},package.json,.*rc}]
indent_style = space
indent_size = 2

# PHP should follow the PSR-2 standard
[*.{json,php,xlf}]
indent_style = space
indent_size = 4

[*.{json,scss}]
max_line_length = 1000

[Sites.xml]
indent_size = 1

[*.{note,md,edit,read}]
trim_trailing-whitespace = false
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Various temporary and editor files
.fuse_hidden
.sass-cache
bower_components
node_modules
*.DS_Store
/.idea
.remote-sync.json
72 changes: 72 additions & 0 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace CodeQ\JumpMarkers\Controller;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Flow\Mvc\Exception\NoSuchArgumentException;
use Neos\Flow\Security\Authorization\PrivilegeManagerInterface;
use Neos\Neos\Controller\Exception\NodeNotFoundException;
use Neos\Neos\Service\LinkingService;
use Neos\Neos\TypeConverter\NodeConverter;

/**
* Controller for displaying nodes in the frontend
*
* @Flow\Scope("singleton")
*/
class BackendController extends ActionController
{
/**
* @Flow\Inject
* @var LinkingService
*/
protected $linkingService;

/**
* @Flow\Inject
* @var PrivilegeManagerInterface
*/
protected $privilegeManager;

/**
* Allow invisible nodes to be previewed
*
* @return void
* @throws NoSuchArgumentException
*/
protected function initializeNodeToUriAction(): void
{
if ($this->arguments->hasArgument('node') && $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
$this->arguments->getArgument('node')->getPropertyMappingConfiguration()->setTypeConverterOption(NodeConverter::class, NodeConverter::INVISIBLE_CONTENT_SHOWN, true);
}
}

/**
* Get an uri to a link that might now be live yet.
*
* @param NodeInterface|null $node
* @return void
* @throws NodeNotFoundException
* @throws \Neos\Flow\Http\Exception
* @throws \Neos\Flow\Mvc\Routing\Exception\MissingActionNameException
* @throws \Neos\Flow\Persistence\Exception\IllegalObjectTypeException
* @throws \Neos\Flow\Property\Exception
* @throws \Neos\Flow\Security\Exception
* @throws \Neos\Neos\Exception
* @Flow\IgnoreValidation("node")
*/
public function nodeToUriAction(NodeInterface $node = null)
{
exit('wanting to see this message');
if ($node === null) {
throw new NodeNotFoundException('The requested node does not exist or isn\'t accessible to the current user', 1430218623);
}
exit('part one');

print_r($this->linkingService->createNodeUri($this->controllerContext, $node, null, null, true));
//print_r($this->linkingService->resolveNodeUri($matches[0], $node, $controllerContext, $absolute);
exit();
}
}
12 changes: 12 additions & 0 deletions Configuration/NodeTypes.Mixin.PageConfiguration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'CodeQ.JumpMarkers:Mixin.PageConfiguration':
abstract: true
properties:
heroHashMenu:
type: boolean
defaultValue: false
ui:
label: i18n
reloadIfChanged: true
inspector:
group: document
position: 1000300
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'CodeQ.JumpMarkers:Mixin.SectionConfiguration.DefaultDisabled':
abstract: true
superTypes:
'CodeQ.JumpMarkers:Mixin.SectionConfiguration': true
properties:
includeInHashMenu:
defaultValue: false
60 changes: 60 additions & 0 deletions Configuration/NodeTypes.Mixin.SectionConfiguration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'CodeQ.JumpMarkers:Mixin.SectionConfiguration':
abstract: true
ui:
inspector:
groups:
jumpmarker:
label: i18n
icon: anchor
position: 950
views:
anchor:
label: 'Anchor view'
group: jumpmarker
view: 'CodeQ.JumpMarkers/Views/AnchorView'
properties:
includeInHashMenu:
type: boolean
defaultValue: false
ui:
label: i18n
help:
message: i18n
reloadPageIfChanged: true
inspector:
group: jumpmarker
position: 'before hashMenuTitle'
hashMenuTitle:
type: string
defaultValue: ''
ui:
label: i18n
help:
message: i18n
reloadPageIfChanged: false
inspector:
hidden: 'ClientEval:node.properties.includeInHashMenu ? false : true'
group: jumpmarker
position: 'before sectionId'
editorOptions:
# Implements a simplified version of the title generation from CodeQ.JumpMarkers:Integration.Helper.NodeTitle
placeholder: "ClientEval: (node.properties.hashMenuTitle || node.properties.heroTitle || node.properties.title || '').replace(/<[^>]*>/g, ' ').substr().trim().replace(/(.*)[:.]$/, /*removeDotsFromTheEnd*/ '$1')"
sectionId:
type: string
ui:
reloadIfChanged: true
label: i18n
inspector:
group: jumpmarker
editorOptions:
# Implements the most common subset of CodeQ.JumpMarkers:Integration.Helper.NodeAnchorId,
# fully implementing Carbon.String.urlize(value) would bloat the code too much
placeholder: "ClientEval: (node.properties.id || node.properties.hashMenuTitle || node.properties.title || ('node-id-' + node.identifier)).replace('&nbsp;', '-').replace(/<[^>]*>/g, ' ').substr(0, 100).trim().toLowerCase().replaceAll('ä', 'ae').replaceAll('ü', 'ue').replaceAll('ö', 'oe').replaceAll('ß', 'ss').replace(/[^A-Za-z0-9\/]+/g, '-').trim().replace(/^.*?([a-z].*)$/, /*remove non-alpha chars from start*/ '$1').replace(/(.*)-$/, /*remove dashes from end*/ '$1')"
help:
message: i18n
validation:
'Neos.Neos/Validation/StringLengthValidator':
minimum: 1
maximum: 255
'Neos.Neos/Validation/RegularExpressionValidator':
regularExpression: '/^[a-z][a-z0-9\-]*$/i'
12 changes: 12 additions & 0 deletions Configuration/Policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
privilegeTargets:
'Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilege':
'CodeQ.JumpMarkers:NodeToUri':
label: Access to the backend for converting a node to an absolute uri
matcher: 'method(CodeQ\JumpMarkers\Controller\BackendController->nodeToUriAction())'

roles:
'Neos.Neos:AbstractEditor':
privileges:
-
privilegeTarget: 'CodeQ.JumpMarkers:NodeToUri'
permission: GRANT
9 changes: 9 additions & 0 deletions Configuration/Routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-
name: 'Node to absolute uri'
uriPattern: 'neos/jump-markers-node-to-uri'
defaults:
'@package': 'CodeQ.JumpMarkers'
'@controller': 'Backend'
'@action': 'nodeToUri'
'@format': 'html'
appendExceedingArguments: true
32 changes: 32 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Neos:
Flow:
mvc:
routes:
'CodeQ.JumpMarkers':
position: 'start'
security:
authentication:
providers:
'Neos.Neos:Backend':
requestPatterns:
'CodeQ.JumpMarkers:Controllers':
pattern: 'ControllerObjectName'
patternOptions:
controllerObjectNamePattern: 'CodeQ\JumpMarkers\Controller\.*'
Neos:
fusion:
autoInclude:
CodeQ.JumpMarkers: true
userInterface:
translation:
autoInclude:
CodeQ.JumpMarkers:
- Main
- 'NodeTypes/*'
requireJsPathMapping:
CodeQ.JumpMarkers/Views: 'resource://CodeQ.JumpMarkers/Public/JavaScript/Inspector/Views'
Ui:
resources:
javascript:
'CodeQ.JumpMarkers:AnchorView':
resource: resource://CodeQ.JumpMarkers/Public/JavaScript/AnchorView/Plugin.js

0 comments on commit f82bf3b

Please sign in to comment.