Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added functionality to list pads on this server.

  • Loading branch information...
commit 198754222df8345b17f9d4b61417d6e8be865817 1 parent a42f220
@spcsser spcsser authored
View
6 src/node/db/API.js
@@ -43,6 +43,12 @@ exports.listPads = groupManager.listPads;
exports.createGroupPad = groupManager.createGroupPad;
/**********************/
+/**PADLIST FUNCTION****/
+/**********************/
+
+exports.listAllPads = padManager.getPads;
+
+/**********************/
/**AUTHOR FUNCTIONS****/
/**********************/
View
3  src/node/db/Pad.js
@@ -473,8 +473,7 @@ Pad.prototype.remove = function remove(callback) {
//delete the pad entry and delete pad from padManager
function(callback)
{
- db.remove("pad:"+padID);
- padManager.unloadPad(padID);
+ padManager.removePad(padID);
hooks.callAll("padRemove", {'padID':padID});
callback();
}
View
55 src/node/db/PadManager.js
@@ -34,10 +34,52 @@ var db = require("./DB").db;
*/
var globalPads = {
get: function (name) { return this[':'+name]; },
- set: function (name, value) { this[':'+name] = value; },
+ set: function (name, value)
+ {
+ this[':'+name] = value;
+ padList.addPad(name);
+ },
remove: function (name) { delete this[':'+name]; }
};
+var padList = {
+ list: [],
+ init: function()
+ {
+ db.get("pads", function(err, dbData)
+ {
+ if(ERR(err)) return;
+ if(dbData != null){
+ dbData.forEach(function(val){
+ padList.addPad(val,false);
+ });
+ }
+ });
+ return this;
+ },
+ getPads: function(){
+ return this.list;
+ },
+ addPad: function(name,immediateSave)
+ {
+ if(this.list.indexOf(name) == -1){
+ this.list.push(name);
+ if(immediateSave == undefined || immediateSave == true){
+ db.set("pads", this.list);
+ }
+ }
+ },
+ removePad: function(name)
+ {
+ var index=this.list.indexOf(name);
+ if(index>-1){
+ this.list.splice(index,1);
+ db.set("pads", this.list);
+ }
+ }
+};
+padList.init();
+
/**
* An array of padId transformations. These represent changes in pad name policy over
* time, and allow us to "play back" these changes so legacy padIds can be found.
@@ -109,6 +151,11 @@ exports.getPad = function(id, text, callback)
}
}
+exports.getPads = function(callback)
+{
+ callback(null,padList.getPads());
+}
+
//checks if a pad exists
exports.doesPadExists = function(padId, callback)
{
@@ -163,6 +210,12 @@ exports.isValidPadId = function(padId)
return /^(g.[a-zA-Z0-9]{16}\$)?[^$]{1,50}$/.test(padId);
}
+exports.removePad = function(padId){
+ db.remove("pad:"+padId);
+ exports.unloadPad(padId);
+ padList.removePad(padId);
+}
+
//removes a pad from the array
exports.unloadPad = function(padId)
{
View
36 src/node/handler/APIHandler.js
@@ -138,6 +138,42 @@ var version =
, "listAllGroups" : []
, "checkToken" : []
}
+, "1.2.1":
+ { "createGroup" : []
+ , "createGroupIfNotExistsFor" : ["groupMapper"]
+ , "deleteGroup" : ["groupID"]
+ , "listPads" : ["groupID"]
+ , "listAllPads" : []
+ , "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"]
+ , "setHTML" : ["padID", "html"]
+ , "getRevisionsCount" : ["padID"]
+ , "getLastEdited" : ["padID"]
+ , "deletePad" : ["padID"]
+ , "getReadOnlyID" : ["padID"]
+ , "setPublicStatus" : ["padID", "publicStatus"]
+ , "getPublicStatus" : ["padID"]
+ , "setPassword" : ["padID", "password"]
+ , "isPasswordProtected" : ["padID"]
+ , "listAuthorsOfPad" : ["padID"]
+ , "padUsersCount" : ["padID"]
+ , "getAuthorName" : ["authorID"]
+ , "padUsers" : ["padID"]
+ , "sendClientsMessage" : ["padID", "msg"]
+ , "listAllGroups" : []
+ , "checkToken" : []
+ }
};
/**

5 comments on commit 1987542

@JohnMcLear
Owner

@spcsser why does this need to run on startup?

@JohnMcLear
Owner

FYI this is really hurting startup performance on large deployments

@spcsser

No other way to ensure to have all pads and enable search & stuff. Querying db was not possible afaik.
Could be run async or delayed somehow.

@spcsser

seems ok to me.

Please sign in to comment.
Something went wrong with that request. Please try again.