Skip to content

comeback y'all~ #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
node_modules/
### intellij ###
*.iml
*.ipr
*.iws
.idea/

### node ###
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules

### example ###
public/lib/
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.0.9 / 2013-09-06
==================

* update today's jquery-file-upload

0.0.8 / 2013-01-01
==================

Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
jquery-file-upload-middleware
=============================

### Personal Patch Repository

Please comeback [Aleksandr Guidrevitch](http://aguidrevitch.blogspot.com/) lol

- use bower to install jquery-file-upload (planed)
- use not npm to install jquery-file-upload-middleware
- use this repository by

```json
{
"name": "your project",
"version": "0.1.0",
"private": true,
"dependencies": {
"express": "3.3.x",
"jquery-file-upload-middleware": "git://github.com/soomtong/jquery-file-upload-middleware.git",
"swig": "1.0.x",
"imagemagick": "0.1.x"
},
"devDependencies": {
"nodeunit":"*"
}
}
```





---

## Readme will update later

jQuery-File-Upload Express.js middleware. Based on the server code of [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload)

Installation:
Expand Down
4 changes: 4 additions & 0 deletions examples/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "public/lib",
"json": "bower.json"
}
15 changes: 15 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## YET ANOTHER JQUERY FILE UPLOAD MIDDLEWARE EXAMPLES

- use bower to install jquery-file-upload script (tested version 8.8.5)

to run

```
project > npm insatll
project > cd examples
project/examples > npm insatll
project/examples > bower insatll
project/examples > node app.js
```

- to image resize : need imagemagick `http://www.imagemagick.org/script/binary-releases.php`
144 changes: 144 additions & 0 deletions examples/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* to run :
* node app.js
* */

/*
* dependencies
* */
var express = require('express'),
http = require('http'),
upload = require('../');

var swig = require('swig');


// configuration
var resizeConf = require('./config').resizeVersion;
var dirs = require('./config').directors;



// express setup
var app = express();


// set template engine
app.engine('html', swig.renderFile);
swig.setDefaults({
cache: false // default 'memory'
});


// jquery-file-upload helper
app.use('/upload/default', function (req, res, next) {
upload.fileHandler({
tmpDir: dirs.temp,
uploadDir: __dirname + dirs.default,
uploadUrl: dirs.default_url,
imageVersions: resizeConf.default
})(req, res, next);
});

app.use('/upload/location', upload.fileHandler({
tmpDir: dirs.temp,
uploadDir: __dirname + dirs.location,
uploadUrl: dirs.location_url,
imageVersions: resizeConf.location
}));

app.use('/upload/location/list', function (req, res, next) {
upload.fileManager({
uploadDir: function () {
return __dirname + dirs.location;
},
uploadUrl: function () {
return dirs.location_url;
}
}).getFiles(function (files) {
res.json(files);
});
});

// bind event
upload.on('end', function (fileInfo) {
// insert file info
console.log("files upload complete");
console.log(fileInfo);
});

upload.on('delete', function (fileName) {
// remove file info
console.log("files remove complete");
console.log(fileName);
});

upload.on('error', function (e) {
console.log(e.message);
});



// Configuration
app.configure(function () {
app.set('port', process.env.PORT || 3001);
app.set('view engine', 'html');
app.set('view options', { layout: false });
app.set('views', __dirname + '/views');

app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('token'));
app.use(express.session({ secret: 'secret' }));
app.use(express.favicon());
app.use(express.static(__dirname + '/public'));
});

app.configure('development', function () {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.set('view cache', false);
});

app.configure('production', function () {
app.use(express.errorHandler());
app.set('view cache', true);
});



/*
* routes
* */
app.get('/', function (req, res) {
var html = [
'<p>Call this url in browser : http://localhost:3001/location/input <a href="/location/input">Go</a></p>',
'<p>Call this url in browser : http://localhost:3001/upload/location/list <a href="/upload/location/list">Go</a></p>'
].join('');
res.send(html);
});


app.get('/location/input', function (req, res) {
var params = {
title: "jquery file upload example"
};

res.render('form', params);
});

app.post('/location/input', function (req, res) {
console.log('\n===============================================\n');
console.log(req.body);
res.send(req.body);
});



/*
* start server
* */
http.createServer(app).listen(app.get('port'), function () {
console.log("Express server listening on port " + app.get('port'));
console.log("access url /location/input");
console.log("access url /upload/location/list");
});
13 changes: 13 additions & 0 deletions examples/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "jquery-file-upload-middleware",
"version": "0.0.1",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"jquery-file-upload": "8.8.5"
},
"devDependencies": {
}
}
56 changes: 56 additions & 0 deletions examples/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
exports.resizeVersion = {
default: {
thumbnail:{
width:80,
height:"80!"
},
small: {
width:200,
height:"150!"
},
medium:{
width:400,
height:300
},
large: {
width: 800,
height: 600
}
},
location : {
thumbnail:{
width:80,
height:"80^",
imageArgs: [
"-gravity", "center",
"-extent", "80x80"
]
},
small: {
width:"200",
height:"150^",
imageArgs: [
"-gravity", "center",
"-extent", "200x150"
]
},
medium:{
width:400,
height:300
},
large: {
width: 800,
height: 600
}
}
};

exports.directors = {
temp: './tmp',

default: '/public/uploads/default',
default_url: '/uploads/default',

location: '/public/uploads/location',
location_url: '/uploads/location'
};
8 changes: 8 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name":"examples",
"version":"0.0.1",
"dependencies":{
"express":"3.3.x",
"swig":"1.0.x"
}
}
Loading