Skip to content

Commit

Permalink
修复ppt路径的问题
Browse files Browse the repository at this point in the history
当自建一个文件夹,取名不是ppt时,解析会有问题。现在将默认的ppt和自建的文件夹处理方式合并,使得流程更清晰
  • Loading branch information
ictliujie committed May 30, 2014
1 parent cb0fc55 commit bf742ff
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,20 @@ function startApp(port, dir, host, argvObj) {
}),

function(req, res) {
var url = URL.parse(req.url).path;
var url = URL.parse(req.url).pathname;
var dirname = path.dirname(url);
var realPath, ext;

if (dirname === '/ppt') {

var uid = req.session.uid;
if (!uid) {
uid = now++; //当前连接用户的UID
req.session.uid = uid;
console.log('new user: ' + uid);
} else {
console.log('welcome back ' + uid);
}

realPath = pptDir + path.basename(url);
ext = 'html';
} else if (dirname === '/') {
var uid = req.session.uid;
if (!uid) {
uid = now++; //当前连接用户的UID
req.session.uid = uid;
console.log('new user: ' + uid);
} else {
console.log('welcome back ' + uid);
}

if (dirname === '/') {
pptlist(res, pptDir, argvObj);
return;
} else if (dirname === '/md') {
Expand All @@ -157,6 +153,7 @@ function startApp(port, dir, host, argvObj) {
return;
} else {
//优先选择pptDir的静态资源
url = url.indexOf("/") === 0 ? url.substring(1) : url;
realPath = pptDir + url;
if (!fs.existsSync(realPath)) {
realPath = staticDir + url;
Expand Down

0 comments on commit bf742ff

Please sign in to comment.