-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a78c3f7
Showing
14 changed files
with
1,090 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace Vette\CodeBlock\DataSources; | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
use Neos\Neos\Service\DataSource\AbstractDataSource; | ||
|
||
/** | ||
* GeshiLanguages DataSource | ||
*/ | ||
class GeshiLanguagesDataSource extends AbstractDataSource | ||
{ | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public static function getIdentifier() | ||
{ | ||
return 'geshiLanguages'; | ||
} | ||
|
||
/** | ||
* @param NodeInterface|null $node | ||
* @param array $arguments | ||
* @return array | ||
*/ | ||
public function getData(NodeInterface $node = null, array $arguments) | ||
{ | ||
$geshi = new \GeSHi(); | ||
$languages = $geshi->get_supported_languages(true); | ||
$data = array(); | ||
foreach ($languages as $language => $fullName) { | ||
$data[] = array( | ||
'value' => $language, | ||
'label' => $fullName | ||
); | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace Vette\CodeBlock\NodeTypes; | ||
|
||
use Neos\Fusion\FusionObjects\AbstractFusionObject; | ||
|
||
/** | ||
* CodeBlock Implementation | ||
*/ | ||
class CodeBlockImplementation extends AbstractFusionObject { | ||
|
||
/** | ||
* Evaluate | ||
* | ||
* @return string | ||
*/ | ||
public function evaluate() | ||
{ | ||
$source = $this->fusionValue('code'); | ||
$language = $this->fusionValue('language'); | ||
$showLineNumbers = $this->fusionValue('showLineNumbers'); | ||
$startLinesAt = $this->fusionValue('startLinesAt'); | ||
$highlightLines = $this->fusionValue('highlightLines'); | ||
$inlineCss = $this->fusionValue('inlineCss'); | ||
|
||
$geshi = new \GeSHi($source, $language); | ||
$geshi->start_line_numbers_at($startLinesAt); | ||
$geshi->highlight_lines_extra($highlightLines); | ||
$geshi->set_overall_class('code-block'); | ||
|
||
if (!$inlineCss) { | ||
$geshi->enable_classes(); | ||
} | ||
|
||
if ($showLineNumbers) { | ||
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); | ||
} | ||
|
||
return $geshi->parse_code(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'Vette.CodeBlock:CodeBlock': | ||
superTypes: | ||
'Neos.Neos:Content': TRUE | ||
ui: | ||
label: i18n | ||
icon: 'icon-code' | ||
group: 'general' | ||
inspector: | ||
groups: | ||
'codeBlock': | ||
label: 'Code Block' | ||
properties: | ||
code: | ||
type: string | ||
ui: | ||
reloadIfChanged: true | ||
label: i18n | ||
inspector: | ||
group: 'codeBlock' | ||
editor: 'Neos.Neos/Inspector/Editors/CodeEditor' | ||
editorOptions: | ||
buttonLabel: 'Edit' | ||
highlightingMode: 'text/plain' | ||
language: | ||
defaultValue: 'text' | ||
type: string | ||
ui: | ||
reloadIfChanged: true | ||
label: i18n | ||
inspector: | ||
group: 'codeBlock' | ||
editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' | ||
editorOptions: | ||
dataSourceIdentifier: 'geshiLanguages' | ||
|
||
showLineNumbers: | ||
type: boolean | ||
defaultValue: true | ||
ui: | ||
reloadIfChanged: true | ||
label: i18n | ||
inspector: | ||
group: 'codeBlock' | ||
startLinesAt: | ||
type: integer | ||
defaultValue: 1 | ||
ui: | ||
reloadIfChanged: true | ||
label: i18n | ||
inspector: | ||
group: 'codeBlock' | ||
highlightLines: | ||
type: string | ||
ui: | ||
reloadIfChanged: true | ||
label: i18n | ||
inspector: | ||
group: 'codeBlock' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Neos: | ||
Neos: | ||
fusion: | ||
autoInclude: | ||
'Vette.CodeBlock': TRUE | ||
userInterface: | ||
translation: | ||
autoInclude: | ||
'Vette.CodeBlock': ['NodeTypes/*'] |
Oops, something went wrong.