Skip to content

Commit

Permalink
FEATURE: Blog posts
Browse files Browse the repository at this point in the history
  • Loading branch information
aertmann committed Apr 19, 2016
1 parent a4eddcb commit 9c2def8
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 1 deletion.
@@ -0,0 +1,42 @@
<?php
namespace Neos\NeosIo\DataSource;

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Persistence\PersistenceManagerInterface;
use TYPO3\Neos\Domain\Service\UserService;
use TYPO3\Neos\Service\DataSource\AbstractDataSource;
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;

class EditorsDataSource extends AbstractDataSource {

/**
* @var string
*/
static protected $identifier = 'neos-neosio-editors';

/**
* @Flow\Inject
* @var UserService
*/
protected $userService;

/**
* @Flow\Inject
* @var PersistenceManagerInterface
*/
protected $persistenceManager;

/**
* @param NodeInterface $node The node that is currently edited (optional)
* @param array $arguments Additional arguments (key / value)
* @return array
*/
public function getData(NodeInterface $node, array $arguments) {
$options = [];
foreach ($this->userService->getUsers() as $user) {
$options[$this->persistenceManager->getIdentifierByObject($user)] = ['label' => $user->getLabel()];
}
return $options;
}

}
@@ -0,0 +1,32 @@
<?php
namespace Neos\NeosIo\Eel\Helper;

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Neos\Domain\Repository\UserRepository;

class DataHelper extends \TYPO3\Eel\Helper\ArrayHelper {

/**
* @Flow\Inject
* @var UserRepository
*/
protected $userRepository;

/**
* @param array $userIdentifiers
* @return array<User>
*/
public function users($userIdentifiers) {
$users = [];
foreach ($userIdentifiers as $userIdentifier) {
$user = $this->userRepository->findByIdentifier($userIdentifier);
if ($user) {
$users[] = $user;
}
}
return implode(', ', array_map(function($user) {
return $user->getLabel();
}, $users));
}

}
144 changes: 144 additions & 0 deletions Packages/Sites/Neos.NeosIo/Configuration/NodeTypes.Post.yaml
@@ -0,0 +1,144 @@
'Neos.NeosIo:Post':
superTypes:
'TYPO3.Neos.NodeTypes:Page': TRUE
'TYPO3.Neos.NodeTypes:ImageMixin': TRUE
'TYPO3.Neos.NodeTypes:ImageCaptionMixin': TRUE
'TYPO3.Neos.Seo:TitleTagMixin': FALSE
'TYPO3.Neos.Seo:TwitterCardMixin': FALSE
'TYPO3.Neos.Seo:CanonicalLinkMixin': FALSE
'TYPO3.Neos.Seo:OpenGraphMixin': FALSE
'TYPO3.Neos.Seo:XmlSitemapMixin': FALSE
ui:
label: 'Post'
icon: 'icon-newspaper'
inspector:
groups:
options:
label: 'Options'
position: 20
author:
label: 'Author'
position: 30
image:
position: 40
collapsed: true
seometa:
position: 50
tab: ~
properties:
datePublished:
type: 'DateTime'
defaultValue: 'now'
ui:
label: 'Publication Date'
reloadPageIfChanged: TRUE
inspector:
group: 'options'
editorOptions:
format: 'Y-m-d'
validation:
'TYPO3.Neos/Validation/NotEmptyValidator': []
'TYPO3.Neos/Validation/DateTimeValidator': []
title:
validation: ~
ui:
inlineEditable: TRUE
inspector:
group: ~
aloha:
placeholder: 'Enter title here'
'format':
'b': TRUE
'i': TRUE
'u': TRUE
'sub': TRUE
'sup': TRUE
'p': FALSE
'h1': FALSE
'h2': FALSE
'h3': FALSE
'pre': FALSE
'removeFormat': FALSE
'table': []
'list': []
'link':
'a': TRUE
'alignment': []
'formatlesspaste':
'button': FALSE
'formatlessPasteOption': TRUE
summary:
type: 'string'
ui:
inlineEditable: TRUE
aloha:
placeholder: 'Enter summary here'
format:
b: TRUE
i: TRUE
u: TRUE
sub: TRUE
sup: TRUE
p: TRUE
h1: TRUE
h2: TRUE
h3: TRUE
h4: FALSE
h5: FALSE
h6: FALSE
removeFormat: TRUE
table:
table: TRUE
link:
a: TRUE
list:
ul: TRUE
ol: TRUE
alignment:
left: TRUE
center: TRUE
right: TRUE
justify: TRUE
featured:
type: boolean
ui:
label: 'Featured'
inspector:
group: 'options'
authors:
type: 'array'
ui:
label: 'Author(s)'
position: 10
reloadPageIfChanged: TRUE
inspector:
group: 'author'
editor: 'TYPO3.Neos/Inspector/Editors/SelectBoxEditor'
editorOptions:
placeholder: 'Choose'
dataSourceIdentifier: 'neos-neosio-editors'
authorAlternative:
type: 'string'
ui:
label: 'Author (alt)'
position: 20
reloadPageIfChanged: TRUE
inspector:
group: 'author'
relatedDocuments:
type: 'references'
ui:
label: 'Related documents'
reloadPageIfChanged: TRUE
inspector:
group: 'options'
editorOptions:
nodeTypes: ['TYPO3.Neos:Document']
metaRobotsNoindex:
ui:
inspector:
group: ~
metaRobotsNofollow:
ui:
inspector:
group: ~
5 changes: 4 additions & 1 deletion Packages/Sites/Neos.NeosIo/Configuration/Settings.yaml
Expand Up @@ -18,7 +18,6 @@ TYPO3:
position: 'after general'
label: 'Special'


