Lots of fixes

This commit is contained in:
Egil Moeller 2015-04-25 19:56:22 +02:00
parent 0ec2592c53
commit e5abd185b5
10 changed files with 1140 additions and 1108 deletions

View file

@ -199,28 +199,7 @@ define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (ho
'));
iframeHTML.push('<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>');
iframeHTML.push(scriptTag('\n\
var pathComponents = parent.parent.location.pathname.split("/");\n\
var baseURL = pathComponents.slice(0,pathComponents.length-2).join("/") + "/";\n\
requirejs.config({\n\
baseUrl: baseURL + "static/plugins",\n\
paths: {underscore: baseURL + "static/plugins/underscore/underscore"}\n\
});\n\
\n\
requirejs(["ep_etherpad-lite/static/js/rjquery", "ep_etherpad-lite/static/js/pluginfw/client_plugins", "ep_etherpad-lite/static/js/ace2_inner"], function (j, plugins, Ace2Inner) {\n\
jQuery = $ = window.jQuery = window.$ = j; // Expose jQuery #HACK\n\
\n\
plugins.adoptPluginsFromAncestorsOf(window, function () {\n\
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");\n\
hooks.plugins = plugins;\n\
\n\
plugins.ensure(function () {\n\
Ace2Inner.init();\n\
});\n\
});\n\
});\n\
'));
iframeHTML.push('<script type="text/javascript" src="../static/plugins/ep_etherpad-lite/static/js/ace2_inner_main.js"></script>');
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');

View file

@ -20,7 +20,9 @@
* limitations under the License.
*/
define(["ep_etherpad-lite/static/js/rjquery", "underscore", 'ep_etherpad-lite/static/js/pluginfw/hooks'], function ($, _, hooks) {
define(["ep_etherpad-lite/static/js/rjquery", "underscore", 'ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/linestylefilter', 'ep_etherpad-lite/static/js/domline'], function ($, _, hooks, linestylefilterMod, domlineMod) {
var linestylefilter = linestylefilterMod.linestylefilter;
var domline = domlineMod.domline;
var exports = {};
var browser = require('./browser').browser;
@ -50,11 +52,9 @@ function Ace2Inner(){
var colorutils = require('./colorutils').colorutils;
var makeContentCollector = require('./contentcollector').makeContentCollector;
var makeCSSManager = require('./cssmanager').makeCSSManager;
var domline = require('./domline').domline;
var AttribPool = require('./AttributePool');
var Changeset = require('./Changeset');
var ChangesetUtils = require('./ChangesetUtils');
var linestylefilter = require('./linestylefilter').linestylefilter;
var SkipList = require('./skiplist');
var undoModule = require('./undomodule').undoModule;
var AttributeManager = require('./AttributeManager');
@ -475,6 +475,7 @@ function Ace2Inner(){
//console.log("Just did action for: "+type);
cleanExit = true;
}
/*
catch (e)
{
caughtErrors.push(
@ -485,6 +486,7 @@ function Ace2Inner(){
dmesg(e.toString());
throw e;
}
*/
finally
{
var cs = currentCallStack;

View file

@ -0,0 +1,26 @@
var pathComponents = parent.parent.location.pathname.split("/");
var baseURL = pathComponents.slice(0,pathComponents.length-2).join("/") + "/";
requirejs.config({
baseUrl: baseURL + "static/plugins",
paths: {underscore: baseURL + "static/plugins/underscore/underscore"}
});
requirejs(
[
"ep_etherpad-lite/static/js/rjquery",
"ep_etherpad-lite/static/js/pluginfw/client_plugins",
"ep_etherpad-lite/static/js/pluginfw/hooks",
"ep_etherpad-lite/static/js/ace2_inner"
],
function (j, plugins, hooks, Ace2Inner) {
jQuery = $ = window.jQuery = window.$ = j; // Expose jQuery #HACK
plugins.adoptPluginsFromAncestorsOf(window, function () {
hooks.plugins = plugins;
plugins.ensure(function () {
Ace2Inner.init();
});
});
}
);

View file

@ -20,19 +20,19 @@
* limitations under the License.
*/
var makeCSSManager = require('./cssmanager').makeCSSManager;
var domline = require('./domline').domline;
var AttribPool = require('./AttributePool');
var Changeset = require('./Changeset');
var linestylefilter = require('./linestylefilter').linestylefilter;
var colorutils = require('./colorutils').colorutils;
var _ = require('./underscore');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/linestylefilter', 'ep_etherpad-lite/static/js/domline', 'underscore'], function (hooks, linetyleFilterMod, domlineMod, _) {
var exports = {};
var makeCSSManager = require('./cssmanager').makeCSSManager;
var domline = domlineMod.domline;
var AttribPool = require('./AttributePool');
var Changeset = require('./Changeset');
var linestylefilter = linetyleFilterMod.linestylefilter;
var colorutils = require('./colorutils').colorutils;
// These parameters were global, now they are injected. A reference to the
// Timeslider controller would probably be more appropriate.
function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider)
{
// These parameters were global, now they are injected. A reference to the
// Timeslider controller would probably be more appropriate.
function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider)
{
var changesetLoader = undefined;
// Below Array#indexOf code was direct pasted by AppJet/Etherpad, licence unknown. Possible source: http://www.tutorialspoint.com/javascript/array_indexof.htm
@ -591,6 +591,9 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
receiveAuthorData(clientVars.collab_client_vars.historicalAuthorData);
return changesetLoader;
}
}
exports.loadBroadcastJS = loadBroadcastJS;
exports.loadBroadcastJS = loadBroadcastJS;
return exports;
});

View file

@ -26,17 +26,18 @@
// requires: plugins
// requires: undefined
var Security = require('./security');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var _ = require('./underscore');
var lineAttributeMarker = require('./linestylefilter').lineAttributeMarker;
var noop = function(){};
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'ep_etherpad-lite/static/js/linestylefilter', 'underscore'], function(hooks, linestylefilterMod, _) {
var exports = {};
var Security = require('./security');
var lineAttributeMarker = linestylefilterMod.lineAttributeMarker;
var noop = function(){};
var domline = {};
var domline = {};
domline.addToLineClass = function(lineClass, cls)
{
domline.addToLineClass = function(lineClass, cls)
{
// an "empty span" at any point can be used to add classes to
// the line, using line:className. otherwise, we ignore
// the span.
@ -49,12 +50,12 @@ domline.addToLineClass = function(lineClass, cls)
}
});
return lineClass;
}
}
// if "document" is falsy we don't create a DOM node, just
// an object with innerHTML and className
domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
{
// if "document" is falsy we don't create a DOM node, just
// an object with innerHTML and className
domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
{
var result = {
node: null,
appendSpan: noop,
@ -254,10 +255,10 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
return curHTML || '';
};
return result;
};
};
domline.processSpaces = function(s, doesWrap)
{
domline.processSpaces = function(s, doesWrap)
{
if (s.indexOf("<") < 0 && !doesWrap)
{
// short-cut
@ -316,6 +317,9 @@ domline.processSpaces = function(s, doesWrap)
}
}
return parts.join('');
};
};
exports.domline = domline;
exports.domline = domline;
return exports;
});

View file

@ -28,35 +28,36 @@
// requires: plugins
// requires: undefined
var Changeset = require('./Changeset');
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
var linestylefilter = {};
var _ = require('./underscore');
var AttributeManager = require('./AttributeManager');
define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (hooks, _) {
var exports = {};
linestylefilter.ATTRIB_CLASSES = {
var Changeset = require('./Changeset');
var linestylefilter = {};
var AttributeManager = require('./AttributeManager');
linestylefilter.ATTRIB_CLASSES = {
'bold': 'tag:b',
'italic': 'tag:i',
'underline': 'tag:u',
'strikethrough': 'tag:s'
};
};
var lineAttributeMarker = 'lineAttribMarker';
exports.lineAttributeMarker = lineAttributeMarker;
var lineAttributeMarker = 'lineAttribMarker';
exports.lineAttributeMarker = lineAttributeMarker;
linestylefilter.getAuthorClassName = function(author)
{
linestylefilter.getAuthorClassName = function(author)
{
return "author-" + author.replace(/[^a-y0-9]/g, function(c)
{
if (c == ".") return "-";
return 'z' + c.charCodeAt(0) + 'z';
});
};
};
// lineLength is without newline; aline includes newline,
// but may be falsy if lineLength == 0
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{
// lineLength is without newline; aline includes newline,
// but may be falsy if lineLength == 0
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{
// Plugin Hook to add more Attrib Classes
hooks.aCallAll('aceAttribClasses', linestylefilter.ATTRIB_CLASSES, function(err, ATTRIB_CLASSES){
@ -184,10 +185,10 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
};
})();
return authorColorFunc;
};
};
linestylefilter.getAtSignSplitterFilter = function(lineText, textAndClassFunc)
{
linestylefilter.getAtSignSplitterFilter = function(lineText, textAndClassFunc)
{
var at = /@/g;
at.lastIndex = 0;
var splitPoints = null;
@ -204,10 +205,10 @@ linestylefilter.getAtSignSplitterFilter = function(lineText, textAndClassFunc)
if (!splitPoints) return textAndClassFunc;
return linestylefilter.textAndClassFuncSplitter(textAndClassFunc, splitPoints);
};
};
linestylefilter.getRegexpFilter = function(regExp, tag)
{
linestylefilter.getRegexpFilter = function(regExp, tag)
{
return function(lineText, textAndClassFunc)
{
regExp.lastIndex = 0;
@ -261,17 +262,17 @@ linestylefilter.getRegexpFilter = function(regExp, tag)
return linestylefilter.textAndClassFuncSplitter(handleRegExpMatchsAfterSplit, splitPoints);
};
};
};
linestylefilter.REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/;
linestylefilter.REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#!;()\[\]$]/.source + '|' + linestylefilter.REGEX_WORDCHAR.source + ')');
linestylefilter.REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|nfs):\/\/|mailto:|www\.)/.source + linestylefilter.REGEX_URLCHAR.source + '*(?![:.,;])' + linestylefilter.REGEX_URLCHAR.source, 'g');
linestylefilter.getURLFilter = linestylefilter.getRegexpFilter(
linestylefilter.REGEX_URL, 'url');
linestylefilter.REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/;
linestylefilter.REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#!;()\[\]$]/.source + '|' + linestylefilter.REGEX_WORDCHAR.source + ')');
linestylefilter.REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|nfs):\/\/|mailto:|www\.)/.source + linestylefilter.REGEX_URLCHAR.source + '*(?![:.,;])' + linestylefilter.REGEX_URLCHAR.source, 'g');
linestylefilter.getURLFilter = linestylefilter.getRegexpFilter(
linestylefilter.REGEX_URL, 'url');
linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt)
{
linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt)
{
var nextPointIndex = 0;
var idx = 0;
@ -316,10 +317,10 @@ linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt)
}
}
return spanHandler;
};
};
linestylefilter.getFilterStack = function(lineText, textAndClassFunc, abrowser)
{
linestylefilter.getFilterStack = function(lineText, textAndClassFunc, abrowser)
{
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
var hookFilters = hooks.callAll("aceGetFilterStack", {
@ -340,11 +341,11 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, abrowser)
lineText, func);
}
return func;
};
};
// domLineObj is like that returned by domline.createDomLine
linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
{
// domLineObj is like that returned by domline.createDomLine
linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
{
// remove final newline from text if any
var text = textLine;
if (text.slice(-1) == '\n')
@ -360,6 +361,9 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
var func = linestylefilter.getFilterStack(text, textAndClassFunc);
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
func(text, '');
};
};
exports.linestylefilter = linestylefilter;
exports.linestylefilter = linestylefilter;
return exports;
});

