Merge branch 'newmaster' of ../etherpad-lite.io2

pull/37/head
Peter 'Pita' Martischka 2011-07-24 21:30:22 +01:00
commit a9673765ae
9 changed files with 89 additions and 84 deletions

View File

@ -29,10 +29,10 @@ var queue = async.queue(doConvertTask, 1);
//spawn the abiword process
var abiword = spawn(settings.abiword, ["--plugin", "AbiCommand"]);
//output error messages to stderr
//append error messages to the buffer
abiword.stderr.on('data', function (data)
{
console.error("Abiword: " + data);
stdoutBuffer += data.toString();
});
//throw exceptions if abiword is dieing
@ -57,8 +57,7 @@ function onAbiwordStdout(data)
if(stdoutBuffer.search("AbiWord:>") != -1)
{
//filter the feedback message
var lines = stdoutBuffer.split("\n");
var err = lines [1] == "OK" ? null : lines[1];
var err = stdoutBuffer.search("OK") != -1 ? null : stdoutBuffer;
//reset the buffer
stdoutBuffer = "";

View File

@ -58,6 +58,38 @@ exports.doImport = function(req, res, padId)
});
},
//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
function(callback)
{
var fileEnding = srcFile.split(".")[1];
var knownFileEndings = ["txt", "doc", "docx", "pdf", "odt", "html", "htm"];
//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(fileEndingKnown)
{
callback();
}
//we need to rename this file with a .txt ending
else
{
var oldSrcFile = srcFile;
srcFile = srcFile.split(".")[0] + ".txt";
fs.rename(oldSrcFile, srcFile, callback);
}
},
//convert file to text
function(callback)
{
@ -109,9 +141,9 @@ exports.doImport = function(req, res, padId)
}
], function(err)
{
if(err) throw err;
//close the connection
res.send("ok");
if(err) throw err;
});
}

View File

@ -228,24 +228,34 @@ exports.padJS = function(req, res)
res.sendfile(pathStr, { maxAge: server.maxAge });
})
}
//minifying is disabled, so load the files with jquery
//minifying is disabled, so put the files together in one file
else
{
res.write("function loadjsfile(filename){\n"+
"var fileref=document.createElement('script');\n"+
"fileref.setAttribute('type','text/javascript');\n"+
"var path = 'static/js/' + filename;\n"+
"fileref.setAttribute('src', path);\n" +
"document.getElementsByTagName('head')[0].appendChild(fileref);\n" +
"}\n");
var fileValues = {};
for(var i in jsFiles)
//read all js files
async.forEach(jsFiles, function (item, callback)
{
console.log(jsFiles[i]);
res.write("loadjsfile('"+ jsFiles[i] + "');\n");
fs.readFile("../static/js/" + item, "utf-8", function(err, data)
{
fileValues[item] = data;
callback(err);
});
},
//send all files together
function(err)
{
if(err) throw err;
for(var i=0;i<jsFiles.length;i++)
{
var fileName = jsFiles[i];
res.write("\n\n\n/*** File: static/js/" + fileName + " ***/\n\n\n");
res.write(fileValues[fileName]);
}
res.end();
});
}
}

View File

@ -1000,6 +1000,10 @@ position: relative;
background-position: 2px -49px;
}
#export a{
text-decoration: none;
}
#importstatusball{
display:none;
}

View File

