diff --git a/app.js b/app.js
index b4c2bec..3e8f0b4 100644
--- a/app.js
+++ b/app.js
@@ -3,15 +3,16 @@ var express = require('express'),
path = require('path'),
conf = require('./conf.js'),
//multer = require('multer'),
- ejs = require('ejs');
+ ejs = require('ejs'),
+ passport = require('passport'),
+ bodyParser = require('body-parser'),
+ cookieParser = require('cookie-parser'),
+ session = require('express-session'),
+ StrategyQQ = require('passport-qq').Strategy;
var app = express();
-
-var bodyParser = require('body-parser');
-
var jsonParser = bodyParser.json();
var urlencodedParser = bodyParser.urlencoded({ extended: false });
-
var errorLogfile = fs.createWriteStream('error.log', {flags: 'a'});
app.engine('.html', ejs.renderFile);
@@ -19,20 +20,35 @@ app.set('etag', 'strong');
app.set('view engine', 'html');
app.set('views', path.join(__dirname, '/views'));
-app.use(express.static(path.join(__dirname, '/public')));
-app.use(express.static(path.join(__dirname, '/download')));
+app.use(cookieParser());
+app.use(bodyParser());
+app.use(session({ secret: 'keyboard cat' }));
-// app.use(multer({ dest: './uploads/'}));
+app.use(passport.initialize());
+app.use(passport.session());
+app.use(require('./route'));
+app.use(express.static(path.join(__dirname, '/public')));
+app.use(express.static(path.join(__dirname, '/download')));
+// app.use(multer({ dest: './uploads/'}));
app.use(jsonParser);
// 缺少这个,会导致 req.body = {}
app.use(urlencodedParser);
-
// cookie
-var cookieParser = require('cookie-parser');
-app.use(cookieParser());
-app.use(require('./routes'));
+
+
+
+
+
+// 授权成功将整个user对象存入session
+passport.serializeUser(function(user, done){
+ done(null, user);
+});
+passport.deserializeUser(function(obj, done){
+ done(null, obj);
+})
+
// app.use(function(err, req, res, next) {
diff --git a/conf.js b/conf.js
index 8b80d6d..b697f31 100644
--- a/conf.js
+++ b/conf.js
@@ -15,6 +15,14 @@ module.exports = {
port: 27017,
dbName: 'iconfonts'
},
+
+ // QQ互联应用信息
+ appId: 101334858,
+ appKey: '6db56cd9b88dc0074cc468d0c444cd0a',
+ origin: 'http://iconfont.imweb.io',
+
+ userID: '833D4B884C0D1DAD412680DDA3031F6B',
+
diff: 32,
auth: {
upload: 1,
diff --git a/log.txt b/log.txt
index 78311ba..cc736e5 100644
--- a/log.txt
+++ b/log.txt
@@ -126,3 +126,149 @@ time: Tue Mar 08 2016 17:22:01 GMT+0800 (CST) | source: progress-now.svg | dest:
time: Tue Mar 08 2016 17:22:01 GMT+0800 (CST) | extname: .svg |
time: Tue Mar 08 2016 17:23:35 GMT+0800 (CST) | source: ke-comment.svg | dest: 0d13c57461232b977d10f417fbb1e03a.svg | username: helondeng |
time: Tue Mar 08 2016 17:23:35 GMT+0800 (CST) | extname: .svg |
+time: Thu Jul 21 2016 17:52:27 GMT+0800 (中国标准时间) | source: social-16px_logo-angellist.svg | dest: d2dead560c35c2e29b86b24da9358b47.svg | username: [object Object] |
+time: Thu Jul 21 2016 17:52:27 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 18:02:37 GMT+0800 (中国标准时间) | source: social-16px_logo-dribbble.svg | dest: f90c2c53ddaf86620b4ba63465542651.svg | username: [object Object] |
+time: Thu Jul 21 2016 18:02:37 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 18:05:00 GMT+0800 (中国标准时间) | source: social-16px_logo-500px.svg | dest: b8300fa1a16f9c8102000c35ca12ec7c.svg | username: [object Object] |
+time: Thu Jul 21 2016 18:05:00 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 18:05:28 GMT+0800 (中国标准时间) | source: social-16px_logo-500px.svg | dest: 88a251389f17a6afb1c2c3267c2ac57e.svg | username: [object Object] |
+time: Thu Jul 21 2016 18:05:28 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:00:39 GMT+0800 (中国标准时间) | source: social-16px_logo-500px.svg | dest: f9fd2d8af88807f22176594d7c7067a3.svg | username: [object Object] |
+time: Thu Jul 21 2016 19:00:39 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:01:07 GMT+0800 (中国标准时间) | source: social-16px_logo-500px.svg | dest: d3a1068c67281730802d36818b2fc8dc.svg | username: [object Object] |
+time: Thu Jul 21 2016 19:01:07 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:12:01 GMT+0800 (中国标准时间) | source: social-16px_logo-500px.svg | dest: 00e86f02c797309020896ab5f6f29444.svg | username: [object Object] |
+time: Thu Jul 21 2016 19:12:01 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:15:23 GMT+0800 (中国标准时间) | source: 1.svg | dest: 4a8ff35862b6ff3670d2bc5ee41eae78.svg | username: [object Object] |
+time: Thu Jul 21 2016 19:15:23 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:23:18 GMT+0800 (中国标准时间) | source: 1.svg | dest: 741b5c9e2271c039f08eea7ec8122295.svg | username: imweb |
+time: Thu Jul 21 2016 19:23:18 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:35:03 GMT+0800 (中国标准时间) | source: social-16px_logo-angellist.svg | dest: 5cce270455583fbfc5216a786579f60a.svg | username: imweb |
+time: Thu Jul 21 2016 19:35:03 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 19:50:11 GMT+0800 (中国标准时间) | source: 1.svg | dest: 02b1b60903a4a16a8c8906d9966cc39c.svg | username: imweb |
+time: Thu Jul 21 2016 19:50:11 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 20:01:15 GMT+0800 (中国标准时间) | source: 1.svg | dest: 6903f46ab37a70af20e30d81eb55082d.svg | username: imweb |
+time: Thu Jul 21 2016 20:01:15 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 20:34:24 GMT+0800 (中国标准时间) | source: 2.svg | dest: 706d911b27a21252c7566855a8bf5301.svg | username: imweb |
+time: Thu Jul 21 2016 20:34:24 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 20:37:42 GMT+0800 (中国标准时间) | source: social-16px_logo-behance.svg | dest: 63c05cf21992651c74e1cf672a6f9dc6.svg | username: imweb |
+time: Thu Jul 21 2016 20:37:42 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 20:38:06 GMT+0800 (中国标准时间) | source: social-16px_logo-facebook.svg | dest: ac6f6670efdbf8236e97961ca448f15e.svg | username: imweb |
+time: Thu Jul 21 2016 20:38:06 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 20:39:44 GMT+0800 (中国标准时间) | source: 1.svg | dest: 0a3a458a323488e394736a40dfd2614c.svg | username: imweb |
+time: Thu Jul 21 2016 20:39:44 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 21 2016 20:40:03 GMT+0800 (中国标准时间) | source: 3.svg | dest: e1c11016c8ddce117aa8c39fc241a1fa.svg | username: imweb |
+time: Thu Jul 21 2016 20:40:03 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 11:23:58 GMT+0800 (中国标准时间) | source: social-color-1_logo-feedly.svg | dest: 5fc5b64ed83d9f94c6e3513a2f79e765.svg | username: imweb |
+time: Fri Jul 22 2016 11:23:58 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 11:24:27 GMT+0800 (中国标准时间) | source: social-color-1_logo-slack.svg | dest: 10928d42bf4c9cff0e572bce128ee155.svg | username: imweb |
+time: Fri Jul 22 2016 11:24:27 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 15:41:54 GMT+0800 (中国标准时间) | source: social-color-1_logo-buffer.svg | dest: 5370db44ec5cd1a15b3d5c3650cb6031.svg | username: wans |
+time: Fri Jul 22 2016 15:41:54 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 16:41:44 GMT+0800 (中国标准时间) | source: social-color-1_logo-deviantart.svg | dest: 9df2b1829da746f0d41045f5bf31ad69.svg | username: wans |
+time: Fri Jul 22 2016 16:41:44 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 17:17:09 GMT+0800 (中国标准时间) | source: social-color-1_logo-evernote.svg | dest: e7d5e982ab0b69c868be3e4cfb6bb4f3.svg | username: wans |
+time: Fri Jul 22 2016 17:17:09 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 17:18:50 GMT+0800 (中国标准时间) | source: social-color-1_logo-evernote.svg | dest: 324492ab233337a4920fe22046fd7c3f.svg | username: wans |
+time: Fri Jul 22 2016 17:18:50 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 17:37:36 GMT+0800 (中国标准时间) | source: social-color-1_logo-feedly.svg | dest: e8699a180e07cc1fb1627988d759ac17.svg | username: wans |
+time: Fri Jul 22 2016 17:37:36 GMT+0800 (中国标准时间) | extname: .svg |
+time: Fri Jul 22 2016 17:37:59 GMT+0800 (中国标准时间) | source: social-color-1_logo-linkedin.svg | dest: 0f9e963f2ed28ff9dd5b3b80aee00554.svg | username: wans |
+time: Fri Jul 22 2016 17:37:59 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 12:01:42 GMT+0800 (中国标准时间) | source: social-16px_logo-github.svg | dest: c1aa2a8b7a563a3edcc8f9e9a57b0be5.svg | username: wans |
+time: Sat Jul 23 2016 12:01:42 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 12:11:58 GMT+0800 (中国标准时间) | source: alert-border.svg | dest: 3a85f143285b988a002fbf98e99b946f.svg | username: wans |
+time: Sat Jul 23 2016 12:11:58 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 12:31:43 GMT+0800 (中国标准时间) | source: arrow-bottom.svg | dest: fd38a2876d27d6b450fd3870ff8e9551.svg | username: wans |
+time: Sat Jul 23 2016 12:31:43 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 14:55:44 GMT+0800 (中国标准时间) | source: alert-border.svg | dest: e2e335adefd9f071d55db601c63b4d1d.svg | username: imweb |
+time: Sat Jul 23 2016 14:55:44 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 14:56:07 GMT+0800 (中国标准时间) | source: career2.svg | dest: cd818cda3c37af679fb5e070b1bcefe5.svg | username: imweb |
+time: Sat Jul 23 2016 14:56:07 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 14:58:36 GMT+0800 (中国标准时间) | source: c-cancel-remind.svg | dest: 32ac829d8171c26e891f2e918a9dc91e.svg | username: imweb |
+time: Sat Jul 23 2016 14:58:36 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 15:02:57 GMT+0800 (中国标准时间) | source: center.svg | dest: 60808093d34e56273ea5e5954db61de1.svg | username: imweb |
+time: Sat Jul 23 2016 15:02:57 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 16:31:00 GMT+0800 (中国标准时间) | source: close.svg | dest: 5b061018c0f842f631570f093d63e79a.svg | username: imweb |
+time: Sat Jul 23 2016 16:31:00 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 18:42:40 GMT+0800 (中国标准时间) | source: cap.svg | dest: f4be95ae64a94d22f79d355072d474f0.svg | username: imweb |
+time: Sat Jul 23 2016 18:42:40 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 19:25:59 GMT+0800 (中国标准时间) | source: vine.svg | dest: b1d6f20a9076c9bfc6b525ed989403a1.svg | username: imweb |
+time: Sat Jul 23 2016 19:25:59 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sat Jul 23 2016 19:27:57 GMT+0800 (中国标准时间) | source: youtube.svg | dest: d16a260795f34cad3b651e6f9814abd5.svg | username: imweb |
+time: Sat Jul 23 2016 19:27:57 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sun Jul 24 2016 16:48:18 GMT+0800 (中国标准时间) | source: dropbox.svg | dest: 7b2c9f6d57d8fd7e42b8eb43d231d421.svg | username: function |
+time: Sun Jul 24 2016 16:48:18 GMT+0800 (中国标准时间) | extname: .svg |
+time: Sun Jul 24 2016 17:22:29 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.rar | dest: def3be4b55cd1b5ee321f7bc5ba21203.rar | username: imweb |
+time: Sun Jul 24 2016 17:22:29 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.rar | dest: def3be4b55cd1b5ee321f7bc5ba21203.rar | username: imweb | error: illegal file extension |
+time: Sun Jul 24 2016 17:27:36 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.zip | dest: 4905422b69bb4e5d22a276749ac722f4.zip | username: imweb |
+time: Sun Jul 24 2016 17:27:36 GMT+0800 (中国标准时间) | extname: .zip |
+time: Sun Jul 24 2016 19:15:12 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.zip | dest: 86bada87e99587eb571a37b371edce8a.zip | username: imweb |
+time: Sun Jul 24 2016 19:15:12 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.zip | dest: 86bada87e99587eb571a37b371edce8a.zip | username: imweb | error: file size too large |
+time: Sun Jul 24 2016 19:15:53 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.zip | dest: b349993bdd3f3e5da2d6b5cf39942512.zip | username: imweb |
+time: Sun Jul 24 2016 19:15:53 GMT+0800 (中国标准时间) | extname: .zip |
+time: Sun Jul 24 2016 19:20:15 GMT+0800 (中国标准时间) | source: ke.qq.com-svg.zip | dest: b19e89ccbb08c0a32bc24a8f99a8fca1.zip | username: imweb |
+time: Sun Jul 24 2016 19:20:15 GMT+0800 (中国标准时间) | extname: .zip |
+time: Sun Jul 24 2016 19:34:16 GMT+0800 (中国标准时间) | source: ke-comment.zip | dest: 73ce04e65a4f3fec93dee5e2a23d8021.zip | username: imweb |
+time: Sun Jul 24 2016 19:34:16 GMT+0800 (中国标准时间) | extname: .zip |
+time: Sun Jul 24 2016 19:50:25 GMT+0800 (中国标准时间) | source: 73ce04e65a4f3fec93dee5e2a23d8021.zip | dest: 738ed91ad8c9cb55e36e9193b589249d.zip | username: imweb |
+time: Sun Jul 24 2016 19:50:25 GMT+0800 (中国标准时间) | extname: .zip |
+time: Sun Jul 24 2016 19:52:46 GMT+0800 (中国标准时间) | source: 73ce04e65a4f3fec93dee5e2a23d8021.zip | dest: b106de653a2a5cf06eaf4a37c72fbf7c.zip | username: wans |
+time: Sun Jul 24 2016 19:52:46 GMT+0800 (中国标准时间) | extname: .zip |
+time: Mon Jul 25 2016 15:06:58 GMT+0800 (中国标准时间) | source: boxiaole.svg | dest: 41041156ed0deb244331aa2adefd7044.svg | username: wans |
+time: Mon Jul 25 2016 15:06:58 GMT+0800 (中国标准时间) | extname: .svg |
+time: Tue Jul 26 2016 19:43:38 GMT+0800 (中国标准时间) | source: behance.svg | dest: 6da17491304b5b68802f998c4f5969ae.svg | username: wans |
+time: Tue Jul 26 2016 19:43:38 GMT+0800 (中国标准时间) | extname: .svg |
+time: Tue Jul 26 2016 20:00:22 GMT+0800 (中国标准时间) | source: behance.svg | dest: 192a2cb3579a4d0e06c11a05be211a8c.svg | username: wans |
+time: Tue Jul 26 2016 20:00:22 GMT+0800 (中国标准时间) | extname: .svg |
+time: Tue Jul 26 2016 20:04:46 GMT+0800 (中国标准时间) | source: behance.svg | dest: 5d9573c25e71be78f1c486c30ba2de15.svg | username: wans |
+time: Tue Jul 26 2016 20:04:46 GMT+0800 (中国标准时间) | extname: .svg |
+time: Tue Jul 26 2016 20:05:45 GMT+0800 (中国标准时间) | source: behance.svg | dest: d0ff18e30bc0760c694f960a8f365eb0.svg | username: wans |
+time: Tue Jul 26 2016 20:05:45 GMT+0800 (中国标准时间) | extname: .svg |
+time: Tue Jul 26 2016 20:07:01 GMT+0800 (中国标准时间) | source: behance.svg | dest: 42df19036eb8006faf3851e720355536.svg | username: wans |
+time: Tue Jul 26 2016 20:07:01 GMT+0800 (中国标准时间) | extname: .svg |
+time: Tue Jul 26 2016 20:09:04 GMT+0800 (中国标准时间) | source: behance.svg | dest: 8e35d4ee195f4868d60b9285ff1b903a.svg | username: wans |
+time: Tue Jul 26 2016 20:09:04 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 12:02:05 GMT+0800 (中国标准时间) | source: iconfont-1469592001699.zip | dest: ec1d087a200abb89a8468648ddb35641.zip | username: imweb |
+time: Wed Jul 27 2016 12:02:05 GMT+0800 (中国标准时间) | source: iconfont-1469592001699.zip | dest: ec1d087a200abb89a8468648ddb35641.zip | username: imweb | error: file size too large |
+time: Wed Jul 27 2016 12:04:22 GMT+0800 (中国标准时间) | source: iconfont-1469592219489.zip | dest: cbab1e29ffeca7638a5081bb2443b95c.zip | username: imweb |
+time: Wed Jul 27 2016 12:04:22 GMT+0800 (中国标准时间) | source: iconfont-1469592219489.zip | dest: cbab1e29ffeca7638a5081bb2443b95c.zip | username: imweb | error: file size too large |
+time: Wed Jul 27 2016 12:05:01 GMT+0800 (中国标准时间) | source: iconfont-1469592283573.zip | dest: 66b9acca467d8f1f6daba3f05d845054.zip | username: function |
+time: Wed Jul 27 2016 12:05:01 GMT+0800 (中国标准时间) | extname: .zip |
+time: Wed Jul 27 2016 17:19:26 GMT+0800 (中国标准时间) | source: class.svg | dest: 1609795a02e954273bd16b0086fa290f.svg | username: wans |
+time: Wed Jul 27 2016 17:19:26 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:20:38 GMT+0800 (中国标准时间) | source: clone.svg | dest: c02538bc4d91d145d31af5cecd131e3a.svg | username: wans |
+time: Wed Jul 27 2016 17:20:38 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:24:57 GMT+0800 (中国标准时间) | source: close.svg | dest: 35edc3930cc529025417b575d65840e5.svg | username: wans |
+time: Wed Jul 27 2016 17:24:57 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:26:48 GMT+0800 (中国标准时间) | source: comment.svg | dest: a87def288fb1f583fa4c71abd04452cc.svg | username: wans |
+time: Wed Jul 27 2016 17:26:48 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:35:49 GMT+0800 (中国标准时间) | source: comment-to.svg | dest: 3cb966ebb8d835ff40d4fdbb07053f1c.svg | username: wans |
+time: Wed Jul 27 2016 17:35:49 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:37:59 GMT+0800 (中国标准时间) | source: computor.svg | dest: d7572018595b85b56511e9c83b344dad.svg | username: wans |
+time: Wed Jul 27 2016 17:37:59 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:38:40 GMT+0800 (中国标准时间) | source: computor2.svg | dest: daddc14229bb99c6766783853a6d6c01.svg | username: wans |
+time: Wed Jul 27 2016 17:38:40 GMT+0800 (中国标准时间) | extname: .svg |
+time: Wed Jul 27 2016 17:42:56 GMT+0800 (中国标准时间) | source: consultation.svg | dest: d265be03c6aa6ac2d279c6b363d5b7c4.svg | username: wans |
+time: Wed Jul 27 2016 17:42:56 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 10:48:17 GMT+0800 (中国标准时间) | source: course-live.svg | dest: 216f083dbd499d2873e769226f1271aa.svg | username: imweb |
+time: Thu Jul 28 2016 10:48:17 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 10:56:56 GMT+0800 (中国标准时间) | source: course-q-a.svg | dest: 156d3b5a94093485c09fa4055a66a2ba.svg | username: imweb |
+time: Thu Jul 28 2016 10:56:56 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 10:59:12 GMT+0800 (中国标准时间) | source: course-record.svg | dest: 3247cb54da4d265bbe146ef6a09899d7.svg | username: imweb |
+time: Thu Jul 28 2016 10:59:12 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 11:17:26 GMT+0800 (中国标准时间) | source: course-record-border.svg | dest: 918b4792e20d942e3e68d15dbb01f0f3.svg | username: imweb |
+time: Thu Jul 28 2016 11:17:26 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 11:20:21 GMT+0800 (中国标准时间) | source: course-test.svg | dest: fdb04639a2169b14874d262a71b29b6f.svg | username: imweb |
+time: Thu Jul 28 2016 11:20:21 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 11:21:01 GMT+0800 (中国标准时间) | source: c-remind.svg | dest: 1d5ee595bd0971a11987c7e3b21a8fd9.svg | username: imweb |
+time: Thu Jul 28 2016 11:21:01 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 19:08:26 GMT+0800 (中国标准时间) | source: class.svg | dest: e70a020199a60bb6005b34514ff4c44b.svg | username: imweb |
+time: Thu Jul 28 2016 19:08:26 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 19:10:00 GMT+0800 (中国标准时间) | source: class.svg | dest: 6ef0c130271548e55d2a0eab277bdac1.svg | username: imweb |
+time: Thu Jul 28 2016 19:10:00 GMT+0800 (中国标准时间) | extname: .svg |
+time: Thu Jul 28 2016 19:15:18 GMT+0800 (中国标准时间) | source: 归档 2.zip | dest: 084ff6ff04685c20a168186e173fd4e8.zip | username: imweb |
+time: Thu Jul 28 2016 19:15:18 GMT+0800 (中国标准时间) | extname: .zip |
+time: Thu Jul 28 2016 19:30:57 GMT+0800 (中国标准时间) | source: coupon.svg | dest: 353f87e63449782d4e9fb924c84bd127.svg | username: imweb |
+time: Thu Jul 28 2016 19:30:57 GMT+0800 (中国标准时间) | extname: .svg |
diff --git a/midware/addUserToMongo.js b/midware/addUserToMongo.js
new file mode 100644
index 0000000..dc32c43
--- /dev/null
+++ b/midware/addUserToMongo.js
@@ -0,0 +1,46 @@
+var User = require('../model/user.js');
+
+
+
+function addUserToMongo(req, res, next){
+ var user = req.user;
+ if (!user) {
+ return res.redirect('http://iconfont.imweb.io/user/auth/qq');
+ }
+
+
+ User.find({
+ id: req.user.id
+ }).exec(function(err, user){
+ // console.log(user);
+ if (err) {
+ return console.log("find user出错")
+ }
+ var newuser = {
+ user: req.user.nickname,
+ id: req.user.id,
+ img: req.user._json.figureurl_qq_1
+ };
+
+ // if (user.length === 0) {
+ // User.create(newuser, function(err){
+ // if (err) return console.log(err);
+ // });
+ // }
+
+ User.update({
+ id: req.user.id
+ },{
+ $set: newuser
+ }).exec(function(err){
+ if (err) {
+ return console.log(err)
+ }
+ })
+
+
+ next();
+ })
+}
+
+module.exports = addUserToMongo;
\ No newline at end of file
diff --git a/midware/auth.js b/midware/auth.js
index 7be886e..fb94cf4 100644
--- a/midware/auth.js
+++ b/midware/auth.js
@@ -14,7 +14,8 @@ var authOptions = {
};
function authCheck(req, res, next) {
- if (req.cookies.accessToken) {
+ if (req.user.accessToken) {
+ console.log(req.user);
authOptions.path = AUTH_URL;
['uin', 'skey', 'accessToken'].forEach(function(key) {
authOptions.path += '/' + req.cookies[key];
@@ -28,7 +29,7 @@ function authCheck(req, res, next) {
res.on('end', function () {
var d = JSON.parse(data);
if(d.retcode !== 200) {
- return res.redirect('http://imweb.io');
+ return res.redirect('http://iconfont.imweb.io/intro');
}
next();
});
@@ -38,7 +39,8 @@ function authCheck(req, res, next) {
});
return authReq.end();
}
- res.redirect('http://imweb.io');
+ console.log(req.user);
+ res.redirect('http://iconfont.imweb.io/intro');
}
module.exports = authCheck;
diff --git a/models/business.js b/model/business.js
similarity index 51%
rename from models/business.js
rename to model/business.js
index 523c9ba..72d82f8 100644
--- a/models/business.js
+++ b/model/business.js
@@ -1,15 +1,17 @@
/*
-* @author helondeng
+* @author junmo
*/
var mongoose = require('mongoose'),
- autoIncrement = require('mongoose-auto-increment');
- db = require('../utils/db.js');
+ autoIncrement = require('mongoose-auto-increment'),
+ db = require('../utils/db.js');
var BusinessSchema = mongoose.Schema({
name: String,
- pm: String
+ pm: String,
+ id: String
});
+
BusinessSchema.plugin(autoIncrement.plugin, {
model: 'Business',
field: 'bid',
@@ -17,8 +19,5 @@ BusinessSchema.plugin(autoIncrement.plugin, {
incrementBy: 1
});
-
-
-var Business = mongoose.model('Business', BusinessSchema);
-
-module.exports = Business;
+var Business = mongoose.model('newbusinesses', BusinessSchema)
+module.exports = Business;
\ No newline at end of file
diff --git a/models/icon.js b/model/icon.js
similarity index 89%
rename from models/icon.js
rename to model/icon.js
index a16c772..7c353d2 100644
--- a/models/icon.js
+++ b/model/icon.js
@@ -1,5 +1,5 @@
/*
- * @author moxhe
+ * @author junmo
*/
var EventEmitter = require('eventemitter2').EventEmitter2,
emitter = new EventEmitter();
@@ -14,7 +14,8 @@ var IconSchema = mongoose.Schema({
//content: String, // content 根据 iconId生成,不需要存储
business: String, // 业务相关,方便后续分类
author: String,
- path: String // 文件路径
+ path: String, // 文件路径
+ id: String
});
// iconId 自增,确保唯一性
@@ -63,15 +64,18 @@ IconSchema.statics.insertByOrder = function (icons, finishCb) {
IconSchema.statics.insertOne = function (obj) {
this.find({
- name: obj.name
+ name: obj.name,
+ id: obj.id
}).exec(function (err, icons) {
+ // console.log('obj是这个:',obj);
if (!icons.length) {
var icon = new Icon({
name: obj.name,
business: obj.business,
path: obj.path,
author: obj.author,
- className: 'i-' + obj.name
+ className: 'i-' + obj.name,
+ id: obj.id
});
icon.save(function (err, icon) {
emitter.emit('insert_success', err, obj);
@@ -82,6 +86,6 @@ IconSchema.statics.insertOne = function (obj) {
});
};
-var Icon = mongoose.model('Icon', IconSchema);
+var Icon = mongoose.model('newicons', IconSchema);
-module.exports = Icon;
+module.exports = Icon;
\ No newline at end of file
diff --git a/models/tag.js b/model/tag.js
similarity index 82%
rename from models/tag.js
rename to model/tag.js
index 084281a..ffabb14 100644
--- a/models/tag.js
+++ b/model/tag.js
@@ -1,5 +1,5 @@
/*
-* @author helondeng
+* @author junmo
*/
var mongoose = require('mongoose'),
autoIncrement = require('mongoose-auto-increment');
@@ -19,9 +19,9 @@ TagSchema.plugin(autoIncrement.plugin, {
});
-var Tag = mongoose.model('Tag', TagSchema);
+var Tag = mongoose.model('newtags', TagSchema);
-module.exports = Tag;
+module.exports = Tag;
\ No newline at end of file
diff --git a/model/user.js b/model/user.js
new file mode 100644
index 0000000..8311558
--- /dev/null
+++ b/model/user.js
@@ -0,0 +1,24 @@
+/*
+* @author junmo
+ */
+var mongoose = require('mongoose'),
+ // autoIncrement = require('mongoose-auto-increment');
+ db = require('../utils/db.js');
+
+var UserSchema =new mongoose.Schema({
+ // imweb.io cookie user's name
+ user: String,
+ id: String,
+ img: String,
+ // 有无更新权限
+ auth: {
+ type: Number,
+ default: 0
+ }
+});
+
+
+
+var User = mongoose.model('newUsers', UserSchema);
+
+module.exports = User;
diff --git a/models/ib.js b/models/ib.js
deleted file mode 100644
index b948fb0..0000000
--- a/models/ib.js
+++ /dev/null
@@ -1,16 +0,0 @@
-
-/*
-* insert business
- */
-var B = require('./business');
-
-var b = new B({
- name: '上课web化',
- pm: 'ouvenzhang'
-});
-
- b.save(function (err, bid) {
- if(err) {
- console.log(err);
- }
-});
diff --git a/models/user.js b/models/user.js
deleted file mode 100644
index 6116bcb..0000000
--- a/models/user.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-* @author helondeng
- */
-var mongoose = require('mongoose'),
- // autoIncrement = require('mongoose-auto-increment');
- db = require('../utils/db.js');
-
-var UserSchema = mongoose.Schema({
- user: String,
- auth: Number
-});
-
-
-
-var User = mongoose.model('User', UserSchema);
-
-module.exports = User;
diff --git a/newLog.log b/newLog.log
deleted file mode 100644
index e69de29..0000000
diff --git a/package.json b/package.json
index 5579078..b191bda 100644
--- a/package.json
+++ b/package.json
@@ -21,14 +21,17 @@
"body-parser": "^1.13.1",
"cookie-parser": "^1.3.5",
"ejs": "~2.3.2",
+ "eventemitter2": "^0.4.14",
"express": "~4.13.0",
+ "express-session": "^1.14.0",
"font-carrier": "0.0.4",
"mongoose": "^4.1.1",
+ "mongoose-auto-increment": "^5.0.1",
"multer": "^0.1.8",
+ "passport": "^0.3.2",
+ "passport-qq": "0.0.3",
"q": "^1.4.1",
- "unzip": "^0.1.11",
- "mongoose-auto-increment": "^4.0.0",
- "eventemitter2": "^0.4.14"
+ "unzip": "^0.1.11"
},
"devDependencies": {
"pm2": "*"
diff --git a/public/css/fonts/iconfont.eot b/public/css/fonts/iconfont.eot
index cafbc80..606fe3f 100644
Binary files a/public/css/fonts/iconfont.eot and b/public/css/fonts/iconfont.eot differ
diff --git a/public/css/fonts/iconfont.svg b/public/css/fonts/iconfont.svg
index cc53b49..bc41862 100644
--- a/public/css/fonts/iconfont.svg
+++ b/public/css/fonts/iconfont.svg
@@ -24,397 +24,94 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/public/css/fonts/iconfont.ttf b/public/css/fonts/iconfont.ttf
index f7975f7..07d2d14 100644
Binary files a/public/css/fonts/iconfont.ttf and b/public/css/fonts/iconfont.ttf differ
diff --git a/public/css/fonts/iconfont.woff b/public/css/fonts/iconfont.woff
index ea30170..341aa37 100644
Binary files a/public/css/fonts/iconfont.woff and b/public/css/fonts/iconfont.woff differ
diff --git a/public/css/header.css b/public/css/header.css
index 9fbfdad..9d1d0c8 100644
--- a/public/css/header.css
+++ b/public/css/header.css
@@ -5,22 +5,33 @@
.menu{
width: 1000px;
margin: 0 auto;
- height: 70px;
+ height: 50px;
}
.menu ul {
position: relative;
+ z-index: 20;
}
.menu-item{
float: left;
- height: 70px;
- line-height: 70px;
- font-size: 18px;
+ height: 50px;
+ line-height: 50px;
+ font-size: 16px;
+}
+.menu-item:hover{
+ background-color: #38a0ea;
+}
+.user-name:hover{
+ background-color: #38b7ea;
+}
+.search-panel:hover{
+ background-color: #38b7ea;
}
.menu-item a {
color: #fff;
- display: block;
+ display: inline-block;
+
padding: 0 15px;
}
.menu-item a:hover{
@@ -28,11 +39,62 @@
color: #fff;
}
-
+#logIn img{
+ vertical-align: middle;
+}
+#logIn a{
+ font-size: 14px;
+}
.user-name {
position: absolute;
right: 200px;
+ width: 110px;
+}
+
+.user-name img{
+ height: 23px;
+ width: 23px;
+ vertical-align: middle;
+}
+.user-name ul li:first-child{
+ margin-top: 6px;
}
+.user-name ul li{
+ background-color: #38b7ea;
+ text-align: center;
+ height: 40px;
+ color: #000;
+ /*margin-top: 6px;*/
+}
+.user-name ul li:hover{
+ background-color: #38a0ea;
+}
+.user-name:hover #personOption{
+ display: block;
+}
+.user-name ul li a{
+ height: inherit;
+ font-size: 14px;
+ line-height: 40px;
+ position: relative;
+ top: -5px;
+}
+#personOption{
+ display: none;
+ margin-top: -6px;
+}
+.arrow{
+ display: none;
+ width: 0;
+ height: 0;
+ border: 6px solid;
+ border-color: transparent transparent #38b7ea transparent;
+ border-style: dashed dashed solid dashed;
+ position: absolute;
+ top: 44px;
+ left: 44px;
+}
+
.search-panel {
float: right;
padding-right: 0;
@@ -56,5 +118,5 @@
position: absolute;
right: 5px;
font-size: 20px;
- top: 26px;
+ top: 16px;
}
diff --git a/public/css/iconfont.css b/public/css/iconfont.css
index 65f1b7a..00fcb19 100644
--- a/public/css/iconfont.css
+++ b/public/css/iconfont.css
@@ -6,123 +6,12 @@ url("./fonts/iconfont.woff") format("woff"),
url("./fonts/iconfont.ttf") format("truetype"),
url("./fonts/iconfont.svg#iconfont") format("svg");}
.icon-font{font-family:"iconfont";font-size:16px;font-style:normal;font-weight: normal;font-variant: normal;text-transform: none;line-height: 1;position: relative;vertical-align:-2px;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
-.i-group:before{content: "\f020";}
-.i-logo:before{content: "\f021";}
-.i-heart:before{content: "\f022";}
-.i-play:before{content: "\f024";}
-.i-calendar:before{content: "\f028";}
-.i-qq-border:before{content: "\f029";}
-.i-edit:before{content: "\f02a";}
-.i-v-top:before{content: "\f02b";}
-.i-alert:before{content: "\f02c";}
-.i-home:before{content: "\f02d";}
-.i-success:before{content: "\f02e";}
-.i-user-border:before{content: "\f02f";}
-.i-search:before{content: "\f032";}
-.i-tel:before{content: "\f033";}
-.i-weixin:before{content: "\f034";}
-.i-lu:before{content: "\f035";}
-.i-qq:before{content: "\f036";}
-.i-empty:before{content: "\f038";}
-.i-info:before{content: "\f039";}
-.i-question:before{content: "\f03b";}
-.i-star:before{content: "\f03d";}
-.i-career:before{content: "\f03e";}
-.i-feeder:before{content: "\f03f";}
-.i-to-top:before{content: "\f040";}
-.i-v-bottom:before{content: "\f041";}
-.i-v-left:before{content: "\f042";}
-.i-language:before{content: "\f043";}
-.i-phone:before{content: "\f044";}
-.i-weixin-border:before{content: "\f045";}
-.i-user-group-border:before{content: "\f047";}
-.i-time:before{content: "\f049";}
-.i-pen:before{content: "\f04a";}
-.i-star-border:before{content: "\f04c";}
-.i-close:before{content: "\f04d";}
-.i-user-group:before{content: "\f04e";}
-.i-v-right:before{content: "\f04f";}
-.i-computor:before{content: "\f050";}
-.i-user:before{content: "\f053";}
-.i-warn:before{content: "\f055";}
-.i-course-data:before{content: "\f056";}
-.i-course-live:before{content: "\f057";}
-.i-course-q-a:before{content: "\f058";}
-.i-course-record:before{content: "\f059";}
-.i-list-dot:before{content: "\f05d";}
-.i-tel-border:before{content: "\f061";}
-.i-group-border:before{content: "\f062";}
-.i-heart-border:before{content: "\f063";}
-.i-center:before{content: "\f064";}
-.i-alert-border:before{content: "\f065";}
-.i-delete:before{content: "\f066";}
-.i-share:before{content: "\f074";}
-.i-arrow-up:before{content: "\f075";}
-.i-arrow-down:before{content: "\f076";}
-.i-course-record-border:before{content: "\f07c";}
-.i-list:before{content: "\f07d";}
-.i-download:before{content: "\f080";}
-.i-class:before{content: "\f081";}
-.i-management:before{content: "\f082";}
-.i-comment:before{content: "\f083";}
-.i-cut:before{content: "\f084";}
-.i-flower:before{content: "\f085";}
-.i-image:before{content: "\f086";}
-.i-msg-filter:before{content: "\f087";}
-.i-no-flower:before{content: "\f088";}
-.i-no-image:before{content: "\f089";}
-.i-course-test:before{content: "\f08b";}
-.i-clone:before{content: "\f096";}
-.i-remind:before{content: "\f098";}
-.i-c-remind:before{content: "\f099";}
-.i-c-cancel-remind:before{content: "\f09a";}
-.i-emoji:before{content: "\f09b";}
-.i-no-msg:before{content: "\f09c";}
-.i-user-edit:before{content: "\f09f";}
-.i-map:before{content: "\f0a0";}
-.i-upload:before{content: "\f0a1";}
-.i-pay-kedian:before{content: "\f0a2";}
-.i-cap:before{content: "\f0a3";}
-.i-career2:before{content: "\f0a4";}
-.i-computor2:before{content: "\f0a5";}
-.i-pen2:before{content: "\f0a6";}
-.i-tea:before{content: "\f0a7";}
-.i-tupu:before{content: "\f0a8";}
-.i-profe-cert:before{content: "\f0a9";}
-.i-teacher-cert:before{content: "\f0aa";}
-.i-auth-cert:before{content: "\f0ab";}
-.i-edu-cert:before{content: "\f0ac";}
-.i-qq-border2:before{content: "\f0ad";}
-.i-edit2:before{content: "\f0ae";}
-.i-boxiaole:before{content: "\f0b0";}
-.i-liepinwang:before{content: "\f0b1";}
-.i-switch-class:before{content: "\f0b3";}
-.i-emoticon:before{content: "\f0b4";}
-.i-keyboard:before{content: "\f0b5";}
-.i-picture:before{content: "\f0b6";}
-.i-view:before{content: "\f0b9";}
-.i-praise:before{content: "\f0ba";}
-.i-forum:before{content: "\f0bb";}
-.i-news:before{content: "\f0bc";}
-.i-interest:before{content: "\f0bd";}
-.i-consultation:before{content: "\f0be";}
-.i-home2:before{content: "\f0bf";}
-.i-plan:before{content: "\f0c0";}
-.i-coupon:before{content: "\f0c1";}
-.i-comment-star:before{content: "\f0c2";}
-.i-flower-bad:before{content: "\f0c3";}
-.i-flower-good:before{content: "\f0c4";}
-.i-flower-medium:before{content: "\f0c5";}
-.i-picture2:before{content: "\f0c6";}
-.i-feedback:before{content: "\f0c7";}
-.i-vip-v:before{content: "\f0c9";}
-.i-image-pc:before{content: "\f0ca";}
-.i-right:before{content: "\f0d1";}
-.i-add:before{content: "\f0d2";}
-.i-arrow-top:before{content: "\f0d3";}
-.i-arrow-bottom:before{content: "\f0d4";}
-.i-qr-code:before{content: "\f0d5";}
-.i-camera:before{content: "\f0d6";}
-.i-insert:before{content: "\f0d7";}
-.i-progress-now:before{content: "\f0d8";}
-.i-ke-comment:before{content: "\f0d9";}
\ No newline at end of file
+.i-course-q-a:before{content: "\f125";}
+.i-course-record:before{content: "\f126";}
+.i-course-record-border:before{content: "\f127";}
+.i-course-test:before{content: "\f128";}
+.i-c-remind:before{content: "\f129";}
+.i-class:before{content: "\f12a";}
+.i-computor:before{content: "\f12b";}
+.i-computor2:before{content: "\f12d";}
+.i-coupon:before{content: "\f12f";}
\ No newline at end of file
diff --git a/public/css/index.css b/public/css/index.css
index 29f445d..e9bf057 100644
--- a/public/css/index.css
+++ b/public/css/index.css
@@ -21,28 +21,44 @@
.relative{
position: relative;
}
-.rightBtn{
- position: absolute;
- display: block;
- right: 0;
- top: 20px;
- height: 40px;
- line-height: 40px;
- font-size: 16px;
- width: 120px;
+.selectAllBtn{
+ display: inline-block !important;
+ margin-left: 30px;
+ height: 35px;
+ line-height: 35px;
+ font-size: 14px;
+ width: 100px;
border-radius: 4px;
text-align: center;
background-color: #38b7ea;
color: #fff;
- display: none;
}
-
+.disabled{
+ background-color: #d2d3d4;
+}
+.downloadBtn{
+ margin-top: 29px;
+ float: right;
+ height: 35px;
+ line-height: 35px;
+ font-size: 14px;
+ width: 100px;
+ border-radius: 4px;
+ text-align: center;
+ /*background-color: #38b7ea;*/
+ background-color: #d2d3d4;
+ color: #fff;
+ /*display: none;*/
+}
+.disabled{
+ background-color: #38b7ea;
+}
.icon{
- margin: 10px 0;
+ padding: 20px 0 0 0;
color:#333;
- width: 100px;
+ width: 110px;
text-align: center;
- height: 100px;
+ height: 110px;
float: left;
}
@@ -63,11 +79,12 @@
}
li.i-right:before{
+ /*content: "hehe";*/
position: absolute;
color: #ff4400;
top: 0;
right: 0;
- background: rgb(245, 245, 245);
+ /*background: rgb(245, 245, 245);*/
}
.icon .icon-content{
@@ -85,7 +102,7 @@ li.i-right:before{
.icon:hover{
- background: rgb(245, 245, 245);
+ background: #efefef;
}
.back2top{
@@ -103,4 +120,15 @@ li.i-right:before{
color: #9c9c9c;
background: rgb(245, 245, 245);
margin-top: 10px;
-}
\ No newline at end of file
+}
+
+#selectAll{
+ width: 15px;
+ height: 15px;
+ vertical-align: middle;
+ margin-left: 20px;
+}
+#allSelect{
+ vertical-align: middle;
+}
+
diff --git a/public/css/login.css b/public/css/login.css
new file mode 100644
index 0000000..c40b05f
--- /dev/null
+++ b/public/css/login.css
@@ -0,0 +1,52 @@
+.loginReg{
+ width: 240px;
+ height: 140px;
+ background: #38b7ea;
+ display: none;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ margin-left: -120px;
+ margin-top: -70px;
+ z-index: 10;
+}
+.loginReg h1{
+ color: #fff;
+ font-size: 20px;
+ font-weight: normal;
+ margin: 10px 0 0 20px;
+}
+
+.wayLogin{
+ margin-top: 20px;
+}
+.wayLogin a{
+ color: #fff;
+}
+.wayLogin a:hover{
+ color: #12536d;
+}
+.wayLogin div{
+ color: #fff;
+ width: 115px;
+ display: inline-block;
+ text-align: center;
+}
+.wayLogin .icon-font{
+ font-size: 48px;
+}
+
+.wayLogin span{
+ font-size: 12px;
+ display: block;
+ /*text-align: center;*/
+}
+
+.otherLogin a,.otherLogin span{
+ color: #81d9fd;
+}
+.otherLogin a:hover{
+ color: #81d9fd;
+}
+
+
diff --git a/public/css/management.css b/public/css/management.css
new file mode 100644
index 0000000..4a5e8b0
--- /dev/null
+++ b/public/css/management.css
@@ -0,0 +1,18 @@
+.wrap{
+ width: 960px;
+ margin: 0 auto;
+}
+a{
+ color: #000;
+}
+.wrap table{
+ margin-top: 20px;
+ width: 100%;
+}
+table tr td{
+ text-align: center;
+ vertical-align: middle;
+}
+table #userAuth{
+
+}
\ No newline at end of file
diff --git a/public/css/tag.css b/public/css/tag.css
new file mode 100644
index 0000000..8b3bf57
--- /dev/null
+++ b/public/css/tag.css
@@ -0,0 +1,88 @@
+ .container {
+ width: 960px;
+ margin: 50px auto 0;
+ height: 500px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ }
+ .s-left {
+ float: left;
+ width: 300px;
+ text-align: center;
+ }
+ .s-right {
+ float: left;
+ margin: 50px 0;
+ height: 400px;
+ border-left: 1px dotted #ccc;
+ padding-left: 50px;
+ max-width: 600px
+ }
+ .tag-list li {
+ display: inline-block;
+ width: 120px;
+ height: 40px;
+ line-height: 40px;
+ text-align: center;
+ color: #fff;
+ background: #38b7ea;
+ margin-top: 20px;
+ margin-right: 20px;
+ border-radius: 5px;
+ position: relative;
+ }
+ .tag-list li:hover .del-btn{
+ display: inline-block;
+ }
+ .sr-add {
+ margin-top: 20px;
+/* padding: 30px;
+border: 1px dotted #ccc;
+border-radius: 5px; */
+ }
+ .sr-add input {
+ height: 40px;
+ line-height: 40px;
+ outline: none;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ font-size: 16px;
+ padding: 0 10px;
+ }
+ .btn {
+ display: inline-block;
+ height: 40px;
+ line-height: 40px;
+ width: 80px;
+ text-align: center;
+ background: #38b7ea;
+ color: #fff;
+ border-radius: 5px;
+ }
+ .sl-name {
+ margin-top: 50px;
+ display: block;
+ font-size: 20px;
+ margin-bottom: 20px;
+ }
+ .icon-font {
+ display: block;
+ font-size: 200px;
+ }
+ .del-btn {
+ display: none;
+ height: 14px;
+ width: 14px;
+ position: absolute;
+ right: 0;
+ top: 13px;
+ }
+ .del-btn i{
+ font-size: 14px;
+ color: #fff;
+ display: inline;
+ margin: 0;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
\ No newline at end of file
diff --git a/public/css/updateIcon.css b/public/css/updateIcon.css
new file mode 100644
index 0000000..a8570cd
--- /dev/null
+++ b/public/css/updateIcon.css
@@ -0,0 +1,66 @@
+.container {
+ width: 960px;
+ margin: 50px auto 0;
+ height: 500px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+}
+
+.side-left {
+ width: 340px;
+ float: left;
+ padding: 30px;
+ height: 100%;
+}
+
+.s-name {
+ margin-top: 50px;
+ display: block;
+ font-size: 20px;
+ margin-bottom: 20px;
+}
+
+.icon-font {
+ display: block;
+ font-size: 200px;
+}
+.side-right {
+ float: left;
+ padding: 30px;
+ width: 500px;
+}
+
+.add-form input {
+ margin-top: 20px;
+ height: 40px;
+ line-height: 40px;
+ outline: none;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ font-size: 16px;
+ padding: 0 10px;
+}
+.btn {
+ display: block;
+ height: 40px;
+ line-height: 40px;
+ width: 140px;
+ text-align: center;
+ background: #38b7ea;
+ color: #fff;
+ border-radius: 5px;
+ margin-top: 20px;
+}
+.add-form select{
+ width: 208px;
+ display: block;
+ margin-top: 20px;
+ height: 42px;
+ padding: 6px 12px;
+ font-size: 16px;
+ line-height: 20px;
+ color: #555;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+}
\ No newline at end of file
diff --git a/public/css/upload.css b/public/css/upload.css
new file mode 100644
index 0000000..6bee7af
--- /dev/null
+++ b/public/css/upload.css
@@ -0,0 +1,158 @@
+.upload-block{
+ width: 960px;
+ margin: 20px auto 50px;
+ height: 350px;
+ padding-top: 200px;
+ border: 1px solid #ddd;
+ position: relative;
+}
+.upload-block p{
+ color: #666;
+ font-size: 14px;
+ line-height: 30px;
+ text-align: center;
+
+}
+.upload-block .highlight{
+ color: red;
+}
+.u-info {
+ width: 960px;
+ margin: 20px auto;
+ display: none;
+ min-height: 500px;
+}
+.u-title {
+ height: 50px;
+ line-height: 50px;
+ font-size: 20px;
+}
+.info li {
+ height: 30px;
+ line-height: 30px;
+}
+.info .error {
+ color: red;
+}
+.mask {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: #999;
+ z-index: 10;
+ display: none;
+}
+
+.mask p {
+ display: block;
+ height: 32px;
+ line-height: 32px;
+ font-size: 20px;
+ position: absolute;
+ width: 100%;
+ top: 50%;
+ text-align: center;
+ margin-top: -16px;
+ color: #fff;
+}
+.option{
+ text-align: center;
+ width: 1000px;
+ margin: 0 auto;
+}
+.option a{
+ display: inline-block;
+ width: 80px;
+ height: 35px;
+ margin-left: 20px;
+ /*float: right;*/
+ background-color: #38b7ea;
+ vertical-align: middle;
+ color: #fff;
+ line-height: 35px;
+ border-radius: 3px;
+ font-size: 14px;
+ cursor: pointer;
+}
+.form-control{
+ width: 850px;
+ display: inline-block;
+ margin: 50px auto 0;
+ height: 34px;
+ padding: 6px 12px;
+ font-size: 14px;
+ line-height: 20px;
+ color: #555;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+}
+.bg{
+ width: 100%;
+ height: 100%;
+ background: rgba(0, 0, 0, 0.8);
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 100;
+ display: none;
+}
+.addProject{
+ display: none;
+ position: absolute;
+ top: 40%;
+ /*margin-top: -60px;*/
+ z-index: 110;
+ left: 40%;
+ border-radius: 5px;
+
+ /*width: 350px;*/
+ /*height: 120px;*/
+
+ color: #000;
+ /*text-align: center;*/
+ font-size: 16px;
+}
+
+.addProject span{
+ margin-left: 10px;
+ font-size: 14px;
+}
+.addProject #project{
+ /*margin-top: 32px;*/
+ /*margin-left: 60px;*/
+ width: 130px;
+ color: #000;
+ outline:none;
+ text-align: left;
+ font-size: 14px;
+ border: 0;
+ padding: 0 149px 0 19px;
+ background-color: #fff;
+ height: 46px;
+ color: #999;
+ border-radius: 4px 0 0 4px;
+ line-height: 46px;
+ float: left;
+
+}
+.addProject .submit{
+ outline:none;
+ cursor: pointer;
+ /*margin-top: 15px;*/
+ /*margin-left: 120px;*/
+ width: 120px;
+ height: 46px;
+ border-radius: 0 4px 4px 0;
+ line-height: 30px;
+ background-color: #38b7ea;
+ color: #fff;
+ border: 1px solid #96d2f6;
+ font-size: 14px;
+
+}
+.addProject .submit:hover{
+ background-color: #40a8d2;
+}
\ No newline at end of file
diff --git a/public/css/user.css b/public/css/user.css
new file mode 100644
index 0000000..2f4b27a
--- /dev/null
+++ b/public/css/user.css
@@ -0,0 +1,33 @@
+.empty {
+ width: 960px;
+ margin: 20px auto;
+ line-height: 300px;
+ text-align: center;
+ font-size: 50px;
+}
+.icon {
+ /*height: 120px;*/
+}
+.icon:hover {
+ background: none;
+}
+.icon:hover .add {
+ display: block;
+ line-height: 20px;
+}
+.icon:hover .add:hover{
+ color: #000;
+
+}
+.icon .add {
+ display: none;
+ color: #c7254e;
+ font-size: 12px;
+}
+.icon-name {
+ height: 20px;
+}
+.del {
+ color: #c7254e;
+ margin-left: 20px;
+}
\ No newline at end of file
diff --git a/public/images/Connect_logo_1.png b/public/images/Connect_logo_1.png
new file mode 100644
index 0000000..6c4e3e2
Binary files /dev/null and b/public/images/Connect_logo_1.png differ
diff --git a/public/images/Connect_logo_4.png b/public/images/Connect_logo_4.png
new file mode 100644
index 0000000..ebca592
Binary files /dev/null and b/public/images/Connect_logo_4.png differ
diff --git a/public/images/Connect_logo_5.png b/public/images/Connect_logo_5.png
new file mode 100644
index 0000000..4bcd0b5
Binary files /dev/null and b/public/images/Connect_logo_5.png differ
diff --git a/public/images/Connect_logo_7.png b/public/images/Connect_logo_7.png
new file mode 100644
index 0000000..75204e2
Binary files /dev/null and b/public/images/Connect_logo_7.png differ
diff --git a/public/js/deletebusiness.js b/public/js/deletebusiness.js
new file mode 100644
index 0000000..f04b81f
--- /dev/null
+++ b/public/js/deletebusiness.js
@@ -0,0 +1,25 @@
+$(function(){
+ $('.del').on('click',function(){
+ var a = confirm("确定删除吗?")
+ if (a) {
+ deletebusiness(this)
+ }
+
+ function deletebusiness(target){
+ var params = {
+ name: $(target).data('name')
+ }
+ $.ajax({
+ type: 'Post',
+ url: '/user/delete',
+ data: params,
+ success: function(data){
+ if (data.retcode == 0) {
+ alert("删除成功");
+ window.location.reload()
+ }
+ }
+ })
+ }
+ })
+})
\ No newline at end of file
diff --git a/public/js/index.js b/public/js/index.js
index 1e2564d..6b57176 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1,28 +1,77 @@
-(function(root){
- function bindEvents(){
- $('#js-back2top').on('click', function(){
+(function(root) {
+ function bindEvents() {
+ $('#js-back2top').on('click', function() {
$(window).scrollTop(0);
});
- $('body').on('click', '.js-pcList li', function(){
- var $this = $(this);
+ $('body').on('click', '.js-pcList li', function() {
+ var $this = $(this),
+ $downloadBtn = $this.parents(".icon-list").siblings('h1').children('#js-download-btn');
+
$this.toggleClass('i-right');
- $('#js-download-btn')[$('.i-right').length > 0 ? 'show' : 'hide']();
+ var $li = $this.parents('.icon-list').children('.i-right');
+ $downloadBtn[$li.length > 0 ? 'addClass' : 'removeClass']('disabled');
});
- $('#js-download-btn').on('click', function(){
+
+ $('.selectAllBtn').on('click', function() {
+ var $list = $(this).parents("h1").siblings('.icon-list').children();
+ var value = $(this).data("value");
+ if (value == 0) {
+ $list.each(function() {
+ $(this).addClass('i-right');
+ })
+ $(this).text("取消全选");
+ $(this).siblings('.downloadBtn').addClass('disabled');
+ $(this).data("value","1");
+ } else {
+ $list.each(function() {
+ $(this).removeClass('i-right');
+ })
+ $(this).text("全选");
+ $(this).siblings('.downloadBtn').removeClass('disabled');
+ $(this).data("value", "0");
+ // value = 0
+ }
+
+ })
+
+ $('.downloadBtn').on('click', function() {
+ var $iconLi = $(this).parents("h1").siblings('.icon-list').children('li.i-right')
+ if ($iconLi.length == 0) {
+ alert("还未选择icon");
+ return false
+ }
+ // console.log($iconLi.length);
var ids = [];
- $('.js-pcList li.i-right').each(function(index, item){
+ $iconLi.each(function(index, item) {
ids.push($(item).data('id'));
});
location.href = '/download/' + ids.join('-');
});
+
+ // $(document).on('click', function() {
+ // $('#personOption,#loginReg,.arrow').hide();
+ // });
+
+ // $('#logIn').on('click', function(e){
+ // e.stopPropagation();
+ // $('#loginReg').toggle();
+ // });
+
+ // $('#person,#personImg').on('click', function(e){
+ // e.stopPropagation();
+ // $('.arrow').toggle();
+ // });
+
+
+
}
- function init(){
+ function init() {
bindEvents();
}
root.init = init;
})(this);
-this.init();
+this.init();
\ No newline at end of file
diff --git a/public/js/management.js b/public/js/management.js
new file mode 100644
index 0000000..9c6f1ac
--- /dev/null
+++ b/public/js/management.js
@@ -0,0 +1,34 @@
+$(function(){
+ $('.userAuth').on('click', function(){
+ var value = parseInt($(this).data("value"));
+ if (value) {
+ $(this).data("value","0");
+ $(this).text("设置权限");
+ // console.log($(this).data("value"))
+ }else{
+ $(this).data("value","1");
+ $(this).text("取消权限");
+ // console.log($(this).data("value"))
+ }
+ var value = parseInt($(this).data("value"));
+ var userID = $(this).parent().prev().data("id")
+ // console.log(userID);
+ var params = {
+ 'value': value,
+ 'userID': userID
+ }
+ sendValue();
+ function sendValue(value){
+ $.ajax({
+ type: 'Post',
+ url: '/management/value',
+ data: params,
+ success: function(data){
+ if (data.retcode == 0) {
+ alert("操作成功");
+ }
+ }
+ })
+ }
+ })
+})
\ No newline at end of file
diff --git a/public/js/search.js b/public/js/search.js
new file mode 100644
index 0000000..2c0eeb5
--- /dev/null
+++ b/public/js/search.js
@@ -0,0 +1,7 @@
+var $searchForm = $('#search_form');
+var ENTER_KEY = 13;
+function searchHandler (event) {
+ if (event.charCode === ENTER_KEY)
+ $searchForm.submit();
+}
+$searchForm.keypress(searchHandler);
\ No newline at end of file
diff --git a/public/js/updateIcon.js b/public/js/updateIcon.js
new file mode 100644
index 0000000..28c769a
--- /dev/null
+++ b/public/js/updateIcon.js
@@ -0,0 +1,61 @@
+(function(exports){
+ var query = function (n) {
+ var m = window.location.search.match(new RegExp("(\\?|&)" + n + "=([^&]*)(&|$)"));
+ return !m ? "" : decodeURIComponent(m[2]);
+ };
+
+
+ var id = query('id'),
+ $updateBtn = $('#js-update'),
+ $form = $('#js-form'),
+ $input = $form.find('input[name="newname"]'),
+ $delBtn = $('#js-del');
+
+ exports.bindEvents = function() {
+ $updateBtn.on('click', function() {
+ var val = $input.val();
+ $.ajax({
+ url: '/update',
+ type: 'post',
+ dataType: 'json',
+ data: {
+ id: id,
+ name: val,
+ business: $('#js-business').val()
+ },
+ success: function(data) {
+ console.log(data);
+ if(data.retcode === 0) {
+ alert('更新成功');
+ }
+ },
+ error: function(data) {
+ console.log(data.retcode);
+ }
+ });
+ });
+
+ $delBtn.on('click', function() {
+ $.ajax({
+ url: '/update/del',
+ type: 'post',
+ dataType: 'json',
+ data: {
+ id: id,
+ },
+ success: function(data) {
+ if(data.retcode === 0) {
+ alert('删除成功');
+ window.location.href="http://iconfont.imweb.io/user";
+ }
+ },
+ error: function(data) {
+ }
+ });
+ });
+ };
+
+
+})(this)
+
+this.bindEvents();
\ No newline at end of file
diff --git a/public/js/upload.js b/public/js/upload.js
new file mode 100644
index 0000000..e7c2995
--- /dev/null
+++ b/public/js/upload.js
@@ -0,0 +1,102 @@
+var obj = $("#upload"),
+ $mask = $('.js-mask'),
+ $select = $('#js-business'),
+ select = $select[0];
+
+$select.on('change', function() {
+ if(select.value == -1) {
+ $mask.find('p').text('请选择项目!');
+ $mask.show();
+ } else {
+ $mask.hide();
+ }
+});
+obj.on('dragenter', function (e){
+ e.stopPropagation();
+ e.preventDefault();
+ $(this).css('border', '2px solid #0B85A1');
+});
+obj.on('dragover', function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+});
+obj.on('drop', function (e) {
+
+ $(this).css('border', '2px dotted #0B85A1');
+ e.preventDefault();
+ var files = e.originalEvent.dataTransfer.files;
+
+ //We need to send dropped files to Server
+ //console.log(files)
+ //
+ if(select.value == -1) {
+ $mask.find('p').text('请选择项目!');
+ $mask.show();
+ } else {
+ $mask.find('p').text('上传中...');
+ $mask.show();
+ handleFileUpload(files,obj);
+ }
+
+});
+
+function handleFileUpload(files,obj){
+ for (var i = 0; i < files.length; i++){
+ var fd = new FormData();
+ fd.append('file', files[i]);
+ fd.append('business', select.value);
+ sendFileToServer(fd,status);
+ }
+}
+
+function sendFileToServer(formData,status){
+
+ var uploadURL ="/upload"; //Upload URL
+ var extraData ={}; //Extra Data.
+ var jqXHR = $.ajax({
+ xhr: function() {
+ var xhrobj = $.ajaxSettings.xhr();
+ if (xhrobj.upload) {
+ xhrobj.upload.addEventListener('progress', function(event) {
+ var percent = 0;
+ var position = event.loaded || event.position;
+ var total = event.total;
+ if (event.lengthComputable) {
+ percent = Math.ceil(position / total * 100);
+ }
+ //Set progress
+ //status.setProgress(percent);
+ }, false);
+ }
+ return xhrobj;
+ },
+ url: uploadURL,
+ type: "POST",
+ contentType:false,
+ processData: false,
+ cache: false,
+ data: formData,
+ success: function(data){
+ if(data.retcode == 0) {
+ data = data.result;
+ $('#upload').hide();
+ var succInfo = [],
+ errInfo = []
+ for(var i in data) {
+ if(data[i]) {
+ errInfo.push('
' + i + ' : ' + data[i] + '')
+ } else {
+ succInfo.push('' + i + ' : ' + '添加成功 ');
+ }
+
+ }
+ $('#js-info').append(errInfo.concat(succInfo).join(''));
+ $('#js-upInfo').show();
+ }
+ },
+ error: function(){
+ $('#js-info').append('服务错误!请联系管理员!');
+ $('#js-upInfo').show();
+ }
+ });
+}
\ No newline at end of file
diff --git a/public/js/uploadAjax.js b/public/js/uploadAjax.js
new file mode 100644
index 0000000..a40e755
--- /dev/null
+++ b/public/js/uploadAjax.js
@@ -0,0 +1,42 @@
+$(function(){
+
+ $('.submit').click(function(){
+ if ($('.addProject #project').val()) {
+ sendProjectName();
+ $('.addProject,.bg').hide();
+ $('#project').val("");
+
+ }else{
+ $('#project').attr('placeholder','项目不能为空')
+ // console.log($('.addProject span').text(""));
+ }
+
+ })
+
+ $('.add').on('click', function() {
+ $('.addProject,.bg').toggle();
+ $('#project').focus().attr('placeholder','项目名称');
+ $('.addProject span').text("")
+ })
+ $('.bg').on('click', function(){
+ $('.addProject,.bg').hide();
+ })
+ // $("#js-business").find("option[value='47']").attr("selected",true);
+ function sendProjectName(){
+ var data = $('#project').val();
+ var params = {
+ "project": data
+ }
+ $.ajax({
+ type: 'Post',
+ url: '/upload/addproject',
+ data: params,
+ success: function(data){
+
+ $('#js-business').append("");
+ $("#js-business").find("option[value="+data[data.length-1].bid+"]").attr("selected",true);
+
+ }
+ })
+ }
+})
\ No newline at end of file
diff --git a/routes/business.js b/route/business.js
similarity index 63%
rename from routes/business.js
rename to route/business.js
index 7872886..0e2872b 100644
--- a/routes/business.js
+++ b/route/business.js
@@ -13,35 +13,26 @@ var bodyParser = require('body-parser'),
conf = require('../conf.js'),
auth = require('../midware/auth.js'),
jsonParser = bodyParser.json();
-
+var addUserToMongo = require('../midware/addUserToMongo.js');
// get all business
-router.get('/', auth, function(req, res, next) {
+router.get('/', addUserToMongo, function(req, res, next) {
// check auth
- var user = req.cookies.user;
- userAuthCheck(user, conf.auth.business, function(hasAuth) {
- if(hasAuth) {
- Business.find()
- .exec(function(err, business) {
- if(err) {
- next(err);
- return;
- }
- res.render('business', {
- user: user,
- business: business
- });
+ var user = req.user;
+ Business.find()
+ .exec(function(err, business) {
+ if(err) {
+ next(err);
+ return;
+ }
+ res.render('business', {
+ user: user,
+ business: business
});
- } else {
- res.render('404', {
- info: '您没有权限查看次页面,请联系管理员!'
- })
- }
-
- });
+ });
});
// add business
-router.post('/add', auth, function(req, res, next) {
+router.post('/add', addUserToMongo, function(req, res, next) {
var params = req.body;
userAuthCheck(req.cookies.user, conf.auth.business, function(hasAuth) {
if(hasAuth) {
@@ -71,4 +62,4 @@ router.post('/add', auth, function(req, res, next) {
});
});
-module.exports = router;
+module.exports = router;
\ No newline at end of file
diff --git a/routes/download.js b/route/download.js
similarity index 96%
rename from routes/download.js
rename to route/download.js
index 8f46568..cc2cfd1 100644
--- a/routes/download.js
+++ b/route/download.js
@@ -1,7 +1,7 @@
var express = require('express'),
router = express.Router();
-var Icon = require('../models/icon.js'),
+var Icon = require('../model/icon.js'),
conf = require('../conf.js'),
svgParser = require('../utils/svg_parser.js'),
download = require('../utils/download.js');
diff --git a/route/index.js b/route/index.js
new file mode 100644
index 0000000..99c85da
--- /dev/null
+++ b/route/index.js
@@ -0,0 +1,156 @@
+var express = require('express'),
+ router = express.Router();
+var User = require('../model/user.js'),
+ Business = require('../model/business.js'),
+ Icon = require('../model/icon.js');
+// var main = require('../routes/main.js'),
+// upload = require('./upload'),
+// download = require('./download'),
+// search = require('./search'),
+// user = require('./user'),
+// tag = require('./tag');
+
+
+var myupload = require('../route/upload'),
+ // mybusiness = require('../route/business'),
+ mymain = require('../route/main'),
+ myuser = require('../route/user'),
+ mytag = require('../route/tag'),
+ myupdate = require('../route/updateIcon'),
+ mydownload = require('../route/download'),
+ mysearch = require('../route/search'),
+ management = require('../route/management');
+
+var addUserToMongo = require('../midware/addUserToMongo.js');
+
+var conf = require('../conf.js');
+// var User = require('../models/user.js');
+
+router.use('/', mymain);
+router.use('/upload', myupload);
+router.use('/download', mydownload);
+router.use('/search', mysearch);
+router.use('/management', management);
+router.use('/checkin', function(req, res){
+ res.render('checkin', {
+ user: req.user
+ });
+ });
+
+// QQ接口登录设置
+passport.use(new StrategyQQ({
+ clientID: conf.appId,
+ clientSecret: conf.appKey,
+ callbackURL: conf.origin + '/user/auth/qq/callback',
+ state: 1
+},function(accessToken, refreshToken, profile, done){
+ // json格式详情见 http://wiki.connect.qq.com/get_user_info
+ // profile = {
+ // id: openid,
+ // nickname: nickname,
+ // _json: json
+ // }
+
+ var newuser = {
+ user: profile.nickname,
+ id: profile.id,
+ img: profile._json.figureurl_qq_1
+ };
+ User.find({
+ id: newuser.id
+ }).exec(function(err, user){
+ if (user.length !== 0) {
+ // Business.update({
+ // pm: user[0].user
+ // },{
+ // "$set":{"id" :user[0].id}
+ // },{multi: 1}).exec(function(err){
+ // if (err) {
+ // console.log(err)
+ // }
+ // console.log("更新成功");
+ // })
+
+
+ // Icon.update({
+ // author: user[0].user
+ // },{
+ // "$set":{"id" :user[0].id}
+ // },{multi: true}).exec(function(err){
+ // if (err) {
+ // console.log(err)
+ // }
+ // console.log("更新成功");
+ // })
+
+ return done(err, profile);
+ }
+ User.create(newuser, function(err){
+ if (err) return console.log(err);
+ return done(err, profile);
+ });
+
+ })
+
+}));
+
+
+router.use('/tag', mytag);
+
+router.use('/user', myuser);
+
+router.get('/rule', function(req, res){
+ res.render('rule',{
+ user: req.user
+ });
+});
+
+router.use('/intro', function(req, res){
+ res.render('intro', {
+ user: req.user
+ });
+ });
+router.use('/myindex', mymain);
+// router.get('/myindex', function(req, res){
+// res.send("ok");
+// });
+router.use('/update', myupdate);
+router.get('/business',function(req, res) {
+ res.render('404', {
+ user: req.user
+ });
+});
+
+router.get('/404', function(req, res) {
+ res.render('404', {
+ user: req.user
+ });
+});
+
+
+router.get('/user/auth/qq',
+ passport.authenticate('qq'),
+ function(req, res){
+// The request will be redirected to qq for authentication, so this
+// function will not be called.
+});
+
+// GET /auth/qq/callback
+// Use passport.authenticate() as route middleware to authenticate the
+// request. If authentication fails, the user will be redirected back to the
+// login page. Otherwise, the primary route function function will be called,
+// which, in this example, will redirect the user to the home page.
+router.get('/user/auth/qq/callback',
+ passport.authenticate('qq', { failureRedirect: '/login' }),
+ function(req, res) {
+ res.redirect('/');
+ });
+
+router.get('/logout', function(req, res){
+ req.logout();
+ res.redirect('/');
+});
+
+
+
+module.exports = router;
diff --git a/route/main.js b/route/main.js
new file mode 100644
index 0000000..09dc164
--- /dev/null
+++ b/route/main.js
@@ -0,0 +1,101 @@
+var express = require('express'),
+ router = express.Router(),
+ Icon = require('../model/icon.js'),
+ Business = require('../model/business.js'),
+ conf = require('../conf.js'),
+ clean = require('../utils/file.js'),
+ svgParser = require('../utils/svg_parser.js'),
+ User = require('../model/user.js');
+
+var author = ['imweb'];
+router.get(['/', '/index'], function(req, res, next) {
+
+ function getAllIcons(cb) {
+ User.find({
+ auth: 1
+ }).exec(function(err, users){
+ // console.log(users)
+ if (users.length == 0) {
+ // return console.error(err);
+ res.render('index', {
+ user: req.user,
+ bMaps: undefined
+ });
+ }
+
+ var newUsers = [];
+ users.forEach(function(user) {
+ newUsers.push({"id": user.id})
+ })
+ // console.log(newUsers)
+ Icon.find({
+ // author: newUsers
+ $or: newUsers
+ //这里用作设置权限
+ }).sort({
+ iconId: 1
+ }).exec(function(err, icons) {
+ if (err) {
+ console.error(err);
+ return typeof cb === 'function' && cb(err, icons);
+ }
+ // console.log(icons)
+ var rets = {};
+ icons.forEach(function(icon) {
+ icon.content = svgParser.generateHtmlIconContent(icon.iconId + conf.diff);
+ if(!rets[icon.business]) {
+ rets[icon.business] = [];
+ }
+ rets[icon.business].push(icon);
+ });
+ // console.log(rets)
+ typeof cb === 'function' && cb(err, rets, icons, users);
+ });
+ })
+ }
+
+
+ clean.cleanPreviousFiles(path.dirname(conf.allSvgZipPath), 24*3600*1000);
+ getAllIcons(function(err, rets, icons, users){
+ if (err) {
+ return next(err);
+ }
+ // if(icons.length > 0) {
+ // svg 文件不存在情况兼容
+ svgParser.genarateFonts(icons);
+ svgParser.generateCss(icons);
+ // }
+ var newBusiness = [];
+ users.forEach(function(user) {
+ newBusiness.push({"id": user.id})
+ })
+ // console.log('newBusiness',newBusiness)
+ Business.find({
+ $or: newBusiness
+ }).exec(function(err, bids) {
+ var bMaps = {};
+ bids.forEach(function(b) {
+ bMaps[b.bid] = b.name;
+ });
+ var empty = isEmptyObject(bMaps);
+ if (empty) {
+ bMaps.business = "none"
+ }
+ res.render('index', {
+ all: rets,
+ user: req.user,
+ bMaps: bMaps,
+ });
+ });
+
+ });
+});
+
+function isEmptyObject(obj) {
+ for (var key in obj) {
+ return false;
+ }
+ return true;
+}
+
+module.exports = router;
\ No newline at end of file
diff --git a/route/management.js b/route/management.js
new file mode 100644
index 0000000..d92685e
--- /dev/null
+++ b/route/management.js
@@ -0,0 +1,66 @@
+var express = require('express'),
+ router = express.Router(),
+ Icon = require('../model/icon.js'),
+ User = require('../model/user.js');
+ Business = require('../model/business.js'),
+ conf = require('../conf.js');
+
+
+var addUserToMongo = require('../midware/addUserToMongo.js');
+
+router.get('/', function(req, res, next){
+
+ if (!req.user) {
+ return res.redirect('http://iconfont.imweb.io/intro');
+ }
+
+ if (req.user.id === conf.userID) {
+ User.find({
+
+ }).exec(function(err, users){
+ if (err) {
+ return console.log(err)
+ }
+ // console.log(users);
+ res.render('management', {
+ user: req.user,
+ all: users
+ });
+ })
+ }else{
+ res.render('404', {
+ user: req.user
+ });
+ }
+
+
+
+})
+
+router.post('/value', function(req, res, next){
+ var value = req.body.value;
+ var userID = req.body.userID
+ // console.log(value);
+ User.update({
+ id: userID
+ },{
+ $set: {
+ auth: value
+ }
+ }).exec(function(err, users){
+ if (err) {
+ return console.log(err)
+ }
+ res.status(200).send({
+ retcode: 0
+ });
+ })
+
+
+})
+
+
+
+
+
+module.exports = router;
\ No newline at end of file
diff --git a/routes/search.js b/route/search.js
similarity index 92%
rename from routes/search.js
rename to route/search.js
index 0a6ee0d..38cf631 100644
--- a/routes/search.js
+++ b/route/search.js
@@ -1,9 +1,9 @@
var express = require('express'),
router = express.Router();
-var Icon = require('../models/icon.js'),
- Tag = require('../models/tag.js'),
- Business = require('../models/business.js'),
+var Icon = require('../model/icon.js'),
+ Tag = require('../model/tag.js'),
+ Business = require('../model/business.js'),
EventEmitter = require('eventemitter2').EventEmitter2,
emitter = new EventEmitter();
svgParser = require('../utils/svg_parser.js');
@@ -17,9 +17,9 @@ router.get('/', function (req, res, next) {
bids.forEach(function(b) {
bMaps[b.bid] = b.name;
});
- res.render('index', {
+ res.render('search', {
all: arr,
- user: req.cookies.user,
+ user: req.user,
bMaps: bMaps
});
});
diff --git a/routes/tag.js b/route/tag.js
similarity index 92%
rename from routes/tag.js
rename to route/tag.js
index 14f71ae..c624e1e 100644
--- a/routes/tag.js
+++ b/route/tag.js
@@ -6,11 +6,11 @@ var bodyParser = require('body-parser'),
var Tag = require('../utils/tag.js'),
auth = require('../midware/auth.js'),
- Icon = require('../models/icon.js');
+ Icon = require('../model/icon.js');
-router.get('/', auth, function (req, res, next) {
+router.get('/', function (req, res, next) {
var id = req.query.id,
- user = req.cookies.user;
+ user = req.user;
Tag.findAllTagsByIconId(id, function(err, tags) {
if(tags.length > 0){
diff --git a/route/updateIcon.js b/route/updateIcon.js
new file mode 100644
index 0000000..849ed95
--- /dev/null
+++ b/route/updateIcon.js
@@ -0,0 +1,128 @@
+var express = require('express'),
+ fs = require('fs'),
+ router = express.Router();
+
+var bodyParser = require('body-parser'),
+ jsonParser = bodyParser.json();
+var conf = require('../conf.js');
+var Tag = require('../utils/tag.js'),
+ auth = require('../midware/auth.js'),
+ userAuthCheck = require('../utils/checkAuth.js'),
+ Business = require('../model/business.js'),
+ svgParser = require('../utils/svg_parser.js'),
+ Icon = require('../model/icon.js');
+var addUserToMongo = require('../midware/addUserToMongo.js');
+
+var currentPath;
+
+router.get('/', addUserToMongo, function (req, res, next) {
+ var id = req.query.id,
+ user = req.user;
+ // update
+ Icon.find({
+ iconId: id
+ }).exec(function(err, icons) {
+ if(err) {
+ res.render('404', {
+ info: '500 内部错误'
+ });
+ return;
+ }
+ if(icons.length === 0) {
+ res.render('404', {
+ info: '未查找到对应的Icon!'
+ });
+ return;
+ }
+ currentPath = icons[0].path || '';
+ Business.find({
+ pm: req.user.nickname
+ }).exec(function(err, bids) {
+ if(err) {
+ console.error(err);
+ next(err);
+ return;
+ }
+ res.render('updateIcon', {
+ icon: icons[0],
+ bids: bids,
+ user: user
+ });
+ });
+
+
+ });
+
+});
+
+
+router.post('/', function (req, res, next) {
+ var user = req.user,
+ params = req.body;
+ // update
+ // 修改文件名
+ // console.log(params);
+ Icon.update({
+ iconId: params.id
+ }, {
+ $set: {
+ name: params.name,
+ className: 'i-' + params.name,
+ business: params.business,
+ path: '' + path.dirname(currentPath) + '/' + params.name + '.svg'
+ }
+ }, function(err) {
+ // 字体文件重新生成
+ if(err) {
+ res.status(200).send({
+ retcode: 2,
+ result: {
+ msg: 'update error!'
+ }
+ })
+ } else {
+ fs.renameSync(path.join(conf.svgPath, currentPath), path.join(conf.svgPath, path.dirname(currentPath), params.name + '.svg'));
+ svgParser.refreshFonts();
+ res.status(200).send({
+ retcode: 0
+ });
+ }
+ });
+});
+
+
+/*
+* del icon
+* remove record from db
+* not unlink file on disk
+ */
+router.post('/del', function (req, res, next) {
+ var user = req.user,
+ id = req.body.id;
+ if(!id) {
+ // id not exist
+ res.status(200).send({
+ retcode: 10
+ });
+ return;
+ }
+ Icon.remove({
+ iconId: id
+ }).exec(function(err, icons) {
+ if(err) {
+ res.status(200).send({
+ retcode: -1,
+ result: {
+ msg: 'remove error !'
+ }
+ });
+ return ;
+ }
+ res.status(200).send({
+ retcode: 0
+ });
+ })
+});
+
+
+module.exports = router;
diff --git a/route/upload.js b/route/upload.js
new file mode 100644
index 0000000..28cbfad
--- /dev/null
+++ b/route/upload.js
@@ -0,0 +1,191 @@
+'use strict';
+/*
+ * @author helondeng, moxhe,junmo
+ */
+var express = require('express'),
+ path = require('path'),
+ fs = require('fs'),
+ router = express.Router();
+
+var bodyParser = require('body-parser'),
+ jsonParser = bodyParser.json();
+
+var conf = require('../conf.js'),
+ clean = require('../utils/file.js'),
+ Icon = require('../model/icon.js'),
+ auth = require('../midware/auth.js'),
+ logger = require('../utils/logger.js'),
+ checkUserAuth = require('../utils/checkAuth.js'),
+ multer = require('multer'),
+ svgParser = require('../utils/svg_parser.js'),
+ store = require('../utils/store.js');
+
+var allowExts = ['.svg', '.zip'],
+ upMulter = multer({dest: './uploads/'}),
+ maxUploadFileSize = 50*1024;
+
+var Business = require('../model/business.js');
+var addUserToMongo = require('../midware/addUserToMongo.js');
+
+router.get('/', addUserToMongo, function(req, res, next){
+ var user = req.user;
+ Business.find({
+ id: req.user.id
+ }).exec(function(err, bids){
+ // console.log(bids);
+ if (err) {
+ console.error(err);
+ next(err);
+ return;
+ }
+
+
+ // if (bids.length === 0) {
+ // var newBusiness = {
+ // name: "默认icon库",
+ // pm: req.user.nickname
+ // }
+ // Business.create(newBusiness, function(err){
+ // if (err) return console.log("添加数据库失败");
+ // console.log("添加数据库成功");
+ // });
+ // }
+ res.render('upload', {
+ user: req.user,
+ bids: bids
+ });
+ })
+});
+
+router.post('/addproject', function(req, res){
+ // console.log(req.body);
+ if (req.body.project) {
+ var newBusiness = {
+ name: req.body.project,
+ pm: req.user.nickname,
+ id: req.user.id
+ }
+ Business.create(newBusiness, function(err){
+ if (err) return console.log("添加数据库失败");
+ // console.log("添加数据库成功");
+
+ Business.find({}).exec(function(err, bids){
+ // console.log(bids);
+ if (err) {
+ console.error(err);
+ next(err);
+ return;
+ }
+ res.send(bids);
+ })
+ });
+
+
+ }
+
+})
+
+/*
+ * upload 成功后,重新生成字体和css
+ */
+router.post('/', jsonParser, upMulter, function(req, res, next) {
+ var user = req.user.nickname,
+ id = req.user.id;
+
+ var file = req.files.file,
+ extname = path.extname(file.path);
+
+ // console.log(file);
+ logger.logMulty({
+ source: file.originalname,
+ dest: file.name,
+ username: user
+ });
+
+ file.author = user;
+ file.business = req.body.business;
+ file.id = id;
+
+
+ if (allowExts.indexOf(extname) == -1) {
+ fs.unlinkSync(path.join('./uploads', file.name));
+ var errInfo = {};
+ errInfo[file.originalname] = '文件后缀名必须是svg或zip';
+ logger.logMulty({
+ source: file.originalname,
+ dest: file.name,
+ username: user,
+ error: 'illegal file extension'
+ });
+ res.status(200).send({
+ retcode: 0,
+ result: errInfo
+ });
+ return;
+ }
+
+
+ if (file.size > maxUploadFileSize) {
+ var errInfo = {};
+ errInfo[file.originalname] = 'SVG文件太大(' + (file.size / 1024).toFixed(2) + 'kb)!';
+ fs.unlinkSync(path.join('./uploads', file.name));
+ logger.logMulty({
+ source: file.originalname,
+ dest: file.name,
+ username: user,
+ error: 'file size too large'
+ });
+ res.status(200).send({
+ retcode: 0,
+ result: errInfo
+ });
+
+ return;
+ }
+
+ upload(file, function(errMaps) {
+ var zips = fs.readdirSync('download'),
+ zipPath;
+ zips.forEach(function(zip) {
+ zipPath = path.join('download', zip);
+ if (fs.statSync(zipPath).isFile()) {
+ fs.unlinkSync(zipPath);
+ } else {
+ clean.cleanDir(zipPath);
+ }
+ });
+
+ // 重新生成字体
+ Icon.find()
+ .exec(function(err, icons) {
+ icons.forEach(function(icon) {
+ icon.content = svgParser.generateHtmlIconContent(icon.iconId);
+ });
+ svgParser.genarateFonts(icons);
+ svgParser.generateCss(icons);
+
+ });
+ res.status(200).send({
+ retcode: 0,
+ result: errMaps
+ });
+ });
+});
+
+
+function upload(file, cb) {
+ var ext = path.extname(file.path);
+ logger.logMulty({
+ extname: ext
+ });
+
+ if (ext == '.svg') {
+ store.storeSvg(file, cb);
+ } else if (['.zip'].indexOf(ext) > -1) {
+ store.storeZip(file, cb);
+ }
+}
+
+
+module.exports = router;
+
diff --git a/route/user.js b/route/user.js
new file mode 100644
index 0000000..68b6160
--- /dev/null
+++ b/route/user.js
@@ -0,0 +1,92 @@
+var express = require('express'),
+ router = express.Router(),
+ Icon = require('../model/icon.js'),
+ Business = require('../model/business.js'),
+ conf = require('../conf.js'),
+ clean = require('../utils/file.js'),
+ svgParser = require('../utils/svg_parser.js');
+
+var addUserToMongo = require('../midware/addUserToMongo.js');
+
+
+router.post('/delete', function(req, res, next){
+ var name = req.body.name;
+ Business.remove({
+ name: name
+ }).exec(function(err, next){
+ if (err) {
+ return console.log(err)
+ }
+ res.status(200).send({
+ retcode: 0
+ });
+ })
+})
+
+
+router.get('/', addUserToMongo, function(req, res, next) {
+ function getAllIcons(cb) {
+ Icon.find({
+ id: req.user.id
+ }).sort({
+ iconId: 1
+ }).exec(function(err, icons) {
+ if (err) {
+ console.error(err);
+ return typeof cb === 'function' && cb(err, icons);
+ }
+
+ var rets = {};
+ icons.forEach(function(icon) {
+ icon.content = svgParser.generateHtmlIconContent(icon.iconId + conf.diff);
+ if(!rets[icon.business]) {
+ rets[icon.business] = [];
+ }
+ rets[icon.business].push(icon);
+ });
+ typeof cb === 'function' && cb(err, rets, icons);
+ });
+ }
+
+
+ clean.cleanPreviousFiles(path.dirname(conf.allSvgZipPath), 24*3600*1000);
+ getAllIcons(function(err, icons, ret){
+ if (err) {
+ return next(err);
+ }
+ // if(icons.length > 0) {
+ // svg 文件不存在情况兼容
+ svgParser.genarateFonts(ret);
+ svgParser.generateCss(ret);
+ // }
+
+ Business.find({
+ id: req.user.id
+ }).exec(function(err, bids) {
+ var bMaps = {};
+ bids.forEach(function(b) {
+ bMaps[b.bid] = b.name;
+ });
+ var empty = isEmptyObject(bMaps);
+ if (empty) {
+ bMaps.business = "none"
+ }
+ res.render('user', {
+ all: icons,
+ user: req.user,
+ bMaps: bMaps
+ });
+ });
+
+ });
+});
+
+function isEmptyObject(obj) {
+ for (var key in obj) {
+ return false;
+ }
+ return true;
+}
+
+
+module.exports = router;
\ No newline at end of file
diff --git a/routes/download.bak.js b/routes/download.bak.js
deleted file mode 100644
index 1594834..0000000
--- a/routes/download.bak.js
+++ /dev/null
@@ -1,45 +0,0 @@
-var express = require('express'),
- router = express.Router();
-
-var Icon = require('../models/icon.js'),
- svgParser = require('../utils/svg_parser.js'),
- download = require('../utils/download.js');
-
-router.get('/:ids', function (req, res, next) {
- var ids = req.params.ids.split('-');
- var handler = function(err, p){
- if (err) return next(err);
- res.setHeader('Content-Type', 'application/zip');
- var filename = path.basename(p);
- res.setHeader('Content-Disposition', 'attachment; filename=' + filename);
- res.download(p, function(err){
- if(err) console.log(err);
- });
- };
- if (ids[0] === '$svgs') downloadSvgs(handler);
- else downloadIconfonts(req.params.ids.split('-'), handler);
-});
-
-function downloadSvgs (cb) {
- // download by project name in future
- download.packUpSvgs(cb);
-}
-
-function downloadIconfonts(ids, cb) {
- Icon.find({
- iconId : {
- '$in' : ids
- }
- }, function (err, icons) {
- if (err) {
- console.error(err);
- return cb(err, icons);
- }
- icons.forEach(function (icon) {
- icon.content = svgParser.generateHtmlIconContent(icon.iconId);
- });
- download.packUpIconfonts(icons, cb);
- });
-}
-
-module.exports = router;
\ No newline at end of file
diff --git a/routes/index.js b/routes/index.js
deleted file mode 100644
index ee5712b..0000000
--- a/routes/index.js
+++ /dev/null
@@ -1,46 +0,0 @@
-var express = require('express'),
- router = express.Router();
-
-var main = require('./main.js'),
- upload = require('./upload'),
- download = require('./download'),
- search = require('./search'),
- user = require('./user'),
- tag = require('./tag');
-
-
-router.use('/', main);
-router.use('/upload', upload);
-router.use('/download', download);
-router.use('/search', search);
-router.use('/checkin', function(req, res){
- res.render('checkin', {
-user: req.cookies.user
- });
- });
-router.use('/tag', tag);
-
-router.use('/user', user);
-
-router.get('/rule', function(req, res){
- res.render('rule',{
- user: req.cookies.user
- });
-});
-
-router.get('/intro', function(req, res){
- res.render('intro', {
- user: req.cookies.user
- });
-});
-
-router.use('/update', require('./updateIcon'));
-router.use('/business', require('./business'));
-
-router.get('/404', function(req, res) {
- res.render('404', {
- user: req.cookies.user
- });
-});
-
-module.exports = router;
diff --git a/routes/main.js b/routes/main.js
deleted file mode 100644
index 5b17100..0000000
--- a/routes/main.js
+++ /dev/null
@@ -1,60 +0,0 @@
-var express = require('express'),
- router = express.Router(),
- Icon = require('../models/icon.js'),
- Business = require('../models/business.js'),
- conf = require('../conf.js'),
- clean = require('../utils/file.js'),
- svgParser = require('../utils/svg_parser.js');
-
-function getAllIcons(cb) {
- Icon.find()
- .sort({
- iconId: 1
- }).exec(function(err, icons) {
- if (err) {
- console.error(err);
- return typeof cb === 'function' && cb(err, icons);
- }
-
- var rets = {};
- icons.forEach(function(icon) {
- icon.content = svgParser.generateHtmlIconContent(icon.iconId + conf.diff);
- if(!rets[icon.business]) {
- rets[icon.business] = [];
- }
- rets[icon.business].push(icon);
- });
- typeof cb === 'function' && cb(err, rets, icons);
- });
-}
-
-router.get(['/', '/index'], function(req, res, next) {
- clean.cleanPreviousFiles(path.dirname(conf.allSvgZipPath), 24*3600*1000);
- getAllIcons(function(err, icons, ret){
- if (err) {
- return next(err);
- }
- // if(icons.length > 0) {
- // svg 文件不存在情况兼容
- svgParser.genarateFonts(ret);
- svgParser.generateCss(ret);
- // }
-
- Business.find().exec(function(err, bids) {
- var bMaps = {};
- bids.forEach(function(b) {
- bMaps[b.bid] = b.name;
- });
- res.render('index', {
- all: icons,
- user: req.cookies.user,
- bMaps: bMaps
- });
- });
-
- });
-});
-
-
-
-module.exports = router;
diff --git a/routes/updateIcon.js b/routes/updateIcon.js
deleted file mode 100644
index 0518c67..0000000
--- a/routes/updateIcon.js
+++ /dev/null
@@ -1,154 +0,0 @@
-var express = require('express'),
- fs = require('fs'),
- router = express.Router();
-
-var bodyParser = require('body-parser'),
- jsonParser = bodyParser.json();
-
-var Tag = require('../utils/tag.js'),
- auth = require('../midware/auth.js'),
- userAuthCheck = require('../utils/checkAuth.js'),
- Business = require('../models/business.js'),
- svgParser = require('../utils/svg_parser.js'),
- Icon = require('../models/icon.js');
-
-
-var currentPath;
-
-router.get('/', auth, function (req, res, next) {
- var id = req.query.id,
- user = req.cookies.user;
- // update
- userAuthCheck(user, conf.auth.updateIcon, function(hasAuth) {
- if(hasAuth) {
- Icon.find({
- iconId: id
- }).exec(function(err, icons) {
- if(err) {
- res.render('404', {
- info: '500 内部错误'
- });
- return;
- }
- if(icons.length === 0) {
- res.render('404', {
- info: '未查找到对应的Icon!'
- });
- return;
- }
- currentPath = icons[0].path || '';
- Business.find({}).exec(function(err, bids) {
- if(err) {
- console.error(err);
- next(err);
- return;
- }
- res.render('updateIcon', {
- icon: icons[0],
- bids: bids,
- user: user
- });
- });
-
-
- });
- } else {
- res.render('404', {
- info: '暂无权限操作,请联系管理员!'
- });
- }
- });
-
-});
-
-
-router.post('/', auth, function (req, res, next) {
- var user = req.cookies.user,
- params = req.body;
- // update
- userAuthCheck(user, conf.auth.updateIcon, function(hasAuth) {
- if(hasAuth && currentPath) {
- // 修改文件名
- Icon.update({
- iconId: params.id
- }, {
- $set: {
- name: params.name,
- className: 'i-' + params.name,
- business: params.business,
- path: '' + path.dirname(currentPath) + '/' + params.name + '.svg'
- }
- }, function(err) {
- // 字体文件重新生成
- if(err) {
- res.status(200).send({
- retcode: 2,
- result: {
- msg: 'update error!'
- }
- })
- } else {
- fs.renameSync(path.join(conf.svgPath, currentPath), path.join(conf.svgPath, path.dirname(currentPath), params.name + '.svg'));
- svgParser.refreshFonts();
- res.status(200).send({
- retcode: 0
- });
- }
- });
-
- } else {
- res.render('404', {
- info: '暂无权限操作,请联系管理员!'
- });
- }
- });
-});
-
-
-/*
-* del icon
-* remove record from db
-* not unlink file on disk
- */
-router.post('/del', auth, function (req, res, next) {
- var user = req.cookies.user,
- id = req.body.id;
- userAuthCheck(user, conf.auth.updateIcon, function(hasAuth) {
- if(hasAuth) {
- if(!id) {
- // id not exist
- res.status(200).send({
- retcode: 10
- });
- return;
- }
- Icon.remove({
- iconId: id
- }).exec(function(err, icons) {
- if(err) {
- res.status(200).send({
- retcode: -1,
- result: {
- msg: 'remove error !'
- }
- });
- return ;
- }
- res.status(200).send({
- retcode: 0
- });
- })
- } else {
- res.status(200).send({
- retcode: 10000,
- result: {
- msg: 'has no auth!'
- }
- });
- }
-
- });
-});
-
-
-module.exports = router;
diff --git a/routes/upload.js b/routes/upload.js
deleted file mode 100644
index 7b90892..0000000
--- a/routes/upload.js
+++ /dev/null
@@ -1,169 +0,0 @@
-'use strict';
-/*
- * @author helondeng, moxhe
- */
-var express = require('express'),
- path = require('path'),
- fs = require('fs'),
- router = express.Router();
-
-var bodyParser = require('body-parser'),
- jsonParser = bodyParser.json();
-
-var conf = require('../conf.js'),
- clean = require('../utils/file.js'),
- Icon = require('../models/icon.js'),
- auth = require('../midware/auth.js'),
- logger = require('../utils/logger.js'),
- checkUserAuth = require('../utils/checkAuth.js'),
- Business = require('../models/business.js'),
- multer = require('multer'),
- svgParser = require('../utils/svg_parser.js'),
- store = require('../utils/store.js');
-
-var allowExts = ['.svg', '.zip'],
- upMulter = multer({dest: './uploads/'}),
- maxUploadFileSize = 50*1024;
-
-router.get('/', auth, function(req, res, next) {
- checkUserAuth(req.cookies.user, conf.auth.upload, function(hasAuth) {
- if (hasAuth) {
-
- Business.find({}).exec(function(err, bids) {
- if (err) {
- console.error(err);
- next(err);
- return;
- }
- res.render('upload', {
- user: req.cookies.user,
- bids: bids
- });
- });
-
- } else {
- res.render('404', {
- info: '没有上传权限,请联系管理员'
- });
- }
- });
-
-});
-
-
-/*
- * upload 成功后,重新生成字体和css
- */
-router.post('/', auth, jsonParser, upMulter, function(req, res, next) {
- var user = req.cookies.user;
-
- checkUserAuth(user, conf.auth.upload, function(hasAuth) {
- if (!hasAuth) {
- logger.logMulty({
- source: file.originalname,
- dest: file.name,
- username: user,
- error: 'has no auth to upload'
- });
- res.status(200).send({
- retCode: 100000,
- result: {
- info: '没有权限'
- }
- });
- } else {
- var file = req.files.file,
- extname = path.extname(file.path);
-
- logger.logMulty({
- source: file.originalname,
- dest: file.name,
- username: user
- });
-
- file.author = user;
- file.business = req.body.business;
-
-
- if (allowExts.indexOf(extname) == -1) {
- fs.unlinkSync(path.join('./uploads', file.name));
- var errInfo = {};
- errInfo[file.originalname] = '文件后缀名必须是svg或zip';
- logger.logMulty({
- source: file.originalname,
- dest: file.name,
- username: user,
- error: 'illegal file extension'
- });
- res.status(200).send({
- retcode: 0,
- result: errInfo
- });
- return;
- }
-
-
- if (file.size > maxUploadFileSize) {
- var errInfo = {};
- errInfo[file.originalname] = 'SVG文件太大(' + (file.size / 1024).toFixed(2) + 'kb)!';
- fs.unlinkSync(path.join('./uploads', file.name));
- logger.logMulty({
- source: file.originalname,
- dest: file.name,
- username: user,
- error: 'file size too large'
- });
- res.status(200).send({
- retcode: 0,
- result: errInfo
- });
-
- return;
- }
-
- upload(file, function(errMaps) {
- var zips = fs.readdirSync('download'),
- zipPath;
- zips.forEach(function(zip) {
- zipPath = path.join('download', zip);
- if (fs.statSync(zipPath).isFile()) {
- fs.unlinkSync(zipPath);
- } else {
- clean.cleanDir(zipPath);
- }
- });
-
- // 重新生成字体
- Icon.find()
- .exec(function(err, icons) {
- icons.forEach(function(icon) {
- icon.content = svgParser.generateHtmlIconContent(icon.iconId);
- });
- svgParser.genarateFonts(icons);
- svgParser.generateCss(icons);
-
- });
- res.status(200).send({
- retcode: 0,
- result: errMaps
- });
- });
- }
- });
-});
-
-
-function upload(file, cb) {
- var ext = path.extname(file.path);
- logger.logMulty({
- extname: ext
- });
-
- if (ext == '.svg') {
- store.storeSvg(file, cb);
- } else if (['.zip'].indexOf(ext) > -1) {
- store.storeZip(file, cb);
- }
-}
-
-module.exports = router;
diff --git a/routes/user.js b/routes/user.js
deleted file mode 100644
index d5713a5..0000000
--- a/routes/user.js
+++ /dev/null
@@ -1,54 +0,0 @@
-var express = require('express'),
- router = express.Router();
-
-var Icon = require('../models/icon.js'),
- auth = require('../midware/auth.js'),
- User = require('../models/user.js');
-
-router.get('/', auth, function(req, res, next) {
- var cookies = req.cookies,
- user = cookies.user;
-
- Icon.find({
- // author: user
- }).exec(function(err, icons) {
-
- User.find({
- user: user
- }).exec(function(err, users) {
- var params = {
- all: icons,
- user: user
- };
- if(err || users.length == 0) {
- res.render('user', params);
- return;
- }
- // 有更新权限
- if((users[0].auth & conf.auth.updateIcon) != 0) {
- params.update = 1;
- }
-
- if((users[0].auth & conf.auth.business) != 0) {
- params.business = 1;
- }
- res.render('user', params);
- });
-
- });
-
-});
-
-/*
-* 检查用户是否有上传权限
-* upload: 1
- */
-function checkAdmin(user, cb) {
- User.find({
- user: user
- }).exec(function(err, users) {
- typeof cb === 'function' && cb(users.length > 0);
- });
-}
-
-module.exports = router;
diff --git a/store/ke.qq.com-svg/11.svg b/store/ke.qq.com-svg/11.svg
new file mode 100644
index 0000000..0cc0bcf
--- /dev/null
+++ b/store/ke.qq.com-svg/11.svg
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/2.svg b/store/ke.qq.com-svg/2.svg
new file mode 100644
index 0000000..fac0cd2
--- /dev/null
+++ b/store/ke.qq.com-svg/2.svg
@@ -0,0 +1,38 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/3.svg b/store/ke.qq.com-svg/3.svg
new file mode 100644
index 0000000..0cc0bcf
--- /dev/null
+++ b/store/ke.qq.com-svg/3.svg
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/__MACOSX/._computor.svg b/store/ke.qq.com-svg/__MACOSX/._computor.svg
new file mode 100644
index 0000000..58c8d07
Binary files /dev/null and b/store/ke.qq.com-svg/__MACOSX/._computor.svg differ
diff --git a/store/ke.qq.com-svg/__MACOSX/._computor2.svg b/store/ke.qq.com-svg/__MACOSX/._computor2.svg
new file mode 100644
index 0000000..28ae5c2
Binary files /dev/null and b/store/ke.qq.com-svg/__MACOSX/._computor2.svg differ
diff --git a/store/ke.qq.com-svg/behance.svg b/store/ke.qq.com-svg/behance.svg
new file mode 100644
index 0000000..ade4fbe
--- /dev/null
+++ b/store/ke.qq.com-svg/behance.svg
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/c-cancel-remind.svg b/store/ke.qq.com-svg/c-cancel-remind-mmmm.svg
similarity index 99%
rename from store/ke.qq.com-svg/c-cancel-remind.svg
rename to store/ke.qq.com-svg/c-cancel-remind-mmmm.svg
index 80a970c..9c48c82 100644
--- a/store/ke.qq.com-svg/c-cancel-remind.svg
+++ b/store/ke.qq.com-svg/c-cancel-remind-mmmm.svg
@@ -1,20 +1,20 @@
-
-
-
-
+
+
+
+
diff --git a/store/ke.qq.com-svg/cap.svg b/store/ke.qq.com-svg/cap-2.svg
similarity index 98%
rename from store/ke.qq.com-svg/cap.svg
rename to store/ke.qq.com-svg/cap-2.svg
index 3776abd..efa2a57 100644
--- a/store/ke.qq.com-svg/cap.svg
+++ b/store/ke.qq.com-svg/cap-2.svg
@@ -1,11 +1,11 @@
-
-
-
-
+
+
+
+
diff --git a/store/ke.qq.com-svg/dropbox.svg b/store/ke.qq.com-svg/dropbox.svg
new file mode 100644
index 0000000..c03146e
--- /dev/null
+++ b/store/ke.qq.com-svg/dropbox.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/facebook.svg b/store/ke.qq.com-svg/facebook.svg
new file mode 100644
index 0000000..d73c9ac
--- /dev/null
+++ b/store/ke.qq.com-svg/facebook.svg
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/feedly.svg b/store/ke.qq.com-svg/feedly.svg
new file mode 100644
index 0000000..936d472
--- /dev/null
+++ b/store/ke.qq.com-svg/feedly.svg
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/ke-comment.zip b/store/ke.qq.com-svg/ke-comment.zip
new file mode 100644
index 0000000..c5ce526
Binary files /dev/null and b/store/ke.qq.com-svg/ke-comment.zip differ
diff --git a/store/ke.qq.com-svg/ke.qq.com-svg.zip b/store/ke.qq.com-svg/ke.qq.com-svg.zip
new file mode 100644
index 0000000..f29507c
Binary files /dev/null and b/store/ke.qq.com-svg/ke.qq.com-svg.zip differ
diff --git a/store/ke.qq.com-svg/social-11.svg b/store/ke.qq.com-svg/social-11.svg
new file mode 100644
index 0000000..bcb44e5
--- /dev/null
+++ b/store/ke.qq.com-svg/social-11.svg
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-16px_logo-500px.svg b/store/ke.qq.com-svg/social-16px_logo-500px.svg
new file mode 100644
index 0000000..0cc0bcf
--- /dev/null
+++ b/store/ke.qq.com-svg/social-16px_logo-500px.svg
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-16px_logo-angellist.svg b/store/ke.qq.com-svg/social-16px_logo-angellist.svg
new file mode 100644
index 0000000..fac0cd2
--- /dev/null
+++ b/store/ke.qq.com-svg/social-16px_logo-angellist.svg
@@ -0,0 +1,38 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-16px_logo-dribbble.svg b/store/ke.qq.com-svg/social-16px_logo-dribbble.svg
new file mode 100644
index 0000000..2ab4f35
--- /dev/null
+++ b/store/ke.qq.com-svg/social-16px_logo-dribbble.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-16px_logo-github.svg b/store/ke.qq.com-svg/social-16px_logo-github.svg
new file mode 100644
index 0000000..8a96ea5
--- /dev/null
+++ b/store/ke.qq.com-svg/social-16px_logo-github.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-color-.svg b/store/ke.qq.com-svg/social-color-.svg
new file mode 100644
index 0000000..85bf87b
--- /dev/null
+++ b/store/ke.qq.com-svg/social-color-.svg
@@ -0,0 +1,22 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-color-1_logo-linkedin.svg b/store/ke.qq.com-svg/social-color-1_logo-linkedin.svg
new file mode 100644
index 0000000..ea0e633
--- /dev/null
+++ b/store/ke.qq.com-svg/social-color-1_logo-linkedin.svg
@@ -0,0 +1,11 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-qqss.svg b/store/ke.qq.com-svg/social-qqss.svg
new file mode 100644
index 0000000..2a6a145
--- /dev/null
+++ b/store/ke.qq.com-svg/social-qqss.svg
@@ -0,0 +1,24 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social-yingxiang.svg b/store/ke.qq.com-svg/social-yingxiang.svg
new file mode 100644
index 0000000..2a6a145
--- /dev/null
+++ b/store/ke.qq.com-svg/social-yingxiang.svg
@@ -0,0 +1,24 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/social.svg b/store/ke.qq.com-svg/social.svg
new file mode 100644
index 0000000..03850c9
--- /dev/null
+++ b/store/ke.qq.com-svg/social.svg
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/vine-moby.svg b/store/ke.qq.com-svg/vine-moby.svg
new file mode 100644
index 0000000..e07f575
--- /dev/null
+++ b/store/ke.qq.com-svg/vine-moby.svg
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/store/ke.qq.com-svg/youtube.svg b/store/ke.qq.com-svg/youtube.svg
new file mode 100644
index 0000000..f3b9a2a
--- /dev/null
+++ b/store/ke.qq.com-svg/youtube.svg
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/utils/checkAuth.js b/utils/checkAuth.js
index 502c579..1c4fe25 100644
--- a/utils/checkAuth.js
+++ b/utils/checkAuth.js
@@ -4,7 +4,7 @@
* 判断用户是否有某个权限
* 二进制权限验证方式
*/
-var User = require('../models/user.js');
+var User = require('../model/user.js');
function checkUserAuth(user, auth, cb) {
User.find({
diff --git a/utils/db_init.js b/utils/db_init.js
index d09d9cb..c2f6de6 100644
--- a/utils/db_init.js
+++ b/utils/db_init.js
@@ -7,7 +7,7 @@
var path = require('path'),
fs = require('fs'),
- Icon = require('../models/icon.js'),
+ Icon = require('../model/icon.js'),
conf = require('../conf.js');
diff --git a/utils/download.js b/utils/download.js
index 9207f91..3279fc3 100644
--- a/utils/download.js
+++ b/utils/download.js
@@ -4,7 +4,7 @@ var path = require('path'),
var Q = require('q'),
fontCarrier = require('font-carrier'),
- Icon = require('../models/icon.js'),
+ Icon = require('../model/icon.js'),
font = fontCarrier.create();
var conf = require('../conf.js'),
diff --git a/utils/store.js b/utils/store.js
index a15a6bf..86a4dca 100644
--- a/utils/store.js
+++ b/utils/store.js
@@ -3,7 +3,7 @@ var path = require('path'),
fs = require('fs'),
unzip = require('unzip');
var conf = require('../conf.js'),
- Icon = require('../models/icon.js');
+ Icon = require('../model/icon.js');
function storeSvg (file, cb) {
var filePath = file.path,
@@ -22,9 +22,11 @@ function storeSvg (file, cb) {
name: path.basename(fileName, '.svg'),
author: file.author,
path: '/' + fileName,
- business: file.business
+ business: file.business,
+ id: file.id
}, function(errMaps) {
// 删除临时文件
+ // console.log(file);
if(fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
@@ -64,7 +66,8 @@ function storeZip (file, cb) {
name: path.basename(fileInfo.name, '.svg'),
path: fileInfo.path,
author: file.author,
- business: file.business
+ business: file.business,
+ id: file.id
});
} else {
entry.autodrain();
diff --git a/utils/svg_parser.js b/utils/svg_parser.js
index 3cadff6..75765f0 100644
--- a/utils/svg_parser.js
+++ b/utils/svg_parser.js
@@ -2,7 +2,7 @@
var conf = require('../conf.js'),
path = require('path'),
fontCarrier = require('font-carrier'),
- Icon = require('../models/icon.js'),
+ Icon = require('../model/icon.js'),
fs = require('fs');
var font = fontCarrier.create(),
@@ -84,7 +84,7 @@ function genarateFonts(icons, csspath){
});
font.setSvg(svgsObj);
- console.log('svgsObj', svgsObj)
+ // console.log('svgsObj', svgsObj)
// 导出字体
font.output({
path: path.join(path.dirname(outputCss ? outputCss : csspath), 'fonts/iconfont')
diff --git a/utils/tag.js b/utils/tag.js
index d1a3493..d8308d6 100644
--- a/utils/tag.js
+++ b/utils/tag.js
@@ -3,7 +3,7 @@
* tag database operation.
*/
-var Tag = require('../models/tag');
+var Tag = require('../model/tag');
/*
* add tag
diff --git a/views/404.html b/views/404.html
index 046bb9b..f2b5e53 100644
--- a/views/404.html
+++ b/views/404.html
@@ -24,5 +24,6 @@
<%= typeof info === 'undefined' ? '404 not found! ' : info %>
<%- include footer.html %>
+