diff --git a/ChangeLog b/ChangeLog
index 96288fd6..4d981243 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/cloudcmd.js b/cloudcmd.js
index 596e188a..c8b9d521 100644
--- a/cloudcmd.js
+++ b/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');
diff --git a/index.html b/index.html
deleted file mode 100644
index 85d13d8c..00000000
--- a/index.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
- Cloud Commander
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js
index 0f7ba500..fc9a1bf8 100644
--- a/lib/client/storage/_github.js
+++ b/lib/client/storage/_github.js
@@ -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
]);
diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js
index 333bfacf..18b2e5ec 100644
--- a/lib/cloudfunc.js
+++ b/lib/cloudfunc.js
@@ -32,7 +32,6 @@ var CloudFunc, exports;
/* length of longest file name */
CloudFunc.SHORTNAMELENGTH = 16;
-
/**
* Функция убирает последний слеш,
* если он - последний символ строки
diff --git a/lib/server.js b/lib/server.js
index 3bf397d6..f14e7c47 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -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;
diff --git a/lib/server/main.js b/lib/server/main.js
index 67c2cd61..2de3ea00 100644
--- a/lib/server/main.js
+++ b/lib/server/main.js
@@ -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,
diff --git a/lib/server/minify.js b/lib/server/minify.js
index 3bcf6ff4..2db3fc90 100644
--- a/lib/server/minify.js
+++ b/lib/server/minify.js
@@ -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,
diff --git a/shell/kill.js b/shell/kill.js
index 7b08dfb5..402593b3 100644
--- a/shell/kill.js
+++ b/shell/kill.js
@@ -1,3 +1,4 @@
+
/* c9.io kill active node process */
(function(){