feature(cloudcmd) add prefix support

This commit is contained in:
coderaiser 2015-06-21 12:50:48 -04:00
parent 67d9b7981e
commit a74e49f4ab
6 changed files with 29 additions and 12 deletions

View file

@ -8,11 +8,11 @@
<link rel="icon" href="/favicon.ico" />
<title>{{ title }}</title>
<link rel=stylesheet href=/cloudcmd/css/urls.css>
<link rel=stylesheet href=/cloudcmd/join:css/reset.css:css/style.css:css/icons.css:css/help.css>
<link rel=stylesheet href="{{ prefix }}/css/urls.css">
<link rel=stylesheet href="{{ prefix }}/join:css/reset.css:css/style.css:css/icons.css:css/help.css">
<noscript>
<link rel=stylesheet href="/cloudcmd/css/nojs.css">
<link rel=stylesheet href="{{ prefix }}/css/nojs.css">
</noscript>
</head>
<body>
@ -31,7 +31,7 @@
<button id=~ class="cmd-button reduce-text icon-console" title="console" >~</button>
<button id=contact class="cmd-button reduce-text icon-contact" title="contact" ></button>
</div>
<script src="/cloudcmd/cloudcmd.js"></script>
<script src="{{ prefix }}/cloudcmd.js"></script>
<script>
!(function() {
'use strict';
@ -40,7 +40,7 @@
function load() {
window.removeEventListener('DOMContentLoaded', load);
CloudCmd();
CloudCmd('{{ prefix }}');
}
})();
</script>

View file

@ -171,7 +171,7 @@ var Util, DOM, CloudFunc, join;
});
};
CloudCmd.PREFIX = prefix;
CloudCmd.PREFIX = prefix;
CloudCmd.LIBDIR = prefix + '/lib/';
CloudCmd.LIBDIRCLIENT = prefix + '/lib/client/';

View file

@ -47,7 +47,7 @@ var CloudCmd;
urlFiles = getJoinURL(files);
if (!prefix)
prefix = '/cloudcmd';
prefix = '';
createScript(prefix + urlFiles, function() {
CloudCmd.init(prefix);

View file

@ -1065,6 +1065,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
this.setHistory = function(data, pTitle, url) {
var ret = window.history;
url = CloudCmd.PREFIX + url;
if (ret)
history.pushState(data, pTitle, url);

View file

@ -37,7 +37,7 @@
module.exports = function(params) {
var keys,
p = params || {},
prefix = p.prefix || '/cloudcmd';
prefix = p.prefix || '';
if (params) {
keys = Object.keys(params);
@ -47,6 +47,9 @@
});
}
if (p.socket)
module.exports.listen(p.socket);
return cloudcmd(prefix);
};
@ -110,7 +113,9 @@
root : root
}),
rest,
route,
route({
prefix: prefix
}),
join({
dir : DIR_ROOT,

View file

@ -36,13 +36,22 @@
Template = {},
Prefix,
FS = CloudFunc.FS;
module.exports = function(req, res, next) {
module.exports = function(params) {
var p = params || {};
Prefix = p.prefix || '';
return middle;
};
function middle(req, res, next) {
readFiles(function() {
route(req, res, next);
});
};
}
/**
* additional processing of index file
@ -77,7 +86,8 @@
data = rendy(data, {
title : CloudFunc.getTitle(),
fm : left + right
fm : left + right,
prefix : Prefix
});
return data;