mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Merge branch 'develop' of github.com:ether/etherpad-lite into develop
This commit is contained in:
commit
d134ba9b64
22 changed files with 529 additions and 361 deletions
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -1,3 +1,18 @@
|
||||||
|
# 1.2.91
|
||||||
|
* NEW: Authors can now send custom object messages to other Authors making 3 way conversations possible. This introduces WebRTC plugin support.
|
||||||
|
* NEW: Hook for Chat Messages Allows for Desktop Notification support
|
||||||
|
* NEW: FreeBSD installation docs
|
||||||
|
* Fix: Cookies inside of plugins
|
||||||
|
* Fix: Refactor Caret navigation with Arrow and Pageup/down keys stops cursor being lost
|
||||||
|
* Fix: Long lines in Firefox now wrap properly
|
||||||
|
* Fix: Log HTTP on DEBUG log level
|
||||||
|
* Fix: Server wont crash on import fails on 0 file import.
|
||||||
|
* Fix: Import no longer fails consistantly
|
||||||
|
* Fix: Language support for non existing languages
|
||||||
|
* Fix: Mobile support for chat notifications are now usable
|
||||||
|
* Fix: Re-Enable Editbar buttons on reconnect
|
||||||
|
* Fix: Clearing authorship colors no longer disconnects all clients
|
||||||
|
|
||||||
# 1.2.9
|
# 1.2.9
|
||||||
* Fix: MAJOR Security issue, where a hacker could submit content as another user
|
* Fix: MAJOR Security issue, where a hacker could submit content as another user
|
||||||
* Fix: security issue due to unescaped user input
|
* Fix: security issue due to unescaped user input
|
||||||
|
@ -6,7 +21,7 @@
|
||||||
* Fix: PadUsers API endpoint
|
* Fix: PadUsers API endpoint
|
||||||
* NEW: A script to import data to all dbms
|
* NEW: A script to import data to all dbms
|
||||||
* NEW: Add authorId to chat and userlist as a data attribute
|
* NEW: Add authorId to chat and userlist as a data attribute
|
||||||
* NEW Refactor and fix our frontend tests
|
* NEW: Refactor and fix our frontend tests
|
||||||
* NEW: Localisation updates
|
* NEW: Localisation updates
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -458,4 +458,4 @@ returns ok when the current api token is valid
|
||||||
lists all pads on this epl instance
|
lists all pads on this epl instance
|
||||||
|
|
||||||
*Example returns:*
|
*Example returns:*
|
||||||
* `{code: 0, message:"ok", data: ["testPad", "thePadsOfTheOthers"]}`
|
* `{code: 0, message:"ok", data: {padIDs: ["testPad", "thePadsOfTheOthers"]}}`
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"pad.toolbar.timeslider.title": "Timeslider",
|
"pad.toolbar.timeslider.title": "Timeslider",
|
||||||
"pad.toolbar.savedRevision.title": "Save Revision",
|
"pad.toolbar.savedRevision.title": "Save Revision",
|
||||||
"pad.toolbar.settings.title": "Settings",
|
"pad.toolbar.settings.title": "Settings",
|
||||||
"pad.toolbar.embed.title": "Embed this pad",
|
"pad.toolbar.embed.title": "Share and Embed this pad",
|
||||||
"pad.toolbar.showusers.title": "Show the users on this pad",
|
"pad.toolbar.showusers.title": "Show the users on this pad",
|
||||||
"pad.colorpicker.save": "Save",
|
"pad.colorpicker.save": "Save",
|
||||||
"pad.colorpicker.cancel": "Cancel",
|
"pad.colorpicker.cancel": "Cancel",
|
||||||
|
|
|
@ -27,49 +27,84 @@ exports.socketio = function (hook_name, args, cb) {
|
||||||
io.on('connection', function (socket) {
|
io.on('connection', function (socket) {
|
||||||
if (!socket.handshake.session.user || !socket.handshake.session.user.is_admin) return;
|
if (!socket.handshake.session.user || !socket.handshake.session.user.is_admin) return;
|
||||||
|
|
||||||
socket.on("load", function (query) {
|
socket.on("getInstalled", function (query) {
|
||||||
// send currently installed plugins
|
// send currently installed plugins
|
||||||
socket.emit("installed-results", {results: plugins.plugins});
|
var installed = Object.keys(plugins.plugins).map(function(plugin) {
|
||||||
socket.emit("progress", {progress:1});
|
return plugins.plugins[plugin].package
|
||||||
|
})
|
||||||
|
socket.emit("results:installed", {installed: installed});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("checkUpdates", function() {
|
socket.on("checkUpdates", function() {
|
||||||
socket.emit("progress", {progress:0, message:'Checking for plugin updates...'});
|
|
||||||
// Check plugins for updates
|
// Check plugins for updates
|
||||||
installer.search({offset: 0, pattern: '', limit: 500}, /*useCache:*/true, function(data) { // hacky
|
installer.getAvailablePlugins(/*maxCacheAge:*/60*10, function(er, results) {
|
||||||
if (!data.results) return;
|
if(er) {
|
||||||
|
console.warn(er);
|
||||||
|
socket.emit("results:updatable", {updatable: {}});
|
||||||
|
return;
|
||||||
|
}
|
||||||
var updatable = _(plugins.plugins).keys().filter(function(plugin) {
|
var updatable = _(plugins.plugins).keys().filter(function(plugin) {
|
||||||
if(!data.results[plugin]) return false;
|
if(!results[plugin]) return false;
|
||||||
var latestVersion = data.results[plugin]['dist-tags'].latest
|
var latestVersion = results[plugin].version
|
||||||
var currentVersion = plugins.plugins[plugin].package.version
|
var currentVersion = plugins.plugins[plugin].package.version
|
||||||
return semver.gt(latestVersion, currentVersion)
|
return semver.gt(latestVersion, currentVersion)
|
||||||
});
|
});
|
||||||
socket.emit("updatable", {updatable: updatable});
|
socket.emit("results:updatable", {updatable: updatable});
|
||||||
socket.emit("progress", {progress:1});
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
socket.on("getAvailable", function (query) {
|
||||||
|
installer.getAvailablePlugins(/*maxCacheAge:*/false, function (er, results) {
|
||||||
|
if(er) {
|
||||||
|
console.error(er)
|
||||||
|
results = {}
|
||||||
|
}
|
||||||
|
socket.emit("results:available", results);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
socket.on("search", function (query) {
|
socket.on("search", function (query) {
|
||||||
socket.emit("progress", {progress:0, message:'Fetching results...'});
|
installer.search(query.searchTerm, /*maxCacheAge:*/60*10, function (er, results) {
|
||||||
installer.search(query, true, function (progress) {
|
if(er) {
|
||||||
if (progress.results)
|
console.error(er)
|
||||||
socket.emit("search-result", progress);
|
results = {}
|
||||||
socket.emit("progress", progress);
|
}
|
||||||
|
var res = Object.keys(results)
|
||||||
|
.map(function(pluginName) {
|
||||||
|
return results[pluginName]
|
||||||
|
})
|
||||||
|
.filter(function(plugin) {
|
||||||
|
return !plugins.plugins[plugin.name]
|
||||||
|
});
|
||||||
|
res = sortPluginList(res, query.sortBy, query.sortDir)
|
||||||
|
.slice(query.offset, query.offset+query.limit);
|
||||||
|
socket.emit("results:search", {results: res, query: query});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("install", function (plugin_name) {
|
socket.on("install", function (plugin_name) {
|
||||||
socket.emit("progress", {progress:0, message:'Downloading and installing ' + plugin_name + "..."});
|
installer.install(plugin_name, function (er) {
|
||||||
installer.install(plugin_name, function (progress) {
|
if(er) console.warn(er)
|
||||||
socket.emit("progress", progress);
|
socket.emit("finished:install", {plugin: plugin_name, error: er? er.message : null});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("uninstall", function (plugin_name) {
|
socket.on("uninstall", function (plugin_name) {
|
||||||
socket.emit("progress", {progress:0, message:'Uninstalling ' + plugin_name + "..."});
|
installer.uninstall(plugin_name, function (er) {
|
||||||
installer.uninstall(plugin_name, function (progress) {
|
if(er) console.warn(er)
|
||||||
socket.emit("progress", progress);
|
socket.emit("finished:uninstall", {plugin: plugin_name, error: er? er.message : null});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sortPluginList(plugins, property, /*ASC?*/dir) {
|
||||||
|
return plugins.sort(function(a, b) {
|
||||||
|
if (a[property] < b[property])
|
||||||
|
return dir? -1 : 1;
|
||||||
|
if (a[property] > b[property])
|
||||||
|
return dir? 1 : -1;
|
||||||
|
// a must be equal to b
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ exports.gracefulShutdown = function(err) {
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.on('uncaughtException', exports.gracefulShutdown);
|
||||||
|
|
||||||
exports.expressCreateServer = function (hook_name, args, cb) {
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
exports.app = args.app;
|
exports.app = args.app;
|
||||||
|
@ -47,6 +48,4 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
//https://github.com/joyent/node/issues/1553
|
//https://github.com/joyent/node/issues/1553
|
||||||
process.on('SIGINT', exports.gracefulShutdown);
|
process.on('SIGINT', exports.gracefulShutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('uncaughtException', exports.gracefulShutdown);
|
|
||||||
}
|
}
|
|
@ -63,7 +63,7 @@ if(os.type().indexOf("Windows") > -1)
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.convertFile = function(srcFile, destFile, type, callback)
|
exports.convertFile = function(srcFile, destFile, type, callback)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ else
|
||||||
firstPrompt = false;
|
firstPrompt = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
spawnAbiword();
|
spawnAbiword();
|
||||||
|
|
||||||
doConvertTask = function(task, callback)
|
doConvertTask = function(task, callback)
|
||||||
|
@ -135,7 +135,7 @@ else
|
||||||
console.log("queue continue");
|
console.log("queue continue");
|
||||||
task.callback(err);
|
task.callback(err);
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
//Queue with the converts we have to do
|
//Queue with the converts we have to do
|
||||||
var queue = async.queue(doConvertTask, 1);
|
var queue = async.queue(doConvertTask, 1);
|
||||||
|
|
|
@ -316,7 +316,7 @@ exports.getPadDokuWikiDocument = function (padId, revNum, callback)
|
||||||
|
|
||||||
getPadDokuWiki(pad, revNum, callback);
|
getPadDokuWiki(pad, revNum, callback);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function _escapeDokuWiki(s)
|
function _escapeDokuWiki(s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ exports.getPadPlainText = function(pad, revNum){
|
||||||
}
|
}
|
||||||
|
|
||||||
return pieces.join('');
|
return pieces.join('');
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
exports._analyzeLine = function(text, aline, apool){
|
exports._analyzeLine = function(text, aline, apool){
|
||||||
|
@ -77,11 +77,11 @@ exports._analyzeLine = function(text, aline, apool){
|
||||||
line.aline = aline;
|
line.aline = aline;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
exports._encodeWhitespace = function(s){
|
exports._encodeWhitespace = function(s){
|
||||||
return s.replace(/[^\x21-\x7E\s\t\n\r]/g, function(c){
|
return s.replace(/[^\x21-\x7E\s\t\n\r]/g, function(c){
|
||||||
return "&#" +c.charCodeAt(0) + ";"
|
return "&#" +c.charCodeAt(0) + ";";
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@ var padManager = require("../db/PadManager");
|
||||||
var ERR = require("async-stacktrace");
|
var ERR = require("async-stacktrace");
|
||||||
var Security = require('ep_etherpad-lite/static/js/security');
|
var Security = require('ep_etherpad-lite/static/js/security');
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
var getPadPlainText = require('./ExportHelper').getPadPlainText
|
var getPadPlainText = require('./ExportHelper').getPadPlainText;
|
||||||
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
||||||
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback)
|
||||||
callback(null, head + html + foot);
|
callback(null, head + html + foot);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// copied from ACE
|
// copied from ACE
|
||||||
|
@ -595,4 +595,3 @@ function _processSpaces(s){
|
||||||
}
|
}
|
||||||
return parts.join('');
|
return parts.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,5 +289,4 @@ exports.getPadTXTDocument = function (padId, revNum, noDocType, callback)
|
||||||
callback(null, html);
|
callback(null, html);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -125,11 +125,11 @@ function requestURIs(locations, method, headers, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function completed() {
|
function completed() {
|
||||||
var statuss = responses.map(function (x) {return x[0]});
|
var statuss = responses.map(function (x) {return x[0];});
|
||||||
var headerss = responses.map(function (x) {return x[1]});
|
var headerss = responses.map(function (x) {return x[1];});
|
||||||
var contentss = responses.map(function (x) {return x[2]});
|
var contentss = responses.map(function (x) {return x[2];});
|
||||||
callback(statuss, headerss, contentss);
|
callback(statuss, headerss, contentss);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +263,7 @@ function getAceFile(callback) {
|
||||||
var filename = item.match(/"([^"]*)"/)[1];
|
var filename = item.match(/"([^"]*)"/)[1];
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
|
|
||||||
var baseURI = 'http://localhost:' + settings.port
|
var baseURI = 'http://localhost:' + settings.port;
|
||||||
var resourceURI = baseURI + path.normalize(path.join('/static/', filename));
|
var resourceURI = baseURI + path.normalize(path.join('/static/', filename));
|
||||||
resourceURI = resourceURI.replace(/\\/g, '/'); // Windows (safe generally?)
|
resourceURI = resourceURI.replace(/\\/g, '/'); // Windows (safe generally?)
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ exports.abiwordAvailable = function()
|
||||||
{
|
{
|
||||||
return "no";
|
return "no";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.reloadSettings = function reloadSettings() {
|
exports.reloadSettings = function reloadSettings() {
|
||||||
// Discover where the settings file lives
|
// Discover where the settings file lives
|
||||||
|
@ -157,7 +157,7 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
try {
|
try {
|
||||||
if(settingsStr) {
|
if(settingsStr) {
|
||||||
settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json");
|
settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json");
|
||||||
settings = JSON.parse(JSON.stringify(settings)) // fix objects having constructors of other vm.context
|
settings = JSON.parse(JSON.stringify(settings)); // fix objects having constructors of other vm.context
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.error('There was an error processing your settings.json file: '+e.message);
|
console.error('There was an error processing your settings.json file: '+e.message);
|
||||||
|
@ -196,9 +196,9 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(exports.dbType === "dirty"){
|
if(exports.dbType === "dirty"){
|
||||||
console.warn("DirtyDB is used. This is fine for testing but not recommended for production.")
|
console.warn("DirtyDB is used. This is fine for testing but not recommended for production.");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// initially load settings
|
// initially load settings
|
||||||
exports.reloadSettings();
|
exports.reloadSettings();
|
||||||
|
|
|
@ -23,7 +23,7 @@ var util = require('util');
|
||||||
var settings = require('./Settings');
|
var settings = require('./Settings');
|
||||||
var semver = require('semver');
|
var semver = require('semver');
|
||||||
|
|
||||||
var existsSync = (semver.satisfies(process.version, '>=0.8.0')) ? fs.existsSync : path.existsSync
|
var existsSync = (semver.satisfies(process.version, '>=0.8.0')) ? fs.existsSync : path.existsSync;
|
||||||
|
|
||||||
var CACHE_DIR = path.normalize(path.join(settings.root, 'var/'));
|
var CACHE_DIR = path.normalize(path.join(settings.root, 'var/'));
|
||||||
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
||||||
|
@ -133,7 +133,7 @@ CachingMiddleware.prototype = new function () {
|
||||||
old_res.write = res.write;
|
old_res.write = res.write;
|
||||||
old_res.end = res.end;
|
old_res.end = res.end;
|
||||||
res.write = function(data, encoding) {};
|
res.write = function(data, encoding) {};
|
||||||
res.end = function(data, encoding) { respond() };
|
res.end = function(data, encoding) { respond(); };
|
||||||
} else {
|
} else {
|
||||||
res.writeHead(status, headers);
|
res.writeHead(status, headers);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ PadDiff.prototype._isClearAuthorship = function(changeset){
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype._createClearAuthorship = function(rev, callback){
|
PadDiff.prototype._createClearAuthorship = function(rev, callback){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -84,7 +84,7 @@ PadDiff.prototype._createClearAuthorship = function(rev, callback){
|
||||||
|
|
||||||
callback(null, changeset);
|
callback(null, changeset);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype._createClearStartAtext = function(rev, callback){
|
PadDiff.prototype._createClearStartAtext = function(rev, callback){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -107,7 +107,7 @@ PadDiff.prototype._createClearStartAtext = function(rev, callback){
|
||||||
callback(null, newAText);
|
callback(null, newAText);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) {
|
PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -124,7 +124,7 @@ PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) {
|
||||||
async.forEach(revisions, function(rev, callback){
|
async.forEach(revisions, function(rev, callback){
|
||||||
self._pad.getRevision(rev, function(err, revision){
|
self._pad.getRevision(rev, function(err, revision){
|
||||||
if(err){
|
if(err){
|
||||||
return callback(err)
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var arrayNum = rev-startRev;
|
var arrayNum = rev-startRev;
|
||||||
|
@ -137,7 +137,7 @@ PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) {
|
||||||
}, function(err){
|
}, function(err){
|
||||||
callback(err, changesets, authors);
|
callback(err, changesets, authors);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype._addAuthors = function(authors) {
|
PadDiff.prototype._addAuthors = function(authors) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -147,7 +147,7 @@ PadDiff.prototype._addAuthors = function(authors) {
|
||||||
self._authors.push(author);
|
self._authors.push(author);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype._createDiffAtext = function(callback) {
|
PadDiff.prototype._createDiffAtext = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -219,7 +219,7 @@ PadDiff.prototype._createDiffAtext = function(callback) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype.getHtml = function(callback){
|
PadDiff.prototype.getHtml = function(callback){
|
||||||
//cache the html
|
//cache the html
|
||||||
|
@ -279,7 +279,7 @@ PadDiff.prototype.getAuthors = function(callback){
|
||||||
} else {
|
} else {
|
||||||
callback(null, self._authors);
|
callback(null, self._authors);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
PadDiff.prototype._extendChangesetWithAuthor = function(changeset, author, apool) {
|
PadDiff.prototype._extendChangesetWithAuthor = function(changeset, author, apool) {
|
||||||
//unpack
|
//unpack
|
||||||
|
@ -312,7 +312,7 @@ PadDiff.prototype._extendChangesetWithAuthor = function(changeset, author, apool
|
||||||
|
|
||||||
//return the modified changeset
|
//return the modified changeset
|
||||||
return Changeset.pack(unpacked.oldLen, unpacked.newLen, assem.toString(), unpacked.charBank);
|
return Changeset.pack(unpacked.oldLen, unpacked.newLen, assem.toString(), unpacked.charBank);
|
||||||
}
|
};
|
||||||
|
|
||||||
//this method is 80% like Changeset.inverse. I just changed so instead of reverting, it adds deletions and attribute changes to to the atext.
|
//this method is 80% like Changeset.inverse. I just changed so instead of reverting, it adds deletions and attribute changes to to the atext.
|
||||||
PadDiff.prototype._createDeletionChangeset = function(cs, startAText, apool) {
|
PadDiff.prototype._createDeletionChangeset = function(cs, startAText, apool) {
|
||||||
|
@ -463,7 +463,7 @@ PadDiff.prototype._createDeletionChangeset = function(cs, startAText, apool) {
|
||||||
// If the text this operator applies to is only a star, than this is a false positive and should be ignored
|
// If the text this operator applies to is only a star, than this is a false positive and should be ignored
|
||||||
if (csOp.attribs && textBank != "*") {
|
if (csOp.attribs && textBank != "*") {
|
||||||
var deletedAttrib = apool.putAttrib(["removed", true]);
|
var deletedAttrib = apool.putAttrib(["removed", true]);
|
||||||
var authorAttrib = apool.putAttrib(["author", ""]);;
|
var authorAttrib = apool.putAttrib(["author", ""]);
|
||||||
|
|
||||||
attribKeys.length = 0;
|
attribKeys.length = 0;
|
||||||
attribValues.length = 0;
|
attribValues.length = 0;
|
||||||
|
@ -473,7 +473,7 @@ PadDiff.prototype._createDeletionChangeset = function(cs, startAText, apool) {
|
||||||
|
|
||||||
if(apool.getAttribKey(n) === "author"){
|
if(apool.getAttribKey(n) === "author"){
|
||||||
authorAttrib = n;
|
authorAttrib = n;
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var undoBackToAttribs = cachedStrFunc(function (attribs) {
|
var undoBackToAttribs = cachedStrFunc(function (attribs) {
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
"nodemailer" : "0.3.x",
|
"nodemailer" : "0.3.x",
|
||||||
"jsdom-nocontextifiy" : "0.2.10",
|
"jsdom-nocontextifiy" : "0.2.10",
|
||||||
"async-stacktrace" : "0.0.2",
|
"async-stacktrace" : "0.0.2",
|
||||||
"npm" : "1.1.x",
|
"npm" : "1.2.x",
|
||||||
"npm-registry-client" : "0.2.10",
|
|
||||||
"ejs" : "0.6.1",
|
"ejs" : "0.6.1",
|
||||||
"graceful-fs" : "1.1.5",
|
"graceful-fs" : "1.1.5",
|
||||||
"slide" : "1.1.3",
|
"slide" : "1.1.3",
|
||||||
|
|
|
@ -43,7 +43,7 @@ div.innerwrapper {
|
||||||
box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.2);
|
box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.2);
|
||||||
margin: auto;
|
margin: auto;
|
||||||
max-width: 1150px;
|
max-width: 1150px;
|
||||||
min-height: 100%;
|
min-height: 101%;/*always display a scrollbar*/
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
@ -102,12 +102,26 @@ input[type="text"] {
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sort {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.sort:after {
|
||||||
|
content: '▲▼'
|
||||||
|
}
|
||||||
|
.sort.up:after {
|
||||||
|
content:'▲'
|
||||||
|
}
|
||||||
|
.sort.down:after {
|
||||||
|
content:'▼'
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
|
position:relative; /* Allows us to position the loading indicator relative to the table */
|
||||||
}
|
}
|
||||||
|
|
||||||
table thead tr {
|
table thead tr {
|
||||||
|
@ -122,13 +136,40 @@ td, th {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#progress {
|
#installed-plugins td>div {
|
||||||
position: absolute;
|
position: relative;/* Allows us to position the loading indicator relative to this row */
|
||||||
bottom: 50px;
|
display: inline-block; /*make this fill the whole cell*/
|
||||||
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#progress img {
|
.messages td>* {
|
||||||
vertical-align: top;
|
display: none;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.messages .fetching {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
position: absolute;
|
||||||
|
top: 0; left: 0; bottom:0; right:0;
|
||||||
|
padding: auto;
|
||||||
|
|
||||||
|
background: rgb(255,255,255);
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-progress.progress {
|
||||||
|
padding-top: 20%;
|
||||||
|
background: rgba(255,255,255,0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress * {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
|
text-align: center;
|
||||||
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings {
|
.settings {
|
||||||
|
@ -147,7 +188,25 @@ a:link, a:visited, a:hover, a:focus {
|
||||||
}
|
}
|
||||||
|
|
||||||
a:focus, a:hover {
|
a:focus, a:hover {
|
||||||
border-bottom: #333333 1px solid;
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.installed-results a:link,
|
||||||
|
.search-results a:link,
|
||||||
|
.installed-results a:visited,
|
||||||
|
.search-results a:visited,
|
||||||
|
.installed-results a:hover,
|
||||||
|
.search-results a:hover,
|
||||||
|
.installed-results a:focus,
|
||||||
|
.search-results a:focus {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.installed-results a:focus,
|
||||||
|
.search-results a:focus,
|
||||||
|
.installed-results a:hover,
|
||||||
|
.search-results a:hover {
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
|
|
@ -559,6 +559,15 @@ table#otheruserstable {
|
||||||
margin: 4px 0 0 4px;
|
margin: 4px 0 0 4px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
#titlesticky{
|
||||||
|
font-size: 10px;
|
||||||
|
padding-top:2px;
|
||||||
|
float: right;
|
||||||
|
text-align: right;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
#titlecross {
|
#titlecross {
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
float: right;
|
float: right;
|
||||||
|
|
|
@ -1013,6 +1013,11 @@ function Ace2Inner(){
|
||||||
return caughtErrors.slice();
|
return caughtErrors.slice();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
editorInfo.ace_getDocument = function()
|
||||||
|
{
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
editorInfo.ace_getDebugProperty = function(prop)
|
editorInfo.ace_getDebugProperty = function(prop)
|
||||||
{
|
{
|
||||||
if (prop == "debugger")
|
if (prop == "debugger")
|
||||||
|
|
|
@ -12,176 +12,248 @@ $(document).ready(function () {
|
||||||
//connect
|
//connect
|
||||||
socket = io.connect(url, {resource : resource}).of("/pluginfw/installer");
|
socket = io.connect(url, {resource : resource}).of("/pluginfw/installer");
|
||||||
|
|
||||||
$('.search-results').data('query', {
|
function search(searchTerm, limit) {
|
||||||
pattern: '',
|
if(search.searchTerm != searchTerm) {
|
||||||
offset: 0,
|
search.offset = 0
|
||||||
limit: 12,
|
search.results = []
|
||||||
});
|
search.end = false
|
||||||
|
}
|
||||||
var doUpdate = false;
|
limit = limit? limit : search.limit
|
||||||
|
search.searchTerm = searchTerm;
|
||||||
var search = function () {
|
socket.emit("search", {searchTerm: searchTerm, offset:search.offset, limit: limit, sortBy: search.sortBy, sortDir: search.sortDir});
|
||||||
socket.emit("search", $('.search-results').data('query'));
|
search.offset += limit;
|
||||||
tasks++;
|
$('#search-progress').show()
|
||||||
|
}
|
||||||
|
search.offset = 0;
|
||||||
|
search.limit = 12;
|
||||||
|
search.results = [];
|
||||||
|
search.sortBy = 'name';
|
||||||
|
search.sortDir = /*DESC?*/true;
|
||||||
|
search.end = true;// have we received all results already?
|
||||||
|
search.messages = {
|
||||||
|
show: function(msg) {
|
||||||
|
$('.search-results .messages').show()
|
||||||
|
$('.search-results .messages .'+msg+'').show()
|
||||||
|
},
|
||||||
|
hide: function(msg) {
|
||||||
|
$('.search-results .messages').hide()
|
||||||
|
$('.search-results .messages .'+msg+'').hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHandlers() {
|
var installed = {
|
||||||
$("form").submit(function(){
|
progress: {
|
||||||
var query = $('.search-results').data('query');
|
show: function(plugin, msg) {
|
||||||
query.pattern = $("#search-query").val();
|
$('.installed-results .'+plugin+' .progress').show()
|
||||||
query.offset = 0;
|
$('.installed-results .'+plugin+' .progress .message').text(msg)
|
||||||
search();
|
if($(window).scrollTop() > $('.'+plugin).offset().top)$(window).scrollTop($('.'+plugin).offset().top-100)
|
||||||
return false;
|
},
|
||||||
});
|
hide: function(plugin) {
|
||||||
|
$('.installed-results .'+plugin+' .progress').hide()
|
||||||
$("#search-query").unbind('keyup').keyup(function () {
|
$('.installed-results .'+plugin+' .progress .message').text('')
|
||||||
var query = $('.search-results').data('query');
|
|
||||||
query.pattern = $("#search-query").val();
|
|
||||||
query.offset = 0;
|
|
||||||
search();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".do-install, .do-update").unbind('click').click(function (e) {
|
|
||||||
var row = $(e.target).closest("tr");
|
|
||||||
doUpdate = true;
|
|
||||||
socket.emit("install", row.find(".name").text());
|
|
||||||
tasks++;
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".do-uninstall").unbind('click').click(function (e) {
|
|
||||||
var row = $(e.target).closest("tr");
|
|
||||||
doUpdate = true;
|
|
||||||
socket.emit("uninstall", row.find(".name").text());
|
|
||||||
tasks++;
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".do-prev-page").unbind('click').click(function (e) {
|
|
||||||
var query = $('.search-results').data('query');
|
|
||||||
query.offset -= query.limit;
|
|
||||||
if (query.offset < 0) {
|
|
||||||
query.offset = 0;
|
|
||||||
}
|
}
|
||||||
search();
|
},
|
||||||
});
|
messages: {
|
||||||
$(".do-next-page").unbind('click').click(function (e) {
|
show: function(msg) {
|
||||||
var query = $('.search-results').data('query');
|
$('.installed-results .messages').show()
|
||||||
var total = $('.search-results').data('total');
|
$('.installed-results .messages .'+msg+'').show()
|
||||||
if (query.offset + query.limit < total) {
|
},
|
||||||
query.offset += query.limit;
|
hide: function(msg) {
|
||||||
|
$('.installed-results .messages').hide()
|
||||||
|
$('.installed-results .messages .'+msg+'').hide()
|
||||||
}
|
}
|
||||||
search();
|
},
|
||||||
});
|
list: []
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHandlers();
|
function displayPluginList(plugins, container, template) {
|
||||||
|
plugins.forEach(function(plugin) {
|
||||||
var tasks = 0;
|
var row = template.clone();
|
||||||
socket.on('progress', function (data) {
|
|
||||||
$("#progress").show();
|
|
||||||
$('#progress').data('progress', data.progress);
|
|
||||||
|
|
||||||
var message = "Unknown status";
|
|
||||||
if (data.message) {
|
|
||||||
message = data.message.toString();
|
|
||||||
}
|
|
||||||
if (data.error) {
|
|
||||||
data.progress = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#progress .message").html(message);
|
|
||||||
|
|
||||||
if (data.progress >= 1) {
|
|
||||||
tasks--;
|
|
||||||
if (tasks <= 0) {
|
|
||||||
// Hide the activity indicator once all tasks are done
|
|
||||||
$("#progress").hide();
|
|
||||||
tasks = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.error) {
|
|
||||||
alert('An error occurred: '+data.error+' -- the server log might know more...');
|
|
||||||
}else {
|
|
||||||
if (doUpdate) {
|
|
||||||
doUpdate = false;
|
|
||||||
socket.emit("load");
|
|
||||||
tasks++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('search-result', function (data) {
|
|
||||||
var widget=$(".search-results");
|
|
||||||
|
|
||||||
widget.data('query', data.query);
|
|
||||||
widget.data('total', data.total);
|
|
||||||
|
|
||||||
widget.find('.offset').html(data.query.offset);
|
|
||||||
if (data.query.offset + data.query.limit > data.total){
|
|
||||||
widget.find('.limit').html(data.total);
|
|
||||||
}else{
|
|
||||||
widget.find('.limit').html(data.query.offset + data.query.limit);
|
|
||||||
}
|
|
||||||
widget.find('.total').html(data.total);
|
|
||||||
|
|
||||||
widget.find(".results *").remove();
|
|
||||||
for (plugin_name in data.results) {
|
|
||||||
var plugin = data.results[plugin_name];
|
|
||||||
var row = widget.find(".template tr").clone();
|
|
||||||
|
|
||||||
for (attr in plugin) {
|
for (attr in plugin) {
|
||||||
if(attr == "name"){ // Hack to rewrite URLS into name
|
if(attr == "name"){ // Hack to rewrite URLS into name
|
||||||
row.find(".name").html("<a target='_blank' href='https://npmjs.org/package/"+plugin['name']+"'>"+plugin[attr]+"</a>");
|
row.find(".name").html("<a target='_blank' title='Plugin details' href='https://npmjs.org/package/"+plugin['name']+"'>"+plugin['name'].substr(3)+"</a>"); // remove 'ep_'
|
||||||
}else{
|
}else{
|
||||||
row.find("." + attr).html(plugin[attr]);
|
row.find("." + attr).html(plugin[attr]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
row.find(".version").html( data.results[plugin_name]['dist-tags'].latest );
|
row.find(".version").html( plugin.version );
|
||||||
|
row.addClass(plugin.name)
|
||||||
widget.find(".results").append(row);
|
row.data('plugin', plugin.name)
|
||||||
}
|
container.append(row);
|
||||||
|
})
|
||||||
updateHandlers();
|
updateHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortPluginList(plugins, property, /*ASC?*/dir) {
|
||||||
|
return plugins.sort(function(a, b) {
|
||||||
|
if (a[property] < b[property])
|
||||||
|
return dir? -1 : 1;
|
||||||
|
if (a[property] > b[property])
|
||||||
|
return dir? 1 : -1;
|
||||||
|
// a must be equal to b
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Infinite scroll
|
||||||
|
$(window).scroll(checkInfiniteScroll)
|
||||||
|
function checkInfiniteScroll() {
|
||||||
|
if(search.end) return;// don't keep requesting if there are no more results
|
||||||
|
try{
|
||||||
|
var top = $('.search-results .results > tr:last').offset().top
|
||||||
|
if($(window).scrollTop()+$(window).height() > top) search(search.searchTerm)
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateHandlers() {
|
||||||
|
// Search
|
||||||
|
$("#search-query").unbind('keyup').keyup(function () {
|
||||||
|
search($("#search-query").val());
|
||||||
|
});
|
||||||
|
|
||||||
|
// update & install
|
||||||
|
$(".do-install, .do-update").unbind('click').click(function (e) {
|
||||||
|
var $row = $(e.target).closest("tr")
|
||||||
|
, plugin = $row.data('plugin');
|
||||||
|
if($(this).hasClass('do-install')) {
|
||||||
|
$row.remove().appendTo('#installed-plugins')
|
||||||
|
installed.progress.show(plugin, 'Installing')
|
||||||
|
}else{
|
||||||
|
installed.progress.show(plugin, 'Updating')
|
||||||
|
}
|
||||||
|
socket.emit("install", plugin);
|
||||||
|
installed.messages.hide("nothing-installed")
|
||||||
|
});
|
||||||
|
|
||||||
|
// uninstall
|
||||||
|
$(".do-uninstall").unbind('click').click(function (e) {
|
||||||
|
var $row = $(e.target).closest("tr")
|
||||||
|
, pluginName = $row.data('plugin');
|
||||||
|
socket.emit("uninstall", pluginName);
|
||||||
|
installed.progress.show(pluginName, 'Uninstalling')
|
||||||
|
installed.list = installed.list.filter(function(plugin) {
|
||||||
|
return plugin.name != pluginName
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sort
|
||||||
|
$('.sort.up').unbind('click').click(function() {
|
||||||
|
search.sortBy = $(this).text().toLowerCase();
|
||||||
|
search.sortDir = false;
|
||||||
|
search.offset = 0;
|
||||||
|
search(search.searchTerm, search.results.length);
|
||||||
|
search.results = [];
|
||||||
|
})
|
||||||
|
$('.sort.down, .sort.none').unbind('click').click(function() {
|
||||||
|
search.sortBy = $(this).text().toLowerCase();
|
||||||
|
search.sortDir = true;
|
||||||
|
search.offset = 0;
|
||||||
|
search(search.searchTerm, search.results.length);
|
||||||
|
search.results = [];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.on('results:search', function (data) {
|
||||||
|
if(!data.results.length) search.end = true;
|
||||||
|
search.messages.hide('nothing-found')
|
||||||
|
search.messages.hide('fetching')
|
||||||
|
$("#search-query").removeAttr('disabled')
|
||||||
|
|
||||||
|
console.log('got search results', data)
|
||||||
|
|
||||||
|
// add to results
|
||||||
|
search.results = search.results.concat(data.results);
|
||||||
|
|
||||||
|
// Update sorting head
|
||||||
|
$('.sort')
|
||||||
|
.removeClass('up down')
|
||||||
|
.addClass('none');
|
||||||
|
$('.search-results thead th[data-label='+data.query.sortBy+']')
|
||||||
|
.removeClass('none')
|
||||||
|
.addClass(data.query.sortDir? 'up' : 'down');
|
||||||
|
|
||||||
|
// re-render search results
|
||||||
|
var searchWidget = $(".search-results");
|
||||||
|
searchWidget.find(".results *").remove();
|
||||||
|
if(search.results.length > 0) {
|
||||||
|
displayPluginList(search.results, searchWidget.find(".results"), searchWidget.find(".template tr"))
|
||||||
|
}else {
|
||||||
|
search.messages.show('nothing-found')
|
||||||
|
}
|
||||||
|
$('#search-progress').hide()
|
||||||
|
checkInfiniteScroll()
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('installed-results', function (data) {
|
socket.on('results:installed', function (data) {
|
||||||
$("#installed-plugins *").remove();
|
installed.messages.hide("fetching")
|
||||||
|
installed.messages.hide("nothing-installed")
|
||||||
|
|
||||||
for (plugin_name in data.results) {
|
installed.list = data.installed
|
||||||
if (plugin_name == "ep_etherpad-lite") continue; // Hack...
|
sortPluginList(installed.list, 'name', /*ASC?*/true);
|
||||||
var plugin = data.results[plugin_name];
|
|
||||||
var row = $("#installed-plugin-template").clone();
|
|
||||||
|
|
||||||
for (attr in plugin.package) {
|
// filter out epl
|
||||||
if(attr == "name"){ // Hack to rewrite URLS into name
|
installed.list = installed.list.filter(function(plugin) {
|
||||||
row.find(".name").html("<a target='_blank' href='https://npmjs.org/package/"+plugin.package['name']+"'>"+plugin.package[attr]+"</a>");
|
return plugin.name != 'ep_etherpad-lite'
|
||||||
}else{
|
})
|
||||||
row.find("." + attr).html(plugin.package[attr]);
|
|
||||||
}
|
// remove all installed plugins (leave plugins that are still being installed)
|
||||||
}
|
installed.list.forEach(function(plugin) {
|
||||||
$("#installed-plugins").append(row);
|
$('#installed-plugins .'+plugin.name).remove()
|
||||||
|
})
|
||||||
|
|
||||||
|
if(installed.list.length > 0) {
|
||||||
|
displayPluginList(installed.list, $("#installed-plugins"), $("#installed-plugin-template"));
|
||||||
|
socket.emit('checkUpdates');
|
||||||
|
}else {
|
||||||
|
installed.messages.show("nothing-installed")
|
||||||
}
|
}
|
||||||
updateHandlers();
|
|
||||||
|
|
||||||
socket.emit('checkUpdates');
|
|
||||||
tasks++;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('updatable', function(data) {
|
socket.on('results:updatable', function(data) {
|
||||||
$('#installed-plugins>tr').each(function(i,tr) {
|
data.updatable.forEach(function(pluginName) {
|
||||||
var pluginName = $(tr).find('.name').text()
|
var $row = $('#installed-plugins > tr.'+pluginName)
|
||||||
|
, actions = $row.find('.actions')
|
||||||
if (data.updatable.indexOf(pluginName) >= 0) {
|
actions.append('<input class="do-update" type="button" value="Update" />')
|
||||||
var actions = $(tr).find('.actions')
|
|
||||||
actions.append('<input class="do-update" type="button" value="Update" />')
|
|
||||||
actions.css('width', 200)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
updateHandlers();
|
updateHandlers();
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.emit("load");
|
socket.on('finished:install', function(data) {
|
||||||
tasks++;
|
if(data.error) {
|
||||||
|
alert('An error occured while installing '+data.plugin+' \n'+data.error)
|
||||||
|
$('#installed-plugins .'+data.plugin).remove()
|
||||||
|
}
|
||||||
|
|
||||||
search();
|
socket.emit("getInstalled");
|
||||||
|
|
||||||
|
// update search results
|
||||||
|
search.offset = 0;
|
||||||
|
search(search.searchTerm, search.results.length);
|
||||||
|
search.results = [];
|
||||||
|
})
|
||||||
|
|
||||||
|
socket.on('finished:uninstall', function(data) {
|
||||||
|
if(data.error) alert('An error occured while uninstalling the '+data.plugin+' \n'+data.error)
|
||||||
|
|
||||||
|
// remove plugin from installed list
|
||||||
|
$('#installed-plugins .'+data.plugin).remove()
|
||||||
|
|
||||||
|
socket.emit("getInstalled");
|
||||||
|
|
||||||
|
// update search results
|
||||||
|
search.offset = 0;
|
||||||
|
search(search.searchTerm, search.results.length);
|
||||||
|
search.results = [];
|
||||||
|
})
|
||||||
|
|
||||||
|
// init
|
||||||
|
updateHandlers();
|
||||||
|
socket.emit("getInstalled");
|
||||||
|
search('');
|
||||||
|
|
||||||
|
// check for updates every 5mins
|
||||||
|
setInterval(function() {
|
||||||
|
socket.emit('checkUpdates');
|
||||||
|
}, 1000*60*5)
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,118 +1,77 @@
|
||||||
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
|
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
|
||||||
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
|
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
|
||||||
var npm = require("npm");
|
var npm = require("npm");
|
||||||
var RegClient = require("npm-registry-client")
|
|
||||||
|
|
||||||
var registry = new RegClient(
|
var npmIsLoaded = false;
|
||||||
{ registry: "http://registry.npmjs.org"
|
var withNpm = function (npmfn) {
|
||||||
, cache: npm.cache }
|
if(npmIsLoaded) return npmfn();
|
||||||
);
|
|
||||||
|
|
||||||
var withNpm = function (npmfn, final, cb) {
|
|
||||||
npm.load({}, function (er) {
|
npm.load({}, function (er) {
|
||||||
if (er) return cb({progress:1, error:er});
|
if (er) return npmfn(er);
|
||||||
|
npmIsLoaded = true;
|
||||||
npm.on("log", function (message) {
|
npm.on("log", function (message) {
|
||||||
cb({progress: 0.5, message:message.msg + ": " + message.pref});
|
console.log('npm: ',message)
|
||||||
});
|
|
||||||
npmfn(function (er, data) {
|
|
||||||
if (er) {
|
|
||||||
console.error(er);
|
|
||||||
return cb({progress:1, error: er.message});
|
|
||||||
}
|
|
||||||
if (!data) data = {};
|
|
||||||
data.progress = 1;
|
|
||||||
data.message = "Done.";
|
|
||||||
cb(data);
|
|
||||||
final();
|
|
||||||
});
|
});
|
||||||
|
npmfn();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// All these functions call their callback multiple times with
|
|
||||||
// {progress:[0,1], message:STRING, error:object}. They will call it
|
|
||||||
// with progress = 1 at least once, and at all times will either
|
|
||||||
// message or error be present, not both. It can be called multiple
|
|
||||||
// times for all values of propgress except for 1.
|
|
||||||
|
|
||||||
exports.uninstall = function(plugin_name, cb) {
|
exports.uninstall = function(plugin_name, cb) {
|
||||||
withNpm(
|
withNpm(function (er) {
|
||||||
function (cb) {
|
if (er) return cb && cb(er);
|
||||||
npm.commands.uninstall([plugin_name], function (er) {
|
npm.commands.uninstall([plugin_name], function (er) {
|
||||||
|
if (er) return cb && cb(er);
|
||||||
|
hooks.aCallAll("pluginUninstall", {plugin_name: plugin_name}, function (er, data) {
|
||||||
if (er) return cb(er);
|
if (er) return cb(er);
|
||||||
hooks.aCallAll("pluginUninstall", {plugin_name: plugin_name}, function (er, data) {
|
plugins.update(cb);
|
||||||
if (er) return cb(er);
|
hooks.aCallAll("restartServer", {}, function () {});
|
||||||
plugins.update(cb);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
function () {
|
});
|
||||||
hooks.aCallAll("restartServer", {}, function () {});
|
|
||||||
},
|
|
||||||
cb
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.install = function(plugin_name, cb) {
|
exports.install = function(plugin_name, cb) {
|
||||||
withNpm(
|
withNpm(function (er) {
|
||||||
function (cb) {
|
if (er) return cb && cb(er);
|
||||||
npm.commands.install([plugin_name], function (er) {
|
npm.commands.install([plugin_name], function (er) {
|
||||||
|
if (er) return cb && cb(er);
|
||||||
|
hooks.aCallAll("pluginInstall", {plugin_name: plugin_name}, function (er, data) {
|
||||||
if (er) return cb(er);
|
if (er) return cb(er);
|
||||||
hooks.aCallAll("pluginInstall", {plugin_name: plugin_name}, function (er, data) {
|
plugins.update(cb);
|
||||||
if (er) return cb(er);
|
hooks.aCallAll("restartServer", {}, function () {});
|
||||||
plugins.update(cb);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
function () {
|
});
|
||||||
hooks.aCallAll("restartServer", {}, function () {});
|
|
||||||
},
|
|
||||||
cb
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.searchCache = null;
|
exports.availablePlugins = null;
|
||||||
|
var cacheTimestamp = 0;
|
||||||
|
|
||||||
exports.search = function(query, cache, cb) {
|
exports.getAvailablePlugins = function(maxCacheAge, cb) {
|
||||||
withNpm(
|
withNpm(function (er) {
|
||||||
function (cb) {
|
if (er) return cb && cb(er);
|
||||||
var getData = function (cb) {
|
if(exports.availablePlugins && maxCacheAge && Math.round(+new Date/1000)-cacheTimestamp <= maxCacheAge) {
|
||||||
if (cache && exports.searchCache) {
|
return cb && cb(null, exports.availablePlugins)
|
||||||
cb(null, exports.searchCache);
|
}
|
||||||
} else {
|
npm.commands.search(['ep_'], /*silent?*/true, function(er, results) {
|
||||||
registry.get(
|
if(er) return cb && cb(er);
|
||||||
"/-/all", 600, false, true,
|
exports.availablePlugins = results;
|
||||||
function (er, data) {
|
cacheTimestamp = Math.round(+new Date/1000);
|
||||||
if (er) return cb(er);
|
cb && cb(null, results)
|
||||||
exports.searchCache = data;
|
})
|
||||||
cb(er, data);
|
});
|
||||||
}
|
};
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
exports.search = function(searchTerm, maxCacheAge, cb) {
|
||||||
getData(
|
exports.getAvailablePlugins(maxCacheAge, function(er, results) {
|
||||||
function (er, data) {
|
if(er) return cb && cb(er);
|
||||||
if (er) return cb(er);
|
var res = {};
|
||||||
var res = {};
|
searchTerm = searchTerm.toLowerCase();
|
||||||
var i = 0;
|
for (var pluginName in results) { // for every available plugin
|
||||||
var pattern = query.pattern.toLowerCase();
|
if (pluginName.indexOf(plugins.prefix) != 0) continue; // TODO: Also search in keywords here!
|
||||||
for (key in data) { // for every plugin in the data from npm
|
if(pluginName.indexOf(searchTerm) < 0 && results[pluginName].description.indexOf(searchTerm) < 0) continue;
|
||||||
if ( key.indexOf(plugins.prefix) == 0
|
res[pluginName] = results[pluginName];
|
||||||
&& key.indexOf(pattern) != -1
|
}
|
||||||
|| key.indexOf(plugins.prefix) == 0
|
cb && cb(null, res)
|
||||||
&& data[key].description.indexOf(pattern) != -1
|
})
|
||||||
) { // If the name contains ep_ and the search string is in the name or description
|
|
||||||
i++;
|
|
||||||
if (i > query.offset
|
|
||||||
&& i <= query.offset + query.limit) {
|
|
||||||
res[key] = data[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cb(null, {results:res, query: query, total:i});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
function () { },
|
|
||||||
cb
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,43 +28,11 @@
|
||||||
<li><a href="plugins/info">Troubleshooting information</a> </li>
|
<li><a href="plugins/info">Troubleshooting information</a> </li>
|
||||||
<% e.end_block(); %>
|
<% e.end_block(); %>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="progress"><img src="../static/img/loading.gif"> <span class="message"></span></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="innerwrapper">
|
<div class="innerwrapper">
|
||||||
<h2>Installed plugins</h2>
|
<h2>Installed plugins</h2>
|
||||||
<table>
|
<table class="installed-results">
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Description</th>
|
|
||||||
<th>Version</th>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="template">
|
|
||||||
<tr id="installed-plugin-template">
|
|
||||||
<td class="name" data-label="Name"></td>
|
|
||||||
<td class="description" data-label="Description"></td>
|
|
||||||
<td class="version" data-label="Version"></td>
|
|
||||||
<td class="actions">
|
|
||||||
<input type="button" value="Uninstall" class="do-uninstall">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<tbody id="installed-plugins">
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div class="paged listing search-results">
|
|
||||||
<div class="separator"></div>
|
|
||||||
|
|
||||||
<h2>Available plugins</h2>
|
|
||||||
<form>
|
|
||||||
<input type="text" name="search" placeholder="Search for plugins to install" id="search-query">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
@ -74,22 +42,69 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="template">
|
<tbody class="template">
|
||||||
<tr>
|
<tr id="installed-plugin-template">
|
||||||
<td class="name" data-label="Name"></td>
|
<td class="name" data-label="Name"></td>
|
||||||
<td class="description" data-label="Description"></td>
|
<td class="description" data-label="Description"></td>
|
||||||
<td class="version" data-label="Version"></td>
|
<td class="version" data-label="Version"></td>
|
||||||
<td class="actions">
|
<td>
|
||||||
<input type="button" value="Install" class="do-install">
|
<div class="actions">
|
||||||
</td>
|
<input type="button" value="Uninstall" class="do-uninstall">
|
||||||
|
<div class="progress"><p><img src="../static/img/loading.gif"/></p><p><span class="message"></span></p></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tbody class="results">
|
<tbody id="installed-plugins">
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tbody class="messages">
|
||||||
|
<tr><td></td><td>
|
||||||
|
<p class="nothing-installed">You haven't installed any plugins yet.</p>
|
||||||
|
<p class="fetching"><img src="../static/img/loading.gif"/><br/>Fetching installed plugins...</p>
|
||||||
|
</td><td></td></tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<input type="button" value="<<" class="do-prev-page">
|
|
||||||
<span class="offset"></span>..<span class="limit"></span> of <span class="total"></span>.
|
<div class="paged listing search-results">
|
||||||
<input type="button" value=">>" class="do-next-page">
|
<div class="separator"></div>
|
||||||
</div>
|
|
||||||
|
<h2>Available plugins</h2>
|
||||||
|
<form>
|
||||||
|
<input type="text" name="search" disabled placeholder="Search for plugins to install" id="search-query">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="sort up" data-label="name">Name</th>
|
||||||
|
<th class="sort none" data-label="description">Description</th>
|
||||||
|
<th class="sort none" data-label="version">Version</th>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="template">
|
||||||
|
<tr>
|
||||||
|
<td class="name" data-label="Name"></td>
|
||||||
|
<td class="description" data-label="Description"></td>
|
||||||
|
<td class="version" data-label="Version"></td>
|
||||||
|
<td>
|
||||||
|
<div class="actions">
|
||||||
|
<input type="button" value="Install" class="do-install">
|
||||||
|
<div class="progress"><p><img src="../static/img/loading.gif"/></p><p><span class="message"></span></p></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody class="results">
|
||||||
|
</tbody>
|
||||||
|
<tbody class="messages">
|
||||||
|
<tr><td></td><td>
|
||||||
|
<div class="search-progress" class="progress"><img src="../static/img/loading.gif"/></div>
|
||||||
|
<p class="nothing-found">No plugins found.</p>
|
||||||
|
<p class="fetching"><img src="../static/img/loading.gif"/><br/>Fetching catalogue...</p>
|
||||||
|
</td><td></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -369,14 +369,17 @@
|
||||||
<% e.end_block(); %>
|
<% e.end_block(); %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="chaticon" onclick="chat.show();return false;">
|
<div id="chaticon" onclick="chat.show();return false;" data-l10n-id="pad.chat">
|
||||||
<span id="chatlabel" data-l10n-id="pad.chat"></span>
|
<span id="chatlabel" data-l10n-id="pad.chat"></span>
|
||||||
<span class="buttonicon buttonicon-chat"></span>
|
<span class="buttonicon buttonicon-chat"></span>
|
||||||
<span id="chatcounter">0</span>
|
<span id="chatcounter">0</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="chatbox">
|
<div id="chatbox">
|
||||||
<div id="titlebar"><span id ="titlelabel" data-l10n-id="pad.chat"></span><a id="titlecross" onClick="chat.hide();return false;">- </a></div>
|
<div id="titlebar"><span id ="titlelabel" data-l10n-id="pad.chat"></span>
|
||||||
|
<a id="titlecross" onClick="chat.hide();return false;">- </a>
|
||||||
|
<a id="titlesticky" onClick="chat.stickToScreen(true);$('#options-stickychat').prop('checked', true);return false;" title="Stick chat to screen">█ </a>
|
||||||
|
</div>
|
||||||
<div id="chattext" class="authorColors">
|
<div id="chattext" class="authorColors">
|
||||||
<img alt="loading.." id="chatloadmessagesball" class="chatloadmessages" src="../static/img/loading.gif" align="top">
|
<img alt="loading.." id="chatloadmessagesball" class="chatloadmessages" src="../static/img/loading.gif" align="top">
|
||||||
<button id="chatloadmessagesbutton" class="chatloadmessages" data-l10n-id="pad.chat.loadmessages"></button>
|
<button id="chatloadmessagesbutton" class="chatloadmessages" data-l10n-id="pad.chat.loadmessages"></button>
|
||||||
|
|
Loading…
Reference in a new issue