Skip to content

Commit 7b0bd05

Browse files
committed
Merge pull request aguidrevitch#27 from soomtong/master
comeback y'all~
2 parents 84ca6fc + 0900480 commit 7b0bd05

18 files changed

+720
-11
lines changed

.gitignore

+25-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
node_modules/
1+
### intellij ###
2+
*.iml
3+
*.ipr
4+
*.iws
5+
.idea/
6+
7+
### node ###
8+
lib-cov
9+
*.seed
10+
*.log
11+
*.csv
12+
*.dat
13+
*.out
14+
*.pid
15+
*.gz
16+
17+
pids
18+
logs
19+
results
20+
21+
npm-debug.log
22+
node_modules
23+
24+
### example ###
25+
public/lib/

History.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.0.9 / 2013-09-06
2+
==================
3+
4+
* update today's jquery-file-upload
5+
16
0.0.8 / 2013-01-01
27
==================
38

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
jquery-file-upload-middleware
22
=============================
33

4+
### Personal Patch Repository
5+
6+
Please comeback [Aleksandr Guidrevitch](http://aguidrevitch.blogspot.com/) lol
7+
8+
- use bower to install jquery-file-upload (planed)
9+
- use not npm to install jquery-file-upload-middleware
10+
- use this repository by
11+
12+
```json
13+
{
14+
"name": "your project",
15+
"version": "0.1.0",
16+
"private": true,
17+
"dependencies": {
18+
"express": "3.3.x",
19+
"jquery-file-upload-middleware": "git://github.com/soomtong/jquery-file-upload-middleware.git",
20+
"swig": "1.0.x",
21+
"imagemagick": "0.1.x"
22+
},
23+
"devDependencies": {
24+
"nodeunit":"*"
25+
}
26+
}
27+
```
28+
29+
30+
31+
32+
33+
---
34+
35+
## Readme will update later
36+
437
jQuery-File-Upload Express.js middleware. Based on the server code of [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload)
538

639
Installation:

examples/.bowerrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"directory": "public/lib",
3+
"json": "bower.json"
4+
}

examples/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## YET ANOTHER JQUERY FILE UPLOAD MIDDLEWARE EXAMPLES
2+
3+
- use bower to install jquery-file-upload script (tested version 8.8.5)
4+
5+
to run
6+
7+
```
8+
project > npm insatll
9+
project > cd examples
10+
project/examples > npm insatll
11+
project/examples > bower insatll
12+
project/examples > node app.js
13+
```
14+
15+
- to image resize : need imagemagick `http://www.imagemagick.org/script/binary-releases.php`