View file

@ -53,7 +53,7 @@ define(["ep_etherpad-lite/static/js/rjquery", "underscore", './shared'], functio
var parentRequire = null;
try {
while (frame = frame.parent) {
if (typeof (frame.require) !== "undefined") {
if (typeof (frame.requirejs) !== "undefined") {
parentRequire = frame.requirejs;
break;
}

View file

@ -70,18 +70,16 @@ exports.flatten = function (lst) {
exports.callAll = function (hook_name, args) {
if (!args) args = {};
if (exports.plugins){
if (exports.plugins.hooks[hook_name] === undefined) return [];
if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return [];
return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) {
return hookCallWrapper(hook, hook_name, args);
}), true);
}
}
exports.aCallAll = function (hook_name, args, cb) {
if (!args) args = {};
if (!cb) cb = function () {};
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
async.map(
exports.plugins.hooks[hook_name],
function (hook, cb) {
@ -95,7 +93,7 @@ exports.aCallAll = function (hook_name, args, cb) {
exports.callFirst = function (hook_name, args) {
if (!args) args = {};
if (exports.plugins.hooks[hook_name] === undefined) return [];
if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return [];
return exports.syncMapFirst(exports.plugins.hooks[hook_name], function (hook) {
return hookCallWrapper(hook, hook_name, args);
});
@ -104,7 +102,7 @@ exports.callFirst = function (hook_name, args) {
exports.aCallFirst = function (hook_name, args, cb) {
if (!args) args = {};
if (!cb) cb = function () {};
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
if (exports.plugins === undefined || exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
exports.mapFirst(
exports.plugins.hooks[hook_name],
function (hook, cb) {

View file

@ -27,8 +27,9 @@ define([
'ep_etherpad-lite/static/js/rjquery',
'ep_etherpad-lite/static/js/pluginfw/hooks',
'ep_etherpad-lite/static/js/pad_utils',
'ep_etherpad-lite/static/js/broadcast_slider'
], function($, hooks, padUtilsMod, broadcastSliderMod) {
'ep_etherpad-lite/static/js/broadcast_slider',
'ep_etherpad-lite/static/js/broadcast',
], function($, hooks, padUtilsMod, broadcastSliderMod, broadcastMod) {
var exports = {};
JSON = window.requireKernel('./json2');
@ -36,6 +37,11 @@ define([
var createCookie = padUtilsMod.createCookie;
var readCookie = padUtilsMod.readCookie;
var randomString = padUtilsMod.randomString;
var broadcastRevisionsMod = require('./broadcast_revisions');
var padimpexpMod = require('./pad_impexp');
//initialize export ui
require('./pad_impexp').padimpexp.init();
var token, padId, export_links;
@ -142,11 +148,11 @@ define([
//load all script that doesn't work without the clientVars
BroadcastSlider = broadcastSliderMod.loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
require('./broadcast_revisions').loadBroadcastRevisionsJS();
changesetLoader = require('./broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
broadcastRevisionsMod.loadBroadcastRevisionsJS();
changesetLoader = broadcastMod.loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
//initialize export ui
require('./pad_impexp').padimpexp.init();
padimpexpMod.padimpexp.init();
//change export urls when the slider moves
BroadcastSlider.onSlider(function(revno)

View file

@ -398,11 +398,9 @@
[
'ep_etherpad-lite/static/js/rjquery',
'ep_etherpad-lite/static/js/pluginfw/client_plugins',
'ep_etherpad-lite/static/js/pluginfw/hooks',
'ep_etherpad-lite/static/js/pad',
'ep_etherpad-lite/static/js/chat',
'ep_etherpad-lite/static/js/pad_editbar',
], function ($, plugins, hooks, padMod, chatMod, padEditbarMod) {
'ep_etherpad-lite/static/js/pluginfw/hooks'
], function ($, plugins, hooks) {
console.log("hooks & plugins modules loaded");
window.$ = $; // Expose jQuery #HACK
window.jQuery = $;
@ -415,14 +413,23 @@
plugins.update(function () {
hooks.plugins = plugins;
console.log("hooks.plugins initialized");
// Call documentReady hook
$(function() {
hooks.aCallAll('documentReady');
});
requirejs(
[
'ep_etherpad-lite/static/js/pad',
'ep_etherpad-lite/static/js/chat',
'ep_etherpad-lite/static/js/pad_editbar',
], function (padMod, chatMod, padEditbarMod) {
console.log("pad loaded");
padMod.baseURL = baseURL;
padMod.init();
});
/* TODO: These globals shouldn't exist. */
pad = padMod.pad;
@ -431,6 +438,9 @@
padimpexp = window.requireKernel('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
}
);
});
}
);
}());
</script>
<% e.end_block(); %>