Skip to content

Commit

Permalink
增加debug,删除pdf支持
Browse files Browse the repository at this point in the history
  • Loading branch information
ksky521 committed May 18, 2016
1 parent a5515b4 commit b377c66
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 55 deletions.
20 changes: 4 additions & 16 deletions bin/nodeppt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ program
.on('--help', function () {
console.log(' Examples:');
console.log();
console.log(' nodeppt generate D:/webppt/demo.md -o D:/output');
console.log(' nodeppt generate D:/webppt/ -o D:/output -a');
console.log(' nodeppt generate /markdown/path.md /output/path');
console.log(' nodeppt generate /markdown/path.md /output/path -a');
console.log();
});

Expand Down Expand Up @@ -90,26 +90,14 @@ program
});



program
.command('pdf')
.usage('[http_url] [save_path.pdf]')
.description('export pdf file. ' + 'Deprecated'.bold.red)
.action(function (http_url, save_path) {
if (typeof http_url !== 'string' || typeof save_path !== 'string') {
console.log('ERROR: pdf need a URL'.bold.red);
this.outputHelp();
return;
}
console.log(' Warning: '.bold.red + 'This command is ' + 'Deprecated'.bold.red);
nodePPT.pdf([http_url, save_path])
console.log(' Warning: '.bold.red + 'This command has been ' + 'Removed'.bold.red);
})
.on('--help', function () {
console.log(' Examples:');
console.log();
console.log(' nodeppt pdf http://127.0.0.1:8080/md/demo.md demo.pdf\n');
console.log(' Warning: '.bold.red + 'This command is ' + 'Deprecated'.bold.red);
console.log();
console.log(' Warning: '.bold.red + 'This command has been ' + 'Removed'.bold.red);
});


Expand Down
1 change: 1 addition & 0 deletions lib/generate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var fs = require('fs');
var path = require('path');
var debug = require('debug')('generate');

var md_parser = require('./md_parser');
var $ = require('./helper');
Expand Down
21 changes: 21 additions & 0 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ var unixifyPath = function(filepath) {
}
};

/**
* mix
* @param {[type]} obj [description]
* @return {[type]} [description]
*/
$.mix = function mix(obj) {
var i = 1,
target, key;
var hasOwnProperty = Object.prototype.hasOwnProperty;
for (; i < arguments.length; i++) {
target = arguments[i];
for (key in target) {
if (hasOwnProperty.call(target, key)) {
obj[key] = target[key];
}
}
}

return obj;
}

/**
* 遍历
* @param {[type]} rootdir [description]
Expand Down
31 changes: 5 additions & 26 deletions lib/md_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var fs = require('fs');
var path = require('path');

//非系统
var debug = require('debug')('parser');
var marked = require('./marked');
var $ = require('./helper');
var libDir = __dirname;
Expand Down Expand Up @@ -51,17 +52,17 @@ var parser = function (string, callback, argvObj, queryObj, commonData) {
var splitReg = /\[slide\s*(.*)\]/ig;
var slidesSetting = string.match(splitReg) || [];
var contents = string.split(/\[slide.*\]/i);
// console.log(contents.length, slidesSetting);
// debug('内容原文:' + contents.length, '设置:' + slidesSetting);
//第一个是封面
var cover = contents.shift();
var json = parseCover(cover);
json = mix({}, json, commonData);
json = $.mix({}, json, commonData);

var config = require(path.join(libDir, '../package.json'));
json.nodeppt_version = config.version;
json.nodeppt_site = config.site;
json = mix({}, defaultJSON, json, {
query: mix(queryObj || {}, argvObj || {})
json = $.mix({}, defaultJSON, json, {
query: $.mix(queryObj || {}, argvObj || {})
});

//优先使用url的参数来控制,使用js来做,不再使用server
Expand Down Expand Up @@ -156,28 +157,6 @@ parser.parseCover = parseCover;

module.exports = parser;

/**
* mix
* @param {[type]} obj [description]
* @return {[type]} [description]
*/

function mix(obj) {
var i = 1,
target, key;
var hasOwnProperty = Object.prototype.hasOwnProperty;
for (; i < arguments.length; i++) {
target = arguments[i];
for (key in target) {
if (hasOwnProperty.call(target, key)) {
obj[key] = target[key];
}
}
}

return obj;
}

/**
* 解析cover的json字符串
* @param {[type]} str [description]
Expand Down
11 changes: 6 additions & 5 deletions lib/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var fs = require('fs');
var URL = require('url');
var debug = require('debug')('server');
var path = require('path');
var exec = require('child_process').exec;

Expand Down Expand Up @@ -173,7 +174,7 @@ function startApp(port, dir, host, argvObj) {
}
var queryObj = URL.parse(req.url, true).query;
realPath = pptDir + basename;
console.log('markdown', realPath, basename);
debug('markdown', realPath, basename);
markdown(realPath, basename, res, argvObj, queryObj);
return;
} else if (/^\/js\/mathjax/.test(dirname)) {
Expand All @@ -199,9 +200,9 @@ function startApp(port, dir, host, argvObj) {
var address = server.address === '0.0.0.0' ? '127.0.0.1' : server.address;
var url = ' http://' + address + ':' + server.port

console.log('ppt directory:'.cyan + ' ' + pptDir);
console.log('assets directory:'.cyan + ' ' + staticDir);
console.log('nodeppt server started:'.cyan + url.yellow);
debug('ppt directory:'.cyan + ' ' + pptDir);
debug('assets directory:'.cyan + ' ' + staticDir);
debug('nodeppt server started:'.cyan + url.yellow);

if (process.platform === 'win32') {
exec('start' + url);
Expand Down Expand Up @@ -356,7 +357,7 @@ function pptlist(res, dir, argvObj) {
if (count == 0) {
//路径不存在ppt
res.write('This directory ' + curPath + ' was not found html on this server.');
console.log(('This directory ' + curPath + ' was not found html on this server.').red);
debug(('This directory ' + curPath + ' was not found html on this server.').red);
}
res.end();
}
Expand Down
17 changes: 9 additions & 8 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nodeppt",
"jsname": "nodeppt",
"description": "A simple, in-browser, markdown-driven presentation framework",
"version": "1.4.1",
"version": "1.4.2",
"site": "https://github.com/ksky521/nodePPT",
"author": {
"name": "Theo Wang",
Expand All @@ -16,16 +16,17 @@
"url": "git://github.com/ksky521/nodePPT"
},
"dependencies": {
"colors": ">=0.6.0-1",
"commander": "2.9.0",
"chokidar": "^1.0.0-rc3",
"colors": "^1.1.2",
"commander": "^2.9.0",
"connect": "2.11.0",
"cookie": ">=0.1.0",
"cookie": "^0.2.3",
"debug": "^2.2.0",
"ejs": "0.8.4",
"ipv4": "0.0.4",
"read": ">=1.0.4",
"socket.io": "1.3.3",
"chokidar": "1.0.0-rc3",
"mathjax": "2.6.1"
"mathjax": "2.6.1",
"read": "^1.0.7",
"socket.io": "1.3.3"
},
"keywords": [
"presentation",
Expand Down

0 comments on commit b377c66

Please sign in to comment.