-
Notifications
You must be signed in to change notification settings - Fork 18
FEATURE: Add IFrame Media Chooser API #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
skurfuerst
wants to merge
1
commit into
Flowpack:main
Choose a base branch
from
skurfuerst:media-chooser-iframe-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,52 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Flowpack\Media\Ui\Controller; | ||
|
|
||
| /* | ||
| * This file is part of the Flowpack.Media.Ui package. | ||
| * | ||
| * (c) Contributors of the Neos Project - www.neos.io | ||
| * | ||
| * This package is Open Source Software. For the full copyright and license | ||
| * information, please view the LICENSE file which was distributed with this | ||
| * source code. | ||
| */ | ||
|
|
||
| use Neos\Flow\Annotations as Flow; | ||
| use Neos\Fusion\View\FusionView; | ||
| use Neos\Neos\Controller\Module\AbstractModuleController; | ||
|
|
||
| /** | ||
| * This is the entry point for choosing Media by opening an iframe. This is useful for | ||
| * Flow applications or "traditional" non-React Neos Backend Modules. | ||
| * | ||
| * @Flow\Scope("singleton") | ||
| */ | ||
| class IframeMediaChooserController extends AbstractModuleController | ||
| { | ||
| /** | ||
| * @var FusionView | ||
| */ | ||
| protected $view; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| protected $defaultViewObjectName = FusionView::class; | ||
|
|
||
| /** | ||
| * @var array | ||
| */ | ||
| protected $viewFormatToObjectNameMap = [ | ||
| 'html' => FusionView::class, | ||
| ]; | ||
|
|
||
| /** | ||
| * Renders the media chooser | ||
| */ | ||
| public function indexAction(): void | ||
| { | ||
| } | ||
| } |
This file contains hidden or 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,57 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Flowpack\Media\Ui\Eel; | ||
|
|
||
| /* | ||
| * This file is part of the Flowpack.Media.Ui package. | ||
| * | ||
| * (c) Contributors of the Neos Project - www.neos.io | ||
| * | ||
| * This package is Open Source Software. For the full copyright and license | ||
| * information, please view the LICENSE file which was distributed with this | ||
| * source code. | ||
| */ | ||
|
|
||
| use Neos\Flow\Annotations as Flow; | ||
| use Neos\Eel\ProtectedContextAwareInterface; | ||
| use Neos\Neos\Service\UserService; | ||
| use Neos\Neos\Service\XliffService; | ||
|
|
||
| /** | ||
| * This helper is used inside the view rendering of {@see IframeMediaChooserController}, | ||
| * to set up a HTML environment as close as possible to the the Fluid-based backend modules. | ||
| * | ||
| * This is a workaround and should NOT be relied upon externally. | ||
| * | ||
| * @internal | ||
| */ | ||
| class MediaChooserNeosConfigHelper implements ProtectedContextAwareInterface | ||
| { | ||
| /** | ||
| * @Flow\Inject | ||
| * @var UserService | ||
| */ | ||
| protected $userService; | ||
|
|
||
| /** | ||
| * @Flow\Inject | ||
| * @var XliffService | ||
| */ | ||
| protected $xliffService; | ||
|
|
||
| public function allowsCallOfMethod($methodName) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| public function backendInterfaceLanguage() | ||
| { | ||
| return $this->userService->getInterfaceLanguage(); | ||
| } | ||
|
|
||
| public function backendXliffCacheVersion() | ||
| { | ||
| return $this->xliffService->getCacheVersion(); | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| include: resource://Neos.Fusion/Private/Fusion/Root.fusion | ||
| include: **/* |
42 changes: 42 additions & 0 deletions
42
Resources/Private/Fusion/Views/IframeMediaChooserController.fusion
This file contains hidden or 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,42 @@ | ||
| // This is the rendering of the stand-alone Iframe Media Selection mode. | ||
| // It emulates the Fluid-based backend layout and calls the Neos JS Bootstrap, | ||
| // so that the Media Selection UI can access e.g. the Neos translations as usual. | ||
| // | ||
| // This whole file is a WORKAROUND and should only be used until we can move some of this | ||
| // into the Neos Core. | ||
| Flowpack.Media.Ui.IframeMediaChooserController { | ||
| index = Neos.Fusion:Component { | ||
| mediaModule = Flowpack.Media.Ui:MediaModule | ||
|
|
||
| _neosJavascriptBasePath = ${StaticResource.uri('Neos.Neos', 'Public/JavaScript')} | ||
| _initScript = ${'<script>window.NeosCMS = {}; window.NeosCMS.Configuration = {}; window.NeosCMS.Configuration.neosJavascriptBasePath = ' + Json.stringify(this._neosJavascriptBasePath) + ';</script>'} | ||
|
|
||
| _xliffAsJsonUri = Neos.Fusion:UriBuilder { | ||
| package = 'Neos.Neos' | ||
| controller = 'Backend\\Backend' | ||
| action = 'xliffAsJson' | ||
| arguments { | ||
| locale = ${FlowpackMediaUi.MediaChooserNeosConfig.backendInterfaceLanguage()} | ||
| version = ${FlowpackMediaUi.MediaChooserNeosConfig.backendXliffCacheVersion()} | ||
| } | ||
| absolute = true | ||
| } | ||
|
|
||
| renderer = afx` | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" href={StaticResource.uri('Neos.Neos', 'Public/Styles/Minimal.css')} /> | ||
| <link rel="stylesheet" href={StaticResource.uri('Flowpack.Media.Ui', 'Public/Assets/main.bundle.css')} /> | ||
|
|
||
| <link rel="neos-xliff" href={props._xliffAsJsonUri} /> | ||
| </head> | ||
| <body class="neos neos-module" style="background-color: #222"> | ||
| {props.mediaModule} | ||
| {props._initScript} | ||
| <script src={StaticResource.uri('Neos.Neos', 'Public/JavaScript/Main.min.js')}></script> | ||
| <script src={StaticResource.uri('Flowpack.Media.Ui', 'Public/Assets/main.bundle.js')}></script> | ||
| </body> | ||
| </html> | ||
| ` | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,27 +1,29 @@ | ||
| Flowpack.Media.Ui.MediaController { | ||
| index = Neos.Fusion:Component { | ||
| data-endpoints = Neos.Fusion:DataStructure { | ||
| graphql = '/neos/graphql/media-assets' | ||
| upload = Neos.Fusion:UriBuilder { | ||
| package = 'Flowpack.Media.Ui' | ||
| controller = 'Upload' | ||
| action = 'upload' | ||
| format = 'json' | ||
| } | ||
| @process.stringify = ${Json.stringify(value)} | ||
| prototype(Flowpack.Media.Ui:MediaModule) < prototype(Neos.Fusion:Component) { | ||
| data-endpoints = Neos.Fusion:DataStructure { | ||
| graphql = '/neos/graphql/media-assets' | ||
| upload = Neos.Fusion:UriBuilder { | ||
| package = 'Flowpack.Media.Ui' | ||
| controller = 'Upload' | ||
| action = 'upload' | ||
| format = 'json' | ||
| } | ||
| @process.stringify = ${Json.stringify(value)} | ||
| } | ||
|
|
||
| data-dummy-image = Neos.Fusion:ResourceUri { | ||
| path = 'resource://Neos.Neos/Public/Images/dummy-image.svg' | ||
| } | ||
| data-dummy-image = Neos.Fusion:ResourceUri { | ||
| path = 'resource://Neos.Neos/Public/Images/dummy-image.svg' | ||
| } | ||
|
|
||
| data-features = ${Configuration.setting('Neos.Neos.Ui.frontendConfiguration')['Flowpack.Media.Ui']} | ||
| [email protected] = ${Json.stringify(value)} | ||
| data-features = ${Configuration.setting('Neos.Neos.Ui.frontendConfiguration')['Flowpack.Media.Ui']} | ||
| [email protected] = ${Json.stringify(value)} | ||
|
|
||
| renderer = afx` | ||
| <div id="media-ui-app" {...props}> | ||
| Loading media ui... | ||
| </div> | ||
| ` | ||
| } | ||
| renderer = afx` | ||
| <div id="media-ui-app" {...props}> | ||
| Loading media ui... | ||
| </div> | ||
| ` | ||
| } | ||
|
|
||
| Flowpack.Media.Ui.MediaController { | ||
| index = Flowpack.Media.Ui:MediaModule | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.