mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
added ability to authorize on github thru new window, changed redirecting url to /auth and added rout function to cloudcmd.js
This commit is contained in:
parent
32ed528c38
commit
9ce26c1640
9 changed files with 76 additions and 80 deletions
|
|
@ -28,6 +28,9 @@ inside event function varible called event do not exist
|
|||
|
||||
* Added ability to upload files to dropbox.
|
||||
|
||||
* Added ability to authorize on github thru new window,
|
||||
changed redirecting url to /auth and added rout function
|
||||
to cloudcmd.js
|
||||
|
||||
2012.12.12, Version 0.1.8
|
||||
|
||||
|
|
|
|||
25
cloudcmd.js
25
cloudcmd.js
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
LIBDIR = main.LIBDIR,
|
||||
SRVDIR = main.SRVDIR,
|
||||
CLIENTDIR = LIBDIR + 'client',
|
||||
|
||||
path = main.path,
|
||||
fs = main.fs,
|
||||
|
|
@ -23,9 +24,10 @@
|
|||
|
||||
readConfig();
|
||||
Server.start(Config, {
|
||||
index : indexProcessing,
|
||||
appcache : appCacheProcessing,
|
||||
rest : rest
|
||||
index : indexProcessing,
|
||||
rest : rest,
|
||||
route : route
|
||||
});
|
||||
|
||||
if(update)
|
||||
|
|
@ -134,6 +136,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* routing of server queries
|
||||
*/
|
||||
function route(pParams){
|
||||
Util.log('* Routing');
|
||||
var lRet,
|
||||
lName = pParams.name;
|
||||
|
||||
if( Util.strCmp(lName, '/auth') ){
|
||||
Util.log('-> auth');
|
||||
pParams.name = main.HTMLDIR + lName + '.html';
|
||||
main.sendFile(pParams);
|
||||
lRet = true;
|
||||
}
|
||||
|
||||
return lRet;
|
||||
}
|
||||
|
||||
|
||||
/* function sets stdout to file log.txt */
|
||||
function writeLogsToFile(){
|
||||
var stdo = fs.createWriteStream('./log.txt');
|
||||
|
|
|
|||
46
index.html
46
index.html
|
|
@ -1,46 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html manifest="/cloudcmd.appcache">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<!-- mobile first design -->
|
||||
<meta content="width=device-width,initial-scale=1" name="viewport" />
|
||||
<title>Cloud Commander</title>
|
||||
|
||||
<link rel=stylesheet href="/css/reset.css">
|
||||
<link rel=stylesheet href="/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<ul class="menu hidden">
|
||||
<li>
|
||||
<!-- http://css-tricks.com/examples/IconFont/ -->
|
||||
<a href=settings onclick="return false;">
|
||||
<span class="menu_icon settings hidden"></span>
|
||||
</a>
|
||||
<a href=refresh onclick="return false;">
|
||||
<span class="menu_icon refresh" id=refresh></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id=fm class=no-js>
|
||||
</div>
|
||||
<div id=keyspanel>
|
||||
<button id=f1 class=cmd-button>F1 - help</button>
|
||||
<button id=f2 class=cmd-button>F2 - rename</button>
|
||||
<button id=f3 class=cmd-button>F3 - view</button>
|
||||
<button id=f4 class=cmd-button>F4 - edit</button>
|
||||
<button id=f5 class=cmd-button>F5 - copy</button>
|
||||
<button id=f6 class=cmd-button>F6 - move</button>
|
||||
<button id=f7 class=cmd-button>F7 - make dir</button>
|
||||
<button id=f8 class=cmd-button>F8 - remove</button>
|
||||
</div>
|
||||
<script src=/lib/util.js></script>
|
||||
<script src=/lib/client/dom.js></script>
|
||||
<script src=/lib/client.js></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js" async></script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" id=jquery_min_js ></script>
|
||||
<script src=/lib/client/ie.js id=ie_js ></script>
|
||||
<![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -51,15 +51,16 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
});
|
||||
}
|
||||
|
||||
function init(pCallBack){
|
||||
|
||||
GithubStore.init = function(pCallBack, pCode){
|
||||
var lToken = Cache.get('token');
|
||||
if(lToken){
|
||||
GithubStore.Login(lToken);
|
||||
Util.exec(pCallBack);
|
||||
}
|
||||
else{
|
||||
var lCode = window.location.search;
|
||||
if ( Util.isContainStr(lCode, '?code=') ){
|
||||
var lCode = pCode || window.location.search;
|
||||
if (pCode || Util.isContainStr(lCode, '?code=') ){
|
||||
lCode = lCode.replace('?code=','');
|
||||
|
||||
var lSuccess = function(pData){
|
||||
|
|
@ -83,14 +84,17 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
DOM.ajax(lData);
|
||||
}
|
||||
else
|
||||
//window.open('welcome.html', 'welcome','width=300,height=200,menubar=yes,status=yes')">
|
||||
window.open('https://github.com/login/oauth/authorize?client_id=' +
|
||||
GitHub_ID + '&&scope=repo,user,gist', 'Cloud Commander Auth');
|
||||
/*
|
||||
window.location =
|
||||
'https://github.com/login/oauth/authorize?client_id=' +
|
||||
GitHub_ID + '&&scope=repo,user,gist';
|
||||
*/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function getUserData(pCallBack){
|
||||
GithubStore.getUserData = function(pCallBack){
|
||||
var lName,
|
||||
|
||||
lShowUserInfo = function(pError, pData){
|
||||
|
|
@ -163,8 +167,8 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
cloudcmd.GitHub.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
Util.retExec(pCallBack),
|
||||
getUserData,
|
||||
init,
|
||||
GithubStore.getUserData,
|
||||
GithubStore.init,
|
||||
setConfig,
|
||||
load
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ var CloudFunc, exports;
|
|||
/* length of longest file name */
|
||||
CloudFunc.SHORTNAMELENGTH = 16;
|
||||
|
||||
|
||||
/**
|
||||
* Функция убирает последний слеш,
|
||||
* если он - последний символ строки
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
Server : {},
|
||||
|
||||
/* КОНСТАНТЫ */
|
||||
INDEX : main.DIR + 'index.html'
|
||||
INDEX : main.DIR + 'html/index.html'
|
||||
},
|
||||
DirPath = '/',
|
||||
|
||||
|
|
@ -134,6 +134,7 @@
|
|||
|
||||
CloudServer.indexProcessing = pProcessing.index;
|
||||
CloudServer.rest = pProcessing.rest;
|
||||
CloudServer.route = pProcessing.route;
|
||||
|
||||
this.init(pProcessing.appcache);
|
||||
|
||||
|
|
@ -182,9 +183,9 @@
|
|||
{
|
||||
/* Читаем содержимое папки, переданное в url */
|
||||
var lConfig = CloudServer.Config,
|
||||
url = main.url,
|
||||
lParsedUrl = url.parse(pReq.url),
|
||||
pathname = lParsedUrl.pathname,
|
||||
lURL = main.url,
|
||||
lParsedUrl = lURL.parse(pReq.url),
|
||||
lPath = lParsedUrl.pathname,
|
||||
|
||||
/* varible contain one of queris:
|
||||
* download - change content-type for
|
||||
|
|
@ -196,13 +197,13 @@
|
|||
* query like this
|
||||
* ?json
|
||||
*/
|
||||
lQuery = lParsedUrl.query;
|
||||
lQuery = lParsedUrl.query;
|
||||
if(lQuery)
|
||||
console.log('query = ' + lQuery);
|
||||
|
||||
/* added supporting of Russian language in directory names */
|
||||
pathname = Querystring.unescape(pathname);
|
||||
console.log('pathname: ' + pathname);
|
||||
lPath = Querystring.unescape(lPath);
|
||||
console.log('pathname: ' + lPath);
|
||||
|
||||
/* получаем поддерживаемые браузером кодировки*/
|
||||
var lAcceptEncoding = pReq.headers['accept-encoding'];
|
||||
|
|
@ -213,14 +214,14 @@
|
|||
if (lAcceptEncoding &&
|
||||
lAcceptEncoding.match(/\bgzip\b/) && Zlib)
|
||||
CloudServer.Gzip = true;
|
||||
|
||||
|
||||
/* путь в ссылке, который говорит
|
||||
* что js отключен
|
||||
*/
|
||||
var lNoJS_s = CloudFunc.NOJS,
|
||||
lFS_s = CloudFunc.FS;
|
||||
|
||||
console.log("request for " + pathname + " received...");
|
||||
console.log("request for " + lPath + " received...");
|
||||
|
||||
if( lConfig.rest ){
|
||||
var lRestWas = Util.exec(CloudServer.rest, {
|
||||
|
|
@ -232,21 +233,32 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if( CloudServer.route){
|
||||
var lRouteWas = Util.exec(CloudServer.route, {
|
||||
name : lPath,
|
||||
request : pReq,
|
||||
response : pRes
|
||||
});
|
||||
|
||||
if(lRouteWas)
|
||||
return;
|
||||
}
|
||||
|
||||
/* если в пути нет информации ни о ФС,
|
||||
* ни об отсутствии js,
|
||||
* ни о том, что это корневой
|
||||
* каталог - загружаем файлы проэкта
|
||||
*/
|
||||
if ( !Util.isContainStr(pathname, lFS_s) &&
|
||||
!Util.isContainStr(pathname, lNoJS_s) &&
|
||||
!Util.strCmp(pathname, '/') &&
|
||||
if ( !Util.isContainStr(lPath, lFS_s) &&
|
||||
!Util.isContainStr(lPath, lNoJS_s) &&
|
||||
!Util.strCmp(lPath, '/') &&
|
||||
!Util.strCmp(lQuery, 'json') ) {
|
||||
|
||||
/* если имена файлов проекта - загружаем их *
|
||||
* убираем слеш и читаем файл с текущец директории */
|
||||
|
||||
/* добавляем текующий каталог к пути */
|
||||
var lName = '.' + pathname;
|
||||
var lName = '.' + lPath;
|
||||
console.log('reading ' + lName);
|
||||
|
||||
/* watching is file changed */
|
||||
|
|
@ -346,16 +358,16 @@
|
|||
* длиннее
|
||||
*/
|
||||
|
||||
if(pathname.indexOf(lNoJS_s) !== lFS_s.length && pathname !== '/')
|
||||
if(lPath.indexOf(lNoJS_s) !== lFS_s.length && lPath !== '/')
|
||||
CloudServer.NoJS = false;
|
||||
else{
|
||||
CloudServer.NoJS = true;
|
||||
pathname = Util.removeStr(pathname, lNoJS_s);
|
||||
lPath = Util.removeStr(lPath, lNoJS_s);
|
||||
}
|
||||
|
||||
/* убираем индекс файловой системы */
|
||||
if(pathname.indexOf(lFS_s) === 0){
|
||||
pathname = Util.removeStr(pathname, lFS_s);
|
||||
if(lPath.indexOf(lFS_s) === 0){
|
||||
lPath = Util.removeStr(lPath, lFS_s);
|
||||
|
||||
/* если посетитель только зашел на сайт
|
||||
* no-js будет пустым, как и fs.
|
||||
|
|
@ -375,10 +387,10 @@
|
|||
/* если в итоге путь пустой
|
||||
* делаем его корневым
|
||||
*/
|
||||
if (pathname === '')
|
||||
pathname = '/';
|
||||
if (lPath === '')
|
||||
lPath = '/';
|
||||
|
||||
DirPath = pathname;
|
||||
DirPath = lPath;
|
||||
|
||||
CloudServer.Responses[DirPath] = pRes;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
exports.SRVDIR = SRVDIR = __dirname + SLASH,
|
||||
exports.LIBDIR = LIBDIR = path.normalize(SRVDIR + '../'),
|
||||
exports.DIR = DIR = path.normalize(LIBDIR + '../'),
|
||||
exports.HTMLDIR = DIR + 'html/',
|
||||
|
||||
/* Functions */
|
||||
exports.generateHeaders = generateHeaders,
|
||||
|
|
@ -180,7 +181,7 @@
|
|||
* @param pGzip - данные сжаты gzip'ом
|
||||
*/
|
||||
function sendFile(pParams){
|
||||
var lRet = false,
|
||||
var lRet,
|
||||
lName = pParams.name,
|
||||
lReq = pParams.request,
|
||||
lRes = pParams.response,
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
var main = global.cloudcmd.main,
|
||||
DIR = main.DIR,
|
||||
LIBDIR = main.LIBDIR;
|
||||
LIBDIR = main.LIBDIR,
|
||||
HTMLDIR = main.HTMLDIR;
|
||||
|
||||
exports.Minify = {
|
||||
/* pathes to directories */
|
||||
INDEX : DIR + 'index.html',
|
||||
INDEX : HTMLDIR + 'index.html',
|
||||
/* приватный переключатель минимизации */
|
||||
_allowed :{
|
||||
css : true,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/* c9.io kill active node process */
|
||||
|
||||
(function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue