From 4b77dd8c7a6d36d441c35fd5e4382d52f92a19d7 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Aug 2011 21:59:12 +0100 Subject: [PATCH 01/11] Beginning of a show chat history function --- static/css/pad.css | 8 ++++++++ static/js/chat.js | 7 +++++++ static/pad.html | 7 +++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/static/css/pad.css b/static/css/pad.css index 7839ff43..df68985c 100644 --- a/static/css/pad.css +++ b/static/css/pad.css @@ -1086,3 +1086,11 @@ width:27px !important; opacity:0.01; display:none; } + +#showhistorylabel{ + position:absolute; + left:58px; + top:4px; + cursor: hand; + cursor: pointer; +} diff --git a/static/js/chat.js b/static/js/chat.js index f617bdb3..9039d9d9 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -28,6 +28,13 @@ var chat = (function() }); }); }, + showHistory: function() + { + // this is a placeholder for the showHistory function + // load the messages from the server + // append them to the UI using addMessage + self.scrollDown(); // scroll down to the bottom of the chat + }, hide: function () { $("#chatcounter").text("0"); diff --git a/static/pad.html b/static/pad.html index 01a095d7..6e1f75b8 100644 --- a/static/pad.html +++ b/static/pad.html @@ -249,14 +249,17 @@ Use this link to share a read-only version of your pad: - Chat + Chat
0
-
Chat
+
Chat | + Show History + +
From db3ee19ced3aff579a5db7975b0d254a5f949808 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Aug 2011 22:10:58 +0100 Subject: [PATCH 02/11] Added support for monospace font to be passed as a parameter in the URL --- static/js/pad2.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index 1fe56b12..7b27ecff 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -18,6 +18,7 @@ var socket; var LineNumbersDisabled = false; +var useMonospaceFontGlobal = false; var globalUserName = false; $(document).ready(function() @@ -77,6 +78,7 @@ function getParams() var showChat = getUrlVars()["showChat"]; var userName = getUrlVars()["userName"]; var showLineNumbers = getUrlVars()["showLineNumbers"]; + var useMonospaceFont = getUrlVars()["useMonospaceFont"]; if(showControls) { if(showControls == "false") @@ -102,6 +104,15 @@ function getParams() } } + if(useMonospaceFont) + { + if(useMonospaceFont == "true") + { + useMonospaceFontGlobal = true; + } + } + + if(userName) { // If the username is set as a parameter we should set a global value that we can call once we have initiated the pad. @@ -183,6 +194,12 @@ function handshake() pad.changeViewOption('showLineNumbers', false); } + // If the Monospacefont value is set to true then change it to monospace. + if (useMonospaceFontGlobal == true) + { + pad.changeViewOption('useMonospaceFont', true); + } + // if the globalUserName value is set we need to tell the server and the client about the new authorname if (globalUserName !== false) { @@ -403,7 +420,8 @@ var pad = { }; options.view[key] = value; pad.handleOptionsChange(options); - if (key != "showLineNumbers") + // if the request isn't to hide line numbers then broadcast this to other users + if (key != "showLineNumbers" && key != "useMonospaceFont") { pad.collabClient.sendClientMessage( { From 10c2497fcca5442ea28ebce71e2d13978069c840 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 14 Aug 2011 14:47:41 +0100 Subject: [PATCH 03/11] Allow cross site export --- node/server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/node/server.js b/node/server.js index 0d8cc303..3805e991 100644 --- a/node/server.js +++ b/node/server.js @@ -204,6 +204,7 @@ async.waterfall([ return; } + res.header("Access-Control-Allow-Origin", "*"); res.header("Server", serverName); exportHandler.doExport(req, res, req.params.pad, req.params.type); }); From da6caedb45be228535ba3ec634bc8472738c4e9c Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 13:02:27 +0100 Subject: [PATCH 04/11] fixed abiword on windows --- node/utils/Abiword.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/utils/Abiword.js b/node/utils/Abiword.js index 3a99f56b..87bbb58d 100644 --- a/node/utils/Abiword.js +++ b/node/utils/Abiword.js @@ -24,12 +24,14 @@ var async = require("async"); var settings = require("./Settings"); var os = require('os'); +var doConvertTask; + //on windows we have to spawn a process for each convertion, cause the plugin abicommand doesn't exist on this platform if(os.type().indexOf("Windows") > -1) { var stdoutBuffer = ""; - function doConvertTask(task, callback) + doConvertTask = function(task, callback) { //span an abiword process to perform the conversion var abiword = spawn(settings.abiword, ["--to=" + task.destFile, task.srcFile]); @@ -123,7 +125,7 @@ else } } - function doConvertTask(task, callback) + doConvertTask = function(task, callback) { abiword.stdin.write("convert " + task.srcFile + " " + task.destFile + " " + task.type + "\n"); From b49123230dc4bd007441af09baeecbe0f61d5463 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 13:03:07 +0100 Subject: [PATCH 05/11] added the dirty db file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 13f01feb..325e11ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ static/js/jquery.min.js bin/abiword.exe bin/node.exe etherpad-lite-win.zip +var/dirty.db \ No newline at end of file From 936a9985e1017c63372c791d87e85ecc47d56af3 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 13:11:48 +0100 Subject: [PATCH 06/11] use the temp enviroment variable for windows --- node/handler/ExportHandler.js | 2 +- node/handler/ImportHandler.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/handler/ExportHandler.js b/node/handler/ExportHandler.js index 674950f4..fd6d26e4 100644 --- a/node/handler/ExportHandler.js +++ b/node/handler/ExportHandler.js @@ -34,7 +34,7 @@ var tempDirectory = "/tmp"; //tempDirectory changes if the operating system is windows if(os.type().indexOf("Windows") > -1) { - tempDirectory = "c:\\Temp"; + tempDirectory = process.env.TEMP; } /** diff --git a/node/handler/ImportHandler.js b/node/handler/ImportHandler.js index c02c9f50..935e95fd 100644 --- a/node/handler/ImportHandler.js +++ b/node/handler/ImportHandler.js @@ -35,7 +35,7 @@ var tempDirectory = "/tmp/"; //tempDirectory changes if the operating system is windows if(os.type().indexOf("Windows") > -1) { - tempDirectory = "c:\\Temp\\"; + tempDirectory = process.env.TEMP; } /** From 0229217bafb0411d16b1ca2a304b9bb4615fe36c Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 20:06:38 +0100 Subject: [PATCH 07/11] updated socket.io --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6005e5fb..735f9b72 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "name": "Robin Buse"} ], "dependencies" : { - "socket.io" : "0.7.8", + "socket.io" : "0.7.9", "ueberDB" : "0.0.15", "async" : "0.1.9", "joose" : "3.18.0", From 793ef42704a0e0ce5bd044567032d697671bb3a8 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sat, 13 Aug 2011 20:20:30 +0100 Subject: [PATCH 08/11] added a error message for invalid padIDs --- node/server.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/node/server.js b/node/server.js index 3805e991..1b35233f 100644 --- a/node/server.js +++ b/node/server.js @@ -162,7 +162,7 @@ async.waterfall([ //ensure the padname is valid and the url doesn't end with a / if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) { - next(); + res.send('Such a padname is forbidden', 404); return; } @@ -177,7 +177,7 @@ async.waterfall([ //ensure the padname is valid and the url doesn't end with a / if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) { - next(); + res.send('Such a padname is forbidden', 404); return; } @@ -189,6 +189,13 @@ async.waterfall([ //serve timeslider.html under /p/$padname/timeslider app.get('/p/:pad/export/:type', function(req, res, next) { + //ensure the padname is valid and the url doesn't end with a / + if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) + { + res.send('Such a padname is forbidden', 404); + return; + } + var types = ["pdf", "doc", "txt", "html", "odt"]; //send a 404 if we don't support this filetype if(types.indexOf(req.params.type) == -1) @@ -212,6 +219,13 @@ async.waterfall([ //handle import requests app.post('/p/:pad/import', function(req, res, next) { + //ensure the padname is valid and the url doesn't end with a / + if(!isValidPadname(req.params.pad) || /\/$/.test(req.url)) + { + res.send('Such a padname is forbidden', 404); + return; + } + //if abiword is disabled, skip handling this request if(settings.abiword == null) { From 37a220fa8787b56bd4ae0035b15d8d439e5a0c46 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Mon, 15 Aug 2011 15:40:38 +0100 Subject: [PATCH 09/11] fixed opera bug thx @johnyma22 --- static/js/pad2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index 7b27ecff..436070c7 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -150,6 +150,8 @@ function handshake() socket.once('connect', function() { var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1); + padId = unescape(padId); // unescape neccesary due to Safari and Opera interpretation of spaces + document.title = document.title + " | " + padId; var token = readCookie("token"); @@ -158,7 +160,7 @@ function handshake() token = randomString(); createCookie("token", token, 60); } - + var msg = { "component": "pad", "type": "CLIENT_READY", From 37224f620f1a0d560bfe3ec50ba3aab534ba25ba Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 15 Aug 2011 15:00:24 +0100 Subject: [PATCH 10/11] Fix issue 82, bullets not showing up in time slider, please note that the timeslider may have other css bugs such as indent etc and this needs testing --- static/css/timeslider.css | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/static/css/timeslider.css b/static/css/timeslider.css index 17518634..c609c2bc 100644 --- a/static/css/timeslider.css +++ b/static/css/timeslider.css @@ -194,3 +194,29 @@ float:right; padding-right: 6pt; } + + + padding: 0; + margin: 0; +} +ul { margin-left: 1.5em; } +ul ul { margin-left: 0 !important; } +ul.list-bullet1 { margin-left: 1.5em; } +ul.list-bullet2 { margin-left: 3em; } +ul.list-bullet3 { margin-left: 4.5em; } +ul.list-bullet4 { margin-left: 6em; } +ul.list-bullet5 { margin-left: 7.5em; } +ul.list-bullet6 { margin-left: 9em; } +ul.list-bullet7 { margin-left: 10.5em; } +ul.list-bullet8 { margin-left: 12em; } + +ul { list-style-type: disc; } +ul.list-bullet1 { list-style-type: disc; } +ul.list-bullet2 { list-style-type: circle; } +ul.list-bullet3 { list-style-type: square; } +ul.list-bullet4 { list-style-type: disc; } +ul.list-bullet5 { list-style-type: circle; } +ul.list-bullet6 { list-style-type: square; } +ul.list-bullet7 { list-style-type: disc; } +ul.list-bullet8 { list-style-type: circle; } + From 7d1dbae5e59e67fc32625c1a79f0175f68752e15 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 15 Aug 2011 11:59:09 +0100 Subject: [PATCH 11/11] Add pad.css and custom/pad.css availability into the iFrame as a fix for issue 83 --- static/js/ace.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/js/ace.js b/static/js/ace.js index bb2e6833..27899aaa 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -248,6 +248,8 @@ function Ace2Editor() // these lines must conform to a specific format because they are passed by the build script: iframeHTML.push($$INCLUDE_CSS_Q("../static/css/iframe_editor.css")); + iframeHTML.push($$INCLUDE_CSS_Q("../static/css/pad.css")); + iframeHTML.push($$INCLUDE_CSS_Q("../static/custom/pad.css")); iframeHTML.push($$INCLUDE_JS_Q("../static/js/ace2_common.js")); iframeHTML.push($$INCLUDE_JS_Q("../static/js/skiplist.js")); iframeHTML.push($$INCLUDE_JS_Q("../static/js/virtual_lines.js")); @@ -267,7 +269,7 @@ function Ace2Editor() var outerScript = 'editorId = "' + info.id + '"; editorInfo = parent.' + thisFunctionsName + '.registry[editorId]; ' + 'window.onload = function() ' + '{ window.onload = null; setTimeout' + '(function() ' + '{ var iframe = document.createElement("IFRAME"); ' + 'iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE 'outerdocbody.insertBefore(iframe, outerdocbody.firstChild); ' + 'iframe.ace_outerWin = window; ' + 'readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; ' + 'var doc = iframe.contentWindow.document; doc.open(); var text = (' + iframeHTML.join('+') + ').replace(/\\\\x3c/g, \'<\');doc.write(text); doc.close(); ' + '}, 0); }'; - var outerHTML = [doctype, '', $$INCLUDE_CSS("../static/css/iframe_editor.css"), + var outerHTML = [doctype, '', $$INCLUDE_CSS("../static/css/iframe_editor.css"), $$INCLUDE_CSS("../static/css/pad.css"), $$INCLUDE_CSS("../static/custom/pad.css"), // bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly // (throbs busy while typing) '', '\x3cscript>\n', outerScript, '\n\x3c/script>', '
x
'];