TYPO3CR:
Search:
# disable realtime search-index updating, as many bugs during publishing appear because of Elasticsearch
Expand All @@ -30,6 +29,10 @@ TYPO3:
# drastically reduces index size and speeds up indexing.
indexAllWorkspaces: false

TypoScript:
defaultContext:
Data: 'Neos\NeosIo\Eel\Helper\DataHelper'

Neos:
NeosIo:
googleAnalyticsTrackingCode: null
Expand Down
@@ -0,0 +1,59 @@
{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace media=TYPO3\Media\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}

<!DOCTYPE html>
<html>
<body>
<f:section name="body">
<f:render partial="SiteHeader.html" arguments="{_all}" />
<f:render partial="KeyVisual.html" arguments="{
isKeyVisualContentsInverted: true,
keyVisualImage: keyVisualImage,
keyVisualImageSrcSet: keyVisualImageSrcSet
}" />

<nav>
{parts.breadcrumb -> f:format.raw()}
</nav>
{content.main -> f:format.raw()}

<f:render partial="SiteFooter.html" arguments="{_all}" />
</f:section>
<f:section name="post">
<div class="stage stage--bright" id="mainContent">
<div class="stage__contents">
<div class="g">
<main class="gi u-w1/1 u-wm9/12" role="main">
<section>
<neos:contentElement.wrap node="{node}">
<time datetime="{datePublished -> f:format.date(format: 'c')}" itemprop="datePublished">{datePublished -> media:format.relativeDate()}</time>
<f:if condition="{author}">
<span itemprop="author" itemscope="" itemtype="https://schema.org/Person"><span itemprop="name">{author}</span></span>
</f:if>
<header>
<neos:contentElement.editable property="title" tag="h1" additionalAttributes="{itemprop: 'headline'}" />
<neos:contentElement.editable property="summary" tag="h2" additionalAttributes="{itemprop: 'description'}" />
</header>
</neos:contentElement.wrap>
{content -> f:format.raw()}
</section>
</main>
<aside class="gi u-w1/1 u-wm3/12 sideBar">
<nav>
<f:if condition="{relatedDocuments}">
<div class="h5">Related</div>
<ul>
<f:for each="{relatedDocuments}" as="relatedDocument">
<li><neos:link.node node="{relatedDocument}" /></li>
</f:for>
</ul>
</f:if>
</nav>
</aside>
</div>
</div>
</div>
</f:section>
</body>
</html>
@@ -0,0 +1,71 @@
prototype(Neos.NeosIo:Post.Document) < prototype(Neos.NeosIo:DefaultPage) {
head {
twitterCard = TYPO3.TypoScript:Array {
@if.isEnabledBlank = 1
@if.isEnabled = 1

cardTypeTag.attributes.content = 'summary'

cardTitleTag {
attributes.content = ${String.crop(String.stripTags(q(node).property('title')), 67, '...')}
@if.isNotBlank = 1
}

cardDescriptionTag {
attributes.content = ${String.crop(String.stripTags(q(node).property('summary')) ? String.stripTags(q(node).property('summary')) : q(node).property('metaDescription'), 197, '...')}
@if.isNotBlank = 1
}

cardImageTag {
attributes.content.asset = ${q(node).property('image')}
@if.isImageSet = ${q(node).property('image') != null}
}
}

openGraphMetaTags {
@context.openGraphType = 'article'

openGraphTitleTag {
@context.openGraphTitle = ${String.crop(String.stripTags(q(node).property('title')), 67, '...')}
}

openGraphDescriptionTag {
@context.openGraphDescription = ${String.crop(String.stripTags(q(node).property('summary')) ? String.stripTags(q(node).property('summary')) : q(node).property('metaDescription'), 152, '...')}
}

openGraphImageTag {
@context.openGraphImage = ${q(node).property('image')}
}

openGraphPublishedTime = TYPO3.TypoScript:Tag {
tagName = 'meta'
attributes {
property = 'article:published_time'
content = ${Date.format(q(node).property('datePublished'), 'c')}
}
}
}
}

body {
templatePath = 'resource://Neos.NeosIo/Private/Templates/Page/Post.html'
title = ${q(node).property('title')}
image = ${q(node).property('image')}
content {
// The default content section
main = Neos.NeosIo:Post {
templatePath = 'resource://Neos.NeosIo/Private/Templates/Page/Post.html'
sectionName = 'post'
content = PrimaryContent {
nodePath = 'main'
}
}
}
keyVisualImage = ${q(documentNode).property('image')}
keyVisualImageSrcSet = TYPO3.TypoScript:Template {
templatePath = 'resource://Neos.NeosIo/Private/Templates/Page/Partials/KeyVisual.html'
sectionName = 'imageSrcSet'
keyVisualImage = ${q(documentNode).property('image')}
}
}
}
@@ -0,0 +1,3 @@
prototype(Neos.NeosIo:Post) {
author = ${this.authors ? Data.users(this.authors) + this.authorAlternative : this.authorAlternative}
}

0 comments on commit 9c2def8

Please sign in to comment.