examples/app.js

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* to run :
3+
* node app.js
4+
* */
5+
6+
/*
7+
* dependencies
8+
* */
9+
var express = require('express'),
10+
http = require('http'),
11+
upload = require('../');
12+
13+
var swig = require('swig');
14+
15+
16+
// configuration
17+
var resizeConf = require('./config').resizeVersion;
18+
var dirs = require('./config').directors;
19+
20+
21+
22+
// express setup
23+
var app = express();
24+
25+
26+
// set template engine
27+
app.engine('html', swig.renderFile);
28+
swig.setDefaults({
29+
cache: false // default 'memory'
30+
});
31+
32+
33+
// jquery-file-upload helper
34+
app.use('/upload/default', function (req, res, next) {
35+
upload.fileHandler({
36+
tmpDir: dirs.temp,
37+
uploadDir: __dirname + dirs.default,
38+
uploadUrl: dirs.default_url,
39+
imageVersions: resizeConf.default
40+
})(req, res, next);
41+
});
42+
43+
app.use('/upload/location', upload.fileHandler({
44+
tmpDir: dirs.temp,
45+
uploadDir: __dirname + dirs.location,
46+
uploadUrl: dirs.location_url,
47+
imageVersions: resizeConf.location
48+
}));
49+
50+
app.use('/upload/location/list', function (req, res, next) {
51+
upload.fileManager({
52+
uploadDir: function () {
53+
return __dirname + dirs.location;
54+
},
55+
uploadUrl: function () {
56+
return dirs.location_url;
57+
}
58+
}).getFiles(function (files) {
59+
res.json(files);
60+
});
61+
});
62+
63+
// bind event
64+
upload.on('end', function (fileInfo) {
65+
// insert file info
66+
console.log("files upload complete");
67+
console.log(fileInfo);
68+
});
69+
70+
upload.on('delete', function (fileName) {
71+
// remove file info
72+
console.log("files remove complete");
73+
console.log(fileName);
74+
});
75+
76+
upload.on('error', function (e) {
77+
console.log(e.message);
78+
});
79+
80+
81+
82+
// Configuration
83+
app.configure(function () {
84+
app.set('port', process.env.PORT || 3001);
85+
app.set('view engine', 'html');
86+
app.set('view options', { layout: false });
87+
app.set('views', __dirname + '/views');
88+
89+
app.use(express.bodyParser());
90+
app.use(express.methodOverride());
91+
app.use(express.cookieParser('token'));
92+
app.use(express.session({ secret: 'secret' }));
93+
app.use(express.favicon());
94+
app.use(express.static(__dirname + '/public'));
95+
});
96+
97+
app.configure('development', function () {
98+
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
99+
app.set('view cache', false);
100+
});
101+
102+
app.configure('production', function () {
103+
app.use(express.errorHandler());
104+
app.set('view cache', true);
105+
});
106+
107+
108+
109+
/*
110+
* routes
111+
* */
112+
app.get('/', function (req, res) {
113+
var html = [
114+
'<p>Call this url in browser : http://localhost:3001/location/input <a href="/location/input">Go</a></p>',
115+
'<p>Call this url in browser : http://localhost:3001/upload/location/list <a href="/upload/location/list">Go</a></p>'
116+
].join('');
117+
res.send(html);
118+
});
119+
120+
121+
app.get('/location/input', function (req, res) {
122+
var params = {
123+
title: "jquery file upload example"
124+
};
125+
126+
res.render('form', params);
127+
});
128+
129+
app.post('/location/input', function (req, res) {
130+
console.log('\n===============================================\n');
131+
console.log(req.body);
132+
res.send(req.body);
133+
});
134+
135+
136+
137+
/*
138+
* start server
139+
* */
140+
http.createServer(app).listen(app.get('port'), function () {
141+
console.log("Express server listening on port " + app.get('port'));
142+
console.log("access url /location/input");
143+
console.log("access url /upload/location/list");
144+
});

examples/bower.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "jquery-file-upload-middleware",
3+
"version": "0.0.1",
4+
"ignore": [
5+
".jshintrc",
6+
"**/*.txt"
7+
],
8+
"dependencies": {
9+
"jquery-file-upload": "8.8.5"
10+
},
11+
"devDependencies": {
12+
}
13+
}

examples/config.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
exports.resizeVersion = {
2+
default: {
3+
thumbnail:{
4+
width:80,
5+
height:"80!"
6+
},
7+
small: {
8+
width:200,
9+
height:"150!"
10+
},
11+
medium:{
12+
width:400,
13+
height:300
14+
},
15+
large: {
16+
width: 800,
17+
height: 600
18+
}
19+
},
20+
location : {
21+
thumbnail:{
22+
width:80,
23+
height:"80^",
24+
imageArgs: [
25+
"-gravity", "center",
26+
"-extent", "80x80"
27+
]
28+
},
29+
small: {
30+
width:"200",
31+
height:"150^",
32+
imageArgs: [
33+
"-gravity", "center",
34+
"-extent", "200x150"
35+
]
36+
},
37+
medium:{
38+
width:400,
39+
height:300
40+
},
41+
large: {
42+
width: 800,
43+
height: 600
44+
}
45+
}
46+
};
47+
48+
exports.directors = {
49+
temp: './tmp',
50+
51+
default: '/public/uploads/default',
52+
default_url: '/uploads/default',
53+
54+
location: '/public/uploads/location',
55+
location_url: '/uploads/location'
56+
};

examples/package.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name":"examples",
3+
"version":"0.0.1",
4+
"dependencies":{
5+
"express":"3.3.x",
6+
"swig":"1.0.x"
7+
}
8+
}

0 commit comments

Comments
 (0)