From 8eb43a3ebf7c1b7bd5474d8abff4223b995e911b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Sun, 18 Mar 2012 09:05:46 +0100 Subject: replaceing AttributePoolFactory by AttributePool --- src/static/js/AttributePoolFactory.js | 114 +++++++++++++++++----------------- src/static/js/Changeset.js | 4 +- src/static/js/ace2_inner.js | 3 +- src/static/js/broadcast.js | 2 +- src/static/js/changesettracker.js | 6 +- 5 files changed, 65 insertions(+), 64 deletions(-) (limited to 'src/static') diff --git a/src/static/js/AttributePoolFactory.js b/src/static/js/AttributePoolFactory.js index 00b58dbb..a9245daf 100644 --- a/src/static/js/AttributePoolFactory.js +++ b/src/static/js/AttributePoolFactory.js @@ -22,69 +22,69 @@ * limitations under the License. */ -exports.createAttributePool = function () { - var p = {}; - p.numToAttrib = {}; // e.g. {0: ['foo','bar']} - p.attribToNum = {}; // e.g. {'foo,bar': 0} - p.nextNum = 0; +var AttributePool = function () { + this.numToAttrib = {}; // e.g. {0: ['foo','bar']} + this.attribToNum = {}; // e.g. {'foo,bar': 0} + this.nextNum = 0; +}; - p.putAttrib = function (attrib, dontAddIfAbsent) { - var str = String(attrib); - if (str in p.attribToNum) { - return p.attribToNum[str]; - } - if (dontAddIfAbsent) { - return -1; - } - var num = p.nextNum++; - p.attribToNum[str] = num; - p.numToAttrib[num] = [String(attrib[0] || ''), String(attrib[1] || '')]; - return num; - }; +AttributePool.prototype.putAttrib = function (attrib, dontAddIfAbsent) { + var str = String(attrib); + if (str in this.attribToNum) { + return this.attribToNum[str]; + } + if (dontAddIfAbsent) { + return -1; + } + var num = this.nextNum++; + this.attribToNum[str] = num; + this.numToAttrib[num] = [String(attrib[0] || ''), String(attrib[1] || '')]; + return num; +}; - p.getAttrib = function (num) { - var pair = p.numToAttrib[num]; - if (!pair) { - return pair; - } - return [pair[0], pair[1]]; // return a mutable copy - }; +AttributePool.prototype.getAttrib = function (num) { + var pair = this.numToAttrib[num]; + if (!pair) { + return pair; + } + return [pair[0], pair[1]]; // return a mutable copy +}; - p.getAttribKey = function (num) { - var pair = p.numToAttrib[num]; - if (!pair) return ''; - return pair[0]; - }; +AttributePool.prototype.getAttribKey = function (num) { + var pair = this.numToAttrib[num]; + if (!pair) return ''; + return pair[0]; +}; - p.getAttribValue = function (num) { - var pair = p.numToAttrib[num]; - if (!pair) return ''; - return pair[1]; - }; +AttributePool.prototype.getAttribValue = function (num) { + var pair = this.numToAttrib[num]; + if (!pair) return ''; + return pair[1]; +}; - p.eachAttrib = function (func) { - for (var n in p.numToAttrib) { - var pair = p.numToAttrib[n]; - func(pair[0], pair[1]); - } - }; +AttributePool.prototype.eachAttrib = function (func) { + for (var n in this.numToAttrib) { + var pair = this.numToAttrib[n]; + func(pair[0], pair[1]); + } +}; - p.toJsonable = function () { - return { - numToAttrib: p.numToAttrib, - nextNum: p.nextNum - }; +AttributePool.prototype.toJsonable = function () { + return { + numToAttrib: this.numToAttrib, + nextNum: this.nextNum }; +}; - p.fromJsonable = function (obj) { - p.numToAttrib = obj.numToAttrib; - p.nextNum = obj.nextNum; - p.attribToNum = {}; - for (var n in p.numToAttrib) { - p.attribToNum[String(p.numToAttrib[n])] = Number(n); - } - return p; - }; +AttributePool.prototype.fromJsonable = function (obj) { + this.numToAttrib = obj.numToAttrib; + this.nextNum = obj.nextNum; + this.attribToNum = {}; + for (var n in this.numToAttrib) { + this.attribToNum[String(this.numToAttrib[n])] = Number(n); + } + return this; +}; + - return p; -} +module.exports = AttributePool; \ No newline at end of file diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index fd1900ba..738ee1ba 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -25,7 +25,7 @@ * limitations under the License. */ -var AttributePoolFactory = require("./AttributePoolFactory"); +var AttributePool = require("./AttributePool"); var _opt = null; @@ -1731,7 +1731,7 @@ exports.appendATextToAssembler = function (atext, assem) { * @param pool {AtributePool} */ exports.prepareForWire = function (cs, pool) { - var newPool = AttributePoolFactory.createAttributePool();; + var newPool = new AttributePool(); var newCs = exports.moveOpsToNewPool(cs, pool, newPool); return { translated: newCs, diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 66f19faf..d278254f 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -43,7 +43,7 @@ var colorutils = require('./colorutils').colorutils; var makeContentCollector = require('./contentcollector').makeContentCollector; var makeCSSManager = require('./cssmanager').makeCSSManager; var domline = require('./domline').domline; -var AttribPool = require('./AttributePoolFactory').createAttributePool; +var AttribPool = require('./AttributePool'); var Changeset = require('./Changeset'); var linestylefilter = require('./linestylefilter').linestylefilter; var newSkipList = require('./skiplist').newSkipList; @@ -51,6 +51,7 @@ var undoModule = require('./undomodule').undoModule; var makeVirtualLineView = require('./virtual_lines').makeVirtualLineView; function Ace2Inner(){ + var DEBUG = false; //$$ build script replaces the string "var DEBUG=true;//$$" with "var DEBUG=false;" // changed to false var isSetUp = false; diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index 485db44f..333e3b65 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -22,7 +22,7 @@ var makeCSSManager = require('./cssmanager').makeCSSManager; var domline = require('./domline').domline; -var AttribPool = require('./AttributePoolFactory').createAttributePool; +var AttribPool = require('./AttributePool'); var Changeset = require('./Changeset'); var linestylefilter = require('./linestylefilter').linestylefilter; var colorutils = require('./colorutils').colorutils; diff --git a/src/static/js/changesettracker.js b/src/static/js/changesettracker.js index b0219852..58ef21cb 100644 --- a/src/static/js/changesettracker.js +++ b/src/static/js/changesettracker.js @@ -20,7 +20,7 @@ * limitations under the License. */ -var AttribPool = require('./AttributePoolFactory').createAttributePool; +var AttributePool = require('./AttributePool'); var Changeset = require('./Changeset'); function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) @@ -83,7 +83,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) baseAText = Changeset.cloneAText(atext); if (apoolJsonObj) { - var wireApool = (new AttribPool()).fromJsonable(apoolJsonObj); + var wireApool = (new AttributePool()).fromJsonable(apoolJsonObj); baseAText.attribs = Changeset.moveOpsToNewPool(baseAText.attribs, wireApool, apool); } submittedChangeset = null; @@ -117,7 +117,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) if (apoolJsonObj) { - var wireApool = (new AttribPool()).fromJsonable(apoolJsonObj); + var wireApool = (new AttributePool()).fromJsonable(apoolJsonObj); c = Changeset.moveOpsToNewPool(c, wireApool, apool); } -- cgit v1.2.3 From 902837f29580996643c99e3b00e74605691cd659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Sun, 18 Mar 2012 09:06:29 +0100 Subject: renaming AttributePoolFactory --- src/static/js/AttributePool.js | 90 +++++++++++++++++++++++++++++++++++ src/static/js/AttributePoolFactory.js | 90 ----------------------------------- 2 files changed, 90 insertions(+), 90 deletions(-) create mode 100644 src/static/js/AttributePool.js delete mode 100644 src/static/js/AttributePoolFactory.js (limited to 'src/static') diff --git a/src/static/js/AttributePool.js b/src/static/js/AttributePool.js new file mode 100644 index 00000000..a9245daf --- /dev/null +++ b/src/static/js/AttributePool.js @@ -0,0 +1,90 @@ +/** + * This code represents the Attribute Pool Object of the original Etherpad. + * 90% of the code is still like in the original Etherpad + * Look at https://github.com/ether/pad/blob/master/infrastructure/ace/www/easysync2.js + * You can find a explanation what a attribute pool is here: + * https://github.com/Pita/etherpad-lite/blob/master/doc/easysync/easysync-notes.txt + */ + +/* + * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var AttributePool = function () { + this.numToAttrib = {}; // e.g. {0: ['foo','bar']} + this.attribToNum = {}; // e.g. {'foo,bar': 0} + this.nextNum = 0; +}; + +AttributePool.prototype.putAttrib = function (attrib, dontAddIfAbsent) { + var str = String(attrib); + if (str in this.attribToNum) { + return this.attribToNum[str]; + } + if (dontAddIfAbsent) { + return -1; + } + var num = this.nextNum++; + this.attribToNum[str] = num; + this.numToAttrib[num] = [String(attrib[0] || ''), String(attrib[1] || '')]; + return num; +}; + +AttributePool.prototype.getAttrib = function (num) { + var pair = this.numToAttrib[num]; + if (!pair) { + return pair; + } + return [pair[0], pair[1]]; // return a mutable copy +}; + +AttributePool.prototype.getAttribKey = function (num) { + var pair = this.numToAttrib[num]; + if (!pair) return ''; + return pair[0]; +}; + +AttributePool.prototype.getAttribValue = function (num) { + var pair = this.numToAttrib[num]; + if (!pair) return ''; + return pair[1]; +}; + +AttributePool.prototype.eachAttrib = function (func) { + for (var n in this.numToAttrib) { + var pair = this.numToAttrib[n]; + func(pair[0], pair[1]); + } +}; + +AttributePool.prototype.toJsonable = function () { + return { + numToAttrib: this.numToAttrib, + nextNum: this.nextNum + }; +}; + +AttributePool.prototype.fromJsonable = function (obj) { + this.numToAttrib = obj.numToAttrib; + this.nextNum = obj.nextNum; + this.attribToNum = {}; + for (var n in this.numToAttrib) { + this.attribToNum[String(this.numToAttrib[n])] = Number(n); + } + return this; +}; + + +module.exports = AttributePool; \ No newline at end of file diff --git a/src/static/js/AttributePoolFactory.js b/src/static/js/AttributePoolFactory.js deleted file mode 100644 index a9245daf..00000000 --- a/src/static/js/AttributePoolFactory.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * This code represents the Attribute Pool Object of the original Etherpad. - * 90% of the code is still like in the original Etherpad - * Look at https://github.com/ether/pad/blob/master/infrastructure/ace/www/easysync2.js - * You can find a explanation what a attribute pool is here: - * https://github.com/Pita/etherpad-lite/blob/master/doc/easysync/easysync-notes.txt - */ - -/* - * Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var AttributePool = function () { - this.numToAttrib = {}; // e.g. {0: ['foo','bar']} - this.attribToNum = {}; // e.g. {'foo,bar': 0} - this.nextNum = 0; -}; - -AttributePool.prototype.putAttrib = function (attrib, dontAddIfAbsent) { - var str = String(attrib); - if (str in this.attribToNum) { - return this.attribToNum[str]; - } - if (dontAddIfAbsent) { - return -1; - } - var num = this.nextNum++; - this.attribToNum[str] = num; - this.numToAttrib[num] = [String(attrib[0] || ''), String(attrib[1] || '')]; - return num; -}; - -AttributePool.prototype.getAttrib = function (num) { - var pair = this.numToAttrib[num]; - if (!pair) { - return pair; - } - return [pair[0], pair[1]]; // return a mutable copy -}; - -AttributePool.prototype.getAttribKey = function (num) { - var pair = this.numToAttrib[num]; - if (!pair) return ''; - return pair[0]; -}; - -AttributePool.prototype.getAttribValue = function (num) { - var pair = this.numToAttrib[num]; - if (!pair) return ''; - return pair[1]; -}; - -AttributePool.prototype.eachAttrib = function (func) { - for (var n in this.numToAttrib) { - var pair = this.numToAttrib[n]; - func(pair[0], pair[1]); - } -}; - -AttributePool.prototype.toJsonable = function () { - return { - numToAttrib: this.numToAttrib, - nextNum: this.nextNum - }; -}; - -AttributePool.prototype.fromJsonable = function (obj) { - this.numToAttrib = obj.numToAttrib; - this.nextNum = obj.nextNum; - this.attribToNum = {}; - for (var n in this.numToAttrib) { - this.attribToNum[String(this.numToAttrib[n])] = Number(n); - } - return this; -}; - - -module.exports = AttributePool; \ No newline at end of file -- cgit v1.2.3 From 38742401c97531d166ad5a02b4e45de913ec272f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Sun, 18 Mar 2012 11:34:56 +0100 Subject: newSkipList() -> new SkipList() --- src/static/js/ace2_inner.js | 4 ++-- src/static/js/skiplist.js | 36 +++++++----------------------------- 2 files changed, 9 insertions(+), 31 deletions(-) (limited to 'src/static') diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index d278254f..f30a0467 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -46,7 +46,7 @@ var domline = require('./domline').domline; var AttribPool = require('./AttributePool'); var Changeset = require('./Changeset'); var linestylefilter = require('./linestylefilter').linestylefilter; -var newSkipList = require('./skiplist').newSkipList; +var SkipList = require('./skiplist'); var undoModule = require('./undomodule').undoModule; var makeVirtualLineView = require('./virtual_lines').makeVirtualLineView; @@ -95,7 +95,7 @@ function Ace2Inner(){ // native IE selections have that behavior (which we try not to interfere with). // Must be false if selection is collapsed! var rep = { - lines: newSkipList(), + lines: new SkipList(), selStart: null, selEnd: null, selFocusAtStart: false, diff --git a/src/static/js/skiplist.js b/src/static/js/skiplist.js index 190bc55b..2132d8e3 100644 --- a/src/static/js/skiplist.js +++ b/src/static/js/skiplist.js @@ -20,11 +20,11 @@ * limitations under the License. */ +var Ace2Common = require('./ace2_common'); +var noop = Ace2Common.noop; +var extend = Ace2Common.extend; -var noop = require('./ace2_common').noop; - - -function newSkipList() +function SkipList() { var PROFILER = window.PROFILER; if (!PROFILER) @@ -284,27 +284,6 @@ function newSkipList() } return dist; } -/*function _debugToString() { - var array = [start]; - while (array[array.length-1] !== end) { - array[array.length] = array[array.length-1].downPtrs[0]; - } - function getIndex(node) { - if (!node) return null; - for(var i=0;i Date: Tue, 27 Mar 2012 11:44:21 +0200 Subject: use underscore in skipList --- src/static/js/skiplist.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/static') diff --git a/src/static/js/skiplist.js b/src/static/js/skiplist.js index 2132d8e3..58477acc 100644 --- a/src/static/js/skiplist.js +++ b/src/static/js/skiplist.js @@ -20,9 +20,10 @@ * limitations under the License. */ -var Ace2Common = require('./ace2_common'); +var Ace2Common = require('./ace2_common'), + _ = require('./underscore'); + var noop = Ace2Common.noop; -var extend = Ace2Common.extend; function SkipList() { @@ -324,8 +325,9 @@ function SkipList() /* The skip-list contains "entries", JavaScript objects that each must have a unique "key" property that is a string. -*/ - extend(this, { + */ + var self = this; + _.extend(this, { length: function() { return numNodes; -- cgit v1.2.3 From c55f54b972e42cdaef6cb402d84027bd39ac5774 Mon Sep 17 00:00:00 2001 From: Sofian Benaissa Date: Tue, 13 Mar 2012 11:54:49 -0300 Subject: Fix the nocolor embed parameter --- src/static/js/pad_editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/static') diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js index 12f83aeb..b8a4ea0e 100644 --- a/src/static/js/pad_editor.js +++ b/src/static/js/pad_editor.js @@ -87,8 +87,6 @@ var padeditor = (function() return defaultValue; } - self.ace.setProperty("showsauthorcolors", !settings.noColors); - self.ace.setProperty("rtlIsTrue", settings.rtlIsTrue); var v; @@ -100,6 +98,8 @@ var padeditor = (function() v = getOption('showAuthorColors', true); self.ace.setProperty("showsauthorcolors", v); padutils.setCheckbox($("#options-colorscheck"), v); + // Override from parameters + self.ace.setProperty("showsauthorcolors", !settings.noColors); v = getOption('useMonospaceFont', false); self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif")); -- cgit v1.2.3 From b2173a10846afd08012d8f082b112ca6e29f8285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Wed, 4 Apr 2012 09:40:18 +0200 Subject: get rid of node.extend (since duplicated by underscorejs) --- src/static/js/pluginfw/plugins.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/static') diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index 058f1351..3bc13ff6 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -12,7 +12,6 @@ if (!exports.isClient) { var fs = require("fs"); var tsort = require("./tsort"); var util = require("util"); - var extend = require("node.extend"); _ = require("underscore"); }else{ var $, jQuery @@ -123,7 +122,7 @@ exports.getPackages = function (cb) { function flatten(deps) { _.chain(deps).keys().each(function (name) { if (name.indexOf(exports.prefix) == 0) { - packages[name] = extend({}, deps[name]); + packages[name] = _.clone(deps[name]); // Delete anything that creates loops so that the plugin // list can be sent as JSON to the web client delete packages[name].dependencies; -- cgit v1.2.3 From 5a779794863c81cb8f297500414fdcb7e2d3ff78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Wed, 4 Apr 2012 09:51:46 +0200 Subject: make jshint happy --- src/static/js/pluginfw/plugins.js | 59 ++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'src/static') diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index 3bc13ff6..1cf1023e 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -14,7 +14,7 @@ if (!exports.isClient) { var util = require("util"); _ = require("underscore"); }else{ - var $, jQuery + var $, jQuery; $ = jQuery = require("ep_etherpad-lite/static/js/rjquery").$; _ = require("ep_etherpad-lite/static/js/underscore"); } @@ -30,15 +30,15 @@ exports.ensure = function (cb) { exports.update(cb); else cb(); -} +}; exports.formatPlugins = function () { return _.keys(exports.plugins).join(", "); -} +}; exports.formatParts = function () { return _.map(exports.parts, function (part) { return part.full_name; }).join("\n"); -} +}; exports.formatHooks = function () { var res = []; @@ -48,7 +48,7 @@ exports.formatHooks = function () { }); }); return res.join("\n"); -} +}; exports.loadFn = function (path) { var x = path.split(":"); @@ -57,7 +57,7 @@ exports.loadFn = function (path) { fn = fn[name]; }); return fn; -} +}; exports.extractHooks = function (parts, hook_set_name) { var hooks = {}; @@ -69,12 +69,12 @@ exports.extractHooks = function (parts, hook_set_name) { if (hook_fn) { hooks[hook_name].push({"hook_name": hook_name, "hook_fn": hook_fn, "hook_fn_name": hook_fn_name, "part": part}); } else { - console.error("Unable to load hook function for " + part.full_name + " for hook " + hook_name + ": " + part.hooks[hook_name]); + console.error("Unable to load hook function for " + part.full_name + " for hook " + hook_name + ": " + part.hooks[hook_name]); } }); }); return hooks; -} +}; if (exports.isClient) { @@ -89,7 +89,7 @@ if (exports.isClient) { console.error("Failed to load plugin-definitions: " + err); cb(); }); - } + }; } else { exports.update = function (cb) { @@ -103,15 +103,15 @@ exports.update = function (cb) { exports.loadPlugin(packages, plugin_name, plugins, parts, cb); }, function (err) { - exports.plugins = plugins; + exports.plugins = plugins; exports.parts = exports.sortParts(parts); exports.hooks = exports.extractHooks(exports.parts, "hooks"); - exports.loaded = true; + exports.loaded = true; cb(err); } ); }); -} + }; exports.getPackages = function (cb) { // Load list of installed NPM packages, flatten it to a list, and filter out only packages with names that @@ -121,49 +121,50 @@ exports.getPackages = function (cb) { var packages = {}; function flatten(deps) { _.chain(deps).keys().each(function (name) { - if (name.indexOf(exports.prefix) == 0) { + if (name.indexOf(exports.prefix) === 0) { packages[name] = _.clone(deps[name]); // Delete anything that creates loops so that the plugin // list can be sent as JSON to the web client delete packages[name].dependencies; delete packages[name].parent; - } - if (deps[name].dependencies !== undefined) - flatten(deps[name].dependencies); + } + + if (deps[name].dependencies !== undefined) flatten(deps[name].dependencies); }); } + var tmp = {}; tmp[data.name] = data; flatten(tmp); cb(null, packages); }); -} + }; -exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) { + exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) { var plugin_path = path.resolve(packages[plugin_name].path, "ep.json"); fs.readFile( plugin_path, function (er, data) { if (er) { - console.error("Unable to load plugin definition file " + plugin_path); + console.error("Unable to load plugin definition file " + plugin_path); return cb(); } try { var plugin = JSON.parse(data); - plugin.package = packages[plugin_name]; - plugins[plugin_name] = plugin; - _.each(plugin.parts, function (part) { - part.plugin = plugin_name; - part.full_name = plugin_name + "/" + part.name; - parts[part.full_name] = part; - }); + plugin['package'] = packages[plugin_name]; + plugins[plugin_name] = plugin; + _.each(plugin.parts, function (part) { + part.plugin = plugin_name; + part.full_name = plugin_name + "/" + part.name; + parts[part.full_name] = part; + }); } catch (ex) { - console.error("Unable to parse plugin definition file " + plugin_path + ": " + ex.toString()); + console.error("Unable to parse plugin definition file " + plugin_path + ": " + ex.toString()); } cb(); } ); -} + }; exports.partsToParentChildList = function (parts) { var res = []; @@ -179,7 +180,7 @@ exports.partsToParentChildList = function (parts) { } }); return res; -} +}; // Used only in Node, so no need for _ -- cgit v1.2.3 From 5115f74f6679af7d7eda37873c92ae936e270df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Wed, 4 Apr 2012 15:03:28 +0200 Subject: use hook name as function name, if not specified Example `"[hookName]": "ep_plugin/static/js/index:[hookName]"` becomes `"[hookName]": "ep_plugin/static/js/index"` --- src/static/js/pluginfw/plugins.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/static') diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index 058f1351..b56c0dd9 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -51,10 +51,12 @@ exports.formatHooks = function () { return res.join("\n"); } -exports.loadFn = function (path) { +exports.loadFn = function (path, hookName) { var x = path.split(":"); var fn = require(x[0]); - _.each(x[1].split("."), function (name) { + var functionName = x[1] ? x[1] : hookName; + + _.each(functionName.split("."), function (name) { fn = fn[name]; }); return fn; @@ -63,14 +65,18 @@ exports.loadFn = function (path) { exports.extractHooks = function (parts, hook_set_name) { var hooks = {}; _.each(parts,function (part) { - _.chain(part[hook_set_name] || {}).keys().each(function (hook_name) { + _.chain(part[hook_set_name] || {}) + .keys() + .each(function (hook_name) { if (hooks[hook_name] === undefined) hooks[hook_name] = []; + + var hook_fn_name = part[hook_set_name][hook_name]; - var hook_fn = exports.loadFn(part[hook_set_name][hook_name]); + var hook_fn = exports.loadFn(hook_fn_name, hook_name); if (hook_fn) { hooks[hook_name].push({"hook_name": hook_name, "hook_fn": hook_fn, "hook_fn_name": hook_fn_name, "part": part}); } else { - console.error("Unable to load hook function for " + part.full_name + " for hook " + hook_name + ": " + part.hooks[hook_name]); + console.error("Unable to load hook function for " + part.full_name + " for hook " + hook_name + ": " + part.hooks[hook_name]); } }); }); -- cgit v1.2.3 From 66fdacf9cf31343721dd8fb38a4584e11ea76e6e Mon Sep 17 00:00:00 2001 From: johnyma22 Date: Thu, 5 Apr 2012 18:04:17 +0100 Subject: move css out of html --- src/static/css/admin.css | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/static/css/admin.css (limited to 'src/static') diff --git a/src/static/css/admin.css b/src/static/css/admin.css new file mode 100644 index 00000000..80089c4c --- /dev/null +++ b/src/static/css/admin.css @@ -0,0 +1,49 @@ +table { + border-collapse: collapse; +} +td, th { + border: 1px solid black; + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + padding-bottom: 2px; +} +.template { + display: none; +} +.dialog { + display: none; + position: absolute; + left: 50%; + top: 50%; + width: 700px; + height: 500px; + margin-left: -350px; + margin-top: -250px; + border: 3px solid #999999; + background: #eeeeee; +} +.dialog .title { + margin: 0; + padding: 2px; + border-bottom: 3px solid #999999; + font-size: 24px; + line-height: 24px; + height: 24px; + overflow: hidden; +} +.dialog .title .close { + float: right; +} +.dialog .history { + background: #222222; + color: #eeeeee; + position: absolute; + top: 41px; + bottom: 10px; + left: 10px; + right: 10px; + padding: 2px; + overflow: auto; +} + -- cgit v1.2.3