├── public
├── home.jpg
├── Screenshot_2019-02-09 LetsChat Home.jpg
├── chat.css
├── app.css
└── cover.css
├── models
├── like.js
├── comment.js
├── post.js
└── user.js
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── views
├── error.ejs
├── createcomment.ejs
├── editcomment.ejs
├── like.ejs
├── createpost.ejs
├── edit.ejs
├── login.ejs
├── index.ejs
├── chat.ejs
├── partials
│ ├── footer.ejs
│ └── header.ejs
├── show.ejs
├── signup.ejs
├── home.ejs
├── useredit.ejs
└── profile.ejs
├── package.json
├── LICENSE
├── routes
├── likes.js
├── comments.js
├── auth_index.js
└── posts.js
├── app.js
├── middleware
└── index.js
└── README.md
/public/home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gargarchit/LetsChat/HEAD/public/home.jpg
--------------------------------------------------------------------------------
/public/Screenshot_2019-02-09 LetsChat Home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gargarchit/LetsChat/HEAD/public/Screenshot_2019-02-09 LetsChat Home.jpg
--------------------------------------------------------------------------------
/public/chat.css:
--------------------------------------------------------------------------------
1 | * { margin: 0; padding: 0; box-sizing: border-box; }
2 | body { font: 13px Helvetica, Arial margin-top:100px}
3 | form { padding: 3px; position: fixed; bottom: 50px; width: 60%; }
4 | #messages { list-style-type: none; margin: 0; padding: 0; }
5 | #messages li { padding: 5px 10px; }
6 | #messages li:nth-child(odd) { background: #eee; }
7 | #messages { margin-bottom: 40px }
--------------------------------------------------------------------------------
/models/like.js:
--------------------------------------------------------------------------------
1 | var mongoose = require("mongoose");
2 |
3 | // Mongoose/Model config
4 | // like Schema
5 | var likeSchema = new mongoose.Schema({
6 | profile: {
7 | id: {
8 | type: mongoose.Schema.Types.ObjectId,
9 | ref: "user"
10 | },
11 | name : String,
12 | username: String
13 | },
14 | created: {type: Date, default: Date.now}
15 | });
16 |
17 | module.exports = mongoose.model('like', likeSchema);
--------------------------------------------------------------------------------
/models/comment.js:
--------------------------------------------------------------------------------
1 | var mongoose = require("mongoose");
2 |
3 | // Mongoose/Model config
4 | // Comment Schema
5 | var commentSchema = new mongoose.Schema({
6 | text: String,
7 | profile: {
8 | id: {
9 | type: mongoose.Schema.Types.ObjectId,
10 | ref: "user"
11 | },
12 | name : String,
13 | username: String
14 | },
15 |
16 | created: {type: Date, default: Date.now}
17 | });
18 |
19 | module.exports = mongoose.model('comment', commentSchema);
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/views/error.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
4 |
5 |
6 |
Oops!
7 |
404 - Page not found
8 |
9 | The page you are looking for might have been removed had its name changed or is temporarily unavailable.
10 |
11 |
14 |
15 |
16 |
17 |
18 | <% include partials/footer.ejs %>
19 |
--------------------------------------------------------------------------------
/models/post.js:
--------------------------------------------------------------------------------
1 | var mongoose = require("mongoose");
2 |
3 | // Mongoose/Model config
4 | // Post Schema
5 | var postSchema = new mongoose.Schema({
6 | caption: String,
7 | image: String,
8 | imageId: String,
9 | created: {type: Date, default: Date.now},
10 | profile: {
11 | id: {
12 | type: mongoose.Schema.Types.ObjectId,
13 | ref: "user"
14 | },
15 | name : String,
16 | username: String
17 | },
18 | comments: [
19 | {
20 | type : mongoose.Schema.Types.ObjectId,
21 | ref: "comment"
22 | }],
23 | like: [
24 | {
25 | type : mongoose.Schema.Types.ObjectId,
26 | ref: "like"
27 | }],
28 | });
29 |
30 | module.exports = mongoose.model('post', postSchema);
--------------------------------------------------------------------------------
/views/createcomment.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
19 |
20 | <% include partials/footer.ejs %>
--------------------------------------------------------------------------------
/views/editcomment.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
19 |
20 | <% include partials/footer.ejs %>
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/views/like.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
4 |
5 |
Likes on <%=post.caption%>
6 |
Go back
7 |
8 |
9 |
10 |
11 | <% if (post.like.length === 0) { %>
12 |
No Likes yet, you can be the first to like it
13 | <% } %>
14 | <% post.like.forEach((like) => { %>
15 |
23 |
24 | <% }); %>
25 |
26 |
27 |
28 |
29 | <% include partials/footer.ejs %>
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "workspace",
3 | "version": "1.0.0",
4 | "description": "letschat",
5 | "main": "app.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node app.js"
9 | },
10 | "author": "Archit",
11 | "license": "ISC",
12 | "dependencies": {
13 | "async": "^2.6.1",
14 | "body-parser": "^1.18.3",
15 | "cloudinary": "^1.13.2",
16 | "connect-flash": "^0.1.1",
17 | "dotenv": "^6.2.0",
18 | "ejs": "^2.6.1",
19 | "expect": "^24.1.0",
20 | "express": "^4.16.4",
21 | "express-generator": "^4.16.0",
22 | "express-sanitizer": "^1.0.4",
23 | "express-session": "^1.15.6",
24 | "faker": "^4.1.0",
25 | "method-override": "^3.0.0",
26 | "mocha": "^5.2.0",
27 | "moment": "^2.23.0",
28 | "mongoose": "^5.4.3",
29 | "multer": "^1.4.1",
30 | "nodemailer": "^5.1.1",
31 | "passport": "^0.4.0",
32 | "passport-local": "^1.0.0",
33 | "passport-local-mongoose": "^5.0.1",
34 | "pusher": "^2.2.0",
35 | "socket.io": "^2.2.0",
36 | "validator": "^10.10.0"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/views/createpost.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
26 |
27 |
28 | <% include partials/footer.ejs %>
--------------------------------------------------------------------------------
/models/user.js:
--------------------------------------------------------------------------------
1 | var mongoose = require("mongoose");
2 | var passportLocalMongoose = require("passport-local-mongoose");
3 | var validator = require("validator");
4 |
5 | var UserSchema = new mongoose.Schema({
6 | name: String,
7 | email: {
8 | type: String,
9 | unique: true,
10 | trim: true,
11 | lowercase: true,
12 | match: [/\S+@\S+\.\S+/, 'is invalid'],
13 | index: true
14 |
15 | },
16 | username: {
17 | type: String,
18 | lowercase: true,
19 | unique: true,
20 | trim: true,
21 | minlength: 4,
22 | match: [/^[a-z]{1}[A-Za-z0-9_]{3,16}$/, 'is invalid'],
23 | index: true
24 |
25 | },
26 | password: {type: String, minlength: 8, maxlength: 20},
27 | image: String,
28 | imageId: String,
29 | about: String,
30 | address: String,
31 | gender: String,
32 | website: String,
33 | contactno : Number,
34 | work: String,
35 | });
36 |
37 | UserSchema.plugin(passportLocalMongoose);
38 |
39 | module.exports = mongoose.model("user", UserSchema);
--------------------------------------------------------------------------------
/views/edit.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
25 | <% include partials/footer.ejs %>
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Archit
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/views/login.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
33 | <% include partials/footer.ejs %>
--------------------------------------------------------------------------------
/routes/likes.js:
--------------------------------------------------------------------------------
1 | var express = require("express"),
2 | router = express.Router({mergeParams: true}),
3 | post = require("../models/post"),
4 | like = require("../models/like"),
5 | user = require("../models/user"),
6 | middleware = require("../middleware");
7 |
8 |
9 | //Like : Create New Like
10 | router.post("/post/:id/likes",middleware.isLoggedIn, (req, res) => {
11 | post.findById(req.params.id, (err, Post) => {
12 | if(err){
13 | res.render("error");
14 | } else {
15 | like.create(req.body.Like, (err, com) => {
16 | if(err){
17 | res.render("error");
18 | } else {
19 | com.profile.id = req.user._id;
20 | com.profile.username = req.user.username;
21 | com.profile.name = req.user.name;
22 | com.save();
23 | Post.like.push(com);
24 | Post.save();
25 | res.redirect('back');
26 | }
27 | });
28 | }
29 | });
30 | });
31 |
32 |
33 | //Show likes
34 | router.get('/post/:id/like', (req,res) => {
35 | post.findById(req.params.id).populate('like').exec((err, foundpost) => {
36 | if(err || !foundpost) {
37 | res.render("error");
38 | } else {
39 | res.render('like', {post:foundpost});
40 | }
41 | });
42 | });
43 | module.exports = router;
--------------------------------------------------------------------------------
/public/app.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | background-color: #d4efdf;
4 | margin-top:100px;
5 | }
6 | body > .grid {
7 | height: 100%;
8 | }
9 | .jumbotron {
10 | margin-top: -60px;
11 | background : url('/home.jpg');
12 | background-repeat: no-repeat;
13 | background-size: cover;
14 | }
15 | .jumbotron .container{
16 | color: white
17 | }
18 | .image {
19 | margin-top: -100px;
20 | }
21 | .column {
22 | max-width: 450px;
23 | }
24 | .container.main {
25 | margin: auto;
26 | position: relative;
27 | top: 25%;
28 | }
29 | .container.text {
30 | margin-top: 3.0em;
31 | }
32 | img {
33 | border-radius: 8px;
34 | max-width: 100%;
35 | height: auto;
36 | display: block;
37 | width: 100%;
38 | }
39 |
40 | .thumbnail img {
41 | width: 100%;
42 | opacity: 1;
43 | transition: opacity 0.3s;
44 | }
45 |
46 | .thumbnail {
47 | padding: 0;
48 | }
49 |
50 | .thumbnail .caption-full {
51 | padding: 9px;
52 | }
53 |
54 | #delete-form {
55 | display: inline;
56 | }
57 |
58 | .navbar .navbar-brand{
59 | margin-left:10%;
60 | }
61 | .navbar .collapse{
62 | margin-left:10%;
63 | margin-right:10%;
64 | }
65 |
66 | .thumbnail img {
67 | width: 100%;
68 | }
69 |
70 | .thumbnail {
71 | padding: 0;
72 | }
73 |
74 | .thumbnail .caption-full {
75 | padding: 9px;
76 | }
77 |
78 | .error-template {padding: 40px 15px;text-align: center;}
79 | .error-actions {margin-top:15px;margin-bottom:15px;}
80 | .error-actions .btn { margin-right:10px; }
--------------------------------------------------------------------------------
/views/index.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
7 |
8 |
9 |
Welcome to LetsChat
10 | Feed Page
11 |
12 |
13 |
14 |
15 | <% post.forEach((posts) => { %>
16 |
17 |
18 |
29 |
30 |
31 |
32 | <% }); %>
33 |
34 |
35 | <% include partials/footer.ejs %>
36 |
--------------------------------------------------------------------------------
/public/cover.css:
--------------------------------------------------------------------------------
1 |
2 | a,
3 | a:focus,
4 | a:hover {
5 | color: #fff;
6 | }
7 | .btn-secondary,
8 | .btn-secondary:hover,
9 | .btn-secondary:focus {
10 | color: #333;
11 | text-shadow: none;
12 | background-color: #fff;
13 | border: .05rem solid #fff;
14 | }
15 |
16 | html,
17 | body {
18 | height: 100%;
19 | background : url('./home.jpg');
20 | background-repeat: no-repeat;
21 | background-size: cover;
22 | }
23 |
24 | body {
25 | display: -ms-flexbox;
26 | display: flex;
27 | color: #fff;
28 | text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5);
29 | box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
30 | }
31 |
32 | .cover-container {
33 | max-width: 42em;
34 | }
35 |
36 |
37 | .masthead {
38 | margin-bottom: 2rem;
39 | }
40 |
41 | .masthead-brand {
42 | margin-bottom: 0;
43 | }
44 |
45 | .nav-masthead .nav-link {
46 | padding: .25rem 0;
47 | font-weight: 700;
48 | color: rgba(255, 255, 255, .5);
49 | background-color: transparent;
50 | border-bottom: .25rem solid transparent;
51 | }
52 |
53 | .nav-masthead .nav-link:hover,
54 | .nav-masthead .nav-link:focus {
55 | border-bottom-color: rgba(255, 255, 255, .25);
56 | }
57 |
58 | .nav-masthead .nav-link + .nav-link {
59 | margin-left: 1rem;
60 | }
61 |
62 | .nav-masthead .active {
63 | color: #fff;
64 | border-bottom-color: #fff;
65 | }
66 |
67 | @media (min-width: 48em) {
68 | .masthead-brand {
69 | float: left;
70 | }
71 | .nav-masthead {
72 | float: right;
73 | }
74 | }
75 |
76 | .cover {
77 | padding: 0 1.5rem;
78 | }
79 | .cover .btn-lg {
80 | padding: .75rem 1.25rem;
81 | font-weight: 700;
82 | }
83 |
84 | .mastfoot {
85 | color: rgba(255, 255, 255, .5);
86 | }
87 |
--------------------------------------------------------------------------------
/views/chat.ejs:
--------------------------------------------------------------------------------
1 | <% include partials/header.ejs %>
2 |
3 |
4 |
Welcome to LetsChat
5 | Chat Room - LoggedIn as : <%=user.name%> @ <%=user.username%>
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Welcome <%=user.name%> to LetsChat's Chat Room
16 |
17 |
18 |
19 |
20 |
21 |
22 |
37 |
38 |
39 |
40 |
41 |
42 |
47 |
61 | <% include partials/footer.ejs %>
62 |
--------------------------------------------------------------------------------
/views/partials/footer.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
26 |
27 |