mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-04 22:27:10 -04:00
Merge a671140378
into 55a2f46ca9
This commit is contained in:
commit
423724716b
9 changed files with 93 additions and 52 deletions
|
@ -199,24 +199,27 @@ async.waterfall([
|
||||||
res.send(html);
|
res.send(html);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve pad.html under /p
|
//serve pad.html under / and /p for compatibility
|
||||||
app.get('/p/:pad', function(req, res, next)
|
app.get( "(/p)?/:pad", function(req, res, next)
|
||||||
{
|
{
|
||||||
//ensure the padname is valid and the url doesn't end with a /
|
// ensure the padname is valid and the url doesn't end with a /
|
||||||
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
// 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);
|
res.send('Such a padname is forbidden.', 404);
|
||||||
return;
|
return;
|
||||||
|
} else if ( /(favicon\.ico|robots\.txt)/.test(req.url) )
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.header("Server", serverName);
|
res.header("Server", serverName);
|
||||||
var filePath = path.normalize(__dirname + "/../static/pad.html");
|
var filePath = path.normalize(__dirname + "/../static/pad.html");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve timeslider.html under /p/$padname/timeslider
|
//serve timeslider.html under /$padname/timeslider
|
||||||
app.get('/p/:pad/timeslider', function(req, res, next)
|
app.get('/:pad/timeslider', function(req, res, next)
|
||||||
{
|
{
|
||||||
//ensure the padname is valid and the url doesn't end with a /
|
//ensure the padname is valid and the url doesn't end with a /
|
||||||
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
||||||
|
@ -229,9 +232,9 @@ async.waterfall([
|
||||||
var filePath = path.normalize(__dirname + "/../static/timeslider.html");
|
var filePath = path.normalize(__dirname + "/../static/timeslider.html");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve timeslider.html under /p/$padname/timeslider
|
//serve export files under /$padname/export
|
||||||
app.get('/p/:pad/export/:type', function(req, res, next)
|
app.get('/:pad/export/:type', function(req, res, next)
|
||||||
{
|
{
|
||||||
//ensure the padname is valid and the url doesn't end with a /
|
//ensure the padname is valid and the url doesn't end with a /
|
||||||
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
||||||
|
@ -265,7 +268,7 @@ async.waterfall([
|
||||||
});
|
});
|
||||||
|
|
||||||
//handle import requests
|
//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 /
|
//ensure the padname is valid and the url doesn't end with a /
|
||||||
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
if(!padManager.isValidPadId(req.params.pad) || /\/$/.test(req.url))
|
||||||
|
@ -358,9 +361,9 @@ async.waterfall([
|
||||||
var filePath = path.normalize(__dirname + "/../static/index.html");
|
var filePath = path.normalize(__dirname + "/../static/index.html");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve robots.txt
|
//serve robots.txt
|
||||||
app.get('/robots.txt', function(req, res)
|
app.get( /.*\/robots.txt/, function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
res.header("Server", serverName);
|
||||||
var filePath = path.normalize(__dirname + "/../static/robots.txt");
|
var filePath = path.normalize(__dirname + "/../static/robots.txt");
|
||||||
|
@ -368,7 +371,7 @@ async.waterfall([
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve favicon.ico
|
//serve favicon.ico
|
||||||
app.get('/favicon.ico', function(req, res)
|
app.get( /.*\/favicon\.ico/, function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
res.header("Server", serverName);
|
||||||
var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico");
|
var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico");
|
||||||
|
@ -382,7 +385,7 @@ async.waterfall([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//let the server listen
|
//let the server listen
|
||||||
app.listen(settings.port, settings.ip);
|
app.listen(settings.port, settings.ip);
|
||||||
console.log("Server is listening at " + settings.ip + ":" + settings.port);
|
console.log("Server is listening at " + settings.ip + ":" + settings.port);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.7 KiB |
|
@ -1,6 +1,6 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<title>Etherpad Lite</title>
|
<title>Etherpad</title>
|
||||||
<style>
|
<style>
|
||||||
*{ margin:0;padding:0; }
|
*{ margin:0;padding:0; }
|
||||||
body {
|
body {
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
text-shadow: 0 -1px 0 rgba(0,0,0,.8);
|
text-shadow: 0 -1px 0 rgba(0,0,0,.8);
|
||||||
height: 70px;
|
height: 70px;
|
||||||
line-height: 70px;
|
line-height: 70px;
|
||||||
width: 300px;
|
width: 500px;
|
||||||
background: #555;
|
background: #555;
|
||||||
background: -webkit-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737);
|
background: -webkit-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737);
|
||||||
background: -moz-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737);
|
background: -moz-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737);
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
#label {
|
#label {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
width: 300px
|
width: 500px
|
||||||
}
|
}
|
||||||
input {
|
input {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
font-size: 15px
|
font-size: 15px
|
||||||
}
|
}
|
||||||
input[type="text"] {
|
input[type="text"] {
|
||||||
width: 243px;
|
width: 443px;
|
||||||
padding: 10px 47px 10px 10px;
|
padding: 10px 47px 10px 10px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border: 1px solid #bbb;
|
border: 1px solid #bbb;
|
||||||
|
@ -90,28 +90,20 @@
|
||||||
<link href="static/custom/index.css" rel="stylesheet">
|
<link href="static/custom/index.css" rel="stylesheet">
|
||||||
<script src="static/custom/index.js"></script>
|
<script src="static/custom/index.js"></script>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="button" onclick="go2Random()">New Pad</div><br><div id="label">or create/open a Pad with the name</div>
|
<div id="button" onclick="go2Random()" title="open a new pad with a generated random name like 'B3GYd74mn2yBH6'">create new random pad</div><br><div id="label">open an existing pad or create a new pad with the name</div>
|
||||||
<form action="#" name="mainform" onsubmit="go2Name();return false;">
|
<form action="#" name="mainform" onsubmit="go2Name();return false;">
|
||||||
<input type="text" name="padname" id="padname" autofocus>
|
<input type="text" name="padname" id="padname" autofocus>
|
||||||
<input type="submit" value="OK">
|
<input type="submit" value="OK">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function go2Name()
|
// var pathName = "p/";
|
||||||
|
var pathName = "";
|
||||||
|
|
||||||
|
function randomPadName()
|
||||||
{
|
{
|
||||||
var padname = document.getElementById("padname").value;
|
var chars = "23456789ABCDEFGHJKLMNPQRSTUWXYZabcdefghijkmnopqrstuwxyz";
|
||||||
padname.length > 0 ? window.location = "p/" + padname : alert("Please enter a name")
|
var string_length = 16;
|
||||||
}
|
|
||||||
|
|
||||||
function go2Random()
|
|
||||||
{
|
|
||||||
window.location = "p/" + randomPadName();
|
|
||||||
}
|
|
||||||
|
|
||||||
function randomPadName()
|
|
||||||
{
|
|
||||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
||||||
var string_length = 10;
|
|
||||||
var randomstring = '';
|
var randomstring = '';
|
||||||
for (var i = 0; i < string_length; i++)
|
for (var i = 0; i < string_length; i++)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +112,34 @@
|
||||||
}
|
}
|
||||||
return randomstring;
|
return randomstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeSanitizedName( name ) {
|
||||||
|
return encodeURIComponent( name.replace( /[\/ ]/g, "_") );
|
||||||
|
}
|
||||||
|
|
||||||
|
function go2Name()
|
||||||
|
{
|
||||||
|
var padname = document.getElementById("padname").value;
|
||||||
|
padname.length > 0 ? window.location = pathName + encodeSanitizedName( padname ) : alert("Please enter a name")
|
||||||
|
}
|
||||||
|
|
||||||
|
function go2Random()
|
||||||
|
{
|
||||||
|
var rnd = randomPadName();
|
||||||
|
var prefixedName = prompt( "You can prefix or modify your random pad name with some reasonable characters.\nSpecial characters will be removed or escaped.\n\n", "-"+rnd );
|
||||||
|
if ( prefixedName == "-" + rnd ) prefixedName = rnd;
|
||||||
|
var escPrefixedName = encodeSanitizedName( prefixedName );
|
||||||
|
if ( prefixedName == null ) return;
|
||||||
|
if ( prefixedName == decodeURIComponent( escPrefixedName )
|
||||||
|
|| ( prefixedName != escPrefixedName
|
||||||
|
&& confirm( "You have used characters which are not allowed in Urls, and the padname will therefore be modified to "
|
||||||
|
+ decodeURIComponent( escPrefixedName )
|
||||||
|
+ ".\nDo you want to use this modifed name?" ) ) ) {
|
||||||
|
window.location = pathName + escPrefixedName;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//start the costum js
|
//start the costum js
|
||||||
if(typeof costumStart == "function") costumStart();
|
if(typeof costumStart == "function") costumStart();
|
||||||
|
|
|
@ -18,7 +18,7 @@ var chat = (function()
|
||||||
{
|
{
|
||||||
var self = {
|
var self = {
|
||||||
show: function ()
|
show: function ()
|
||||||
{
|
{
|
||||||
$("#chaticon").hide("slide", {
|
$("#chaticon").hide("slide", {
|
||||||
direction: "down"
|
direction: "down"
|
||||||
}, 500, function ()
|
}, 500, function ()
|
||||||
|
@ -55,9 +55,10 @@ var chat = (function()
|
||||||
scrollDown: function()
|
scrollDown: function()
|
||||||
{
|
{
|
||||||
//console.log($('#chatbox').css("display"));
|
//console.log($('#chatbox').css("display"));
|
||||||
|
if($('#chatbox').css("display") != "none") {
|
||||||
if($('#chatbox').css("display") != "none")
|
|
||||||
$('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow");
|
$('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow");
|
||||||
|
$("#chatinput").focus();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
send: function()
|
send: function()
|
||||||
{
|
{
|
||||||
|
@ -98,7 +99,7 @@ var chat = (function()
|
||||||
var count = Number($("#chatcounter").text());
|
var count = Number($("#chatcounter").text());
|
||||||
count++;
|
count++;
|
||||||
$("#chatcounter").text(count);
|
$("#chatcounter").text(count);
|
||||||
// chat throb stuff -- Just make it throb in for ~2 secs then fadeotu
|
// chat throb stuff -- Just make it throb in for ~2 secs then fadeout
|
||||||
$('#chatthrob').html("<b>"+authorName+"</b>" + ": " + text);
|
$('#chatthrob').html("<b>"+authorName+"</b>" + ": " + text);
|
||||||
$('#chatthrob').effect("pulsate", {times:1,mode:"hide"},2000);
|
$('#chatthrob').effect("pulsate", {times:1,mode:"hide"},2000);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +109,13 @@ var chat = (function()
|
||||||
},
|
},
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
|
$("#chaticon").mouseenter(function(){
|
||||||
|
self.show();
|
||||||
|
});
|
||||||
|
$("#chatbox").mouseenter(function(evt){
|
||||||
|
if ( !$("#chatinput").is(":focus") ) $("#chatinput").focus();
|
||||||
|
});
|
||||||
|
|
||||||
$("#chatinput").keypress(function(evt)
|
$("#chatinput").keypress(function(evt)
|
||||||
{
|
{
|
||||||
//if the user typed enter, fire the send
|
//if the user typed enter, fire the send
|
||||||
|
|
|
@ -173,9 +173,9 @@ function handshake()
|
||||||
socket.once('connect', function()
|
socket.once('connect', function()
|
||||||
{
|
{
|
||||||
var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
|
var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
|
||||||
padId = unescape(padId); // unescape neccesary due to Safari and Opera interpretation of spaces
|
padId = decodeURIComponent(padId); // unescape neccesary due to Safari and Opera interpretation of spaces
|
||||||
|
|
||||||
document.title = document.title + " | " + padId;
|
document.title = padId.replace( /_/g, " ") + " | " + document.title;
|
||||||
|
|
||||||
var token = readCookie("token");
|
var token = readCookie("token");
|
||||||
if (token == null)
|
if (token == null)
|
||||||
|
|
|
@ -122,6 +122,10 @@ var padeditbar = (function()
|
||||||
else if (cmd == 'save')
|
else if (cmd == 'save')
|
||||||
{
|
{
|
||||||
padsavedrevs.saveNow();
|
padsavedrevs.saveNow();
|
||||||
|
}
|
||||||
|
else if (cmd == 'tglfont')
|
||||||
|
{
|
||||||
|
pad.changeViewOption('useMonospaceFont', !(pad.padOptions.view&&pad.padOptions.view.useMonospaceFont));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="robots" content="noindex, nofollow">
|
<meta name="robots" content="noindex, nofollow">
|
||||||
|
|
||||||
<title>Etherpad Lite Timeslider</title>
|
<title>Etherpad Timeslider</title>
|
||||||
<link rel="stylesheet" href="../../static/css/pad.css">
|
<link rel="stylesheet" href="../../static/css/pad.css">
|
||||||
<link rel="stylesheet" href="../../static/css/timeslider.css">
|
<link rel="stylesheet" href="../../static/css/timeslider.css">
|
||||||
<style type="text/css" title="dynamicsyntax"></style>
|
<style type="text/css" title="dynamicsyntax"></style>
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
|
|
||||||
//get the padId out of the url
|
//get the padId out of the url
|
||||||
var urlParts= document.location.pathname.split("/");
|
var urlParts= document.location.pathname.split("/");
|
||||||
padId = urlParts[urlParts.length-2];
|
padId = decodeURIComponent(urlParts[urlParts.length-2]);
|
||||||
|
|
||||||
//set the title
|
//set the title
|
||||||
document.title = document.title + " | " + padId;
|
document.title = padId.replace( /_/g, " ") + " | " + document.title;
|
||||||
|
|
||||||
//ensure we have a token
|
//ensure we have a token
|
||||||
token = readCookie("token");
|
token = readCookie("token");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue