Merge pull request #5 from wookiecooking/master
Accepted merge. Closes Issue #4
This commit is contained in:
commit
225e1bc80d
7 changed files with 94 additions and 16 deletions
1
.jshintignore
Normal file
1
.jshintignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
php-webkit/jquery.min.js
|
||||
29
.jshintrc
Normal file
29
.jshintrc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"node": true,
|
||||
"esnext": true,
|
||||
"camelcase": false,
|
||||
"curly": true,
|
||||
"-W041": false,
|
||||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"regexp": true,
|
||||
"undef": false,
|
||||
"unused": false,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"white": true,
|
||||
"globals": {
|
||||
/* Mocha */
|
||||
"describe": false,
|
||||
"it": false,
|
||||
"before": false,
|
||||
"beforeEach": false,
|
||||
"after": false,
|
||||
"afterEach": false,
|
||||
/* Lodash / Underscore */
|
||||
"_": false
|
||||
}
|
||||
}
|
||||
21
gulpfile.js
Normal file
21
gulpfile.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
var mocha = require('gulp-mocha');
|
||||
var jshint = require('gulp-jshint');
|
||||
var stylish = require('jshint-stylish');
|
||||
|
||||
gulp.task('lint', function () {
|
||||
return gulp.src([
|
||||
'./php-webkit/**/*.js',
|
||||
'./lib/**/*.js'
|
||||
])
|
||||
.pipe(jshint())
|
||||
.pipe(jshint.reporter(stylish))
|
||||
.pipe(jshint.reporter('fail'));
|
||||
});
|
||||
|
||||
gulp.task('test', ['lint'], function () {
|
||||
return gulp.src('./tests/index.js')
|
||||
.pipe(mocha({bail: true}));
|
||||
});
|
||||
|
|
@ -19,8 +19,12 @@ function runPHP(req, response, next, phpinfo){
|
|||
|
||||
var pathinfo = "";
|
||||
var i = req.url.indexOf(".php");
|
||||
if(i > 0) pathinfo = parts.pathname.substring(i+4);
|
||||
else pathinfo = parts.pathname;
|
||||
|
||||
if(i > 0) {
|
||||
pathinfo = parts.pathname.substring(i+4);
|
||||
} else {
|
||||
pathinfo = parts.pathname;
|
||||
}
|
||||
|
||||
var env = {
|
||||
SERVER_SIGNATURE: "php-webkit",
|
||||
|
|
@ -65,7 +69,7 @@ function runPHP(req, response, next, phpinfo){
|
|||
REDIRECT_STATUS: 1
|
||||
};
|
||||
|
||||
Object.keys(req.headers).map(function(x){return env["HTTP_"+x.toUpperCase().replace("-", "_")] = req.headers[x];});
|
||||
Object.keys(req.headers).map(function(x){env["HTTP_"+x.toUpperCase().replace("-", "_")] = req.headers[x];});
|
||||
|
||||
if(/.*?\.php$/.test(file)){
|
||||
var res = "", err = "";
|
||||
|
|
@ -104,7 +108,7 @@ function runPHP(req, response, next, phpinfo){
|
|||
if(lines.length){
|
||||
do {
|
||||
var m = lines[line].split(": ");
|
||||
if(m[0] === "") break;
|
||||
if(m[0] === "") { break; }
|
||||
|
||||
//console.log("HEADER: "+m[0]+": "+m[1]);
|
||||
if(m[0] == "Status"){
|
||||
|
|
@ -141,8 +145,11 @@ exports.cgi = function(phpinfo){
|
|||
req.on('data', function(chunk) {
|
||||
//data.write(chunk.toString('binary'), data.length, chunk.length, 'binary');
|
||||
//console.log(chunk);
|
||||
if(!data) data = chunk;
|
||||
else data = data+chunk;
|
||||
if(!data) {
|
||||
data = chunk;
|
||||
} else {
|
||||
data = data+chunk;
|
||||
}
|
||||
//data = data.concat(chunk);
|
||||
});
|
||||
req.on('end', function() {
|
||||
|
|
@ -151,5 +158,5 @@ exports.cgi = function(phpinfo){
|
|||
//console.log("ENCODING: "+req.get("Content-type")+", len: "+req.rawBody.length);
|
||||
runPHP(req, res, next, phpinfo);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
25
package.json
25
package.json
|
|
@ -1,17 +1,28 @@
|
|||
{
|
||||
"name": "php-webkit",
|
||||
"description": "Allows you to run PHP within node-webkit.",
|
||||
"version": "0.1",
|
||||
"dependencies":{
|
||||
"express":"4.*.*"
|
||||
"version": "0.0.1",
|
||||
"dependencies":{
|
||||
"express":"*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/gulp/bin/gulp.js test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "1.*",
|
||||
"must": ">= 0.11 < 1",
|
||||
"gulp": "3.*",
|
||||
"gulp-jshint": "1.*",
|
||||
"gulp-mocha": "0.*",
|
||||
"jshint-stylish": "0.*"
|
||||
},
|
||||
"main": "./php-webkit/index.html",
|
||||
"node-remote": "<local>",
|
||||
"phpwebkit": {
|
||||
"bin": "", //The location of your php-cgi binary
|
||||
"path": "./application", //The path to your PHP application
|
||||
"host": "127.0.0.1", //The host the PHP app runs on
|
||||
"port": 9090 //The port the PHP app runs on
|
||||
"bin": "",
|
||||
"path": "./application",
|
||||
"host": "127.0.0.1",
|
||||
"port": 9090
|
||||
},
|
||||
"license":"MIT",
|
||||
"window": {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var gui = require('nw.gui');
|
||||
var win = gui.Window.get();
|
||||
var http = require('http');
|
||||
var php = require('./bridge');
|
||||
var php = require('../lib/bridge');
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
var os = require('os');
|
||||
|
|
|
|||
9
tests/index.js
Normal file
9
tests/index.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
var phpBridge = require('../lib/bridge');
|
||||
var demand = require('must');
|
||||
|
||||
describe('php-nw Bridge.js', function () {
|
||||
it('should exist', function () {
|
||||
demand(phpBridge).to.exist();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue