Skip to content

Commit b4e50f5

Browse files
Merge pull request #192 from codeuino/development
Development--->Master merge
2 parents c1df08c + 0c84d1a commit b4e50f5

31 files changed

+2589
-404
lines changed

.DS_Store

8 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ typings/
7979

8080
# Config files
8181
credential.js
82-
secret.js
82+
secret.js
83+
84+
views/images/uploads

Contributing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Contributing to Donut
2+
==========================
3+
4+
We welcome community contributions to plotsbot! To setup Donut locally, follow the instructions in the [README.md file](https://github.com/codeuino/Social-Platform-Donut/blob/master/README.md).
5+
6+
## First Timers Welcome!
7+
8+
New to open source/free software? Here are a selection of issues we've made especially for first-timers. We're here to help, so just ask if one looks interesting:
9+
10+
11+
Thank you so much!
12+
13+
Learn more about contributing to Codeuino code projects on these pages:
14+
15+
* https://github.com/codeuino/Social-Platform-Donut/blob/master/PR_Template.md
16+
17+
* https://github.com/codeuino/Social-Platform-Donut/issues/new?assignees=&labels=&template=pull-request-template.md&title=
18+
19+
## Bug reports & troubleshooting
20+
21+
If you are submitting a bug, please go to https://github.com/codeuino/Social-Platform-Donut/issues/new
22+
23+
## Make sure to follow templates for the same

PR_Template.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
### **Problem**
2-
_Describe the problem you are trying to achieve. Please provide in detail_
3-
2+
new and robust schema needed for users, project and notification.
43
### **Issue this PR referred to**
5-
_Please refer to the issue this PR is referred to write in this format `Fixes #<issue number>`, Refer to this [link](https://help.github.com/en/articles/closing-issues-using-keywords) for more details_
4+
Fixes issue number 146, Refer to this [link](https://github.com/codeuino/Social-Platform-Donut/issues/146) for more details_
65

76
### **Solution of problem**
8-
_How did you solve this problem? Please provide in detail_
7+
I added some new fields to the schema of the user.js, project.js and notification.js
98

10-
### **Before and After Screenshots**
11-
_**Before** [How was it earlier, add it here]_
9+
# in notification.js
10+
- added field shortinfo(type:string) for short description about notification.
11+
# in user.js
12+
- added field website(type:string) for any personal website user has.
13+
- added followerList and followingList(type:\[number]) to include the name of all the followers and following.
14+
- add field status(type:string) for status of user.
15+
- added field school(type:string) for user's schoolname.
16+
- added field collegeTimeperiod and schoolTimeperiod (type:\[Date]) for time period of college and school respectively.
17+
- added field blockedUser(type:\[Number]) for keeping track of all users blocked.
18+
# in project.js
19+
- added field endAt(type:\[Date]) as to when is the deadline.
20+
- added field shortDesc(type:String) for one liner description of the project.
21+
- added field linkedUser(type:\[Number]) for all the people linked with project.
1222

13-
_**After** [How it looks now, add it here]_
23+
### **Before and After Screenshots**
1424

1525
### **Type of Change**
16-
- [ ] Bug fix
17-
- [ ] New Feature
18-
- [ ] Development of UI/UX prototypes
19-
- [ ] Small refactor
20-
- [ ] Change in Documentation
26+
- Small refactor
2127

2228
### **Checklist**
23-
- [ ] My code follow the same style as the codebase
24-
- [ ] My Code changed required change in documentation
25-
- [ ] I have updated the Readme accordingly
26-
- [ ] I made PR within **development branch only**
29+
- My code follow the same style as the codebase
30+
- My Code changed required change in documentation
31+
- I have updated the Readme accordingly
32+
- I made PR within **development branch only**

config/credential.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
module.exports = {
2-
oauth: {
3-
clientID: "192695093229-kf95jtdv1jge25d86ak99e68dkrpu33o.apps.googleusercontent.com",
4-
clientSecret: "rXvfxBahDlJF1ORk7y660XM8"
5-
},
6-
database: 'YOUR MONGODB URL',
7-
github: {
8-
clientID: 'c9afdb238ed98b213912',
9-
clientSecret: '3031efea8badea1381da682fd5f21e88e5a15d2f'
10-
},
11-
facebook: {
12-
clientID: '383717979035587',
13-
clientSecret: '82bd80d286ef6e45606da6d53a97efbc'
14-
}
15-
}
1+
module.exports = {
2+
oauth: {
3+
clientID: "192695093229-kf95jtdv1jge25d86ak99e68dkrpu33o.apps.googleusercontent.com",
4+
clientSecret: "rXvfxBahDlJF1ORk7y660XM8"
5+
},
6+
database: 'mongodb://localhost:27017/donut1',
7+
github: {
8+
clientID: 'c9afdb238ed98b213912',
9+
clientSecret: '3031efea8badea1381da682fd5f21e88e5a15d2f'
10+
},
11+
facebook: {
12+
clientID: '383717979035587',
13+
clientSecret: '82bd80d286ef6e45606da6d53a97efbc'
14+
}
15+
}

config/local.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const passport = require('passport');
22
const LocalStrategy = require('passport-local');
33
const User = require('../schema/user');
4+
const path=require('path')
45

56
passport.serializeUser(function(user, done) {
67
done(null, user.id);
@@ -28,7 +29,14 @@ passport.use(
2829
if (user) {
2930
return done(null, false);
3031
}
31-
32+
33+
upload(req,res,(err)=>{
34+
if(err){
35+
let img="oldMan.jpeg"
36+
}else{
37+
let img=req.file.filename
38+
}
39+
})
3240
let newUser = new User();
3341
newUser.fname = req.body.fname;
3442
newUser.lname = req.body.lname;
@@ -41,6 +49,7 @@ passport.use(
4149
newUser.following = 0;
4250
newUser.status = 'idle';
4351
newUser.Eid = newUser.id;
52+
newUser.profilePicture=img;
4453

4554
newUser.save(err => {
4655
if (err) {

controller/image.controller.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const Jimp=require('jimp')
2+
3+
module.exports={
4+
ppResize:function(img,height,width){
5+
imgDir="./views/uploads/profilePics/"+img
6+
console.log(typeof(imgDir))
7+
Jimp.read(imgDir, (err, img) => {
8+
if (err) throw err;
9+
img
10+
.resize(width,height)
11+
.quality(60)
12+
.write(imgDir)
13+
});
14+
}
15+
}

controller/profile.controller.js

Lines changed: 90 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
const user = require('../schema/user.js');
22
const proj = require('../schema/project.js');
3-
3+
const expressValidator = require('express-validator');
4+
const { check, validationResult } = require('express-validator/check');
5+
// var multer = require('multer');
6+
// var storage = multer.diskStorage({
7+
// destination: (req, file, cb) => {
8+
// cb(null, 'public/images/uploads')
9+
// },
10+
// filename: (req, file, cb) => {
11+
// cb(null, file.fieldname + '-' + Date.now())
12+
// }
13+
// });
14+
// var upload = multer({storage: storage});
415
module.exports = {
516
SubmitprojectForm:function(req,res){
617
res.render('projectForm')
@@ -33,28 +44,47 @@ module.exports = {
3344
]).sort({createdAt:-1}).then((da)=>{
3445
console.log(req.user);
3546
user.findOne({ Eid: req.params.sd }).then(function (use) {
47+
console.log(da)
3648
res.render('other-landing', { use: use, ques: da, sign: req.user});
3749
})
3850
})
3951
},
4052
publish: function(req, res) {
41-
var lan=req.body.genre.split(',');
42-
new proj({
43-
createdAt:Date.now(),
44-
pname: req.body.contentname,
45-
pid: req.user.Eid,
46-
github: req.body.git,
47-
Lang:lan,
48-
content: req.body.cont,
49-
upvote: '',
50-
downvote: '',
51-
proid: Math.floor(Math.random() * 100000)
52-
})
53-
.save()
54-
.then(function() {
55-
res.redirect('/profile/profileview/' + req.user.Eid);
56-
});
57-
},
53+
var lan=req.body.genre.split(',');
54+
req.check('contentname','Project name is required !!').notEmpty();
55+
req.check('git','Github url is required !!').isURL();
56+
req.check('cont','Description is required !!').notEmpty();
57+
req.check('genre','Language used is required !!').notEmpty();
58+
req.getValidationResult(req)
59+
.then((result)=>{
60+
if(result.isEmpty() === false){
61+
result.array().forEach((error)=>{
62+
console.log(error.msg);
63+
res.redirect('/profile/submitProject');
64+
});
65+
} else {
66+
new proj({
67+
createdAt:Date.now(),
68+
pname: req.body.contentname,
69+
pid: req.user.Eid,
70+
github: req.body.git,
71+
Lang:lan,
72+
content: req.body.cont,
73+
upvote: '',
74+
downvote: '',
75+
proid: Math.floor(Math.random() * 100000),
76+
image:'/images/uploads/'+req.file.filename
77+
})
78+
.save()
79+
.then(function() {
80+
res.redirect('/profile/profileview/' + req.user.Eid);
81+
});
82+
}
83+
})
84+
.catch((err)=>{
85+
console.log(`${err}`);
86+
});
87+
},
5888
upDownVote: function (req,res) {
5989
proj.findOne({proid: req.body.project}).then((pro)=>{
6090
if(pro.upDownVote.get(req.body.client)){
@@ -90,19 +120,48 @@ module.exports = {
90120
updateDetails: function(req, res) {
91121
user.findOne({ Eid: req.user.Eid }).then(function(data) {
92122
// prettier-ignore
93-
(data.fname = req.body.fname),
94-
(data.lname = req.body.lname),
95-
(data.bio = req.body.bio),
96-
(data.college = req.body.college),
97-
(data.email = req.body.email),
98-
(data.github = req.body.githubUrl),
99-
(data.linkedin = req.body.linkedinUrl),
100-
(data.city = req.body.city),
101-
(data.country = req.body.country),
102-
(data.lang = req.body.languages),
103-
(data.facebook = req.body.facebookUrl);
104-
data.save();
105-
res.send('success');
123+
req.check('fname','First name is required !').notEmpty();
124+
req.check('lname','Last name is required !').notEmpty();
125+
req.check('bio','Bio is required !').notEmpty();
126+
req.check('college','College name is required !').notEmpty();
127+
req.check('email','Email is required !').isEmail();
128+
req.check('githubUrl','Github url is required !').isURL();
129+
req.check('linkedinUrl','Linkedin url is required !').isURL();
130+
req.check('facebookUrl','Facebook url is required !').isURL();
131+
req.check('city','City name is required !').notEmpty();
132+
req.check('country','Country name is required !').notEmpty();
133+
req.check('languages','Language is required !').notEmpty();
134+
req.getValidationResult(req)
135+
.then((result)=>{
136+
if(result.isEmpty() === true){
137+
result.array().forEach((error)=>{
138+
console.log(error.msg);
139+
res.redirect('/profile/setting');
140+
});
141+
}
142+
})
143+
.catch((err)=>{
144+
console.log(`${err}`);
145+
});
146+
(data.fname = req.body.fname),
147+
(data.lname = req.body.lname),
148+
(data.bio = req.body.bio),
149+
(data.college = req.body.college),
150+
(data.email = req.body.email),
151+
(data.github = req.body.githubUrl),
152+
(data.linkedin = req.body.linkedinUrl),
153+
(data.city = req.body.city),
154+
(data.country = req.body.country),
155+
(data.lang = req.body.languages),
156+
(data.facebook = req.body.facebookUrl);
157+
data.save()
158+
.then(()=>{
159+
console.log('profile updated !');
160+
// res.send('success');
161+
})
162+
.catch((err)=>{
163+
console.log(`${err}`);
164+
});
106165
});
107166
},
108167
getDetails: function(req, res) {

0 commit comments

Comments
 (0)