Skip to content

Commit

Permalink
Added support for configurable location of external libraries
Browse files Browse the repository at this point in the history
Also upgraded ACE dependency to latest version
  • Loading branch information
gnikolaidis committed Feb 27, 2019
1 parent 6b4ca8e commit bdb8bd1
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 32 deletions.
17 changes: 15 additions & 2 deletions qookery/source/class/qookery/Qookery.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ qx.Class.define("qookery.Qookery", {
*/
OPTION_DEFAULT_NATIVE_CONTEXT_MENU: "q:default-native-context-menu",

/**
* {String} Path to directory containing external libraries used by Qookery, defaults to <code>qookery/lib</code>.
*/
OPTION_EXTERNAL_LIBRARIES: "q:external-libraries",

// Services

/**
Expand All @@ -79,7 +84,12 @@ qx.Class.define("qookery.Qookery", {
*/
SERVICE_RESOURCE_LOADER: "qookery.IResourceLoader",

__OPTIONS: { },
__OPTIONS: {

// Default values

"q:external-libraries": "qookery/lib"
},

/**
* Return an option's value
Expand All @@ -90,8 +100,10 @@ qx.Class.define("qookery.Qookery", {
* @return {any} option value
*/
getOption: function(optionName, defaultValue) {
qx.core.Assert.assertString(optionName);
var value = qookery.Qookery.__OPTIONS[optionName];
if(value === undefined) return defaultValue;
if(value === undefined)
return defaultValue;
return value;
},

Expand All @@ -102,6 +114,7 @@ qx.Class.define("qookery.Qookery", {
* @param value {any} new option value
*/
setOption: function(optionName, value) {
qx.core.Assert.assertString(optionName);
qookery.Qookery.__OPTIONS[optionName] = value;
},

Expand Down
3 changes: 3 additions & 0 deletions qookery/source/class/qookery/internal/util/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ qx.Class.define("qookery.internal.util.Library", {
else if(qx.lang.String.endsWith(resourceName, ".css")) {
resourceType = "css";
}
resourceName = resourceName.replace(/\$\{([\w:-]*)\}/g, function(match, optionName) {
return qookery.Qookery.getOption(optionName);
});

var resourceLoader = qookery.Qookery.getService("qookery.IResourceLoader", true);
var resourceUri = resourceLoader.resolveResourceUri(resourceName);
Expand Down
2 changes: 1 addition & 1 deletion qookeryace/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-->
<project name="qookery.ace" basedir=".">

<property name="ace.version" value="1.2.8" />
<property name="ace.version" value="1.4.3" />
<property name="ace.downloadBase" value="https://raw.githubusercontent.com/ajaxorg/ace-builds/v${ace.version}/src-min" />
<property name="ace.target" location="../qookeryace/source/resource/qookery/lib/ace" />

Expand Down
1 change: 0 additions & 1 deletion qookeryace/docs/form-ace.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<attribute name="print-margin-column" type="nonNegativeInteger" default="80" />
<attribute name="show-fold-widgets" type="boolean" default="true" />
<attribute name="show-invisibles" type="boolean" default="false" />
<attribute name="show-line-numbers" type="boolean" default="true" />
<attribute name="show-gutter" type="boolean" default="true" />
<attribute name="show-print-margin" type="boolean" default="true" />
<attribute name="tab-size" type="nonNegativeInteger" default="4" />
Expand Down
2 changes: 1 addition & 1 deletion qookeryace/source/class/qookery/ace/Bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ qx.Bootstrap.define("qookery.ace.Bootstrap", {

defer: function() {
qookery.Qookery.getRegistry().registerLibrary("ace", [
(qx.core.Environment.get("qookery.ace.path") || "qookery/lib/ace") + "/ace.js"
"${q:external-libraries}/ace/ace.js"
]);
qookery.Qookery.getRegistry().registerComponentType("{http://www.qookery.org/ns/Form/Ace}editor", qookery.ace.internal.AceComponent);
}
Expand Down
29 changes: 11 additions & 18 deletions qookeryace/source/class/qookery/ace/__init__.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,23 @@

/**
* The Qookery ACE plugin allows to use the ACE editor in qookery forms
*
* The main minified ACE source file must be named ace.js and reside in
* <code>${q:external-libraries}/ace/</code>. Additional ACE files may exist
* alongside for additional themes, workers etc. To get the editor working,
* the minimal set is "ace.js" and "theme-eclipse.js".
*
* You will need to download a version of the editor with the required plugins
* yourself and include it manually into your application.
* yourself. This can be done manually, or via the included ANT task in build.xml.
*
* If you are using the javascript compiler, add the following code to your
* compile.json file:
*
* <pre>
* "include": [
* "qookery.*",
* "qookery.ace.*"
* ...
* ],
* "environment": {
* "qookery.ace.path": "subdir-of-resource-folder",
* ...
* }
* "qookery.*",
* "qookery.ace.*"
* ...
* ]
* </pre>
*
* The environment variable "qookery.ace.path" must contain the path to the
* directory containing the necessary (minified) ACE source files. This directory
* should be a subdirectory the main library's source/resource/app-namespace
* folder, since only then will these files be automatically copied to the final
* build. For example, if the library namespace is foo, and ace.js is placed
* into source/resource/foo/js/ace, define "qookery.ace.path": "foo/js/ace".
* The minimal files to get the editor running are "ace.js" and "theme-eclipse.js".
*
*/
2 changes: 0 additions & 2 deletions qookeryace/source/class/qookery/ace/internal/AceComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ qx.Class.define("qookery.ace.internal.AceComponent", {
case "highlight-active-line":
case "show-fold-widgets":
case "show-invisibles":
case "show-line-numbers":
case "show-gutter":
case "show-print-margin":
case "use-soft-tabs":
Expand Down Expand Up @@ -154,7 +153,6 @@ qx.Class.define("qookery.ace.internal.AceComponent", {
renderer.setShowGutter(this.getAttribute("show-gutter", true));
renderer.setHScrollBarAlwaysVisible(this.getAttribute("h-scroll-bar-always-visible", false));
renderer.setVScrollBarAlwaysVisible(this.getAttribute("v-scroll-bar-always-visible", false));
renderer.setOption("showLineNumbers", this.getAttribute("show-line-numbers", true));
renderer.setTheme("ace/theme/" + this.getAttribute("theme", "textmate"));

var session = editor.getSession();
Expand Down
10 changes: 5 additions & 5 deletions qookerycalendar/source/class/qookery/calendar/Bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ qx.Bootstrap.define("qookery.calendar.Bootstrap", {
defer: function() {
var registry = qookery.Qookery.getRegistry();

registry.registerLibrary("jquery", [ "qookery/lib/jquery/jquery.min.js" ], null, function() { jQuery.noConflict(); });
registry.registerLibrary("moment", [ "qookery/lib/moment/moment.min.js" ]);
registry.registerLibrary("jquery", [ "${q:external-libraries}/jquery/jquery.min.js" ], null, function() { jQuery.noConflict(); });
registry.registerLibrary("moment", [ "${q:external-libraries}/moment/moment.min.js" ]);
registry.registerLibrary("fullcalendar", [
"qookery/lib/fullcalendar/fullcalendar.min.css",
"qookery/lib/fullcalendar/fullcalendar.min.js",
"qookery/lib/fullcalendar/lang/el.js"
"${q:external-libraries}/fullcalendar/fullcalendar.min.css",
"${q:external-libraries}/fullcalendar/fullcalendar.min.js",
"${q:external-libraries}/fullcalendar/lang/el.js"
], [ "moment", "jquery" ]);

registry.registerComponentType("{http://www.qookery.org/ns/Form/Calendar}calendar", qookery.calendar.internal.CalendarComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

<ace:editor xmlns:ace="http://www.qookery.org/ns/Form/Ace"
id="jsonEditor" mode="json" flex="1" create-label="false"
tab-size="3" show-line-numbers="false" show-invisibles="true" />
tab-size="3" show-invisibles="true" />

</composite>

Expand Down
2 changes: 1 addition & 1 deletion qookeryrichtext/source/class/qookery/richtext/Bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
qx.Bootstrap.define("qookery.richtext.Bootstrap", {

defer: function() {
qookery.Qookery.getRegistry().registerLibrary("ckeditor", [ "qookery/lib/ckeditor/ckeditor.js" ], null, function() {
qookery.Qookery.getRegistry().registerLibrary("ckeditor", [ "${q:external-libraries}/ckeditor/ckeditor.js" ], null, function() {
CKEDITOR.disableAutoInline = true;
CKEDITOR.config.basicEntities = false;
CKEDITOR.config.entities = true;
Expand Down

0 comments on commit bdb8bd1

Please sign in to comment.