skins: finalize support for multiple skins

The old "static/custom" directory is replaced by "static/skins/<skinName>",
where <skinName> is taken from settings.json.
When no value is found, a default of "no-skin" is assumed, so that backward
compatibility is maintained.

The most evident security concerns have been addressed.

Closes #3471.
pull/3476/head
muxator 2018-08-26 03:43:53 +02:00 committed by muxator
parent e34c74b24d
commit 9c990ab08a
5 changed files with 14 additions and 14 deletions

View File

@ -26,7 +26,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve robots.txt
args.app.get('/robots.txt', function(req, res)
{
var filePath = path.join(settings.root, "src", "static", "custom", "robots.txt");
var filePath = path.join(settings.root, "src", "static", "skins", settings.skinName, "robots.txt");
res.sendFile(filePath, function(err)
{
//there is no custom favicon, send the default robots.txt which dissallows all
@ -79,7 +79,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve favicon.ico from all path levels except as a pad name
args.app.get( /\/favicon.ico$/, function(req, res)
{
var filePath = path.join(settings.root, "src", "static", "custom", "favicon.ico");
var filePath = path.join(settings.root, "src", "static", "skins", settings.skinName, "favicon.ico");
res.sendFile(filePath, function(err)
{

View File

@ -230,7 +230,7 @@ function Ace2Editor()
// disableCustomScriptsAndStyles can be used to disable loading of custom scripts
if(!clientVars.disableCustomScriptsAndStyles){
$$INCLUDE_CSS("../static/css/pad.css");
$$INCLUDE_CSS("../static/custom/pad.css");
$$INCLUDE_CSS(`../static/skins/${clientVars.skinName}/pad.css`);
}
var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){
@ -314,7 +314,7 @@ window.onload = function () {\n\
var $$INCLUDE_CSS = function(filename) {includedCSS.push(filename)};
$$INCLUDE_CSS("../static/css/iframe_editor.css");
$$INCLUDE_CSS("../static/css/pad.css");
$$INCLUDE_CSS("../static/custom/pad.css");
$$INCLUDE_CSS(`../static/skins/${clientVars.skinName}/pad.css`);
var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){

View File

@ -156,7 +156,7 @@
}
}
</style>
<link href="static/custom/index.css" rel="stylesheet">
<link href="static/skins/<%=encodeURI(settings.skinName)%>/index.css" rel="stylesheet">
<div id="wrapper">
<% e.begin_block("indexWrapper"); %>
@ -171,7 +171,7 @@
<% e.end_block(); %>
</div>
<script src="static/custom/index.js"></script>
<script src="static/skins/<%=encodeURI(settings.skinName)%>/index.js"></script>
<script>
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
function go2Name()

View File

@ -34,19 +34,19 @@
<td><a href="/static/js/require-kernel.js">require-kernel.js</a></td>
</tr>
<tr>
<td><a href="/static/custom/index.js">index.js</a></td>
<td><a href="/static/skins/<%=encodeURI(settings.skinName)%>/index.js">index.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a></td>
<td><a href="/static/custom/index.js">index.js</a></td>
<td><a href="/static/skins/<%=encodeURI(settings.skinName)%>/index.js">index.js</a></td>
</tr>
<tr>
<td><a href="/static/custom/timeslider.js">timeslider.js</a></td>
<td><a href="/static/skins/<%=encodeURI(settings.skinName)%>/timeslider.js">timeslider.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a></td>
<td><a href="/static/custom/timeslider.js">timeslider.js</a></td>
<td><a href="/static/skins/<%=encodeURI(settings.skinName)%>/timeslider.js">timeslider.js</a></td>
</tr>
<tr>
<td><a href="/static/custom/pad.js">pad.js</a></td>
<td><a href="/static/skins/<%=encodeURI(settings.skinName)%>/pad.js">pad.js</a></td>
<td><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache-2.0-only</a></td>
<td><a href="/static/custom/pad.js">pad.js</a></td>
<td><a href="/static/skins/<%=encodeURI(settings.skinName)%>/pad.js">pad.js</a></td>
</tr>
<tr>
<td><a href="/static/js/admin/plugins.js">plugins.js</a></td>

View File

@ -44,7 +44,7 @@
<link href="../static/css/pad.css" rel="stylesheet">
<% e.begin_block("customStyles"); %>
<link href="../static/custom/pad.css" rel="stylesheet">
<link href="../static/skins/<%=encodeURI(settings.skinName)%>/pad.css" rel="stylesheet">
<% e.end_block(); %>
<style title="dynamicsyntax"></style>
@ -378,7 +378,7 @@
<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define"></script>
<% e.begin_block("customScripts"); %>
<script type="text/javascript" src="../static/custom/pad.js"></script>
<script type="text/javascript" src="../static/skins/<%=encodeURI(settings.skinName)%>/pad.js"></script>
<% e.end_block(); %>
<!-- Bootstrap page -->