@ -21,13 +21,6 @@ var socket;
$(document).ready(function()
{
handshake();
// This is a temporary location, Peter to move
$("#exporthtmla").attr("href", document.location.href + "/export/html");
$("#exportplaina").attr("href", document.location.href + "/export/txt");
$("#exportworda").attr("href", document.location.href + "/export/doc");
$("#exportpdfa").attr("href", document.location.href + "/export/pdf");
$("#exportopena").attr("href", document.location.href + "/export/odt");
$("#exportwordlea").attr("href", document.location.href + "/export/wordle");
});
$(window).unload(function()
@ -35,18 +28,6 @@ $(window).unload(function()
pad.dispose();
});
// Wordle code, Peter to move
function loadCont(){
padUrl = location.pathname;
padHost = location.host;
var padUrl = "http://" + padHost + padUrl + "/export/txt";
$.get(padUrl, function(data) {
$('.result').html(data);
$('#text').html(data);
$('#wordlepost').submit();
});
}
function createCookie(name, value, days)
{
if (days)
@ -99,7 +80,7 @@ function handshake()
resource: resource
});
socket.on('connect', function()
socket.once('connect', function()
{
var padId = document.URL.substring(document.URL.lastIndexOf("/") + 1);

View File

@ -230,6 +230,14 @@ var padimpexp = (function()
var self = {
init: function()
{
// build the export links
$("#exporthtmla").attr("href", document.location.href + "/export/html");
$("#exportplaina").attr("href", document.location.href + "/export/txt");
$("#exportworda").attr("href", document.location.href + "/export/doc");
$("#exportpdfa").attr("href", document.location.href + "/export/pdf");
$("#exportopena").attr("href", document.location.href + "/export/odt");
$("#exportwordlea").attr("href", document.location.href + "/export/wordle");
$("#importform").get(0).setAttribute('action', document.location.href + "/import");
$("#impexp-close").click(function()
@ -264,6 +272,19 @@ var padimpexp = (function()
$("#impexp-disabled-clickcatcher").hide();
$("#import").css('opacity', 1);
$("#impexp-export").css('opacity', 1);
},
export2Wordle: function()
{
padUrl = location.pathname;
padHost = location.host;
var padUrl = "http://" + padHost + padUrl + "/export/txt";
$.get(padUrl, function(data)
{
$('.result').html(data);
$('#text').html(data);
$('#wordlepost').submit();
});
}
};
return self;

View File

@ -7,12 +7,8 @@
<meta http-equiv="Content-Language" content="en-us"/>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/>
<title>Etherpad Lite</title>
<!-- <base href="http://localhost:9001/" />-->
<!-- CSS -->
<link href="../static/css/pad_lite.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 7]>
<link href="../static/css/pad_ie_lite.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<link href="../static/css/pad.css" rel="stylesheet" type="text/css"/>
<!-- javascript -->
<script type="text/javascript">
// <![CDATA[
@ -234,7 +230,7 @@ We removed this feature cause its not worth the space it needs in the editbar
<a id="exportworda" target="_blank" class="exportlink"><div class="exporttype" id="exportword">Microsoft Word</div></a>
<a id="exportpdfa" target="_blank" class="exportlink"><div class="exporttype" id="exportpdf">PDF</div></a>
<a id="exportopena" target="_blank" class="exportlink"><div class="exporttype" id="exportopen">OpenDocument</div></a>
<a id="exportwordlea" target="_blank" onClick="loadCont();return false;" class="exportlink"><div class="exporttype" id="exportwordle">Wordle</div></a>
<a id="exportwordlea" target="_blank" onClick="padimpexp.export2Wordle();return false;" class="exportlink"><div class="exporttype" id="exportwordle">Wordle</div></a>
<form id="wordlepost" name="wall" action="http://wordle.net/advanced" method="POST" style="margin-left:0px;">
<div id="hidetext" style=""><textarea id="text" name="text" id="text" style="display:none;">Coming soon!</textarea></div>
</form>

View File

@ -1,37 +0,0 @@
var padManager = require("../node/PadManager");
/**
* Tests if new Pads a created with the correct inital values
*/
exports.createAPad = function(test)
{
test.expect(7);
//Test if PadManager gives null when a Pad don't exist and you don't wish to create it
var pad = padManager.getPad("test", false);
test.equal(pad, null, "The PadManager gives a value for a pad that was never created'");
//Test if PadManager creates a Pad with the correct id when you want to create it
pad = padManager.getPad("test", true);
test.equal(pad.id, "test", "The PadManager gave a pad with a other id than expeted");
//Test if the startText is correct set
var atext = pad.atext;
test.equal(atext.text, padManager.startText + "\n", "The Starttext of a Pad is wrong set");
//Test if the atext().text and text() is the same
test.equal(atext.text, pad.text(), "pad.atext.text is not pad.text()");
//Test if the Revision Number is Zero
var head = pad.getHeadRevisionNumber();
test.equal(head, 0, "The Revision Number is not zero!");
//Check if the first Author is a empty String
var firstAuthor = pad.getRevisionAuthor(0);
test.equal(firstAuthor, '', "The Author of the First Revision is not a empty String");
var firstChangeset = pad.getRevisionChangeset(0);
test.ok(firstChangeset.indexOf(padManager.startText) > -1, "The first Changeset does not contain the inital Text");
test.done();
}

View File

@ -1 +0,0 @@
You can run the tests with runTests.sh in the bin folder