From 2f0e45efe331d7a98c98ae2f3e5d385c6f71878c Mon Sep 17 00:00:00 2001 From: Wikinaut Date: Thu, 10 Nov 2011 00:06:43 +0100 Subject: [PATCH] patch allows nice pad urls server/padname and also the old form server/p/padname; first commit to my remote repository --- node/server.js | 41 ++++++++++++++++++++++------------------- static/index.html | 32 ++++++++++++++++---------------- static/pad.html | 6 +++--- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/node/server.js b/node/server.js index 2bebe6a24..5ff11ca7e 100644 --- a/node/server.js +++ b/node/server.js @@ -196,24 +196,27 @@ async.waterfall([ res.send(html); }); }); - - //serve pad.html under /p - app.get('/p/:pad', function(req, res, next) + + //serve pad.html under / and /p for compatibility + app.get( "(/p)?/:pad", function(req, res, next) { - //ensure the padname is valid and the url doesn't end with a / - if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url)) - { - res.send('Such a padname is forbidden', 404); + // ensure the padname is valid and the url doesn't end with a / + // and that reserved pathnames are served as files, not as pads + if( !padManager.isValidPadId(req.params.pad) || /\/+$/.test(req.url)) { + res.send('Such a padname is forbidden.', 404); return; + } else if ( /(favicon\.ico|robots\.txt)/.test(req.url) ) + { + next(); + return; } - res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/pad.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); - - //serve timeslider.html under /p/$padname/timeslider - app.get('/p/:pad/timeslider', function(req, res, next) + + //serve timeslider.html under /$padname/timeslider + app.get('/:pad/timeslider', function(req, res, next) { //ensure the padname is valid and the url doesn't end with a / if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url)) @@ -226,9 +229,9 @@ async.waterfall([ var filePath = path.normalize(__dirname + "/../static/timeslider.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); - - //serve timeslider.html under /p/$padname/timeslider - app.get('/p/:pad/export/:type', function(req, res, next) + + //serve export files under /$padname/export + app.get('/:pad/export/:type', function(req, res, next) { //ensure the padname is valid and the url doesn't end with a / if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url)) @@ -262,7 +265,7 @@ async.waterfall([ }); //handle import requests - app.post('/p/:pad/import', function(req, res, next) + app.post('/:pad/import', function(req, res, next) { //ensure the padname is valid and the url doesn't end with a / if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url)) @@ -341,9 +344,9 @@ async.waterfall([ var filePath = path.normalize(__dirname + "/../static/index.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); - + //serve robots.txt - app.get('/robots.txt', function(req, res) + app.get( /.*\/robots.txt/, function(req, res) { res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/robots.txt"); @@ -351,7 +354,7 @@ async.waterfall([ }); //serve favicon.ico - app.get('/favicon.ico', function(req, res) + app.get( /.*\/favicon\.ico/, function(req, res) { res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico"); @@ -365,7 +368,7 @@ async.waterfall([ } }); }); - + //let the server listen app.listen(settings.port, settings.ip); console.log("Server is listening at " + settings.ip + ":" + settings.port); diff --git a/static/index.html b/static/index.html index e995cdb2f..fb53acb20 100644 --- a/static/index.html +++ b/static/index.html @@ -1,6 +1,6 @@ - Etherpad Lite + Etherpad -
-
New Pad

or create/open a Pad with the name
-
- - -
-
- +
+
create new random pad

open an existing pad or create a new pad with the name
+
+ + +
+
\ No newline at end of file diff --git a/static/pad.html b/static/pad.html index 980905e99..d1679202e 100644 --- a/static/pad.html +++ b/static/pad.html @@ -172,7 +172,7 @@
- Loading... +Loading...
@@ -266,7 +266,7 @@ Use this link to share a read-only version of your pad:
- Connecting... + Connecting...
Reestablishing connection... @@ -315,7 +315,7 @@ Use this link to share a read-only version of your pad:

- If this continues to happen, please let us know +