Skip to content
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

integrate ckeditor #46

Merged
merged 6 commits into from
Apr 15, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
/vendor/
Resources/public/vendor/hallo
vendor/
Resources/public/vendor/hallo
Resources/public/vendor/ckeditor
44 changes: 44 additions & 0 deletions Composer/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,48 @@ public static function initSubmodules($event)
die("Running git submodule --init --recursive failed with $status\n");
}
}

public static function downloadCkeditor($event)
{
$directory = __DIR__ . '/../Resources/public/vendor';
$repository = 'https://github.com/ckeditor/ckeditor-releases.git';
$commitId = 'bba29309f93a1ace1e2e3a3bd086025975abbad0';

ScriptHandler::gitSynchronize($directory, $repository, 'ckeditor', $commitId);
}

/**
* @param string $directory The parent directory where the repository should be clone into
* @param string $repository The git repository
* @param string $name The name of the clone
* @param string $commitId The commit id
*/
public static function gitSynchronize($directory, $repository, $name, $commitId)
{
$currentDirectory = getcwd();

$status = null;
$output = array();
chdir($directory);

if (is_dir($name)) {
chdir($name);
exec("git remote update", $output, $status);
if ($status) {
die("Running git pull $repository failed with $status\n");
}
} else {
exec("git clone $repository $name", $output, $status);
if ($status) {
die("Running git clone $repository failed with $status\n");
}
}

exec("git checkout $commitId", $output, $status);
if ($status) {
die("Running git clone $repository failed with $status\n");
}

chdir($currentDirectory);
}
}
1 change: 0 additions & 1 deletion Resources/public/.gitignore

This file was deleted.

46 changes: 46 additions & 0 deletions Resources/public/js/init-create-ckeditor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
jQuery(document).ready(function() {
jQuery('body').midgardCreate({
url: function() {
if (this.id) {
if (this.id.charAt(0) == "<") {
return cmfCreatePutDocument + this.id.substring(1, this.id.length - 1);
}
return cmfCreatePutDocument + "/" + this.id;
}
return cmfCreatePutDocument;
},
stanbolUrl: cmfCreateStanbolUrl,
tags: true,
editorWidgets: {
'default': 'ckeditor',
'dcterms:description': null
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the editorWidgets section should be done in userland, or not? we do not do it in the corresponding script of the hallo editor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

editorOptions: {
ckeditor: {
widget: 'ckeditorWidget'
}
},
collectionWidgets: {
'default': null,
'feature': 'midgardCollectionAdd'
}
});

window.CKEDITOR.basePath = "/bundles/symfonycmfcreate/vendor/ckeditor/";
window.CKEDITOR.plugins.basePath = "/bundles/symfonycmfcreate/vendor/ckeditor/plugins/";
window.CKEDITOR.config.skin = "moono,/bundles/symfonycmfcreate/vendor/ckeditor/skins/moono/";
window.CKEDITOR.config.customConfig = "/bundles/symfonycmfcreate/vendor/ckeditor/config.js";
window.CKEDITOR.config.removePlugins = 'smiley,flash,horizontalrule,magicline,pagebreak,iframe,wsc';
window.CKEDITOR.config.toolbarGroups = [
{ name: 'clipboard' },
{ name: 'undo' },
{ name: 'links' },
{ name: 'insert' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'align' ] },
'/',
{ name: 'styles' },
{ name: 'colors' }
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the doc will explain that you can overwrite these configuration options in a javascript loaded afterwards. i think this is good enough so we don't want to expose any configuration options to symfony for this but have people change those variables (particularly the config.customConfig path to use a non-default config.js)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's better ;)

});
9 changes: 9 additions & 0 deletions Resources/views/includejsfiles-ckeditor.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% include "SymfonyCmfCreateBundle::includejsfiles-create.html.twig" %}

<script>window.CKEDITOR_BASEPATH = "/bundles/symfonycmfcreate/vendor/ckeditor/";</script>
{% javascripts output="/js/ckeditor.js"
'@SymfonyCmfCreateBundle/Resources/public/js/init-create-ckeditor.js'
'@SymfonyCmfCreateBundle/Resources/public/vendor/ckeditor/ckeditor.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}