Skip to content

Commit

Permalink
Merge pull request #192 from codeuino/development
Browse files Browse the repository at this point in the history
Development--->Master merge
  • Loading branch information
jaskiratsingh2000 authored May 23, 2019
2 parents c1df08c + 0c84d1a commit b4e50f5
Show file tree
Hide file tree
Showing 31 changed files with 2,589 additions and 404 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ typings/

# Config files
credential.js
secret.js
secret.js

views/images/uploads
23 changes: 23 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Contributing to Donut
==========================

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).

## First Timers Welcome!

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:


Thank you so much!

Learn more about contributing to Codeuino code projects on these pages:

* https://github.com/codeuino/Social-Platform-Donut/blob/master/PR_Template.md

* https://github.com/codeuino/Social-Platform-Donut/issues/new?assignees=&labels=&template=pull-request-template.md&title=

## Bug reports & troubleshooting

If you are submitting a bug, please go to https://github.com/codeuino/Social-Platform-Donut/issues/new

## Make sure to follow templates for the same
38 changes: 22 additions & 16 deletions PR_Template.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
### **Problem**
_Describe the problem you are trying to achieve. Please provide in detail_

new and robust schema needed for users, project and notification.
### **Issue this PR referred to**
_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_
Fixes issue number 146, Refer to this [link](https://github.com/codeuino/Social-Platform-Donut/issues/146) for more details_

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

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

_**After** [How it looks now, add it here]_
### **Before and After Screenshots**

### **Type of Change**
- [ ] Bug fix
- [ ] New Feature
- [ ] Development of UI/UX prototypes
- [ ] Small refactor
- [ ] Change in Documentation
- Small refactor

### **Checklist**
- [ ] My code follow the same style as the codebase
- [ ] My Code changed required change in documentation
- [ ] I have updated the Readme accordingly
- [ ] I made PR within **development branch only**
- My code follow the same style as the codebase
- My Code changed required change in documentation
- I have updated the Readme accordingly
- I made PR within **development branch only**
30 changes: 15 additions & 15 deletions config/credential.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
oauth: {
clientID: "192695093229-kf95jtdv1jge25d86ak99e68dkrpu33o.apps.googleusercontent.com",
clientSecret: "rXvfxBahDlJF1ORk7y660XM8"
},
database: 'YOUR MONGODB URL',
github: {
clientID: 'c9afdb238ed98b213912',
clientSecret: '3031efea8badea1381da682fd5f21e88e5a15d2f'
},
facebook: {
clientID: '383717979035587',
clientSecret: '82bd80d286ef6e45606da6d53a97efbc'
}
}
module.exports = {
oauth: {
clientID: "192695093229-kf95jtdv1jge25d86ak99e68dkrpu33o.apps.googleusercontent.com",
clientSecret: "rXvfxBahDlJF1ORk7y660XM8"
},
database: 'mongodb://localhost:27017/donut1',
github: {
clientID: 'c9afdb238ed98b213912',
clientSecret: '3031efea8badea1381da682fd5f21e88e5a15d2f'
},
facebook: {
clientID: '383717979035587',
clientSecret: '82bd80d286ef6e45606da6d53a97efbc'
}
}
11 changes: 10 additions & 1 deletion config/local.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const passport = require('passport');
const LocalStrategy = require('passport-local');
const User = require('../schema/user');
const path=require('path')

