mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added appcache paramter to config.json
This commit is contained in:
parent
b52910a2cf
commit
94c94f2e4f
7 changed files with 74 additions and 38 deletions
|
|
@ -60,6 +60,8 @@ disabled in browsers.
|
|||
|
||||
* Added ability to execute commands on server thrue terminal.
|
||||
|
||||
* Added appcache paramter to config.json
|
||||
|
||||
|
||||
2012.08.24, Version 0.1.6
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"cache" : {"allowed" : false},
|
||||
"appcache" : true,
|
||||
"minification" : {
|
||||
"js" : false,
|
||||
"css" : true,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
/* module make possible connectoin thrue socket.io on a client */
|
||||
var CloudCommander, io, socket, Term;
|
||||
var CloudCommander, io, socket;
|
||||
(function(){
|
||||
"use strict";
|
||||
var Util = CloudCommander.Util;
|
||||
|
||||
var cloudcmd = CloudCommander,
|
||||
Util = cloudcmd.Util,
|
||||
Term = cloudcmd.Terminal.JqueryTerminal.Term;
|
||||
|
||||
Util.jsload("/socket.io/lib/socket.io.js", {
|
||||
onload : function(){
|
||||
socket = io.connect(document.location.hostname);
|
||||
|
||||
cloudcmd.Socket = socket;
|
||||
|
||||
socket.on('connect', function () {
|
||||
console.log('socket connected');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
var CloudCommander, $, Term, socket;
|
||||
var CloudCommander, $;
|
||||
/* object contains terminal jqconsole */
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var cloudcmd = CloudCommander,
|
||||
Util = CloudCommander.Util,
|
||||
KeyBinding = CloudCommander.KeyBinding,
|
||||
var cloudcmd = CloudCommander,
|
||||
|
||||
Util = cloudcmd.Util,
|
||||
KeyBinding = cloudcmd.KeyBinding,
|
||||
TerminalId,
|
||||
Hidden = false;
|
||||
Term,
|
||||
Hidden = false;
|
||||
|
||||
cloudcmd.Terminal = {};
|
||||
cloudcmd.Terminal = {};
|
||||
|
||||
var jqconsole = {};
|
||||
var JqueryTerminal = {};
|
||||
|
||||
|
||||
jqconsole.load = (function(){
|
||||
JqueryTerminal.load = (function(){
|
||||
Util.cssLoad({
|
||||
src : 'lib/client/terminal/jquery-terminal/jquery.terminal.css'
|
||||
});
|
||||
|
|
@ -25,8 +27,8 @@ var CloudCommander, $, Term, socket;
|
|||
var lLoadTerm_func = function(){
|
||||
Util.jsload('lib/client/terminal/jquery-terminal/jquery.terminal.js',
|
||||
function(){
|
||||
jqconsole.init();
|
||||
jqconsole.show();
|
||||
JqueryTerminal.init();
|
||||
JqueryTerminal.show();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -35,7 +37,7 @@ var CloudCommander, $, Term, socket;
|
|||
});
|
||||
|
||||
|
||||
jqconsole.init = (function(){
|
||||
JqueryTerminal.init = (function(){
|
||||
if(!TerminalId){
|
||||
var lFM = Util.getById('fm');
|
||||
if(lFM)
|
||||
|
|
@ -50,7 +52,7 @@ var CloudCommander, $, Term, socket;
|
|||
console.log('Error. Something went wrong FM not found');
|
||||
});
|
||||
|
||||
jqconsole.show = function(){
|
||||
JqueryTerminal.show = function(){
|
||||
Util.Images.hideLoad();
|
||||
Util.hidePanel();
|
||||
KeyBinding.unSet();
|
||||
|
|
@ -59,24 +61,14 @@ var CloudCommander, $, Term, socket;
|
|||
$('#terminal').terminal(function(command, term) {
|
||||
Term = term;
|
||||
term.echo('');
|
||||
socket.send(command);
|
||||
cloudcmd.Socket.send(command);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function jqueryLoad (pCallBack)
|
||||
{
|
||||
/* загружаем jquery: */
|
||||
Util.jsload('lib/client/terminal/jquery-terminal/jquery-1.7.1.min.js',
|
||||
function(){
|
||||
if(typeof pCallBack === 'function')
|
||||
pCallBack();
|
||||
});
|
||||
}
|
||||
|
||||
cloudcmd.Terminal.Keys = (function(){
|
||||
cloudcmd.Terminal.Keys = (function(){
|
||||
/* loading js and css*/
|
||||
Util.jqueryLoad( jqconsole.load );
|
||||
Util.jqueryLoad( JqueryTerminal.load );
|
||||
|
||||
var key_event = function(event){
|
||||
/* если клавиши можно обрабатывать */
|
||||
|
|
@ -86,7 +78,7 @@ var CloudCommander, $, Term, socket;
|
|||
Util.show(TerminalId);
|
||||
TerminalId.focus();
|
||||
|
||||
jqconsole.show();
|
||||
JqueryTerminal.show();
|
||||
}
|
||||
|
||||
if(!Hidden && event.keyCode === cloudcmd.KEY.ESC){
|
||||
|
|
@ -107,5 +99,7 @@ var CloudCommander, $, Term, socket;
|
|||
document.onkeypress = key_event;
|
||||
});
|
||||
|
||||
cloudcmd.Terminal.jqconsole = jqconsole;
|
||||
JqueryTerminal.Term = Term;
|
||||
cloudcmd.Terminal.JqueryTerminal = JqueryTerminal;
|
||||
|
||||
})();
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<script src="jquery-1.7.1.min.js"></script>
|
||||
<script src="jquery.mousewheel-min.js"></script>
|
||||
<script src="/lib/client/jquery.js"></script>
|
||||
<script src="jquery.mousewheel.js"></script>
|
||||
<script src="http://terminal.jcubic.pl/js/jquery.terminal-0.4.17.js"></script>
|
||||
<link href="jquery.terminal.css" rel="stylesheet">
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,19 @@ exports.watch = function(pFileName){
|
|||
|
||||
if(!FileNames[pFileName] &&
|
||||
pFileName !== './cloudcmd.appcache'){
|
||||
try{
|
||||
fs_watch(pFileName, on_fs_watch(pFileName));
|
||||
}catch(pError){}
|
||||
|
||||
/* adding try...catch
|
||||
* if watched files would be more then system limit
|
||||
*/
|
||||
var lWatch_f = tryCatch(function(){
|
||||
fs_watch(pFileName, on_fs_watch(pFileName));
|
||||
});
|
||||
/* if file.exists function exist and
|
||||
* file actually exists
|
||||
*/
|
||||
if(fs.exists)
|
||||
fs.exists(pFileName, lWatch_f);
|
||||
else lWatch_f();
|
||||
|
||||
NamesList_s += pFileName + '\n';
|
||||
FileNames[pFileName] = true;
|
||||
|
|
@ -125,4 +135,22 @@ function cloudRequire(pModule){
|
|||
catch(pError){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function execute param function in
|
||||
* try...catch block
|
||||
*
|
||||
* @param pFunction_f
|
||||
*/
|
||||
function tryCatch(pFunction_f){
|
||||
return function(){
|
||||
var lRet = true;
|
||||
try{
|
||||
pFunction_f();
|
||||
}
|
||||
catch(pError){lRet = pError;}
|
||||
|
||||
return lRet;
|
||||
};
|
||||
}
|
||||
14
server.js
14
server.js
|
|
@ -12,6 +12,7 @@ var CloudServer = {
|
|||
cache : {
|
||||
allowed : true
|
||||
},
|
||||
appcache : false,
|
||||
minification : {
|
||||
js : false,
|
||||
css : false,
|
||||
|
|
@ -134,9 +135,10 @@ CloudServer.init = (function(){
|
|||
/* Если нужно минимизируем скрипты */
|
||||
this.Minify.doit();
|
||||
|
||||
/* создаём файл app cache */
|
||||
|
||||
var lAppCache = CloudServer.AppCache;
|
||||
if(lAppCache && this.Config.server){
|
||||
/* создаём файл app cache */
|
||||
if(this.Config.appcache && lAppCache && this.Config.server){
|
||||
lAppCache.addFiles(
|
||||
[{'//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff' : './font/DroidSansMono.woff'},
|
||||
{'//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js' : './lib/client/jquery.js'},
|
||||
|
|
@ -310,7 +312,8 @@ CloudServer._controller = function(pReq, pRes)
|
|||
console.log('reading '+lName);
|
||||
|
||||
/* watching is file changed */
|
||||
CloudServer.AppCache.watch(lName);
|
||||
if(CloudServer.Config.appcache)
|
||||
CloudServer.AppCache.watch(lName);
|
||||
|
||||
/* сохраняем указатель на response и имя */
|
||||
CloudServer.Responses[lName] = pRes;
|
||||
|
|
@ -673,7 +676,10 @@ CloudServer.indexReaded = function(pList){
|
|||
/* меняем title */
|
||||
pIndex = pIndex.replace('<title>Cloud Commander</title>',
|
||||
'<title>' + CloudFunc.setTitle() + '</title>');
|
||||
|
||||
|
||||
if(!CloudServer.Config.appcache)
|
||||
pIndex = pIndex.replace('/cloudcmd.appcache', '');
|
||||
|
||||
var lHeader;
|
||||
/* если браузер поддерживает gzip-сжатие*/
|
||||
lHeader = CloudServer.generateHeaders('index.html', CloudServer.Gzip);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue