mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-27 19:06:15 -04:00
first ditch, test still not working but hitting API URL working
This commit is contained in:
parent
d545630912
commit
248ec967e5
8 changed files with 88 additions and 14 deletions
|
@ -342,19 +342,25 @@ exports.appendText = function(padID, text, callback)
|
|||
|
||||
|
||||
/**
|
||||
getHTML(padID, [rev]) returns the html of a pad
|
||||
getHTML(padID, [rev], [authorColor]) returns the html of a pad
|
||||
|
||||
Example returns:
|
||||
|
||||
{code: 0, message:"ok", data: {text:"Welcome <strong>Text</strong>"}}
|
||||
{code: 1, message:"padID does not exist", data: null}
|
||||
*/
|
||||
exports.getHTML = function(padID, rev, callback)
|
||||
exports.getHTML = function(padID, rev, authorColor, callback)
|
||||
{
|
||||
console.log("tits");
|
||||
console.log("authorColor", authorColor);
|
||||
if(typeof authorColor == "function"){
|
||||
callback = authorColor;
|
||||
authorColor = undefined;
|
||||
}
|
||||
if(typeof rev == "function")
|
||||
{
|
||||
callback = rev;
|
||||
rev = undefined;
|
||||
rev = undefined;
|
||||
}
|
||||
|
||||
if (rev !== undefined && typeof rev != "number")
|
||||
|
@ -397,7 +403,7 @@ exports.getHTML = function(padID, rev, callback)
|
|||
}
|
||||
|
||||
//get the html of this revision
|
||||
exportHtml.getPadHTML(pad, rev, function(err, html)
|
||||
exportHtml.getPadHTML(pad, rev, authorColor, function(err, html)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
html = "<!DOCTYPE HTML><html><body>" +html; // adds HTML head
|
||||
|
@ -409,7 +415,7 @@ exports.getHTML = function(padID, rev, callback)
|
|||
//the client wants the latest text, lets return it to him
|
||||
else
|
||||
{
|
||||
exportHtml.getPadHTML(pad, undefined, function (err, html)
|
||||
exportHtml.getPadHTML(pad, undefined, authorColor, function (err, html)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
html = "<!DOCTYPE HTML><html><body>" +html; // adds HTML head
|
||||
|
|
|
@ -120,7 +120,7 @@ var padIdTransforms = [
|
|||
* @param {Function} callback
|
||||
*/
|
||||
exports.getPad = function(id, text, callback)
|
||||
{
|
||||
{
|
||||
//check if this is a valid padId
|
||||
if(!exports.isValidPadId(id))
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ exports.getPad = function(id, text, callback)
|
|||
callback(new customError("text is not a string","apierror"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//check if text is less than 100k chars
|
||||
if(text.length > 100000)
|
||||
{
|
||||
|
|
BIN
src/node/handler/.APIHandler.js.swp
Normal file
BIN
src/node/handler/.APIHandler.js.swp
Normal file
Binary file not shown.
|
@ -495,10 +495,61 @@ var version =
|
|||
, "restoreRevision" : ["padID", "rev"]
|
||||
, "appendText" : ["padID", "text"]
|
||||
}
|
||||
, "1.2.14":
|
||||
{ "createGroup" : []
|
||||
, "createGroupIfNotExistsFor" : ["groupMapper"]
|
||||
, "deleteGroup" : ["groupID"]
|
||||
, "listPads" : ["groupID"]
|
||||
, "listAllPads" : []
|
||||
, "createDiffHTML" : ["padID", "startRev", "endRev"]
|
||||
, "createPad" : ["padID", "text"]
|
||||
, "createGroupPad" : ["groupID", "padName", "text"]
|
||||
, "createAuthor" : ["name"]
|
||||
, "createAuthorIfNotExistsFor": ["authorMapper" , "name"]
|
||||
, "listPadsOfAuthor" : ["authorID"]
|
||||
, "createSession" : ["groupID", "authorID", "validUntil"]
|
||||
, "deleteSession" : ["sessionID"]
|
||||
, "getSessionInfo" : ["sessionID"]
|
||||
, "listSessionsOfGroup" : ["groupID"]
|
||||
, "listSessionsOfAuthor" : ["authorID"]
|
||||
, "getText" : ["padID", "rev"]
|
||||
, "setText" : ["padID", "text"]
|
||||
, "getHTML" : ["padID", "rev", "authorColor"]
|
||||
, "setHTML" : ["padID", "html"]
|
||||
, "getAttributePool" : ["padID"]
|
||||
, "getRevisionsCount" : ["padID"]
|
||||
, "getSavedRevisionsCount" : ["padID"]
|
||||
, "listSavedRevisions" : ["padID"]
|
||||
, "saveRevision" : ["padID", "rev"]
|
||||
, "getRevisionChangeset" : ["padID", "rev"]
|
||||
, "getLastEdited" : ["padID"]
|
||||
, "deletePad" : ["padID"]
|
||||
, "copyPad" : ["sourceID", "destinationID", "force"]
|
||||
, "movePad" : ["sourceID", "destinationID", "force"]
|
||||
, "getReadOnlyID" : ["padID"]
|
||||
, "getPadID" : ["roID"]
|
||||
, "setPublicStatus" : ["padID", "publicStatus"]
|
||||
, "getPublicStatus" : ["padID"]
|
||||
, "setPassword" : ["padID", "password"]
|
||||
, "isPasswordProtected" : ["padID"]
|
||||
, "listAuthorsOfPad" : ["padID"]
|
||||
, "padUsersCount" : ["padID"]
|
||||
, "getAuthorName" : ["authorID"]
|
||||
, "padUsers" : ["padID"]
|
||||
, "sendClientsMessage" : ["padID", "msg"]
|
||||
, "listAllGroups" : []
|
||||
, "checkToken" : []
|
||||
, "appendChatMessage" : ["padID", "text", "authorID", "time"]
|
||||
, "getChatHistory" : ["padID"]
|
||||
, "getChatHistory" : ["padID", "start", "end"]
|
||||
, "getChatHead" : ["padID"]
|
||||
, "restoreRevision" : ["padID", "rev"]
|
||||
, "appendText" : ["padID", "text"]
|
||||
}
|
||||
};
|
||||
|
||||
// set the latest available API version here
|
||||
exports.latestApiVersion = '1.2.13';
|
||||
exports.latestApiVersion = '1.2.14';
|
||||
|
||||
// exports the versions so it can be used by the new Swagger endpoint
|
||||
exports.version = version;
|
||||
|
|
BIN
src/node/utils/.ExportTxt.js.swp
Normal file
BIN
src/node/utils/.ExportTxt.js.swp
Normal file
Binary file not shown.
|
@ -25,7 +25,7 @@ var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
|||
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
||||
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
||||
|
||||
function getPadHTML(pad, revNum, callback)
|
||||
function getPadHTML(pad, revNum, authorColors, callback)
|
||||
{
|
||||
var atext = pad.atext;
|
||||
var html;
|
||||
|
@ -53,7 +53,7 @@ function getPadHTML(pad, revNum, callback)
|
|||
|
||||
function (callback)
|
||||
{
|
||||
html = getHTMLFromAtext(pad, atext);
|
||||
html = getHTMLFromAtext(pad, atext, authorColors);
|
||||
callback(null);
|
||||
}],
|
||||
// run final callback
|
||||
|
|
BIN
tests/backend/specs/api/.pad.js.swp
Normal file
BIN
tests/backend/specs/api/.pad.js.swp
Normal file
Binary file not shown.
|
@ -10,7 +10,7 @@ var filePath = path.join(__dirname, '../../../../APIKEY.txt');
|
|||
|
||||
var apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'});
|
||||
apiKey = apiKey.replace(/\n$/, "");
|
||||
var apiVersion = 1;
|
||||
var apiVersion = "1.2.14";
|
||||
var testPadId = makeid();
|
||||
var lastEdited = "";
|
||||
var text = generateLongText();
|
||||
|
@ -84,7 +84,8 @@ describe('Permission', function(){
|
|||
-> setHTML(padID) -- Should fail on invalid HTML
|
||||
-> setHTML(padID) *3 -- Should fail on invalid HTML
|
||||
-> getHTML(padID) -- Should return HTML close to posted HTML
|
||||
-> createPad -- Tries to create pads with bad url characters
|
||||
-> getHTML(padID, authorColor) -- Should return HTML close to posted HTML with some Author markup
|
||||
-> createPad -- Tries to create pads with bad url characters
|
||||
|
||||
*/
|
||||
|
||||
|
@ -200,7 +201,9 @@ describe('getText', function(){
|
|||
|
||||
describe('setText', function(){
|
||||
it('creates a new Pad with text', function(done) {
|
||||
api.get(endPoint('setText')+"&padID="+testPadId+"&text=testTextTwo")
|
||||
var textString = "testText\tTwo"; // note the \t to emualte a tab
|
||||
console.warn("Set text as ", textString);
|
||||
api.get(endPoint('setText')+"&padID="+testPadId+"&text="+textString)
|
||||
.expect(function(res){
|
||||
if(res.body.code !== 0) throw new Error("Pad setting text failed");
|
||||
})
|
||||
|
@ -213,7 +216,8 @@ describe('getText', function(){
|
|||
it('gets the Pad text', function(done) {
|
||||
api.get(endPoint('getText')+"&padID="+testPadId)
|
||||
.expect(function(res){
|
||||
if(res.body.data.text !== "testTextTwo\n") throw new Error("Setting Text")
|
||||
var expectedString = "testText Two\n";
|
||||
if(res.body.data.text !== expectedString) throw new Error("Getting Text error")
|
||||
})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200, done)
|
||||
|
@ -545,6 +549,19 @@ describe('getHTML', function(){
|
|||
});
|
||||
})
|
||||
|
||||
describe('getHTML', function(){
|
||||
it('Gets the HTML of a Pad and include author info', function(done) {
|
||||
api.get(endPoint('getHTML')+"&padID="+testPadId+"&authorColor=true")
|
||||
.expect(function(res){
|
||||
var html = res.body.data.html;
|
||||
console.warn("html", html);
|
||||
if(html !== html) throw new Error("Imported HTML does not match served HTML")
|
||||
})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200, done)
|
||||
});
|
||||
})
|
||||
|
||||
describe('createPad', function(){
|
||||
it('errors if pad can be created', function(done) {
|
||||
var badUrlChars = ["/", "%23", "%3F", "%26"];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue