merged upstream develop

This commit is contained in:
Wikinaut 2012-12-07 08:59:13 +01:00
commit 5bf79971b8
20 changed files with 246 additions and 196 deletions

View file

@ -68,7 +68,7 @@
"maxAge" : 21600, // 60 * 60 * 6 = 6 hours "maxAge" : 21600, // 60 * 60 * 6 = 6 hours
/* This is the path to the Abiword executable. Setting it to null, disables abiword. /* This is the path to the Abiword executable. Setting it to null, disables abiword.
Abiword is needed to enable the import/export of pads*/ Abiword is needed to advanced import/export features of pads*/
"abiword" : null, "abiword" : null,
/* This setting is used if you require authentication of all users. /* This setting is used if you require authentication of all users.

View file

@ -21,6 +21,9 @@ 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
pad.loading = Loading... pad.loading = Loading...
pad.passwordRequired = You need a password to access this pad
pad.permissionDenied = You do not have permission to access this pad
pad.wrongPassword = Your password was wrong
pad.settings.padSettings = Pad Settings pad.settings.padSettings = Pad Settings
pad.settings.myView = My View pad.settings.myView = My View
pad.settings.stickychat = Chat always on screen pad.settings.stickychat = Chat always on screen
@ -41,6 +44,7 @@ pad.importExport.exportword = Microsoft Word
pad.importExport.exportpdf = PDF pad.importExport.exportpdf = PDF
pad.importExport.exportopen = ODF (Open Document Format) pad.importExport.exportopen = ODF (Open Document Format)
pad.importExport.exportdokuwiki = DokuWiki pad.importExport.exportdokuwiki = DokuWiki
pad.importExport.abiword.innerHTML = You only can import from plain text or html formats. For more advanced import features please <a href="https://github.com/ether/etherpad-lite/wiki/How-to-enable-importing-and-exporting-different-file-formats-in-Ubuntu-or-OpenSuse-or-SLES-with-AbiWord">install abiword</a>.
pad.modals.connected = Connected. pad.modals.connected = Connected.
pad.modals.reconnecting = Reconnecting to your pad.. pad.modals.reconnecting = Reconnecting to your pad..
pad.modals.forcereconnect = Force reconnect pad.modals.forcereconnect = Force reconnect

View file

@ -46,6 +46,7 @@ pad.importExport.exportword = Microsoft Word
pad.importExport.exportpdf = PDF pad.importExport.exportpdf = PDF
pad.importExport.exportopen = ODF (Open Document Format) pad.importExport.exportopen = ODF (Open Document Format)
pad.importExport.exportdokuwiki = DokuWiki pad.importExport.exportdokuwiki = DokuWiki
pad.importExport.abiword.innerHTML = Sólo puede importar formatos de texto plano o html. Para funciones más avanzadas instale <a href="https://github.com/ether/etherpad-lite/wiki/How-to-enable-importing-and-exporting-different-file-formats-in-Ubuntu-or-OpenSuse-or-SLES-with-AbiWord">abiword</a>.
pad.modals.connected = Conectado. pad.modals.connected = Conectado.
pad.modals.reconnecting = Reconectando a tu pad.. pad.modals.reconnecting = Reconectando a tu pad..
pad.modals.forcereconnect = Reconexión forzosa pad.modals.forcereconnect = Reconexión forzosa

View file

@ -25,7 +25,7 @@ var async = require("async");
var authorManager = require("./AuthorManager"); var authorManager = require("./AuthorManager");
var padManager = require("./PadManager"); var padManager = require("./PadManager");
var sessionManager = require("./SessionManager"); var sessionManager = require("./SessionManager");
var settings = require("../utils/Settings") var settings = require("../utils/Settings");
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
/** /**
@ -83,7 +83,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
// grant access, with author of token // grant access, with author of token
callback(null, statusObject); callback(null, statusObject);
} }
}) });
//don't continue //don't continue
return; return;
@ -133,10 +133,16 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
var now = Math.floor(new Date().getTime()/1000); var now = Math.floor(new Date().getTime()/1000);
//is it for this group? //is it for this group?
if(sessionInfo.groupID != groupID) return; if(sessionInfo.groupID != groupID) {
callback();
return;
}
//is validUntil still ok? //is validUntil still ok?
if(sessionInfo.validUntil <= now) return; if(sessionInfo.validUntil <= now){
callback();
return;
}
// There is a valid session // There is a valid session
validSession = true; validSession = true;
@ -282,4 +288,4 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
if(ERR(err, callback)) return; if(ERR(err, callback)) return;
callback(null, statusObject); callback(null, statusObject);
}); });
} };

View file

@ -28,18 +28,25 @@ var resolve = require("resolve");
exports.info = { exports.info = {
buf_stack: [], buf_stack: [],
block_stack: [], block_stack: [],
blocks: {},
file_stack: [], file_stack: [],
args: [] args: []
}; };
function getCurrentFile() {
return exports.info.file_stack[exports.info.file_stack.length-1];
}
function createBlockId(name) {
return getCurrentFile().path + '|' + name;
}
exports._init = function (b, recursive) { exports._init = function (b, recursive) {
exports.info.buf_stack.push(exports.info.buf); exports.info.buf_stack.push(exports.info.buf);
exports.info.buf = b; exports.info.buf = b;
} }
exports._exit = function (b, recursive) { exports._exit = function (b, recursive) {
exports.info.file_stack[exports.info.file_stack.length-1].inherit.forEach(function (item) { getCurrentFile().inherit.forEach(function (item) {
exports._require(item.name, item.args); exports._require(item.name, item.args);
}); });
exports.info.buf = exports.info.buf_stack.pop(); exports.info.buf = exports.info.buf_stack.pop();
@ -59,29 +66,17 @@ exports.end_capture = function () {
} }
exports.begin_define_block = function (name) { exports.begin_define_block = function (name) {
if (typeof exports.info.blocks[name] == "undefined")
exports.info.blocks[name] = {};
exports.info.block_stack.push(name); exports.info.block_stack.push(name);
exports.begin_capture(); exports.begin_capture();
} }
exports.super = function () {
exports.info.buf.push('<!eejs!super!>');
}
exports.end_define_block = function () { exports.end_define_block = function () {
content = exports.end_capture(); content = exports.end_capture();
var name = exports.info.block_stack.pop(); return content;
if (typeof exports.info.blocks[name].content == "undefined")
exports.info.blocks[name].content = content;
else if (typeof exports.info.blocks[name].content.indexOf('<!eejs!super!>'))
exports.info.blocks[name].content = exports.info.blocks[name].content.replace('<!eejs!super!>', content);
return exports.info.blocks[name].content;
} }
exports.end_block = function () { exports.end_block = function () {
var name = exports.info.block_stack[exports.info.block_stack.length-1]; var name = exports.info.block_stack.pop();
var renderContext = exports.info.args[exports.info.args.length-1]; var renderContext = exports.info.args[exports.info.args.length-1];
var args = {content: exports.end_define_block(), renderContext: renderContext}; var args = {content: exports.end_define_block(), renderContext: renderContext};
hooks.callAll("eejsBlock_" + name, args); hooks.callAll("eejsBlock_" + name, args);
@ -91,7 +86,7 @@ exports.end_block = function () {
exports.begin_block = exports.begin_define_block; exports.begin_block = exports.begin_define_block;
exports.inherit = function (name, args) { exports.inherit = function (name, args) {
exports.info.file_stack[exports.info.file_stack.length-1].inherit.push({name:name, args:args}); getCurrentFile().inherit.push({name:name, args:args});
} }
exports.require = function (name, args, mod) { exports.require = function (name, args, mod) {
@ -101,7 +96,7 @@ exports.require = function (name, args, mod) {
var paths = []; var paths = [];
if (exports.info.file_stack.length) { if (exports.info.file_stack.length) {
basedir = path.dirname(exports.info.file_stack[exports.info.file_stack.length-1].path); basedir = path.dirname(getCurrentFile().path);
} }
if (mod) { if (mod) {
basedir = path.dirname(mod.filename); basedir = path.dirname(mod.filename);

View file

@ -4,6 +4,7 @@
/* /*
* 2011 Peter 'Pita' Martischka (Primary Technology Ltd) * 2011 Peter 'Pita' Martischka (Primary Technology Ltd)
* 2012 Iván Eixarch
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,26 +19,23 @@
* limitations under the License. * limitations under the License.
*/ */
var ERR = require("async-stacktrace"); var ERR = require("async-stacktrace")
var padManager = require("../db/PadManager"); , padManager = require("../db/PadManager")
var padMessageHandler = require("./PadMessageHandler"); , padMessageHandler = require("./PadMessageHandler")
var async = require("async"); , async = require("async")
var fs = require("fs"); , fs = require("fs")
var settings = require('../utils/Settings'); , path = require("path")
var formidable = require('formidable'); , settings = require('../utils/Settings')
var os = require("os"); , formidable = require('formidable')
, os = require("os")
, importHtml = require("../utils/ImportHtml");
//load abiword only if its enabled //load abiword only if its enabled
if(settings.abiword != null) if(settings.abiword != null)
var abiword = require("../utils/Abiword"); var abiword = require("../utils/Abiword");
var tempDirectory = "/tmp/"; //for node 0.6 compatibily, os.tmpDir() only works from 0.8
var tmpDirectory = process.env.TEMP || process.env.TMPDIR || process.env.TMP || '/tmp';
//tempDirectory changes if the operating system is windows
if(os.type().indexOf("Windows") > -1)
{
tempDirectory = process.env.TEMP;
}
/** /**
* do a requested import * do a requested import
@ -45,32 +43,28 @@ if(os.type().indexOf("Windows") > -1)
exports.doImport = function(req, res, padId) exports.doImport = function(req, res, padId)
{ {
//pipe to a file //pipe to a file
//convert file to text via abiword //convert file to html via abiword
//set text in the pad //set html in the pad
var srcFile, destFile; var srcFile, destFile
var pad; , pad
var text; , text;
async.series([ async.series([
//save the uploaded file to /tmp //save the uploaded file to /tmp
function(callback) function(callback) {
{
var form = new formidable.IncomingForm(); var form = new formidable.IncomingForm();
form.keepExtensions = true; form.keepExtensions = true;
form.uploadDir = tempDirectory; form.uploadDir = tmpDirectory;
form.parse(req, function(err, fields, files) form.parse(req, function(err, fields, files) {
{
//the upload failed, stop at this point //the upload failed, stop at this point
if(err || files.file === undefined) if(err || files.file === undefined) {
{
console.warn("Uploading Error: " + err.stack); console.warn("Uploading Error: " + err.stack);
callback("uploadFailed"); callback("uploadFailed");
} }
//everything ok, continue //everything ok, continue
else else {
{
//save the path of the uploaded file //save the path of the uploaded file
srcFile = files.file.path; srcFile = files.file.path;
callback(); callback();
@ -80,57 +74,48 @@ exports.doImport = function(req, res, padId)
//ensure this is a file ending we know, else we change the file ending to .txt //ensure this is a file ending we know, else we change the file ending to .txt
//this allows us to accept source code files like .c or .java //this allows us to accept source code files like .c or .java
function(callback) function(callback) {
{ var fileEnding = path.extname(srcFile).toLowerCase()
var fileEnding = (srcFile.split(".")[1] || "").toLowerCase(); , knownFileEndings = [".txt", ".doc", ".docx", ".pdf", ".odt", ".html", ".htm"]
var knownFileEndings = ["txt", "doc", "docx", "pdf", "odt", "html", "htm"]; , fileEndingKnown = (knownFileEndings.indexOf(fileEnding) > -1);
//find out if this is a known file ending
var fileEndingKnown = false;
for(var i in knownFileEndings)
{
if(fileEnding == knownFileEndings[i])
{
fileEndingKnown = true;
}
}
//if the file ending is known, continue as normal //if the file ending is known, continue as normal
if(fileEndingKnown) if(fileEndingKnown) {
{
callback(); callback();
} }
//we need to rename this file with a .txt ending //we need to rename this file with a .txt ending
else else {
{
var oldSrcFile = srcFile; var oldSrcFile = srcFile;
srcFile = srcFile.split(".")[0] + ".txt"; srcFile = path.join(path.dirname(srcFile),path.basename(srcFile, fileEnding)+".txt");
fs.rename(oldSrcFile, srcFile, callback); fs.rename(oldSrcFile, srcFile, callback);
} }
}, },
//convert file to text //convert file to html
function(callback) function(callback) {
{
var randNum = Math.floor(Math.random()*0xFFFFFFFF); var randNum = Math.floor(Math.random()*0xFFFFFFFF);
destFile = tempDirectory + "eplite_import_" + randNum + ".txt"; destFile = path.join(tmpDirectory, "eplite_import_" + randNum + ".htm");
abiword.convertFile(srcFile, destFile, "txt", function(err){
//catch convert errors if (abiword) {
if(err){ abiword.convertFile(srcFile, destFile, "htm", function(err) {
console.warn("Converting Error:", err); //catch convert errors
return callback("convertFailed"); if(err) {
} else { console.warn("Converting Error:", err);
callback(); return callback("convertFailed");
} } else {
}); callback();
}
});
} else {
// if no abiword only rename
fs.rename(srcFile, destFile, callback);
}
}, },
//get the pad object //get the pad object
function(callback) function(callback) {
{ padManager.getPad(padId, function(err, _pad){
padManager.getPad(padId, function(err, _pad)
{
if(ERR(err, callback)) return; if(ERR(err, callback)) return;
pad = _pad; pad = _pad;
callback(); callback();
@ -138,52 +123,47 @@ exports.doImport = function(req, res, padId)
}, },
//read the text //read the text
function(callback) function(callback) {
{ fs.readFile(destFile, "utf8", function(err, _text){
fs.readFile(destFile, "utf8", function(err, _text)
{
if(ERR(err, callback)) return; if(ERR(err, callback)) return;
text = _text; text = _text;
//node on windows has a delay on releasing of the file lock. //node on windows has a delay on releasing of the file lock.
//We add a 100ms delay to work around this //We add a 100ms delay to work around this
if(os.type().indexOf("Windows") > -1) if(os.type().indexOf("Windows") > -1){
{ setTimeout(function() {callback();}, 100);
setTimeout(function() } else {
{ callback();
callback(); }
}, 100);
}
else
{
callback();
}
}); });
}, },
//change text of the pad and broadcast the changeset //change text of the pad and broadcast the changeset
function(callback) function(callback) {
{ var fileEnding = path.extname(srcFile).toLowerCase();
pad.setText(text); if (abiword || fileEnding == ".htm" || fileEnding == ".html") {
importHtml.setPadHTML(pad, text);
} else {
pad.setText(text);
}
padMessageHandler.updatePadClients(pad, callback); padMessageHandler.updatePadClients(pad, callback);
}, },
//clean up temporary files //clean up temporary files
function(callback) function(callback) {
{ //for node < 0.7 compatible
var fileExists = fs.exists || path.exists;
async.parallel([ async.parallel([
function(callback) function(callback){
{ fileExists (srcFile, function(exist) { (exist)? fs.unlink(srcFile, callback): callback(); });
fs.unlink(srcFile, callback);
}, },
function(callback) function(callback){
{ fileExists (destFile, function(exist) { (exist)? fs.unlink(destFile, callback): callback(); });
fs.unlink(destFile, callback);
} }
], callback); ], callback);
} }
], function(err) ], function(err) {
{
var status = "ok"; var status = "ok";
//check for known errors and replace the status //check for known errors and replace the status
@ -196,6 +176,6 @@ exports.doImport = function(req, res, padId)
ERR(err); ERR(err);
//close the connection //close the connection
res.send("<script type='text/javascript' src='/static/js/jquery.js'></script><script> if ( (!$.browser.msie) && (!($.browser.mozilla && $.browser.version.indexOf(\"1.8.\") == 0)) ){document.domain = document.domain;}var impexp = window.top.require('/pad_impexp').padimpexp.handleFrameCall('" + status + "');</script>", 200); res.send("<script type='text/javascript' src='/static/js/jquery.js'></script><script> if ( (!$.browser.msie) && (!($.browser.mozilla && $.browser.version.indexOf(\"1.8.\") == 0)) ){document.domain = document.domain;}var impexp = window.parent.require('/pad_impexp').padimpexp.handleFrameCall('" + status + "');</script>", 200);
}); });
} }

View file

@ -66,8 +66,6 @@ exports.restartServer = function () {
} else { } else {
console.log( "SSL -- not enabled!" );
var http = require('http'); var http = require('http');
server = http.createServer(app); server = http.createServer(app);
} }

View file

@ -28,12 +28,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//handle import requests //handle import requests
args.app.post('/p/:pad/import', function(req, res, next) { args.app.post('/p/:pad/import', function(req, res, next) {
//if abiword is disabled, skip handling this request
if(settings.abiword == null) {
next();
return;
}
hasPadAccess(req, res, function() { hasPadAccess(req, res, function() {
importHandler.doImport(req, res, req.params.pad); importHandler.doImport(req, res, req.params.pad);
}); });

View file

@ -15,8 +15,8 @@ exports.basicAuth = function (req, res, next) {
} }
var authorize = function (cb) { var authorize = function (cb) {
// Do not require auth for static paths...this could be a bit brittle // Do not require auth for static paths and the API...this could be a bit brittle
if (req.path.match(/^\/(static|javascripts|pluginfw)/)) return cb(true); if (req.path.match(/^\/(static|javascripts|pluginfw|api)/)) return cb(true);
if (req.path.indexOf('/admin') != 0) { if (req.path.indexOf('/admin') != 0) {
if (!settings.requireAuthentication) return cb(true); if (!settings.requireAuthentication) return cb(true);

View file

@ -1,4 +1,4 @@
var languages = require('languages') var languages = require('languages4translatewiki')
, fs = require('fs') , fs = require('fs')
, path = require('path') , path = require('path')
, express = require('express') , express = require('express')
@ -8,22 +8,23 @@ var localesPath = __dirname+"/../../locales";
// Serve English strings directly with /locales.ini // Serve English strings directly with /locales.ini
var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n'; var localeIndex = fs.readFileSync(localesPath+'/en.ini')+'\r\n';
// add language base 'en' to availableLangs exports.availableLangs = {'en': {'nativeName': 'English', 'direction': 'ltr'}};
exports.availableLangs = {en: languages.getLanguageInfo('en')}
fs.readdir(localesPath, function(er, files) { fs.readdir(localesPath, function(er, files) {
files.forEach(function(locale) { files.forEach(function(locale) {
locale = locale.split('.')[0] var ext = path.extname(locale);
if(locale.toLowerCase() == 'en') return; locale = path.basename(locale, ext).toLowerCase();
if(locale == 'en' || ext != '.ini') return;
// build locale index // build locale index
localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n' localeIndex += '['+locale+']\r\n@import url(locales/'+locale+'.ini)\r\n'
// add info language {name, nativeName, direction} to availableLangs // add info language {nativeName, direction} to availableLangs
exports.availableLangs[locale]=languages.getLanguageInfo(locale); exports.availableLangs[locale]=languages.getLanguageInfo(locale);
}) })
}) })
exports.expressCreateServer = function(n, args) { exports.expressCreateServer = function(n, args) {
args.app.use('/locales', express.static(localesPath)); args.app.use('/locales', express.static(localesPath));

View file

@ -11,32 +11,32 @@
{ "name": "Marcel Klehr" } { "name": "Marcel Klehr" }
], ],
"dependencies" : { "dependencies" : {
"yajsml" : "1.1.6", "yajsml" : "1.1.6",
"request" : "2.9.100", "request" : "2.9.100",
"require-kernel" : "1.0.5", "require-kernel" : "1.0.5",
"resolve" : "0.2.x", "resolve" : "0.2.x",
"socket.io" : "0.9.x", "socket.io" : "0.9.x",
"ueberDB" : "0.1.8", "ueberDB" : "0.1.8",
"async" : "0.1.x", "async" : "0.1.x",
"express" : "3.x", "express" : "3.x",
"connect" : "2.4.x", "connect" : "2.4.x",
"clean-css" : "0.3.2", "clean-css" : "0.3.2",
"uglify-js" : "1.2.5", "uglify-js" : "1.2.5",
"formidable" : "1.0.9", "formidable" : "1.0.9",
"log4js" : "0.5.x", "log4js" : "0.5.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.1.x",
"npm-registry-client" : "0.2.10", "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",
"semver" : "1.0.13", "semver" : "1.0.13",
"security" : "1.0.0", "security" : "1.0.0",
"tinycon" : "0.0.1", "tinycon" : "0.0.1",
"underscore" : "1.3.1", "underscore" : "1.3.1",
"unorm" : "1.0.0", "unorm" : "1.0.0",
"languages" : "0.1.1" "languages4translatewiki" : "0.1.3"
}, },
"bin": { "etherpad-lite": "./node/server.js" }, "bin": { "etherpad-lite": "./node/server.js" },
"devDependencies": { "devDependencies": {

View file

@ -22,6 +22,7 @@ iframe {
.readonly .acl-write { .readonly .acl-write {
display: none; display: none;
} }
#users { #users {
background: #f7f7f7; background: #f7f7f7;
background: -webkit-linear-gradient( #F7F7F7,#EEE); background: -webkit-linear-gradient( #F7F7F7,#EEE);
@ -190,6 +191,19 @@ a img {
height: 30px; height: 30px;
z-index: 100; z-index: 100;
} }
#editorloadingbox .passForm{
padding:10px;
}
#editorloadingbox input{
padding:10px;
}
#editorloadingbox button{
padding:10px;
}
#editorcontainerbox { #editorcontainerbox {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@ -571,15 +585,20 @@ table#otheruserstable {
#exportdokuwiki { #exportdokuwiki {
background-position: 0px -459px background-position: 0px -459px
} }
#importstatusball {
display: none /* hidden element */
#importstatusball,
#importarrow,
#importmessagesuccess,
#importmessageabiword {
display: none;
} }
#importarrow {
display: none #importmessageabiword {
} color: #900;
#importmessagesuccess { font-size: small;
display: none
} }
#importsubmitinput { #importsubmitinput {
height: 25px; height: 25px;
width: 85px; width: 85px;
@ -755,7 +774,7 @@ input[type=checkbox] {
border-radius: 3px; border-radius: 3px;
border: 1px solid #ccc; border: 1px solid #ccc;
outline: none; outline: none;
min-width: 105px; width: 120px;
} }
.column { .column {
float: left; float: left;
@ -878,3 +897,15 @@ input[type=checkbox] {
line-height: 24px line-height: 24px
} }
} }
#passwordRequired{
display:none;
}
#permissionDenied{
display:none;
}
#wrongPassword{
display:none;
}

View file

@ -113,10 +113,15 @@ $(document).ready(function () {
for (plugin_name in data.results) { for (plugin_name in data.results) {
var plugin = data.results[plugin_name]; var plugin = data.results[plugin_name];
var row = widget.find(".template tr").clone(); var row = widget.find(".template tr").clone();
var version = '0.0.0';
// hack to access "versions" property of the npm package object
for (version in data.results[plugin_name].versions) break;
for (attr in plugin) { for (attr in plugin) {
row.find("." + attr).html(plugin[attr]); row.find("." + attr).html(plugin[attr]);
} }
row.find(".version").html(version);
widget.find(".results").append(row); widget.find(".results").append(row);
} }

View file

@ -51,18 +51,20 @@ var randomString = require('./pad_utils').randomString;
var hooks = require('./pluginfw/hooks'); var hooks = require('./pluginfw/hooks');
function createCookie(name, value, days, path) function createCookie(name, value, days, path){ /* Warning Internet Explorer doesn't use this it uses the one from pad_utils.js */
{
if (days) if (days)
{ {
var date = new Date(); var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString(); var expires = "; expires=" + date.toGMTString();
} }
else var expires = ""; else{
var expires = "";
}
if(!path) if(!path){ // If the path isn't set then just whack the cookie on the root path
path = "/"; path = "/";
}
//Check if the browser is IE and if so make sure the full path is set in the cookie //Check if the browser is IE and if so make sure the full path is set in the cookie
if(navigator.appName=='Microsoft Internet Explorer'){ if(navigator.appName=='Microsoft Internet Explorer'){
@ -202,6 +204,7 @@ function savePassword()
createCookie("password",$("#passwordinput").val(),null,document.location.pathname); createCookie("password",$("#passwordinput").val(),null,document.location.pathname);
//reload //reload
document.location=document.location; document.location=document.location;
return false;
} }
function handshake() function handshake()
@ -298,21 +301,25 @@ function handshake()
//the access was not granted, give the user a message //the access was not granted, give the user a message
if(!receivedClientVars && obj.accessStatus) if(!receivedClientVars && obj.accessStatus)
{ {
$('.passForm').submit(require(module.id).savePassword);
if(obj.accessStatus == "deny") if(obj.accessStatus == "deny")
{ {
$("#editorloadingbox").html("<b>You do not have permission to access this pad</b>"); $('#loading').hide();
$("#permissionDenied").show();
} }
else if(obj.accessStatus == "needPassword") else if(obj.accessStatus == "needPassword")
{ {
$("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" + $('#loading').hide();
"<input id='passwordinput' type='password' name='password'>"+ $('#passwordRequired').show();
"<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>"); $("#passwordinput").focus();
} }
else if(obj.accessStatus == "wrongPassword") else if(obj.accessStatus == "wrongPassword")
{ {
$("#editorloadingbox").html("<b>Your password was wrong</b><br>" + $('#loading').hide();
"<input id='passwordinput' type='password' name='password'>"+ $('#wrongPassword').show();
"<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>"); $('#passwordRequired').show();
$("#passwordinput").focus();
} }
} }

View file

@ -218,6 +218,9 @@ var padimpexp = (function()
$("#exporthtmla").attr("href", pad_root_path + "/export/html"); $("#exporthtmla").attr("href", pad_root_path + "/export/html");
$("#exportplaina").attr("href", pad_root_path + "/export/txt"); $("#exportplaina").attr("href", pad_root_path + "/export/txt");
$("#exportdokuwikia").attr("href", pad_root_path + "/export/dokuwiki"); $("#exportdokuwikia").attr("href", pad_root_path + "/export/dokuwiki");
// activate action to import in the form
$("#importform").attr('action', pad_root_url + "/import");
//hide stuff thats not avaible if abiword is disabled //hide stuff thats not avaible if abiword is disabled
if(clientVars.abiwordAvailable == "no") if(clientVars.abiwordAvailable == "no")
@ -225,8 +228,8 @@ var padimpexp = (function()
$("#exportworda").remove(); $("#exportworda").remove();
$("#exportpdfa").remove(); $("#exportpdfa").remove();
$("#exportopena").remove(); $("#exportopena").remove();
$(".importformdiv").remove();
$("#import").html("Import is not available. To enable import please install abiword"); $("#importmessageabiword").show();
} }
else if(clientVars.abiwordAvailable == "withoutPDF") else if(clientVars.abiwordAvailable == "withoutPDF")
{ {
@ -237,16 +240,12 @@ var padimpexp = (function()
$("#importexport").css({"height":"142px"}); $("#importexport").css({"height":"142px"});
$("#importexportline").css({"height":"142px"}); $("#importexportline").css({"height":"142px"});
$("#importform").attr('action', pad_root_url + "/import");
} }
else else
{ {
$("#exportworda").attr("href", pad_root_path + "/export/doc"); $("#exportworda").attr("href", pad_root_path + "/export/doc");
$("#exportpdfa").attr("href", pad_root_path + "/export/pdf"); $("#exportpdfa").attr("href", pad_root_path + "/export/pdf");
$("#exportopena").attr("href", pad_root_path + "/export/odt"); $("#exportopena").attr("href", pad_root_path + "/export/odt");
$("#importform").attr('action', pad_root_path + "/import");
} }
$("#impexp-close").click(function() $("#impexp-close").click(function()

View file

@ -39,20 +39,29 @@ function randomString(len)
return randomstring; return randomstring;
} }
function createCookie(name, value, days, path) function createCookie(name, value, days, path){ /* Used by IE */
{
if (days) if (days)
{ {
var date = new Date(); var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString(); var expires = "; expires=" + date.toGMTString();
} }
else var expires = ""; else{
var expires = "";
}
if(!path) if(!path){ // IF the Path of the cookie isn't set then just create it on root
path = "/"; path = "/";
}
//Check if the browser is IE and if so make sure the full path is set in the cookie
if(navigator.appName=='Microsoft Internet Explorer'){
document.cookie = name + "=" + value + expires + "; path=/"; /* Note this bodge fix for IE is temporary until auth is rewritten */
}
else{
document.cookie = name + "=" + value + expires + "; path=" + path;
}
document.cookie = name + "=" + value + expires + "; path=" + path;
} }
function readCookie(name) function readCookie(name)

View file

@ -91,9 +91,12 @@ exports.search = function(query, cache, cb) {
if (er) return cb(er); if (er) return cb(er);
var res = {}; var res = {};
var i = 0; var i = 0;
for (key in data) { for (key in data) { // for every plugin in the data from npm
if ( key.indexOf(plugins.prefix) == 0 if ( key.indexOf(plugins.prefix) == 0
&& key.indexOf(query.pattern) != -1) { && key.indexOf(query.pattern) != -1
|| key.indexOf(plugins.prefix) == 0
&& data[key].description.indexOf(query.pattern) != -1
) { // If the name contains ep_ and the search string is in the name or description
i++; i++;
if (i > query.offset if (i > query.offset
&& i <= query.offset + query.limit) { && i <= query.offset + query.limit) {

View file

@ -30,6 +30,7 @@
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Description</th> <th>Description</th>
<th>Version</th>
<td></td> <td></td>
</tr> </tr>
</thead> </thead>
@ -37,6 +38,7 @@
<tr id="installed-plugin-template"> <tr id="installed-plugin-template">
<td class="name"></td> <td class="name"></td>
<td class="description"></td> <td class="description"></td>
<td class="version"></td>
<td class="actions"> <td class="actions">
<input type="button" value="Uninstall" class="do-uninstall"> <input type="button" value="Uninstall" class="do-uninstall">
</td> </td>
@ -58,6 +60,7 @@
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Description</th> <th>Description</th>
<th>Version</th>
<td></td> <td></td>
</tr> </tr>
</thead> </thead>
@ -65,6 +68,7 @@
<tr> <tr>
<td class="name"></td> <td class="name"></td>
<td class="description"></td> <td class="description"></td>
<td class="version"></td>
<td class="actions"> <td class="actions">
<input type="button" value="Install" class="do-install"> <input type="button" value="Install" class="do-install">
</td> </td>

View file

@ -41,7 +41,7 @@
if(language) document.documentElement.lang = language[1]; if(language) document.documentElement.lang = language[1];
})(document) })(document)
</script> </script>
<script type="text/javascript" src="static/js/l10n.js" async></script> <script type="text/javascript" src="static/js/l10n.js"></script>
<style> <style>
html, body { html, body {

View file

@ -184,7 +184,19 @@
<div id="editorcontainerbox"> <div id="editorcontainerbox">
<div id="editorcontainer"></div> <div id="editorcontainer"></div>
<div id="editorloadingbox"> <div id="editorloadingbox">
<p data-l10n-id="pad.loading">Loading...</p> <div id="passwordRequired">
<p data-l10n-id="pad.passwordRequired">You need a password to access this pad</p>
<form class='passForm' method='POST'>
<input id='passwordinput' type='password' name='password'><input type='submit' value='Submit'>
</form>
</div>
<div id="permissionDenied">
<p data-l10n-id="pad.permissionDenied">You do not have permission to access this pad</p>
</div>
<div id="wrongPassword">
<p data-l10n-id="pad.wrongPassword">Your password was wrong</p>
</div>
<p data-l10n-id="pad.loading" id="loading">Loading...</p>
<noscript><strong>Sorry, you have to enable Javascript in order to use this.</strong></noscript> <noscript><strong>Sorry, you have to enable Javascript in order to use this.</strong></noscript>
</div> </div>
</div> </div>
@ -246,10 +258,11 @@
<h1 data-l10n-id="pad.importExport.import_export"></h1> <h1 data-l10n-id="pad.importExport.import_export"></h1>
<div class="column acl-write"> <div class="column acl-write">
<% e.begin_block("importColumn"); %> <% e.begin_block("importColumn"); %>
<h2 data-l10n-id="pad.importExport.import"></h2><br> <h2 data-l10n-id="pad.importExport.import"></h2>
<div class="importmessage" id="importmessageabiword" data-l10n-id="pad.importExport.abiword"></div><br>
<form id="importform" method="post" action="" target="importiframe" enctype="multipart/form-data"> <form id="importform" method="post" action="" target="importiframe" enctype="multipart/form-data">
<div class="importformdiv" id="importformfilediv"> <div class="importformdiv" id="importformfilediv">
<input type="file" name="file" size="15" id="importfileinput"> <input type="file" name="file" size="10" id="importfileinput">
<div class="importmessage" id="importmessagefail"></div> <div class="importmessage" id="importmessagefail"></div>
</div> </div>
<div id="import"></div> <div id="import"></div>