Skip to content

Commit 2070124

Browse files
author
codepad
committed
0.8.9
1 parent 964f8cd commit 2070124

File tree

124 files changed

+2056
-11839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2056
-11839
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This etherpad-lite plugin merges functionality of simple plugins, and adds some
55
- Adds tons of themes, properly implemented with css, and a theme generator
66
- beutify html/css/javascript code with jsBeutify
77
- Syntax-check javascipt with jsHint, and display results
8-
- save/commit/push and play
8+
- save/commit/push (F2) and play
99

1010
- It sets some reasonable defaults and customizes buttons
1111
- Admin interface based on adminpads
@@ -25,7 +25,9 @@ Currently the following codepad parameters are supported in etherpad's settings.
2525
- log_path for displaying logs (parent dir needs execute right)
2626
- button to open a browser to the project
2727
- action to perform when pushing files
28-
- authentication password-hash, custom color with these defaults
28+
- authentication password-hash, custom colors
29+
30+
The use of authentication and https recommended.
2931

3032
```
3133
"ep_codepad": {

ep.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
"padCreate": "ep_codepad:padCreate"
3737
}
3838
}, {
39-
"name": "ep_codepad_linkcolor",
39+
"name": "ep_codepad_editorfixes",
4040
"client_hooks": {
41-
"aceEditorCSS": "ep_codepad/static/js/ace.js"
41+
"aceEditorCSS": "ep_codepad/static/js/ace:aceEditorCSS"
4242
}
4343
}, {
4444
"name": "ep_codepad_defaults",

ep_hash_auth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ exports.handleMessage = function(hook_name, context, cb) {
8686
else return cb([null]);
8787
}
8888
return cb([context.message]);
89-
};
89+
};

extensions.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var findExtension = function(ext) {
2-
2+
33
// Diff
44
if (['diff', 'patch'].indexOf(ext) > -1) return 'diff';
55
// TAP
@@ -57,9 +57,10 @@ var findExtension = function(ext) {
5757

5858
// plain text
5959
if (['txt', 'text', 'md', 'htaccess', 'log', 'err', 'nfo'].indexOf(ext) > -1) return 'plain';
60+
if (ext === '') return 'plain';
6061

6162
return false;
62-
}
63+
};
6364

6465

6566
exports.getExtension = function(filename) {
@@ -76,4 +77,3 @@ exports.getBrush = function(filename) {
7677
var ext = (i < 0) ? '' : filename.substr(i + 1).toLowerCase();
7778
return findExtension(ext);
7879
};
79-

handleButtonMessage.js

+30-20
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ var crypto = require('crypto'),
66

77
// read base project folder from settings.json
88
var settings = require('ep_etherpad-lite/node/utils/Settings');
9+
var authorManager = require('ep_etherpad-lite/node/db/AuthorManager');
10+
var sessionManager = require('ep_etherpad-lite/node/db/SessionManager');
11+
912
var project_path = '/tmp/';
1013

1114
if (!settings.ep_codepad) {
@@ -37,9 +40,13 @@ var padMessageHandler = require("ep_etherpad-lite/node/handler/PadMessageHandler
3740

3841

3942
exports.handleMessage = function(hook_name, context, callback) {
43+
4044
if (context.message && context.message.data) {
4145

46+
var cb = function() {};
47+
4248
var msg = context.message.data.type;
49+
console.log("MSG: " + msg);
4350

4451
if (msg == msg_read) {
4552
padManager.getPad(context.message.data.padId, null, function(err, value) {
@@ -66,9 +73,8 @@ exports.handleMessage = function(hook_name, context, callback) {
6673
}
6774
});
6875
});
69-
callback([null]);
76+
callback(null);
7077
}
71-
7278
if (msg == msg_write || msg == msg_push) {
7379

7480
padManager.getPad(context.message.data.padId, null, function(err, value) {
@@ -77,10 +83,14 @@ exports.handleMessage = function(hook_name, context, callback) {
7783
var padsi = padid.indexOf('/');
7884
var folder = '';
7985

86+
// since EEXISTS is an error, we skip that error
87+
// TODO, use mkdirP ?
88+
mkdir_err = function(err) {};
89+
8090
// create subfolders
8191
while (padsi > 0) {
8292
folder = padid.substring(0, padsi);
83-
fs.mkdir(project_path + folder);
93+
fs.mkdir(project_path + folder, mkdir_err);
8494
padsi = padid.indexOf('/', 1 + folder.length);
8595
}
8696

@@ -91,8 +101,8 @@ exports.handleMessage = function(hook_name, context, callback) {
91101

92102
// the beutified text of the pad
93103

94-
// remove two newline characters from the end of the string.
95-
var beat = value.atext.text.slice(0, -2);
104+
// remove newline character from the end of the string.
105+
var beat = value.atext.text.slice(0, -1);
96106

97107

98108
// if .js file beautify
@@ -102,7 +112,7 @@ exports.handleMessage = function(hook_name, context, callback) {
102112
});
103113

104114

105-
//padMessageHandler.updatePadClients(value, callback);
115+
//padMessageHandler.updatePadClients(value, cb);
106116

107117
if (!jshint(beat)) {
108118

@@ -159,7 +169,7 @@ exports.handleMessage = function(hook_name, context, callback) {
159169
}
160170
}
161171
};
162-
padMessageHandler.handleCustomObjectMessage(err_msg, undefined, callback);
172+
padMessageHandler.handleCustomObjectMessage(err_msg, undefined, cb);
163173

164174
} else {
165175
var ok_msg = {
@@ -173,11 +183,11 @@ exports.handleMessage = function(hook_name, context, callback) {
173183
}
174184
}
175185
};
176-
padMessageHandler.handleCustomObjectMessage(ok_msg, undefined, callback);
186+
padMessageHandler.handleCustomObjectMessage(ok_msg, undefined, cb);
177187
}
178188

179-
value.setText(beat);
180-
padMessageHandler.updatePadClients(value, callback);
189+
if (msg == msg_push) value.setText(beat);
190+
padMessageHandler.updatePadClients(value, cb);
181191
}
182192

183193
// if .css file beautify
@@ -186,7 +196,7 @@ exports.handleMessage = function(hook_name, context, callback) {
186196
indent_size: 4
187197
});
188198
value.setText(beat);
189-
padMessageHandler.updatePadClients(value, callback);
199+
padMessageHandler.updatePadClients(value, cb);
190200
}
191201

192202
// if .html file beautify
@@ -195,7 +205,7 @@ exports.handleMessage = function(hook_name, context, callback) {
195205
indent_size: 4
196206
});
197207
value.setText(beat);
198-
padMessageHandler.updatePadClients(value, callback);
208+
padMessageHandler.updatePadClients(value, cb);
199209
}
200210

201211
// WRITE to the FILE
@@ -213,7 +223,7 @@ exports.handleMessage = function(hook_name, context, callback) {
213223
}
214224
}
215225
};
216-
padMessageHandler.handleCustomObjectMessage(err_msg, undefined, callback);
226+
padMessageHandler.handleCustomObjectMessage(err_msg, undefined, cb);
217227
} else {
218228
console.log("Wrote pad contents to " + path);
219229
var ok_msg = {
@@ -227,7 +237,7 @@ exports.handleMessage = function(hook_name, context, callback) {
227237
}
228238
}
229239
};
230-
padMessageHandler.handleCustomObjectMessage(ok_msg, undefined, callback);
240+
padMessageHandler.handleCustomObjectMessage(ok_msg, undefined, cb);
231241
// if push_action is defined in settings.json, it will run here, use it for git/svn/hg ... or whatever.
232242
if (settings.ep_codepad && msg == msg_push) {
233243
if (settings.ep_codepad.push_action) {
@@ -245,7 +255,7 @@ exports.handleMessage = function(hook_name, context, callback) {
245255
}
246256
}
247257
};
248-
padMessageHandler.handleCustomObjectMessage(err_msg, undefined, callback);
258+
padMessageHandler.handleCustomObjectMessage(err_msg, undefined, cb);
249259
}
250260
if (stdout) console.log("codepad-push-stdout: " + stdout);
251261
if (stderr) console.log("codepad-push-stderr: " + stderr);
@@ -255,11 +265,11 @@ exports.handleMessage = function(hook_name, context, callback) {
255265
}
256266
});
257267
});
258-
callback([null]);
259-
}
260-
}
268+
callback(null);
269+
} //END if (msg == msg_write || msg == msg_push)
270+
} //END if (context.message && context.message.data)
261271
callback();
262-
};
272+
}; //END exports.handleMessage
263273

264274
/// jshint - quickhelp
265275
/* An example from err.
@@ -273,4 +283,4 @@ exports.handleMessage = function(hook_name, context, callback) {
273283
"scope": "(main)",
274284
"reason": "Missing semicolon."
275285
276-
*/
286+
*****/

0 commit comments

Comments
 (0)