sitegeist/noderobis

v2.0.0 2023-08-28 12:15 UTC

README

Cli-kickstarter for Neos CMS - NodeTypes

作者 & 赞助商

此包的开发和公共发布得到了我们雇主 http://www.sitegeist.de 的慷慨赞助。

安装

Sitegeist.Noderobis 可通过 Packagist 获取,并可以使用命令 composer require sitegeist/noderobis 进行安装。

我们使用语义版本控制,每次重大变更都会增加主版本号。

使用方法

该包提供 cli 命令来定义新的 nodetypes。这些命令将创建一个 NodeTypes/*.yaml 文件和一个 NodeTypes/*.fusion 渲染器(用于非抽象 nodetypes),该渲染器通过 afx 渲染所有属性和子项。

PACKAGE "SITEGEIST.NODEROBIS":
-------------------------------------------------------------------------------
  kickstart:document                       
  kickstart:content                        
  kickstart:mixin                          

创建 Document|Content|Mixin NodeTypes 的命令

./flow kickstart:document [<options>] <name>
./flow kickstart:content [<options>] <name>
./flow kickstart:mixin [<options>] <name>

ARGUMENTS:
  --name               Node Name, last part of NodeType

OPTIONS:
  --package-key        (optional) Package, uses fallback from configuration
  --mixin              (optional) Mixin-types to add as SuperTypes, can be used
                       multiple times
  --child-node         (optional) childNode-names and childNode-NodeType
                       seperated by a colon, can be used multiple times
  --property           (optional) property-names and property-NodeType
                       seperated by a colon, can be used multiple times
  --abstract           (optional) By default contents and documents are created
                       non abstract
  --yes                (optional) Skip refinement-process and apply all
                       modifications directly

规范细化

创建命令将在初始规范创建后调用交互式细化过程。这将允许指定额外的属性、mixins 等,因为将这些全部放入单个 cli 调用中将会非常繁琐。

Vendor.Example:Document.Article
  SuperTypes: Neos.Neos:Document

What is next?
  [0] FINISH and generate files
  [1] add Label
  [2] add Icon
  [3] add Property
  [4] add ChildNode
  [5] add SuperType
  [6] add Mixin
  [7] make Abstract
  [8] exit
 > 

细化会显示迄今为止的规范摘要,并提供进行调整的选项。一旦您满意,请选择 "完成并生成文件" 以触发生成过程。

配置

该包允许为 packageKeys、superTypes 和每个属性类型的生成融合代码配置默认值。

Sitegeist:
  Noderobis:
    # package key to be used by default if none is specified
    defaultPackageKey: ~

    # default supertypes for nodetypes when no supertype is found in the package namespace
    superTypeDefaults:
      Document: Neos.Neos:Document
      Content: Neos.Neos:Content

    # modification generators that will be applied
    modificationGenerators:
      createNodeTypeYamlFile: '\Sitegeist\Noderobis\Domain\Generator\CreateNodeTypeYamlFileModificationGenerator'
      createFusionRenderer: '\Sitegeist\Noderobis\Domain\Generator\CreateFusionRendererModificationGenerator'
      includeFusionFromNodeTypes: '\Sitegeist\Noderobis\Domain\Generator\IncludeFusionFromNodeTypesModificationGenerator'
      
    # configuration for accessing and rendering properties in fusion the key `default` is used if no special
    # config is found for a type
    properties:
      'default':
        prop: '###NAME### = ${q(node).property("###NAME###")}'
        afx: '{String.htmlSpecialChars(Json.serialize(props.###NAME###))}'
      'inlineEditable':
        afx: '<Neos.Neos:Editable property="###NAME###" />'
      'Neos\Media\Domain\Model\ImageInterface':
        afx: '<Neos.Neos:ImageTag asset={props.###NAME###} preset="Neos.Media.Browser:Thumbnail" />'
      'Neos\Media\Domain\Model\Asset':
        afx: '<Neos.Fusion:Link.Resource href.resource={props.###NAME###.resource} >{props.###NAME###.label}</Neos.Fusion:Link.Resource>'
      'array<Neos\Media\Domain\Model\Asset>':
        afx: '<ul><Neos.Fusion:Loop items={props.###NAME###} itemName="asset"><li><Neos.Fusion:Link.Resource href.resource={asset.resource} >{asset.label}</Neos.Fusion:Link.Resource></li></Neos.Fusion:Loop></ul>'
      'DateTime':
        afx: '{Date.format(props.###NAME### , "Y-m-d")}'
      'reference':
        afx: '<Neos.Neos:NodeLink node={props.###NAME###} >{props.###NAME###.label}</Neos.Neos:NodeLink>'
      'references':
        afx: '<ul><Neos.Fusion:Loop items={props.###NAME###} itemName="reference"><li><Neos.Neos:NodeLink node={reference} >{reference.label}</Neos.Neos:NodeLink></li></Neos.Fusion:Loop></ul>'
      'string':
        afx: '{props.###NAME###}'
      'integer':
        afx: '{props.###NAME###}'
      'boolean':
        afx: '{props.###NAME### ? "true" : "false"}'

支持 Sitegeist.Kaleidoscope 的配置

以下 Settings.yaml 调整了 Neos\Media\Domain\Model\ImageInterface props 生成的代码,以使用 Sitegeist.Kaleidoscope 包。

Sitegeist:
  Noderobis:
    properties:

      # Adjust generation of Image props to render using Sitegeist.Kaleidoscope
      # with fallback to a dummy image in backend
      'Neos\Media\Domain\Model\ImageInterface':
        prop: |
          ###NAME### = Neos.Fusion:Case {
              image {
                  condition = ${q(node).property('###NAME###')}
                  renderer = Sitegeist.Kaleidoscope:AssetImageSource {
                      asset = ${q(node).property('###NAME###')}
                      # @todo !!! ensure property ###NAME###Title really exists
                      title = ${q(node).property('###NAME###Title')}
                      # @todo !!! ensure property ###NAME###Alt really exists
                      alt = ${q(node).property('###NAME###Alt')}
                  }
              }
              dummyImage {
                  condition = ${node.context.inBackend}
                  renderer = Sitegeist.Kaleidoscope:DummyImageSource {
                      alt = "dummy"
                      title = "image"
                  }
              }
          }
        afx: '<Sitegeist.Kaleidoscope:Image imageSource={props.###NAME###} />'

工作原理

该包首先将使用 cli 流程生成一个 NodeTypeSpecification 值对象。此规范用于创建一个 NodeType 对象。然后,该对象用于生成所需的 NodeTypes/*.yaml 文件和用于渲染的 NodeTypes/*.fusion 文件。

贡献

我们非常乐意接受贡献。请发送给我们 pull 请求。