passport.serializeUser(function(user, done) {
done(null, user.id);
Expand Down Expand Up @@ -28,7 +29,14 @@ passport.use(
if (user) {
return done(null, false);
}


upload(req,res,(err)=>{
if(err){
let img="oldMan.jpeg"
}else{
let img=req.file.filename
}
})
let newUser = new User();
newUser.fname = req.body.fname;
newUser.lname = req.body.lname;
Expand All @@ -41,6 +49,7 @@ passport.use(
newUser.following = 0;
newUser.status = 'idle';
newUser.Eid = newUser.id;
newUser.profilePicture=img;

newUser.save(err => {
if (err) {
Expand Down
15 changes: 15 additions & 0 deletions controller/image.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Jimp=require('jimp')

module.exports={
ppResize:function(img,height,width){
imgDir="./views/uploads/profilePics/"+img
console.log(typeof(imgDir))
Jimp.read(imgDir, (err, img) => {
if (err) throw err;
img
.resize(width,height)
.quality(60)
.write(imgDir)
});
}
}
121 changes: 90 additions & 31 deletions controller/profile.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
const user = require('../schema/user.js');
const proj = require('../schema/project.js');

const expressValidator = require('express-validator');
const { check, validationResult } = require('express-validator/check');
// var multer = require('multer');
// var storage = multer.diskStorage({
// destination: (req, file, cb) => {
// cb(null, 'public/images/uploads')
// },
// filename: (req, file, cb) => {
// cb(null, file.fieldname + '-' + Date.now())
// }
// });
// var upload = multer({storage: storage});
module.exports = {
SubmitprojectForm:function(req,res){
res.render('projectForm')
Expand Down Expand Up @@ -33,28 +44,47 @@ module.exports = {
]).sort({createdAt:-1}).then((da)=>{
console.log(req.user);
user.findOne({ Eid: req.params.sd }).then(function (use) {
console.log(da)
res.render('other-landing', { use: use, ques: da, sign: req.user});
})
})
},
publish: function(req, res) {
var lan=req.body.genre.split(',');
new proj({
createdAt:Date.now(),
pname: req.body.contentname,
pid: req.user.Eid,
github: req.body.git,
Lang:lan,
content: req.body.cont,
upvote: '',
downvote: '',
proid: Math.floor(Math.random() * 100000)
})
.save()
.then(function() {
res.redirect('/profile/profileview/' + req.user.Eid);
});
},
var lan=req.body.genre.split(',');
req.check('contentname','Project name is required !!').notEmpty();
req.check('git','Github url is required !!').isURL();
req.check('cont','Description is required !!').notEmpty();
req.check('genre','Language used is required !!').notEmpty();
req.getValidationResult(req)
.then((result)=>{
if(result.isEmpty() === false){
result.array().forEach((error)=>{
console.log(error.msg);
res.redirect('/profile/submitProject');
});
} else {
new proj({
createdAt:Date.now(),
pname: req.body.contentname,
pid: req.user.Eid,
github: req.body.git,
Lang:lan,
content: req.body.cont,
upvote: '',
downvote: '',
proid: Math.floor(Math.random() * 100000),
image:'/images/uploads/'+req.file.filename
})
.save()
.then(function() {
res.redirect('/profile/profileview/' + req.user.Eid);
});
}
})
.catch((err)=>{
console.log(`${err}`);
});
},
upDownVote: function (req,res) {
proj.findOne({proid: req.body.project}).then((pro)=>{
if(pro.upDownVote.get(req.body.client)){
Expand Down Expand Up @@ -90,19 +120,48 @@ module.exports = {
updateDetails: function(req, res) {
user.findOne({ Eid: req.user.Eid }).then(function(data) {
// prettier-ignore
(data.fname = req.body.fname),
(data.lname = req.body.lname),
(data.bio = req.body.bio),
(data.college = req.body.college),
(data.email = req.body.email),
(data.github = req.body.githubUrl),
(data.linkedin = req.body.linkedinUrl),
(data.city = req.body.city),
(data.country = req.body.country),
(data.lang = req.body.languages),
(data.facebook = req.body.facebookUrl);
data.save();
res.send('success');
req.check('fname','First name is required !').notEmpty();
req.check('lname','Last name is required !').notEmpty();
req.check('bio','Bio is required !').notEmpty();
req.check('college','College name is required !').notEmpty();
req.check('email','Email is required !').isEmail();
req.check('githubUrl','Github url is required !').isURL();
req.check('linkedinUrl','Linkedin url is required !').isURL();
req.check('facebookUrl','Facebook url is required !').isURL();
req.check('city','City name is required !').notEmpty();
req.check('country','Country name is required !').notEmpty();
req.check('languages','Language is required !').notEmpty();
req.getValidationResult(req)
.then((result)=>{
if(result.isEmpty() === true){
result.array().forEach((error)=>{
console.log(error.msg);
res.redirect('/profile/setting');
});
}
})
.catch((err)=>{
console.log(`${err}`);
});
(data.fname = req.body.fname),
(data.lname = req.body.lname),
(data.bio = req.body.bio),
(data.college = req.body.college),
(data.email = req.body.email),
(data.github = req.body.githubUrl),
(data.linkedin = req.body.linkedinUrl),
(data.city = req.body.city),
(data.country = req.body.country),
(data.lang = req.body.languages),
(data.facebook = req.body.facebookUrl);
data.save()
.then(()=>{
console.log('profile updated !');
// res.send('success');
})
.catch((err)=>{
console.log(`${err}`);
});
});
},
getDetails: function(req, res) {
Expand Down
Loading

0 comments on commit b4e50f5

Please sign in to comment.