mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Read only access works
This commit is contained in:
parent
1c1e035bf1
commit
93ccbaef3a
3 changed files with 82 additions and 10 deletions
|
@ -31,6 +31,8 @@ var async = require('async');
|
|||
var express = require('express');
|
||||
var path = require('path');
|
||||
var minify = require('./minify');
|
||||
var exporthtml;
|
||||
var readOnlyManager;
|
||||
|
||||
//try to get the git version
|
||||
var version = "";
|
||||
|
@ -63,6 +65,10 @@ async.waterfall([
|
|||
//create server
|
||||
var app = express.createServer();
|
||||
|
||||
//load modules that needs a initalized db
|
||||
readOnlyManager = require("./ReadOnlyManager");
|
||||
exporthtml = require("./exporters/exporthtml");
|
||||
|
||||
//set logging
|
||||
if(settings.logHTTP)
|
||||
app.use(express.logger({ format: ':date: :status, :method :url' }));
|
||||
|
@ -92,6 +98,55 @@ async.waterfall([
|
|||
}
|
||||
});
|
||||
|
||||
//serve read only pad
|
||||
app.get('/ro/:id', function(req, res)
|
||||
{
|
||||
res.header("Server", serverName);
|
||||
|
||||
var html;
|
||||
var padId;
|
||||
var pad;
|
||||
|
||||
async.series([
|
||||
//translate the read only pad to a padId
|
||||
function(callback)
|
||||
{
|
||||
readOnlyManager.getPadId(req.params.id, function(err, _padId)
|
||||
{
|
||||
padId = _padId;
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
//render the html document
|
||||
function(callback)
|
||||
{
|
||||
//return if the there is no padId
|
||||
if(padId == null)
|
||||
{
|
||||
callback("notfound");
|
||||
return;
|
||||
}
|
||||
|
||||
//render the html document
|
||||
exporthtml.getPadHTMLDocument(padId, null, false, function(err, _html)
|
||||
{
|
||||
html = _html;
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
], function(err)
|
||||
{
|
||||
//throw any unexpected error
|
||||
if(err && err != "notfound")
|
||||
throw err;
|
||||
|
||||
if(err == "notfound")
|
||||
res.send('404 - Not Found', 404);
|
||||
else
|
||||
res.send(html);
|
||||
});
|
||||
});
|
||||
|
||||
//serve pad.html under /p
|
||||
app.get('/p/:pad', function(req, res, next)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue