├── Procfile
├── .gitignore
├── Website Mindmap.png
├── public
├── Images
│ ├── logo.png
│ └── CodingClubLogo.jpg
├── Team
│ └── teammanager.js
├── Blog
│ ├── Blogmanager.js
│ ├── showblog.css
│ └── script.js
├── Resources
│ └── ResourceManager.js
├── Event
│ └── EventManager.js
└── login
│ └── style.css
├── models
├── video.js
├── achievement.js
├── teamMember.js
├── event.js
├── material.js
├── Webinar.js
├── Programming.js
├── project.js
├── user.js
└── blog.js
├── Admin Pannel
├── project.js
├── admin.js
├── resources.js
├── teams.js
├── blog.js
└── event.js
├── Authentication
├── middleware
│ └── check_auth.js
└── routes
│ └── user.js
├── Mongodb
├── connection.js
└── gridfs.js
├── LICENSE
├── package.json
├── contributing.md
├── api_v1
├── video.js
├── images.js
├── event.js
├── project.js
├── webinarEvent.js
├── material.js
├── programmingEvent.js
├── team.js
├── achievement.js
└── blog.js
├── views
├── Admin
│ ├── Login
│ │ ├── login.ejs
│ │ └── changepass.ejs
│ ├── Resources Page
│ │ ├── addVideo.ejs
│ │ ├── addMaterial.ejs
│ │ └── ResourceManager.ejs
│ ├── Events Page
│ │ ├── addAchievement.ejs
│ │ ├── updateAchievement.ejs
│ │ ├── addEvent.ejs
│ │ ├── addWebinar.ejs
│ │ ├── addProgramming.ejs
│ │ ├── updateProgramming.ejs
│ │ └── EventManager.ejs
│ ├── Teams Page
│ │ ├── TeamManager.ejs
│ │ ├── addteammember.ejs
│ │ └── updateTeam.ejs
│ ├── Projects Page
│ │ └── addProject.ejs
│ ├── Blog Page
│ │ ├── BlogManager.ejs
│ │ ├── updateBlog.ejs
│ │ └── addBlog.ejs
│ └── admin.ejs
└── Blog
│ └── showBlog.ejs
├── README.md
└── index.js
/Procfile:
--------------------------------------------------------------------------------
1 | web: node index.js
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/node_modules
2 | .env
--------------------------------------------------------------------------------
/Website Mindmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite/HEAD/Website Mindmap.png
--------------------------------------------------------------------------------
/public/Images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite/HEAD/public/Images/logo.png
--------------------------------------------------------------------------------
/public/Images/CodingClubLogo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite/HEAD/public/Images/CodingClubLogo.jpg
--------------------------------------------------------------------------------
/models/video.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | const videoSchema = new Schema({
6 | Title: String,
7 | Link: String,
8 | });
9 | module.exports = mongoose.model("Video", videoSchema);
--------------------------------------------------------------------------------
/Admin Pannel/project.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const https = require('https')
4 | const checkAuth = require('../Authentication/middleware/check_auth');
5 |
6 |
7 | router.get("/addProject", checkAuth, function(req, res) {
8 | res.render("Admin/Projects Page/addProject");
9 | });
10 |
11 | module.exports = router
--------------------------------------------------------------------------------
/Admin Pannel/admin.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const https = require('https')
4 | const checkAuth = require('../Authentication/middleware/check_auth');
5 |
6 | router.get('/', checkAuth, function(req, res) {
7 | res.render('Admin/admin', {
8 | name: req.cookies.name,
9 | role: req.cookies.role,
10 | });
11 | });
12 |
13 | module.exports = router
--------------------------------------------------------------------------------
/models/achievement.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | const achievementSchema = new Schema({
6 | Name: String,
7 | Date: {
8 | type: Date,
9 | default: Date.now
10 | },
11 | Description: String,
12 | Link: String,
13 | FileName: String,
14 | });
15 | module.exports = mongoose.model("Achievement", achievementSchema);
--------------------------------------------------------------------------------
/Authentication/middleware/check_auth.js:
--------------------------------------------------------------------------------
1 | const jwt = require('jsonwebtoken');
2 |
3 | module.exports = (req, res, next) => {
4 | try {
5 | const token = req.cookies.token;
6 | console.log(token);
7 | const decoded = jwt.verify(token, process.env.JWT_KEY);
8 | req.userData = decoded;
9 | next();
10 | } catch (error) {
11 | return res.redirect('/auth/login');
12 | }
13 | };
--------------------------------------------------------------------------------
/Mongodb/connection.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | const db = mongoose.connection;
3 | require('dotenv').config();
4 | mongoose.connect(process.env.MONGO_DB_URL, {
5 | useNewUrlParser: true,
6 | useUnifiedTopology: true
7 | });
8 | db.on('error', console.error.bind(console, 'connection error:'));
9 | db.once('open', () => {
10 | console.log("DataBase: We are connected");
11 | });
12 |
13 | module.exports = db
--------------------------------------------------------------------------------
/public/Team/teammanager.js:
--------------------------------------------------------------------------------
1 | var url = 'https://codingclubnitm.herokuapp.com/api/v1/teammember/'
2 |
3 | function deleteteam(id) {
4 | console.log('Fired')
5 | var result = confirm("Want to delete?");
6 | if (result) {
7 | fetch(url + id, {
8 | method: 'DELETE',
9 | }).then(res => {
10 | window.location.reload()
11 | return res.json()
12 | });
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/models/teamMember.js:
--------------------------------------------------------------------------------
1 | const mongoose= require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var memberSchema = new Schema({
6 | FirstName: String,
7 | LastName: String,
8 | Designation: Number,
9 | DesignationName: String,
10 | Github: String,
11 | LinkedIn: String,
12 | Facebook: String,
13 | filename: String,
14 | });
15 |
16 | module.exports = mongoose.model("TeamMember", memberSchema);
--------------------------------------------------------------------------------
/models/event.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var EventSchema = new Schema({
6 | EventName: String,
7 | StartDate: {
8 | type: Date,
9 | default: Date.now
10 | },
11 | EndDate: {
12 | type: Date,
13 | default: Date.now
14 | },
15 | FileName: String,
16 | Link: String,
17 | });
18 |
19 | module.exports = mongoose.model("Event", EventSchema);
--------------------------------------------------------------------------------
/models/material.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var MaterialSchema = new Schema({
6 | Year: String,
7 | Field: {
8 | Orientation: {
9 | Event: [],
10 | },
11 | Assignment: {
12 | Event: [],
13 | },
14 | Presentation: {
15 | Event: [],
16 | },
17 | }
18 | });
19 |
20 | module.exports = mongoose.model("Material", MaterialSchema);
--------------------------------------------------------------------------------
/models/Webinar.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var WebinarSchema = new Schema({
6 | Title: String,
7 | StartDate: {
8 | type: Date,
9 | default: Date.now
10 | },
11 | EndDate: {
12 | type: Date,
13 | default: Date.now
14 | },
15 | Time: String,
16 | ShortDescription: String,
17 | RegistrationLink: String,
18 | Link: String,
19 | FileName: String
20 | });
21 |
22 | module.exports = mongoose.model("Webinar", WebinarSchema);
--------------------------------------------------------------------------------
/models/Programming.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var ProgrammingSchema = new Schema({
6 | Title: String,
7 | StartDate: {
8 | type: Date,
9 | default: Date.now
10 | },
11 | EndDate: {
12 | type: Date,
13 | default: Date.now
14 | },
15 | Time: String,
16 | ShortDescription: String,
17 | RegistrationLink: String,
18 | Link: String,
19 | FileName: String
20 | });
21 |
22 | module.exports = mongoose.model("Programming", ProgrammingSchema);
--------------------------------------------------------------------------------
/models/project.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var ProjectSchema = new Schema({
6 | Name: String,
7 | Field: String, //like web,app etc
8 | Status: String, //ongoing/completed etc.
9 | StartDate: {
10 | type: Date,
11 | default: Date.now
12 | },
13 | EndDate: {
14 | type: Date,
15 | default: Date.now
16 | },
17 | ShortDescription: String,
18 | Description: String,
19 | Github: String,
20 | Link: String,
21 | FileName: String
22 | });
23 |
24 | module.exports = mongoose.model("Project", ProjectSchema);
--------------------------------------------------------------------------------
/models/user.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | var userSchema = new Schema({
6 | email: {
7 | type: String,
8 | required: true,
9 | unique: true,
10 | },
11 | firstname: {
12 | type: String,
13 | required: true
14 | },
15 | lastname: {
16 | type: String,
17 | required: true
18 | },
19 | password: {
20 | type: String,
21 | required: true,
22 | },
23 | role: {
24 | type: String,
25 | required: true
26 | }
27 | });
28 |
29 | module.exports = mongoose.model("User", userSchema);
--------------------------------------------------------------------------------
/public/Blog/Blogmanager.js:
--------------------------------------------------------------------------------
1 | var url = '/api/v1/blog/'
2 |
3 | function deleteblog(id) {
4 | console.log('Fired')
5 | var result = confirm("Want to delete?");
6 | if (result) {
7 | fetch(url + id, {
8 | method: 'DELETE',
9 | }).then(res => {
10 | window.location.reload()
11 | return res.json()
12 | });
13 | }
14 |
15 | }
16 |
17 | function makepublished(id) {
18 | console.log("Fired: " + id);
19 | let route = "/api/v1/updateblog/" + id;
20 | fetch(route, {
21 | method: 'PATCH',
22 | }).then(res => {
23 | window.location.reload()
24 | return res.json()
25 | });
26 | }
--------------------------------------------------------------------------------
/public/Resources/ResourceManager.js:
--------------------------------------------------------------------------------
1 | // function deleteMaterial(id) {
2 | // console.log('Fired: ' + id)
3 | // var result = confirm("Want to delete?");
4 | // if (result) {
5 | // fetch(event_url + id, {
6 | // method: 'DELETE',
7 | // }).then(res => {
8 | // window.location.reload()
9 | // return res.json()
10 | // });
11 | // }
12 | // }
13 |
14 |
15 | var webinar = '/api/v1/video/'
16 |
17 | function deleteVideo(id) {
18 | console.log('Fired')
19 | var result = confirm("Want to delete?");
20 | if (result) {
21 | fetch(webinar + id, {
22 | method: 'DELETE',
23 | }).then(res => {
24 | window.location.reload()
25 | return res.json()
26 | });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/models/blog.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | //Schema setup
4 | const Schema = mongoose.Schema
5 | const blogSchema = new Schema({
6 | Title: {
7 | type: String,
8 | required: true,
9 | },
10 | AuthorName: String,
11 | AuthorEmail: String,
12 | AuthorLinkedIn: String,
13 | Category: String,
14 | Content: String,
15 | ShortDescription: String,
16 | Tags: String,
17 | CreatedDate: {
18 | type: Date,
19 | default: Date.now
20 | },
21 | Link: {
22 | type: String,
23 | default: ""
24 | },
25 | FileName: {
26 | type: String,
27 | default: "",
28 | },
29 | Status: {
30 | type: String,
31 | default: "in-review"
32 | }
33 | });
34 | module.exports = mongoose.model("Blog", blogSchema);
--------------------------------------------------------------------------------
/Mongodb/gridfs.js:
--------------------------------------------------------------------------------
1 | const multer = require('multer');
2 | const GridFsStorage = require('multer-gridfs-storage');
3 | const crypto = require('crypto');
4 | const path = require('path');
5 | const storage = new GridFsStorage({
6 | url: process.env.MONGO_DB_URL,
7 | file: (req, file) => {
8 | return new Promise((resolve, reject) => {
9 | crypto.randomBytes(16, (err, buf) => {
10 | if (err) {
11 | return reject(err);
12 | }
13 | const filename = buf.toString('hex') + path.extname(file.originalname);
14 | const fileInfo = {
15 | filename: filename,
16 | bucketName: 'uploads'
17 | };
18 | resolve(fileInfo);
19 | });
20 | });
21 | }
22 | });
23 | const upload = multer({
24 | storage
25 | });
26 |
27 | module.exports = upload
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Coding Club NIT Meghalaya
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 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "codingclubwebsite",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite.git"
13 | },
14 | "author": "",
15 | "license": "ISC",
16 | "bugs": {
17 | "url": "https://github.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite/issues"
18 | },
19 | "homepage": "https://github.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite#readme",
20 | "dependencies": {
21 | "bcrypt": "^5.0.1",
22 | "body-parser": "^1.19.0",
23 | "cookie-parser": "^1.4.5",
24 | "cors": "^2.8.5",
25 | "dotenv": "^10.0.0",
26 | "ejs": "^3.1.5",
27 | "express": "^4.17.1",
28 | "express-fileupload": "^1.2.1",
29 | "express-openid-connect": "^2.4.0",
30 | "file-upload": "^0.0.0",
31 | "froala-editor": "^4.0.1",
32 | "gridfs-stream": "^1.1.1",
33 | "jsonwebtoken": "^8.5.1",
34 | "loopback-ssl": "^1.0.4",
35 | "method-override": "^3.0.0",
36 | "mongoose": "^5.11.15",
37 | "morgan": "^1.10.0",
38 | "multer": "^1.4.2",
39 | "multer-gridfs-storage": "^4.2.0",
40 | "wysiwyg-editor-node-sdk": "^4.0.0"
41 | },
42 | "devDependencies": {
43 | "nodemon": "^2.0.7"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/public/Blog/showblog.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #ececec;
3 | font-family: 'Roboto', sans-serif;
4 | }
5 |
6 | .blog-container {
7 | margin-top: 60px;
8 | margin-left: 40px;
9 | }
10 |
11 | .tag-container {
12 | display: flex;
13 | flex-wrap: wrap;
14 | flex-direction: row;
15 | font-weight: 500;
16 | }
17 |
18 | .tag {
19 | border: 1px solid rgb(154, 168, 236);
20 | padding: 5px;
21 | border-radius: 18px;
22 | margin-top: 8px;
23 | color: rgb(109, 131, 242)
24 | }
25 |
26 | .tag:hover {
27 | background-color: rgb(166, 178, 236);
28 | color: whitesmoke;
29 | }
30 |
31 | .author {
32 | display: flex;
33 | flex-wrap: wrap;
34 | flex-direction: column;
35 | font-weight: 500;
36 | font-size: 18px;
37 | color: rgb(109, 131, 242)
38 | }
39 |
40 | .col {
41 | word-wrap: break-word;
42 | max-width: 70%;
43 | }
44 |
45 | #rightcol {
46 | position: fixed;
47 | float: right;
48 | right: 0;
49 | max-width: 30%;
50 | }
51 |
52 | @media screen and (max-width: 600px) {
53 | #rightcol {
54 | position: static;
55 | float: none;
56 | max-width: 100%;
57 | right: none;
58 | }
59 | img {
60 | max-width: 100%;
61 | }
62 | .col {
63 | word-wrap: break-word;
64 | max-width: 100%;
65 | }
66 | .blog-container {
67 | margin-top: 10px;
68 | margin-left: 10px;
69 | }
70 | }
--------------------------------------------------------------------------------
/Admin Pannel/resources.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const https = require('https')
4 | const Material = require('../models/material');
5 | const Video = require('../models/video');
6 | const checkAuth = require('../Authentication/middleware/check_auth');
7 |
8 |
9 | router.get("/addMaterial", checkAuth, function(req, res) {
10 | res.render("Admin/Resources Page/addMaterial");
11 | });
12 | router.get("/addVideo", checkAuth, function(req, res) {
13 | res.render("Admin/Resources Page/addVideo");
14 | });
15 | router.get("/resource_manager/:id", checkAuth, function(req, res) {
16 | if (req.params.id === "Material") {
17 | Material.find((err, obj) => {
18 | if (err) {
19 | res.send({
20 | "error": err.message
21 | });
22 | } else {
23 | res.render('Admin/Resources Page/ResourceManager', {
24 | obj: obj,
25 | id: req.params.id
26 | });
27 | }
28 | });
29 | } else {
30 | Video.find((err, obj) => {
31 | if (err) {
32 | res.send({
33 | "error": err.message
34 | });
35 | } else {
36 | res.render('Admin/Resources Page/ResourceManager', {
37 | obj: obj,
38 | id: req.params.id
39 | });
40 | }
41 | });
42 |
43 | }
44 |
45 | });
46 |
47 | module.exports = router
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Files Description:eyeglasses:
4 |
5 | * **index.js** is the main file that is the heart of our web application and contains the Routes defined for each event.
6 | * **views** directory contains the relevant pages and partials, the EJS templates, that render on each event.(these are basically the html files)
7 | * **public** directory contains neccesary CSS along with the assets
8 | * **package.json** file contains the information towards the various dependencies and packages
9 |
10 | ## Run it locally:computer:
11 |
12 | :camera::camera::camera::camera::camera::camera::camera:
13 | *Start with Smile*:smile::smile:
14 |
15 | 1. Install [NodeJS](https://nodejs.org/en/):arrow_double_down:
16 | 2. Install [mongodb](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/):arrow_double_down:
17 | 3. Create a empty file and Open in your favourite code Editor.....shh...[VS Code Editor](https://code.visualstudio.com/download):wink:
18 | 4. Open the terminal window and write
19 | ```
20 | git clone https://github.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite.git
21 | ```
22 | This will files from repository to your local computer.:clock1::relieved::sun_with_face:
23 | 5. Next thing to write on terminal is
24 | ```
25 | node index.js
26 | ```
27 | 6. **HURRAHHH**:boom: You completed all steps successfully go to [localhost:8000](http://localhost:8000/) on your browser and enjoy.
28 |
29 | 7. ***OHHH WAIT WAIT***, you forgot giving Star to the repository.:star::stuck_out_tongue::stuck_out_tongue_winking_eye:
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/public/Event/EventManager.js:
--------------------------------------------------------------------------------
1 | function myfun(href) {
2 | location.replace("/admin/event_manager/" + href);
3 | }
4 |
5 |
6 | var event_url = '/api/v1/event/'
7 |
8 | function deleteEvent(id) {
9 | console.log('Fired: ' + id)
10 | var result = confirm("Want to delete?");
11 | if (result) {
12 | fetch(event_url + id, {
13 | method: 'DELETE',
14 | }).then(res => {
15 | window.location.reload()
16 | return res.json()
17 | });
18 | }
19 | }
20 |
21 | var webinar = '/api/v1/webinar/'
22 |
23 | function deleteWebinar(id) {
24 | console.log('Fired')
25 | var result = confirm("Want to delete?");
26 | if (result) {
27 | fetch(webinar + id, {
28 | method: 'DELETE',
29 | }).then(res => {
30 | window.location.reload()
31 | return res.json()
32 | });
33 | }
34 | }
35 |
36 | var programming = '/api/v1/programming/'
37 |
38 | function deleteProgramming(id) {
39 | console.log('Fired')
40 | var result = confirm("Want to delete?");
41 | if (result) {
42 | fetch(programming + id, {
43 | method: 'DELETE',
44 | }).then(res => {
45 | window.location.reload()
46 | return res.json()
47 | });
48 | }
49 | }
50 |
51 | var achievement = '/api/v1/achievement/'
52 |
53 | function deleteAchievement(id) {
54 | console.log('Fired')
55 | var result = confirm("Want to delete?");
56 | if (result) {
57 | fetch(achievement + id, {
58 | method: 'DELETE',
59 | }).then(res => {
60 | window.location.reload()
61 | return res.json()
62 | });
63 | }
64 | }
--------------------------------------------------------------------------------
/api_v1/video.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Video = require('../models/video');
4 | const upload = require('../Mongodb/gridfs');
5 | const checkAuth = require('../Authentication/middleware/check_auth');
6 |
7 | router.get('/video', function (req, res) {
8 | Video.find((err, obj) => {
9 | if (err)
10 | res.status(500).json({
11 | err: err.message,
12 | });
13 | else {
14 | res.status(200).json({
15 | message: 'SUccessfull get request',
16 | count: obj.length,
17 | video_data: obj,
18 | });
19 | }
20 | }).sort({ _id: -1 });
21 | });
22 | router.post("/video", checkAuth, function (req, res) {
23 | let newVideo = req.body;
24 | Video.create(newVideo, function (err, obj) {
25 | if (err) {
26 | res.status(500).json({
27 | err: err.message,
28 | });
29 | } else {
30 | res.status(201).json({
31 | message: 'SUccessfull post request',
32 | count: obj.length,
33 | video_data: obj,
34 | });
35 | }
36 | });
37 | });
38 | router.delete('/video/:id', checkAuth, function (req, res, next) {
39 | Video.deleteOne({
40 | _id: req.params.id
41 | }, (err, obj) => {
42 | if (err) {
43 | res.status(500).json({
44 | err: err.message
45 | });
46 | } else {
47 | res.status(200).json({
48 | message: 'Data Successfully Deleted'
49 | });
50 | }
51 | });
52 | });
53 |
54 | module.exports = router
--------------------------------------------------------------------------------
/Admin Pannel/teams.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const teamMember = require('../models/teamMember');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const https = require('https')
9 | const checkAuth = require('../Authentication/middleware/check_auth');
10 | let gfs;
11 | db.once('open', () => {
12 | gfs = Grid(db.db, mongoose.mongo);
13 | gfs.collection('uploads');
14 | });
15 |
16 | router.get("/teammanager", checkAuth, function(req, res) {
17 |
18 | teamMember.find((err, obj) => {
19 | if (err) {
20 | res.status(500).json({
21 | error: err.message
22 | });
23 | } else {
24 | res.render("Admin/Teams Page/TeamManager", {
25 | obj: obj,
26 | })
27 | }
28 | });
29 | });
30 | router.post("/teammanager", checkAuth, function(req, res) {
31 | console.log(req.body);
32 | Team.find({
33 | $or: [{
34 | FirstName: req.body.firstname
35 | }, {
36 | DesignationName: req.body.firstname
37 | }]
38 | }, (err, obj) => {
39 | if (err) {
40 | res.status(500).json({
41 | error: err.message
42 | });
43 | } else {
44 | console.log(obj);
45 | res.render("Admin/Teams Page/TeamManager", {
46 | obj: obj,
47 | })
48 |
49 | }
50 | });
51 | });
52 | router.get("/addteammember", function(req, res) {
53 | res.render("Admin/Teams Page/addteammember")
54 |
55 | });
56 | module.exports = router
--------------------------------------------------------------------------------
/Admin Pannel/blog.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Blog = require('../models/blog');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const https = require('https')
9 | const checkAuth = require('../Authentication/middleware/check_auth');
10 | let gfs;
11 | db.once('open', () => {
12 | gfs = Grid(db.db, mongoose.mongo);
13 | gfs.collection('uploads');
14 | });
15 | router.get("/addBlog", (req, res) => {
16 | res.render("Admin/Blog Page/addBlog");
17 | });
18 | router.post("/blogmanager", checkAuth, function(req, res) {
19 | console.log(req.body);
20 | Blog.find({
21 | $or: [{
22 | AuthorName: req.body.Author
23 | }, {
24 | Title: req.body.Author
25 | }]
26 | }, (err, obj) => {
27 | if (err) {
28 | res.status(500).json({
29 | error: err.message
30 | });
31 | } else {
32 |
33 | res.render("Admin/Blog Page/BlogManager", {
34 | blogs: obj,
35 | })
36 |
37 | }
38 | });
39 | });
40 |
41 | router.get("/blogmanager", checkAuth, function(req, res) {
42 |
43 | Blog.find((err, obj) => {
44 | if (err) {
45 | res.status(500).json({
46 | error: err.message
47 | });
48 | } else {
49 | res.render("Admin/Blog Page/BlogManager", {
50 | blogs: obj,
51 | })
52 | }
53 | });
54 |
55 | });
56 |
57 | router.get("/addUser", checkAuth, function(req, res) {
58 | res.render("Admin/Login/addUser");
59 | });
60 |
61 | module.exports = router
--------------------------------------------------------------------------------
/views/Admin/Login/login.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Document
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | <%if(wrong==0){%>
28 |
29 | <%=msg%>
30 |
31 | <%}%>
32 |
33 |
34 |
35 |
36 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/views/Admin/Resources Page/addVideo.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddVideo
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Video to the database
19 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/views/Admin/Login/changepass.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Document
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | <%if(wrong==0){%>
28 |
29 | <%=msg%>
30 |
31 | <%}%>
32 |
33 |
34 |
35 |
36 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/api_v1/images.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const upload = require('../Mongodb/gridfs');
4 | const db = require('../Mongodb/connection');
5 | const Grid = require('gridfs-stream');
6 | const mongoose = require('mongoose');
7 | var FroalaEditor = require('../node_modules/wysiwyg-editor-node-sdk/lib/froalaEditor');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 | let gfs;
10 | db.once('open', () => {
11 | gfs = Grid(db.db, mongoose.mongo);
12 | gfs.collection('uploads');
13 | });
14 | router.get('/image/:filename', (req, res) => {
15 | gfs.files.findOne({
16 | filename: req.params.filename
17 | }, (err, file) => {
18 | //check if file
19 | if (!file || file.length === 0) {
20 | return res.status(404).json({
21 | err: 'No file Exists'
22 | });
23 | }
24 | //check if image
25 | if (file.contentType == 'image/jpeg' || file.contentType == 'image/png') {
26 | //Read output to the browser
27 | const readStream = gfs.createReadStream(file.filename);
28 | readStream.pipe(res);
29 | } else {
30 | res.status(404).json({
31 | err: 'Not an Image'
32 | });
33 | }
34 | })
35 | });
36 |
37 | router.post('/image_upload', checkAuth, upload.single('file'), function(req, res) {
38 | var url = "https://codingclubnitm.herokuapp.com/api/v1/image/" + req.file.filename;
39 | res.send({
40 | link: url
41 | });
42 | })
43 | router.delete('/image/del/:filename', checkAuth, (req, res) => {
44 | gfs.files.deleteOne({
45 | filename: req.params.filename
46 | }, (err, data) => {
47 |
48 | if (err) {
49 | console.log(err);
50 |
51 | return res.status(404).json({
52 | err: err.message
53 | });
54 | }
55 | res.status(200).json({
56 | message: "Image Succesfully Deleted",
57 | })
58 | });
59 | });
60 | module.exports = router
--------------------------------------------------------------------------------
/public/Blog/script.js:
--------------------------------------------------------------------------------
1 | var example = document.querySelector('#example');
2 | // console.log(example);
3 | var editor = new FroalaEditor(example, {
4 | imageUploadURL: "https://codingclubnitm.herokuapp.com/api/v1/image_upload",
5 | videoUpload: false,
6 | fileUpload: false,
7 | pastePlain: true,
8 | placeholderText: 'Write Your Blog here....',
9 | attribution: false,
10 | htmlExecuteScripts: true,
11 | spellcheck: true,
12 | emoticonsUseImage: false,
13 | toolbarButtons: {
14 | 'moreText': {
15 | 'buttons': ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', 'textColor', 'backgroundColor', 'inlineClass', 'inlineStyle', 'clearFormatting']
16 | },
17 | 'moreParagraph': {
18 | 'buttons': ['alignLeft', 'alignCenter', 'formatOLSimple', 'alignRight', 'alignJustify', 'formatOL', 'formatUL', 'paragraphFormat', 'paragraphStyle', 'lineHeight', 'outdent', 'indent', 'quote']
19 | },
20 | 'moreRich': {
21 | 'buttons': ['insertLink', 'insertCode', 'insertImage', 'insertVideo', 'insertTable', 'emoticons', 'fontAwesome', 'specialCharacters', 'embedly', 'insertFile', 'insertHR']
22 | },
23 | 'moreMisc': {
24 | 'buttons': ['undo', 'redo', 'fullscreen', 'print', 'getPDF', 'spellChecker', 'selectAll', 'html', 'help'],
25 | 'align': 'right',
26 | 'buttonsVisible': 2
27 | }
28 | },
29 | events: {
30 | 'image.removed': function($img) {
31 | var xhttp = new XMLHttpRequest();
32 | xhttp.onreadystatechange = function() {
33 |
34 | // Image was removed.
35 | if (this.readyState == 4 && this.status == 200) {
36 | console.log('image was deleted');
37 | }
38 | };
39 | var url = $img.attr('src');
40 | var filename = url.substring(url.lastIndexOf('/') + 1)
41 | xhttp.open("DELETE", "https://codingclubnitm.herokuapp.com/api/v1/image/del/" + filename, true);
42 | xhttp.send(JSON.stringify({
43 | src: $img.attr('src')
44 | }));
45 | }
46 | },
47 | height: 1000,
48 | });
--------------------------------------------------------------------------------
/views/Admin/Resources Page/addMaterial.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddMaterial
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Material to the database
19 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/views/Admin/Events Page/addAchievement.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 | AddAchievement
13 |
14 |
15 |
16 |
17 |
18 |
19 |
Add Achievement to The database
20 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/views/Admin/Events Page/updateAchievement.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 | AddAchievement
13 |
14 |
15 |
16 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/views/Admin/Events Page/addEvent.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddEventPoster
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Event to The Database
19 |
20 |
25 |
26 |
27 |
Start Date
28 |
29 |
30 |
34 |
35 |
36 |
44 |
45 | Event Link (if any):
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/Admin Pannel/event.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const https = require('https')
4 | const Event = require('../models/event');
5 | const Webinar = require('../models/Webinar');
6 | const Programming = require('../models/Programming');
7 | const Achievement = require('../models/achievement');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 |
10 |
11 | router.get("/addEvent", checkAuth, function(req, res) {
12 | res.render("Admin/Events Page/addEvent");
13 | });
14 | router.get("/addAchievement", checkAuth, function(req, res) {
15 | res.render("Admin/Events Page/addAchievement");
16 | });
17 | router.get("/addProgramming", checkAuth, function(req, res) {
18 | res.render("Admin/Events Page/addProgramming");
19 | });
20 | router.get("/addWebinar", checkAuth, function(req, res) {
21 | res.render("Admin/Events Page/addWebinar");
22 | });
23 |
24 | router.get("/event_manager", checkAuth, function(req, res) {
25 | Event.find((err, obj) => {
26 | if (err) {
27 | res.send({
28 | "error": err.message
29 | });
30 | } else {
31 | res.render('Admin/Events Page/EventManager', {
32 | obj: obj,
33 | id: 'Event'
34 | });
35 | }
36 | });
37 | });
38 | router.get("/event_manager/:id", function(req, res) {
39 |
40 | if (req.params.id == 'Event') {
41 | Event.find((err, obj) => {
42 |
43 | if (err) {
44 | res.send({
45 | "error": err.message
46 | });
47 | } else {
48 | res.render('Admin/Events Page/EventManager', {
49 | obj: obj,
50 | id: req.params.id
51 | });
52 | }
53 | });
54 | } else if (req.params.id == 'Webinar') {
55 | Webinar.find((err, obj) => {
56 | if (err) {
57 | res.send({
58 | "error": err.message
59 | });
60 | } else {
61 | res.render('Admin/Events Page/EventManager', {
62 | obj: obj,
63 | id: req.params.id
64 | });
65 | }
66 | });
67 | } else if (req.params.id == 'Programming') {
68 | Programming.find((err, obj) => {
69 | if (err) {
70 | res.send({
71 | "error": err.message
72 | });
73 | } else {
74 | res.render('Admin/Events Page/EventManager', {
75 | obj: obj,
76 | id: req.params.id
77 | });
78 | }
79 | });
80 | } else {
81 | Achievement.find((err, obj) => {
82 | if (err) {
83 | res.send({
84 | "error": err.message
85 | });
86 | } else {
87 | res.render('Admin/Events Page/EventManager', {
88 | obj: obj,
89 | id: req.params.id
90 | });
91 | }
92 | });
93 | }
94 | });
95 |
96 | module.exports = router
--------------------------------------------------------------------------------
/api_v1/event.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Event = require('../models/event');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 | let gfs;
10 | db.once('open', () => {
11 | gfs = Grid(db.db, mongoose.mongo);
12 | gfs.collection('uploads');
13 | });
14 | router.get("/event", function(req, res) {
15 | Event.find(function(err, obj) {
16 | if (err)
17 | res.status(500).json({
18 | err: err.message,
19 | });
20 | else {
21 | res.status(200).json({
22 | message: 'Successfull get request',
23 | count: obj.length,
24 | event_data: obj,
25 | });
26 | }
27 | }).sort({
28 | StartDate: -1
29 | });
30 | });
31 | router.get("/event/:id", (req, res, next) => {
32 | let Foundid = req.params.id;
33 | Event.findOne({
34 | _id: Foundid
35 | }, (err, obj) => {
36 | if (err) {
37 | res.status(500).json({
38 | err: err.message,
39 | });
40 | } else {
41 | res.status(200).json({
42 | message: 'Successful Get Request',
43 | count: obj.length,
44 | event_data: obj,
45 | });
46 | }
47 | });
48 | });
49 | router.post("/event", checkAuth, upload.single('EventPoster'), function(req, res) {
50 | let newEvent = req.body;
51 | newEvent["FileName"] = req.file.filename;
52 | Event.create(newEvent, (err, obj) => {
53 | if (err)
54 | res.status(500).json({
55 | err: err.message,
56 | });
57 | else
58 | res.status(201).json({
59 | message: 'Successfull post request',
60 | count: obj.length,
61 | event_data: obj,
62 | });
63 | });
64 | });
65 | router.delete('/event/:id', checkAuth, function(req, res, next) {
66 | Event.findOne({
67 | _id: req.params.id
68 | }, (err, obj) => {
69 | if (err) {
70 | res.status(500).json({
71 | err: err.message
72 | });
73 | } else {
74 | gfs.files.deleteOne({
75 | filename: obj.FileName
76 | }, (err, data) => {
77 | if (err) return res.status(404).json({
78 | err: err.message
79 | });
80 | else {
81 | Event.deleteOne({
82 | _id: req.params.id
83 | }, (err, obj) => {
84 | if (err) return res.status(404).json({
85 | err: err.message
86 | });
87 | else {
88 | res.status(200).json({
89 | message: 'Data and Image Sucessfully Deleted',
90 | });
91 | }
92 | });
93 | }
94 | });
95 | }
96 | });
97 | });
98 |
99 | module.exports = router
--------------------------------------------------------------------------------
/api_v1/project.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Project = require('../models/project');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 | let gfs;
10 | db.once('open', () => {
11 | gfs = Grid(db.db, mongoose.mongo);
12 | gfs.collection('uploads');
13 | });
14 | router.get("/project", function(req, res) {
15 | Project.find(function(err, obj) {
16 | if (err)
17 | res.status(500).json({
18 | err: err.message,
19 | });
20 | else
21 | res.status(200).json({
22 | message: 'Successfull get request',
23 | count: obj.length,
24 | project_data: obj,
25 | });
26 | }).sort({
27 | StartDate: 1
28 | });
29 | });
30 | router.get("/project/:id", (req, res, next) => {
31 | let Foundid = req.params.id;
32 | Project.findOne({
33 | _id: Foundid
34 | }, (err, obj) => {
35 | if (err) {
36 | res.status(500).json({
37 | err: err.message,
38 | });
39 | } else {
40 | res.status(200).json({
41 | message: 'Successful Get Request',
42 | count: obj.length,
43 | project_data: obj,
44 | });
45 | }
46 | });
47 | });
48 | router.post("/project", checkAuth, upload.single('projectImage'), function(req, res) {
49 | let data = req.body;
50 | data["FileName"] = req.file.filename;
51 | Project.create(data, (err, obj) => {
52 | if (err)
53 | res.status(500).json({
54 | err: err.message,
55 | });
56 | else
57 | res.status(201).json({
58 | message: 'Successfull post request',
59 | count: obj.length,
60 | project_data: obj,
61 | });
62 | });
63 | });
64 |
65 | router.delete('/project/:id', checkAuth, function(req, res, next) {
66 | Project.findOne({
67 | _id: req.params.id
68 | }, (err, obj) => {
69 | if (err) {
70 | res.status(500).json({
71 | err: err.message
72 | });
73 | } else {
74 | gfs.files.deleteOne({
75 | filename: obj.FileName
76 | }, (err, data) => {
77 | if (err) return res.status(404).json({
78 | err: err.message
79 | });
80 | else {
81 | Project.deleteOne({
82 | _id: req.params.id
83 | }, (err, obj) => {
84 | if (err) return res.status(404).json({
85 | err: err.message
86 | });
87 | else {
88 | res.status(200).json({
89 | message: 'Data and Image Sucessfully Deleted',
90 | });
91 | }
92 | });
93 | }
94 | });
95 | }
96 | });
97 | });
98 | module.exports = router
--------------------------------------------------------------------------------
/api_v1/webinarEvent.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Webinar = require('../models/Webinar');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 | let gfs;
10 | db.once('open', () => {
11 | gfs = Grid(db.db, mongoose.mongo);
12 | gfs.collection('uploads');
13 | });
14 | router.get('/webinar', function(req, res) {
15 | Webinar.find(function(err, obj) {
16 | if (err)
17 | res.status(500).json({
18 | err: err.message,
19 | });
20 | else {
21 | res.status(200).json({
22 | message: 'Successful Get Request',
23 | count: obj.length,
24 | webinar_data: obj,
25 | });
26 | }
27 | }).sort({
28 | StartDate: -1,
29 | });
30 | });
31 | router.get("/webinar/:id", (req, res, next) => {
32 | let Foundid = req.params.id;
33 | Webinar.findOne({
34 | _id: Foundid
35 | }, (err, obj) => {
36 | if (err) {
37 | res.status(500).json({
38 | err: err.message,
39 | });
40 | } else {
41 | res.status(200).json({
42 | message: 'Successful Get Request',
43 | count: obj.length,
44 | webinar_data: obj,
45 | });
46 | }
47 | });
48 | });
49 | router.post("/webinar", checkAuth, upload.single('Image'), function(req, res) {
50 | let newProgEvent = req.body;
51 | newProgEvent["FileName"] = req.file.filename;
52 | Webinar.create(newProgEvent, function(err, obj) {
53 | if (err)
54 | res.status(500).json({
55 | err: err.message,
56 | });
57 | else {
58 | res.status(201).json({
59 | message: 'Successful post Request',
60 | count: obj.length,
61 | webinar_data: obj,
62 | });
63 | }
64 | })
65 | });
66 | router.delete('/webinar/:id', checkAuth, function(req, res, next) {
67 | Webinar.findOne({
68 | _id: req.params.id
69 | }, (err, obj) => {
70 | if (err) {
71 | res.status(500).json({
72 | err: err.message
73 | });
74 | } else {
75 | gfs.files.deleteOne({
76 | filename: obj.FileName
77 | }, (err, data) => {
78 | if (err) return res.status(404).json({
79 | err: err.message
80 | });
81 | else {
82 | Webinar.deleteOne({
83 | _id: req.params.id
84 | }, (err, obj) => {
85 | if (err) return res.status(404).json({
86 | err: err.message
87 | });
88 | else {
89 | res.status(200).json({
90 | message: 'Data and Image Sucessfully Deleted',
91 | });
92 | }
93 | });
94 | }
95 | });
96 | }
97 | });
98 | });
99 | module.exports = router
--------------------------------------------------------------------------------
/views/Admin/Teams Page/TeamManager.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Team Manager
11 |
12 |
13 |
14 |
15 |
16 |
Admin
17 |
18 |
19 |
20 |
36 |
37 |
38 | <%for(let i=0;i
39 |
40 |
41 |
42 | <%=obj[i].FirstName%>
43 | <%=obj[i].LastName%>
44 |
45 |
46 | <%=obj[i].DesignationName%>
47 |
48 |
Update
49 |
Delete
50 |
51 |
52 | <%}%>
53 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/views/Admin/Events Page/addWebinar.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddWebinar
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Webinar Event to The Database
19 |
20 |
25 |
26 |
27 |
Start Date
28 |
29 |
30 |
34 |
38 |
39 |
40 |
41 |
42 |
43 | Short Description of Event
44 |
45 |
46 | Registration Link:
47 |
48 |
49 |
50 | Any Other Link(if any) :
51 |
52 |
53 |
54 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/views/Admin/Events Page/addProgramming.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddProgramming
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Programming Event to The Database
19 |
20 |
25 |
26 |
27 |
Start Date
28 |
29 |
30 |
34 |
38 |
39 |
40 |
41 |
42 | Short Description of Event
43 |
44 |
45 | Registration Link:
46 |
47 |
48 |
49 | Any Other Link(if any) :
50 |
51 |
52 |
53 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 🤍 Club Website 🤍
3 |
4 |
5 | 
6 | 
7 | 
8 | [](https://github.com/GovindCodes)
9 |
10 |
11 | ## Instructions: 🙅🏼 🙅🏼♂️
12 |
13 | ### 1. 🔰 Setup Your computer
14 | ##### Download [Git](https://git-scm.com/download) and after installing go to git bash or cmd window and setup your identity using
15 | `git config --global user.name "Github wala username"`
16 | `git config --global user.email example@gmail.com`
17 |
18 | ##### Download and install [VS code editor](https://code.visualstudio.com/download) for getting good feel while writing codes
19 |
20 | ### 2. 🔰Star this Repository
21 |
22 | ###### You can star ⭐ this repository on GitHub by navigating at the top of this repository.
23 |
24 |
25 | ### 3. 🔰Clone the Repository
26 |
27 | ###### To make your own local copy of the repository you would like to contribute to, let’s first open up a terminal window(Command prompt).
28 |
29 | ###### We’ll use the `git clone` command along with the URL of the repository.
30 |
31 |
32 | `git clone https://github.com/Coding-Club-NIT-Meghalaya/CodingClubWebsite.git`
33 |
34 | ###### Now we have the copy of file in our computer (you can cross verify it by going to the location showing in Command Prompt)
35 |
36 |
37 | ### 4. 🔀Navigate to the repository folder and make changes
38 |
39 | ###### to navigate from command prompt we have simple command called as `cd folderName` Here we will do:
40 |
41 | ##### ` cd CodingClubWebsite`
42 |
43 | #### Make Changes Locally
44 | ##### For Ex:
45 | ##### Open the folder in VS code manually or use `code .` in command prompt it will directly open the all the files in editor.
46 |
47 | ##### Add your changes
48 |
49 | ###### Once you have modified existing files or added new files to the project, you can add them to your local repository, which you can do in two stages- (First Staging and then Commiting)
50 |
51 | ###### For Staging we will use `git add` command with dot(.) that means stage all changes
52 |
53 | ##### `git add .`
54 |
55 | ###### Next, we’ll want to record the changes that we made to the repository with the `git commit` command.
56 |
57 | ###### The commit message is an important aspect of your code contribution; it helps the other contributors fully understand the change you have made, why you made it, and how significant it is.
58 |
59 | ###### If you have a very short message, you can record that with the -m flag and the message in quotes:
60 |
61 |
62 | ##### `git commit -m "Added any Feature"`
63 |
64 | ###### At this point you can use the git push command to push the changes github repository:
65 |
66 | `git push origin main`
67 |
68 |
69 |
70 | #### :zap::zap: Hurray you have contributed to the repository. Go and cross verify it in Github.
71 |
72 | ### 5. 🔁Update Local Repository
73 |
74 | ###### While working on a project alongside other contributors, it is important for you to keep your local repository up-to-date with the project. To keep your local copy of the code base updated, you’ll need to sync the changes mage by others by pulling the changes by others.
75 |
76 | ###### For this we use:
77 | ###### `git pull` or `git pull origin main`
78 | ###### After writing this on command prompt all the files in Github repository will come to your computer. It is recommended to do this before pushing the code to repository.
79 |
80 |
81 |
82 | ## 👑 👑 Hurray!!! WE just got closer to COMPLETING Website. 😃
83 |
84 |
85 | ### 🖤💯💥 Thanks to our awesome contributors 💥💯🖤
86 |
87 |
88 |
90 |
92 |
93 |
--------------------------------------------------------------------------------
/api_v1/material.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Materials = require('../models/material');
4 | const upload = require('../Mongodb/gridfs');
5 | const checkAuth = require('../Authentication/middleware/check_auth');
6 | router.get('/material', function (req, res) {
7 | Materials.find((err, obj) => {
8 | if (err)
9 | res.status(500).json({
10 | err: err.message,
11 | });
12 | else {
13 | res.status(200).json({
14 | message: 'Successfull Get Request',
15 | count: obj.length,
16 | material_data: obj,
17 | });
18 | }
19 | }).sort({ Year: -1 });
20 | });
21 | router.post("/material", checkAuth, function (req, res) {
22 | let newData = req.body;
23 | let getYear = newData.AcademicYear;
24 | Materials.findOne({
25 | Year: getYear
26 | }, function (err, foundData) {
27 | if (err) {
28 | res.status(500).json({
29 | err: err.message,
30 | });
31 | } else {
32 | if (foundData === null) {
33 | let newobj = {
34 | Year: getYear,
35 | Field: {
36 | Orientation: {
37 | Event: [],
38 | },
39 | Assignment: {
40 | Event: [],
41 | },
42 | Presentation: {
43 | Event: [],
44 | }
45 | }
46 | }
47 | Materials.create(newobj, function (err, newBlog) {
48 | if (err) {
49 | res.status(500).json({
50 | err: err.message,
51 | });
52 | } else {
53 | var str = "Field." + newData.Field + ".Event";
54 | Materials.findOneAndUpdate({
55 | Year: getYear
56 | }, {
57 | $push: {
58 | [str]: {
59 | Link: newData.Link,
60 | Name: newData.Name
61 | }
62 | }
63 | }, null, function (err, docs) {
64 | if (err) {
65 | res.status(500).json({
66 | err: err.message,
67 | });
68 | } else {
69 | res.status(201).json({
70 | message: 'Successfull Post Request',
71 | count: docs.length,
72 | material_data: docs,
73 | });
74 | }
75 | });
76 | }
77 | });
78 |
79 | } else {
80 | var str = "Field." + newData.Field + ".Event";
81 | Materials.findOneAndUpdate({
82 | Year: getYear
83 | }, {
84 | $push: {
85 | [str]: {
86 | Link: newData.Link,
87 | Name: newData.Name
88 | }
89 | }
90 | }, null, function (err, docs) {
91 | if (err) {
92 | res.status(500).json({
93 | err: err.message,
94 | });
95 | } else {
96 | res.status(201).json({
97 | message: 'Successfull Post Request',
98 | count: docs.length,
99 | material_data: docs,
100 | });
101 | }
102 | });
103 | }
104 | }
105 | });
106 | });
107 | module.exports = router
--------------------------------------------------------------------------------
/views/Admin/Projects Page/addProject.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddProject
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Project to The database
19 |
20 |
31 |
32 |
33 |
Start Date:
34 |
35 |
36 |
40 |
41 |
42 |
43 | Short Description of Project
44 |
45 |
46 |
47 | Full Description of Project
48 |
49 |
50 |
51 | Project Github Link:
52 |
53 |
54 |
55 | Live Project Link (if any):
56 |
57 |
58 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/views/Admin/Events Page/updateProgramming.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddProgramming
12 |
13 |
14 |
15 |
16 |
17 |
18 |
Add Programming Event to The Database
19 |
20 |
25 |
41 |
42 |
43 | <%=arr.ShortDescription%>
44 | Short Description of Event
45 |
46 |
47 | Registration Link:
48 |
49 |
50 |
51 | Any Other Link(if any) :
52 |
53 |
54 |
55 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/views/Admin/Blog Page/BlogManager.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Blog Manager
11 |
12 |
13 |
14 |
15 |
16 |
Admin
17 |
18 |
19 |
20 |
35 |
36 |
37 |
38 | <%for(let i=0;i
39 |
40 |
41 |
42 | <%=blogs[i].Title%>
43 | <%if(blogs[i].Status=="in-review"){%>
44 |
45 |
46 | Make Published
47 |
48 | <%}else{%>
49 |
50 |
51 | Make Published
52 |
53 | <%}%>
54 |
55 |
56 | By:
57 | <%=blogs[i].AuthorName%>
58 |
59 |
60 | <%=blogs[i].ShortDescription%>
61 |
62 |
Read
63 |
Update
64 |
Delete
65 |
66 |
67 | <%}%>
68 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/views/Admin/Teams Page/addteammember.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddUser
12 |
13 |
14 |
15 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/views/Admin/Resources Page/ResourceManager.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Admin
12 |
13 |
14 |
15 |
16 |
17 |
Admin
18 |
19 |
20 |
21 |
32 |
33 |
34 |
35 |
36 |
Material
37 |
Video
38 |
39 | <% if(id=='Material'){%>
40 |
Add Material
41 | <%for(let i=0;i
42 | <%for(let j=0;j
43 |
44 |
45 |
46 | <%=obj[i].Field.Orientation.Event[j].Name%>
47 |
48 |
Type: Orientation
49 |
Session:
50 | <%=obj[i].Year%>
51 |
52 |
View
53 |
Delete
54 |
55 |
56 | <%}%>
57 | <%}}else{%>
58 | Add Video
59 | <%for(let i=0;i
60 |
61 |
62 |
63 | Title:
64 | <%=obj[i].Title%>
65 |
66 |
View
67 |
Delete
68 |
69 |
70 | <%}}%>
71 |
72 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/views/Admin/Teams Page/updateTeam.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 | AddUser
12 |
13 |
14 |
15 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var express = require("express");
2 | var app = express();
3 | const path = require('path');
4 | const crypto = require('crypto');
5 | const methodOverride = require('method-override');
6 | const bodyParser = require("body-parser");
7 | const morgan = require('morgan');
8 | const db = require('./Mongodb/connection');
9 | const checkAuth = require('./Authentication/middleware/check_auth');
10 | var cors = require('cors');
11 | const port = process.env.PORT || 8000;
12 | var cookieParser = require('cookie-parser');
13 | app.use(cookieParser());
14 | require('dotenv').config();
15 | const {
16 | connected
17 | } = require("process");
18 |
19 | app.use(bodyParser.urlencoded({
20 | extended: true
21 | }));
22 | app.use(bodyParser.json());
23 | app.use(morgan('dev'));
24 | app.use(express.urlencoded());
25 | app.use(cors());
26 | app.use(methodOverride('_method'));
27 |
28 | app.use(express.static(path.join(__dirname, 'public')));
29 | app.set("views", __dirname + "/views");
30 | app.set("view engine", "ejs");
31 | const {
32 | response
33 | } = require("express");
34 | app.use('/api/v1/', require('./api_v1/project'), require('./api_v1/achievement'), require('./api_v1/event'),
35 | require('./api_v1/programmingEvent'), require('./api_v1/images'), require('./api_v1/webinarEvent'), require('./api_v1/blog'), require('./api_v1/material'), require('./api_v1/team'), require('./api_v1/video'));
36 | var Blog = require('./models/blog');
37 | app.use('/auth', require('./Authentication/routes/user'));
38 | app.use('/admin', require('./Admin Pannel/admin'), require('./Admin Pannel/teams'), require('./Admin Pannel/blog'), require('./Admin Pannel/event'), require('./Admin Pannel/project'), require('./Admin Pannel/resources'));
39 |
40 | app.get('/', function(req, res) {
41 |
42 | res.status(200).json({
43 | Blog: {
44 | url: "https://codingclubnitm.herokuapp.com/api/v1/blog"
45 | },
46 | Events: {
47 | UpcomingEvent: {
48 | url: "https://codingclubnitm.herokuapp.com/api/v1/event"
49 | },
50 | ProgrammingEvent: {
51 | url: "https://codingclubnitm.herokuapp.com/api/v1/programming"
52 | },
53 | Webinar: {
54 | url: "https://codingclubnitm.herokuapp.com/api/v1/webinar"
55 | },
56 | Achievement: {
57 | url: "https://codingclubnitm.herokuapp.com/api/v1/achievement"
58 | }
59 | },
60 | Project: {
61 | url: "https://codingclubnitm.herokuapp.com/api/v1/project"
62 | },
63 | Resources: {
64 | Materials: {
65 | url: "https://codingclubnitm.herokuapp.com/api/v1/material"
66 | },
67 | Video: {
68 | url: "https://codingclubnitm.herokuapp.com/api/v1/video"
69 | }
70 | },
71 | Teams: {
72 | url: "https://codingclubnitm.herokuapp.com/api/v1/teammember"
73 |
74 | }
75 | });
76 | });
77 | app.get("/blog/:id", function(req, res) {
78 | var id = req.params.id;
79 | Blog.find({
80 | _id: id
81 | }, function(err, data) {
82 | if (err) {
83 | res.status(500).send(err.error);
84 | } else {
85 | var match = getHashTags(data[0].Tags);
86 | console.log(match);
87 | var url = "https://codingclubnitm.herokuapp.com/blog/" + data[0]._id;
88 | var imageurl = "https://codingclubnitm.herokuapp.com/api/v1/image/23653886ca4150e80f80a4cc5ca82d73.jpg"
89 | res.render('Blog/showBlog', {
90 | blog: data,
91 | match: match,
92 | url: url,
93 | imageurl: imageurl,
94 | });
95 | }
96 | });
97 | });
98 | app.use((req, res, next) => {
99 | const error = new Error('Not Found');
100 | error.status = 404;
101 | next(error);
102 | });
103 | app.use((error, req, res, next) => {
104 | res.status(error.status || 500);
105 | res.json({
106 | error: {
107 | message: error.message,
108 | },
109 | });
110 | });
111 | app.use((req, res, next) => {
112 | res.header("Access-Control-Allow-Origin", "*");
113 | res.header("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Authorization");
114 | if (req.method === 'OPTIONS') {
115 | res.header('Access-Control-Allow-Methods', 'PUT,POST,DELETE,PATCH,GET');
116 | res.status(200).json({});
117 | }
118 | next();
119 | });
120 |
121 | function getHashTags(inputText) {
122 | var regex = /(?:^|\s)(?:#)([a-zA-Z\d]+)/gm;
123 | var matches = [];
124 | var match;
125 |
126 | while ((match = regex.exec(inputText))) {
127 | matches.push(match[1]);
128 | }
129 |
130 | return matches;
131 | }
132 | app.listen(port, () => {
133 | console.log(`Server running on port: ${port}`);
134 | });
--------------------------------------------------------------------------------
/api_v1/programmingEvent.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const upload = require('../Mongodb/gridfs');
4 | const db = require('../Mongodb/connection');
5 | const Grid = require('gridfs-stream');
6 | const mongoose = require('mongoose');
7 | const Programming = require('../models/Programming');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 | const https = require('https');
10 | let gfs;
11 | db.once('open', () => {
12 | gfs = Grid(db.db, mongoose.mongo);
13 | gfs.collection('uploads');
14 | });
15 | router
16 | router.get('/programming', function(req, res) {
17 | Programming.find(function(err, obj) {
18 | if (err)
19 | res.status(500).json({
20 | err: err.message,
21 | });
22 | else {
23 | res.status(200).json({
24 | message: 'Successfull get request',
25 | count: obj.length,
26 | programming_data: obj,
27 | });
28 | }
29 | }).sort({
30 | StartDate: -1,
31 | });
32 | });
33 | router.post("/programming", checkAuth, upload.single('Image'), function(req, res) {
34 | let newProgEvent = req.body;
35 | console.log(newProgEvent);
36 | newProgEvent["FileName"] = req.file.filename;
37 | Programming.create(newProgEvent, function(err, obj) {
38 | if (err)
39 | res.status(500).json({
40 | err: err.message,
41 | })
42 | else {
43 | res.status(201).json({
44 | message: 'Successfull post request',
45 | count: obj.length,
46 | programming_data: obj,
47 | });
48 | }
49 | });
50 | });
51 |
52 | router.delete('/programming/:id', checkAuth, function(req, res, next) {
53 | Programming.findOne({
54 | _id: req.params.id
55 | }, (err, obj) => {
56 | if (err) {
57 | res.status(500).json({
58 | err: err.message
59 | });
60 | } else {
61 | gfs.files.deleteOne({
62 | filename: obj.FileName
63 | }, (err, data) => {
64 | if (err) return res.status(404).json({
65 | err: err.message
66 | });
67 | else {
68 | Programming.deleteOne({
69 | _id: req.params.id
70 | }, (err, obj) => {
71 | if (err) return res.status(404).json({
72 | err: err.message
73 | });
74 | else {
75 | res.status(200).json({
76 | message: 'Data and Image Sucessfully Deleted',
77 | });
78 | }
79 | });
80 | }
81 | });
82 | }
83 | });
84 | });
85 | router.get("/updateprogramming/:id", (req, res) => {
86 | Programming.findOne({
87 | _id: req.params.id
88 | }, (err, obj) => {
89 | if (err) {
90 | res.status(500).json({
91 | error: err.message
92 | });
93 | } else {
94 | res.render("Admin/Events Page/updateProgramming", {
95 | arr: obj
96 | })
97 | }
98 | })
99 | });
100 | router.post('/update/programming/:id', upload.single('Image'), function(req, res) {
101 | let newData = req.body;
102 | console.log(req.body);
103 | if (req.file != undefined) {
104 | Programming.findOne({
105 | _id: req.params.id
106 | }, (err, obj) => {
107 | if (err) {
108 | res.status(500).json({
109 | error: err.message
110 | });
111 | } else {
112 | const options = {
113 | hostname: 'codingclubnitm.herokuapp.com',
114 | path: '/api/v1/image/del/' + req.file.filename,
115 | method: 'DELETE'
116 | }
117 | const hreq = https.request(options, hres => {
118 | console.log(`statusCode: ${hres.statusCode}`)
119 | console.log("sucessfull")
120 | })
121 | hreq.on('error', error => {
122 | console.error(error)
123 | })
124 | hreq.end()
125 | }
126 | })
127 | newData["FileName"] = req.file.filename;
128 | }
129 | console.log(newData);
130 | Programming.updateOne({
131 | _id: req.params.id
132 | }, newData, (err, obj) => {
133 | if (err) {
134 | res.status(500).json({
135 | error: err.message,
136 | });
137 | } else {
138 | res.status(201).json({
139 | message: 'Successfully Updated',
140 | });
141 | }
142 | })
143 | });
144 | module.exports = router
--------------------------------------------------------------------------------
/views/Admin/admin.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Admin
12 |
13 |
14 |
15 |
16 |
17 |
Admin
18 |
19 |
20 |
21 |
22 |
31 |
32 |
Welcome,
33 | <%=name%>
34 |
35 |
36 |
37 |
38 |
39 |
40 |
55 | <%if(role=='admin'){%>
56 |
87 | <%}%>
88 |
89 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/api_v1/team.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const TeamMember = require('../models/teamMember');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const checkAuth = require('../Authentication/middleware/check_auth');
9 | let gfs;
10 | db.once('open', () => {
11 | gfs = Grid(db.db, mongoose.mongo);
12 | gfs.collection('uploads');
13 | });
14 | router.get("/teammember", function(req, res) {
15 |
16 | TeamMember.find(function(err, obj) {
17 | if (err)
18 | res.status(500).json({
19 | err: err.message,
20 | });
21 | else
22 | res.status(200).json({
23 | message: 'Succesfull get request',
24 | count: obj.length,
25 | team_data: obj,
26 | });
27 | }).sort({
28 | Designation: 1
29 | });
30 | });
31 | router.get("/teammember/:id", (req, res, next) => {
32 | let Foundid = req.params.id;
33 | TeamMember.findOne({
34 | _id: Foundid
35 | }, (err, obj) => {
36 | if (err) {
37 | res.status(500).json({
38 | err: err.message,
39 | });
40 | } else {
41 | res.status(200).json({
42 | message: 'Successful Get Request',
43 | count: obj.length,
44 | Team_data: obj,
45 | });
46 | }
47 | });
48 | });
49 | router.post("/teammember", checkAuth, upload.single('profileImage'), function(req, res) {
50 | let data = req.body;
51 | data["filename"] = req.file.filename;
52 | TeamMember.create(data, (err, obj) => {
53 | if (err)
54 | res.status(500).json({
55 | err: err.message,
56 | });
57 | else
58 | res.status(201).json({
59 | message: 'Succesfull post request',
60 | count: obj.length,
61 | team_data: obj,
62 | });
63 | });
64 | });
65 | router.get("/update/teammember/:id", (req, res, next) => {
66 | let Foundid = req.params.id;
67 | TeamMember.findOne({
68 | _id: Foundid
69 | }, (err, obj) => {
70 | if (err) {
71 | res.status(500).json({
72 | err: err.message,
73 | });
74 | } else {
75 | res.render("Admin/Teams Page/updateTeam", {
76 | arr: obj,
77 | });
78 | }
79 | });
80 | });
81 | router.post('/update/teammember/:id', upload.single('userImage'), function(req, res) {
82 | let newData = req.body;
83 | console.log(req.body);
84 | if (req.file != undefined) {
85 | TeamMember.findOne({
86 | _id: req.params.id
87 | }, (err, obj) => {
88 | if (err) {
89 | res.status(500).json({
90 | error: err.message
91 | });
92 | } else {
93 |
94 | const options = {
95 | hostname: 'codingclubnitm.herokuapp.com',
96 | path: '/api/v1/image/del/' + req.file.filename,
97 | method: 'DELETE'
98 | }
99 | const hreq = https.request(options, hres => {
100 | console.log(`statusCode: ${hres.statusCode}`)
101 | console.log("sucessfull")
102 | })
103 | hreq.on('error', error => {
104 | console.error(error)
105 | })
106 | hreq.end()
107 | }
108 | })
109 | newData["FileName"] = req.file.filename;
110 | }
111 | TeamMember.updateOne({
112 | _id: req.params.id
113 | }, newData, (err, obj) => {
114 | if (err) {
115 | res.status(500).json({
116 | error: err.message,
117 | });
118 | } else {
119 | res.status(201).json({
120 | message: 'Successfully Updated TeamMember',
121 | });
122 | }
123 | })
124 | });
125 | router.delete('/teammember/:id', checkAuth, function(req, res, next) {
126 | TeamMember.findOne({
127 | _id: req.params.id
128 | }, (err, obj) => {
129 | if (err) {
130 | res.status(500).json({
131 | err: err.message
132 | });
133 | } else {
134 | gfs.files.deleteOne({
135 | filename: obj.FileName
136 | }, (err, data) => {
137 | if (err) return res.status(404).json({
138 | err: err.message
139 | });
140 | else {
141 | TeamMember.deleteOne({
142 | _id: req.params.id
143 | }, (err, obj) => {
144 | if (err) return res.status(404).json({
145 | err: err.message
146 | });
147 | else {
148 | res.status(200).json({
149 | message: 'Data and Image Sucessfully Deleted',
150 | });
151 | }
152 | });
153 | }
154 | });
155 | }
156 | });
157 | });
158 |
159 | module.exports = router
--------------------------------------------------------------------------------
/views/Blog/showBlog.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | />
8 |
9 |
10 |
11 | />
12 | Blog
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
Home
29 |
30 |
31 |
32 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | <%=blog[0].CreatedDate.toDateString()%>
52 |
53 |
54 |
10min read
55 |
56 |
57 | <%=blog[0].Title%>
58 |
59 |
60 |
61 | <%-blog[0].Content%>
62 |
63 |
64 |
65 |
Tags
66 |
67 | <%for(let i=0;i
68 |
69 | #
70 | <%=match[i]%>
71 |
72 | <%}%>
73 |
74 |
75 |
Author
76 |
77 |
<%=blog[0].AuthorName%>
78 |
80 |
81 |
Share
82 |
83 |
84 |
85 |
95 |
96 |
97 |
98 |
data-layout="button_count">
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/views/Admin/Blog Page/updateBlog.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 | AddBlog
13 |
14 |
15 |
16 |
17 |
18 |
19 |
Welcome to CCNITM Blogs
20 |
21 |
26 |
27 |
28 |
Author Name
29 |
30 |
31 |
32 |
Author Email
33 |
34 |
35 |
36 |
Linked Profile Link
37 |
38 |
39 |
40 |
41 | Choose Category
42 | Competitive Programming
43 | Web Development
44 | Machine Learning
45 | Network Security
46 | App Development
47 |
48 | Write Your Blog Here (Please do not use copy-paste from outside
49 | website)
50 |
51 |
52 |
53 | <%=arr.ShortDescription%>
54 | Short Description of the Blog(less then 200 words)
55 |
56 |
57 | <%=arr.Tags%>
58 | Related Tags (Please add a # before every tag)
59 |
60 | Any Link
61 |
62 | Link(if any)
63 |
64 |
65 |
73 |
74 |
75 |
76 |
77 |
78 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/api_v1/achievement.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Achievement = require('../models/achievement');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const checkAuth = require('../Authentication/middleware/check_auth');
8 | const mongoose = require('mongoose');
9 | let gfs;
10 | db.once('open', () => {
11 | gfs = Grid(db.db, mongoose.mongo);
12 | gfs.collection('uploads');
13 | });
14 | router.get('/achievement', function (req, res, next) {
15 | Achievement.find(function (err, obj) {
16 | if (err)
17 | res.status(500).json({
18 | err: err.message
19 | });
20 | else {
21 | res.status(200).json({
22 | message: 'Successful Get Request',
23 | count: obj.length,
24 | achievement_data: obj,
25 | });
26 | }
27 | }).sort({
28 | Date: -1,
29 | });
30 | });
31 | router.get("/achievement/:id", (req, res, next) => {
32 | let Foundid = req.params.id;
33 | Achievement.findOne({
34 | _id: Foundid
35 | }, (err, obj) => {
36 | if (err) {
37 | res.status(500).json({
38 | err: err.message,
39 | });
40 | } else {
41 | res.status(200).json({
42 | message: 'Successful Get Request',
43 | count: obj.length,
44 | achievement_data: obj,
45 | });
46 | }
47 | });
48 | });
49 | router.post("/achievement", checkAuth, upload.single('achievementImage'), function (req, res, next) {
50 | let newAchievement = {
51 | Name: req.body.Name,
52 | Date: Date.now(),
53 | Description: req.body.Description,
54 | Link: req.body.Link,
55 | FileName: req.file.filename,
56 | }
57 | console.log(req);
58 | console.log(req.file);
59 | Achievement.create(newAchievement, (err, obj) => {
60 | if (err)
61 | res.json({
62 | err: err.message,
63 | });
64 | else
65 | res.status(201).json({
66 | message: 'Successfully Created',
67 | added_achievement: obj,
68 | });
69 | });
70 | });
71 | router.delete('/achievement/:id', checkAuth, function (req, res, next) {
72 | Achievement.findOne({
73 | _id: req.params.id
74 | }, (err, obj) => {
75 | if (err) {
76 | res.status(500).json({
77 | err: err.message
78 | });
79 | } else {
80 | gfs.files.deleteOne({
81 | filename: obj.FileName
82 | }, (err, data) => {
83 | if (err) return res.status(404).json({
84 | err: err.message
85 | });
86 | else {
87 | Achievement.deleteOne({
88 | _id: req.params.id
89 | }, (err, obj) => {
90 | if (err) return res.status(404).json({
91 | err: err.message
92 | });
93 | else {
94 | res.status(200).json({
95 | message: 'Data and Image Sucessfully Deleted',
96 | });
97 | }
98 | });
99 | }
100 | });
101 | }
102 | });
103 | });
104 | router.get("/update/achievement/:id", (req, res, next) => {
105 | let Foundid = req.params.id;
106 | Achievement.findOne({
107 | _id: Foundid
108 | }, (err, obj) => {
109 | if (err) {
110 | res.status(500).json({
111 | err: err.message,
112 | });
113 | } else {
114 | // let Date = new Date(obj.Date);
115 | var date = new Date(obj.Date);
116 | console.log(date);
117 | var curr_date = date.getDate();
118 |
119 | var curr_month = date.getMonth() + 1;
120 |
121 | var curr_year = date.getFullYear();
122 |
123 |
124 | date = curr_year + "-" + curr_month + "-" + curr_date;
125 | console.log(date);
126 | res.render("Admin/Events Page/updateAchievement", {
127 | obj: obj,
128 | date: date,
129 | });
130 | }
131 | });
132 | });
133 | router.post('/update/achievement/:id', upload.single('achievementImage'), function (req, res) {
134 | let newData = req.body;
135 | console.log(req.body);
136 | if (req.file != undefined) {
137 | Achievement.findOne({
138 | _id: req.params.id
139 | }, (err, obj) => {
140 | if (err) {
141 | res.status(500).json({
142 | error: err.message
143 | });
144 | } else {
145 |
146 | const options = {
147 | hostname: 'codingclubnitm.herokuapp.com',
148 | path: '/api/v1/image/del/' + req.file.filename,
149 | method: 'DELETE'
150 | }
151 | const hreq = https.request(options, hres => {
152 | console.log(`statusCode: ${hres.statusCode}`)
153 | console.log("sucessfull")
154 | })
155 | hreq.on('error', error => {
156 | console.error(error)
157 | })
158 | hreq.end()
159 | }
160 | })
161 | newData["FileName"] = req.file.filename;
162 | }
163 | Achievement.updateOne({
164 | _id: req.params.id
165 | }, newData, (err, obj) => {
166 | if (err) {
167 | res.status(500).json({
168 | error: err.message,
169 | });
170 | } else {
171 | res.status(201).json({
172 | message: 'Successfully Updated Achievement',
173 | });
174 | }
175 | })
176 | });
177 | module.exports = router
--------------------------------------------------------------------------------
/views/Admin/Events Page/EventManager.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Admin
12 |
13 |
14 |
15 |
16 |
17 |
Admin
18 |
19 |
20 |
21 |
32 |
33 |
34 |
35 |
36 |
Event
37 |
Programming Event
38 |
Webinar Event
39 |
Achievement
40 | <% if(id=='Event'){%>
41 |
Add Event
42 | <%for(let i=0;i
43 |
44 |
45 |
46 | <%=obj[i].EventName%>
47 |
48 |
49 | Delete
50 |
51 |
52 | <%}}else if(id=='Programming'){%>
53 | Add Programming Event
54 | <%for(let i=0;i
55 |
56 |
57 |
58 | <%=obj[i].Title%>
59 |
60 |
Update
61 |
Delete
62 |
63 |
64 | <%}}else if(id=='Webinar'){%>
65 | Add Webinar Event
66 | <%for(let i=0;i
67 |
68 |
69 |
70 | <%=obj[i].Title%>
71 |
72 |
73 | Delete
74 |
75 |
76 | <%}}else{%>
77 | Add Achievement
78 | <%for(let i=0;i
79 |
80 |
81 |
82 | <%=obj[i].Name%>
83 |
84 |
Update
85 |
Delete
86 |
87 |
88 |
89 | <%}}%>
90 |
91 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/api_v1/blog.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const Blog = require('../models/blog');
4 | const upload = require('../Mongodb/gridfs');
5 | const db = require('../Mongodb/connection');
6 | const Grid = require('gridfs-stream');
7 | const mongoose = require('mongoose');
8 | const https = require('https')
9 | const checkAuth = require('../Authentication/middleware/check_auth');
10 | let gfs;
11 | db.once('open', () => {
12 | gfs = Grid(db.db, mongoose.mongo);
13 | gfs.collection('uploads');
14 | });
15 | router.get('/blog', function(req, res) {
16 | Blog.find({
17 | Status: "published"
18 | }, (err, obj) => {
19 | if (err) {
20 | res.status(500).json({
21 | err: err.message,
22 | });
23 | } else {
24 | res.status(200).json({
25 | message: 'Successfull Get Request',
26 | count: obj.length,
27 | blog_data: obj,
28 | });
29 | }
30 | }).sort({
31 | CreatedDate: -1,
32 | });
33 | });
34 | router.get("/blog/:id", (req, res) => {
35 | let Foundid = req.params.id;
36 | Blog.findOne({
37 | _id: Foundid
38 | }, (err, obj) => {
39 | if (err) {
40 | res.json({
41 | err: err.message,
42 | });
43 | } else {
44 | res.status(200).json({
45 | message: 'Successfull Get Request',
46 | count: obj.length,
47 | blog_data: obj,
48 | });
49 | }
50 | });
51 | });
52 | router.post("/blog", upload.single('blogImage'), function(req, res) {
53 | let newData = req.body;
54 | if (req.file != undefined)
55 | newData["FileName"] = req.file.filename;
56 | console.log(newData);
57 | Blog.create(newData, (err, obj) => {
58 | if (err) {
59 | res.json({
60 | err: err.message,
61 | });
62 | } else {
63 | res.status(201).json({
64 | message: 'Successfull Post Request',
65 | count: obj.length,
66 | blog_data: obj,
67 | });
68 | }
69 | });
70 | });
71 | router.post('/update/blog/:id', upload.single('blogImage'), function(req, res) {
72 | let newData = req.body;
73 | console.log(req.body);
74 | console.log(req.body.Status)
75 | if (req.file != undefined) {
76 | Blog.findOne({
77 | _id: req.params.id
78 | }, (err, obj) => {
79 | if (err) {
80 | res.status(500).json({
81 | error: err.message
82 | });
83 | } else {
84 |
85 | const options = {
86 | hostname: 'codingclubnitm.herokuapp.com',
87 | path: '/api/v1/image/del/' + req.file.filename,
88 | method: 'DELETE'
89 | }
90 | const hreq = https.request(options, hres => {
91 | console.log(`statusCode: ${hres.statusCode}`)
92 | console.log("sucessfull")
93 | })
94 | hreq.on('error', error => {
95 | console.error(error)
96 | })
97 | hreq.end()
98 | }
99 | })
100 | newData["FileName"] = req.file.filename;
101 | }
102 | Blog.updateOne({
103 | _id: req.params.id
104 | }, {
105 | $set: newData
106 | }, (err, obj) => {
107 | if (err) {
108 | res.status(500).json({
109 | error: err.message,
110 | });
111 | } else {
112 | res.status(201).json({
113 | message: 'Successfull Updated Blog',
114 | });
115 | }
116 | })
117 | });
118 | router.delete('/blog/:id', checkAuth, function(req, res, next) {
119 | Blog.findOne({
120 | _id: req.params.id
121 | }, (err, obj) => {
122 | if (err) {
123 | res.status(500).json({
124 | err: err.message
125 | });
126 | } else {
127 | gfs.files.deleteOne({
128 | filename: obj.FileName
129 | }, (err, data) => {
130 | if (err) return res.status(404).json({
131 | err: err.message
132 | });
133 | else {
134 | Blog.deleteOne({
135 | _id: req.params.id
136 | }, (err, obj) => {
137 | if (err) return res.status(404).json({
138 | err: err.message
139 | });
140 | else {
141 | res.status(200).json({
142 | message: 'Data and Image Sucessfully Deleted',
143 | });
144 | }
145 | });
146 | }
147 | });
148 | }
149 | });
150 | });
151 | router.get("/updateblog/:id", (req, res) => {
152 | Blog.findOne({
153 | _id: req.params.id
154 | }, (err, obj) => {
155 | if (err) {
156 | res.status(500).json({
157 | error: err.message
158 | });
159 | } else {
160 | res.render("Admin/Blog Page/updateBlog", {
161 | arr: obj
162 | })
163 | }
164 | })
165 | });
166 | router.patch("/updateblog/:id", (req, res) => {
167 | Blog.findOne({
168 | _id: req.params.id
169 | }, (err, obj) => {
170 | var temp_obj = {
171 | Status: "published"
172 | };
173 | if (obj.Status === "published") {
174 | temp_obj.Status = "in-review";
175 | }
176 | Blog.updateOne({
177 | _id: req.params.id
178 | }, {
179 | $set: temp_obj
180 | }, (err, obj) => {
181 | if (err) {
182 | res.status(500).json({
183 | error: err.message
184 | });
185 | } else {
186 | res.json({
187 | "msg": "Successfully Updated"
188 | });
189 | }
190 | });
191 | });
192 | });
193 | module.exports = router
--------------------------------------------------------------------------------
/public/login/style.css:
--------------------------------------------------------------------------------
1 | /* BASIC */
2 |
3 | html {
4 | background-color: #56baed;
5 | }
6 |
7 | body {
8 | font-family: "Poppins", sans-serif;
9 | height: 100vh;
10 | }
11 |
12 | a {
13 | color: #92badd;
14 | display: inline-block;
15 | text-decoration: none;
16 | font-weight: 400;
17 | }
18 |
19 | h2 {
20 | text-align: center;
21 | font-size: 16px;
22 | font-weight: 600;
23 | text-transform: uppercase;
24 | display: inline-block;
25 | margin: 40px 8px 10px 8px;
26 | color: #cccccc;
27 | }
28 |
29 |
30 | /* STRUCTURE */
31 |
32 | .wrapper {
33 | display: flex;
34 | align-items: center;
35 | flex-direction: column;
36 | justify-content: center;
37 | width: 100%;
38 | min-height: 100%;
39 | padding: 20px;
40 | }
41 |
42 | #formContent {
43 | -webkit-border-radius: 10px 10px 10px 10px;
44 | border-radius: 10px 10px 10px 10px;
45 | background: #fff;
46 | padding: 30px;
47 | width: 90%;
48 | max-width: 450px;
49 | position: relative;
50 | padding: 0px;
51 | -webkit-box-shadow: 0 30px 60px 0 rgba(0, 0, 0, 0.3);
52 | box-shadow: 0 30px 60px 0 rgba(0, 0, 0, 0.3);
53 | text-align: center;
54 | }
55 |
56 | #formFooter {
57 | background-color: #f6f6f6;
58 | border-top: 1px solid #dce8f1;
59 | padding: 25px;
60 | text-align: center;
61 | -webkit-border-radius: 0 0 10px 10px;
62 | border-radius: 0 0 10px 10px;
63 | }
64 |
65 |
66 | /* TABS */
67 |
68 | h2.inactive {
69 | color: #cccccc;
70 | }
71 |
72 | h2.active {
73 | color: #0d0d0d;
74 | border-bottom: 2px solid #5fbae9;
75 | }
76 |
77 |
78 | /* FORM TYPOGRAPHY*/
79 |
80 | input[type=button],
81 | input[type=submit],
82 | input[type=reset] {
83 | background-color: #56baed;
84 | border: none;
85 | color: white;
86 | padding: 15px 80px;
87 | text-align: center;
88 | text-decoration: none;
89 | display: inline-block;
90 | text-transform: uppercase;
91 | font-size: 13px;
92 | -webkit-box-shadow: 0 10px 30px 0 rgba(95, 186, 233, 0.4);
93 | box-shadow: 0 10px 30px 0 rgba(95, 186, 233, 0.4);
94 | -webkit-border-radius: 5px 5px 5px 5px;
95 | border-radius: 5px 5px 5px 5px;
96 | margin: 5px 20px 40px 20px;
97 | -webkit-transition: all 0.3s ease-in-out;
98 | -moz-transition: all 0.3s ease-in-out;
99 | -ms-transition: all 0.3s ease-in-out;
100 | -o-transition: all 0.3s ease-in-out;
101 | transition: all 0.3s ease-in-out;
102 | }
103 |
104 | input[type=button]:hover,
105 | input[type=submit]:hover,
106 | input[type=reset]:hover {
107 | background-color: #39ace7;
108 | }
109 |
110 | input[type=button]:active,
111 | input[type=submit]:active,
112 | input[type=reset]:active {
113 | -moz-transform: scale(0.95);
114 | -webkit-transform: scale(0.95);
115 | -o-transform: scale(0.95);
116 | -ms-transform: scale(0.95);
117 | transform: scale(0.95);
118 | }
119 |
120 | input[type=text],
121 | input[type=password] {
122 | background-color: #f6f6f6;
123 | border: none;
124 | color: #0d0d0d;
125 | padding: 15px 32px;
126 | text-align: center;
127 | text-decoration: none;
128 | display: inline-block;
129 | font-size: 16px;
130 | margin: 5px;
131 | width: 85%;
132 | border: 2px solid #f6f6f6;
133 | -webkit-transition: all 0.5s ease-in-out;
134 | -moz-transition: all 0.5s ease-in-out;
135 | -ms-transition: all 0.5s ease-in-out;
136 | -o-transition: all 0.5s ease-in-out;
137 | transition: all 0.5s ease-in-out;
138 | -webkit-border-radius: 5px 5px 5px 5px;
139 | border-radius: 5px 5px 5px 5px;
140 | }
141 |
142 | input[type=text]:focus,
143 | input[type=password]:focus {
144 | background-color: #fff;
145 | border-bottom: 2px solid #5fbae9;
146 | }
147 |
148 | input[type=text]:placeholder,
149 | input[type=password]:placeholder {
150 | color: #cccccc;
151 | }
152 |
153 |
154 | /* ANIMATIONS */
155 |
156 |
157 | /* Simple CSS3 Fade-in-down Animation */
158 |
159 | .fadeInDown {
160 | -webkit-animation-name: fadeInDown;
161 | animation-name: fadeInDown;
162 | -webkit-animation-duration: 1s;
163 | animation-duration: 1s;
164 | -webkit-animation-fill-mode: both;
165 | animation-fill-mode: both;
166 | }
167 |
168 | @-webkit-keyframes fadeInDown {
169 | 0% {
170 | opacity: 0;
171 | -webkit-transform: translate3d(0, -100%, 0);
172 | transform: translate3d(0, -100%, 0);
173 | }
174 | 100% {
175 | opacity: 1;
176 | -webkit-transform: none;
177 | transform: none;
178 | }
179 | }
180 |
181 | @keyframes fadeInDown {
182 | 0% {
183 | opacity: 0;
184 | -webkit-transform: translate3d(0, -100%, 0);
185 | transform: translate3d(0, -100%, 0);
186 | }
187 | 100% {
188 | opacity: 1;
189 | -webkit-transform: none;
190 | transform: none;
191 | }
192 | }
193 |
194 |
195 | /* Simple CSS3 Fade-in Animation */
196 |
197 | @-webkit-keyframes fadeIn {
198 | from {
199 | opacity: 0;
200 | }
201 | to {
202 | opacity: 1;
203 | }
204 | }
205 |
206 | @-moz-keyframes fadeIn {
207 | from {
208 | opacity: 0;
209 | }
210 | to {
211 | opacity: 1;
212 | }
213 | }
214 |
215 | @keyframes fadeIn {
216 | from {
217 | opacity: 0;
218 | }
219 | to {
220 | opacity: 1;
221 | }
222 | }
223 |
224 | .fadeIn {
225 | opacity: 0;
226 | -webkit-animation: fadeIn ease-in 1;
227 | -moz-animation: fadeIn ease-in 1;
228 | animation: fadeIn ease-in 1;
229 | -webkit-animation-fill-mode: forwards;
230 | -moz-animation-fill-mode: forwards;
231 | animation-fill-mode: forwards;
232 | -webkit-animation-duration: 1s;
233 | -moz-animation-duration: 1s;
234 | animation-duration: 1s;
235 | }
236 |
237 | .fadeIn.first {
238 | -webkit-animation-delay: 0.4s;
239 | -moz-animation-delay: 0.4s;
240 | animation-delay: 0.4s;
241 | }
242 |
243 | .fadeIn.second {
244 | -webkit-animation-delay: 0.6s;
245 | -moz-animation-delay: 0.6s;
246 | animation-delay: 0.6s;
247 | }
248 |
249 | .fadeIn.third {
250 | -webkit-animation-delay: 0.8s;
251 | -moz-animation-delay: 0.8s;
252 | animation-delay: 0.8s;
253 | }
254 |
255 | .fadeIn.fourth {
256 | -webkit-animation-delay: 1s;
257 | -moz-animation-delay: 1s;
258 | animation-delay: 1s;
259 | }
260 |
261 |
262 | /* Simple CSS3 Fade-in Animation */
263 |
264 | .underlineHover:after {
265 | display: block;
266 | left: 0;
267 | bottom: -10px;
268 | width: 0;
269 | height: 2px;
270 | background-color: #56baed;
271 | content: "";
272 | transition: width 0.2s;
273 | }
274 |
275 | .underlineHover:hover {
276 | color: #0d0d0d;
277 | }
278 |
279 | .underlineHover:hover:after {
280 | width: 100%;
281 | }
282 |
283 |
284 | /* OTHERS */
285 |
286 | *:focus {
287 | outline: none;
288 | }
289 |
290 | #icon {
291 | width: 60%;
292 | }
--------------------------------------------------------------------------------
/Authentication/routes/user.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const User = require('../../models/user');
4 | const bcrypt = require('bcrypt');
5 | const jwt = require('jsonwebtoken');
6 | const checkAuth = require('../middleware/check_auth');
7 |
8 |
9 | //************** Get Requests***************
10 |
11 |
12 | router.get('/login', function(req, res) {
13 | res.render('Admin/Login/login', {
14 | wrong: 1,
15 | msg: "",
16 | });
17 | });
18 | router.get('/changepass', function(req, res) {
19 | res.render('Admin/Login/changepass', {
20 | wrong: 1,
21 | msg: "",
22 | });
23 | });
24 |
25 |
26 | //******************** */ Post Requests*******************
27 |
28 |
29 | router.post('/signup', checkAuth, (req, res) => {
30 | console.log(req.body);
31 | User.find({
32 | email: req.body.email
33 | }).exec().then(user => {
34 | if (user.length >= 1) {
35 | res.status(409).json({
36 | message: 'User Already exist'
37 | });
38 | } else {
39 | bcrypt.hash(req.body.password, 10, (err, hash) => {
40 | if (err) {
41 | res.status(500).json({
42 | error: err.message,
43 | });
44 | } else {
45 | const obj = new User({
46 | email: req.body.email,
47 | firstname: req.body.firstname,
48 | lastname: req.body.lastname,
49 | role: req.body.role,
50 | password: hash,
51 | });
52 | obj.save().then(result => {
53 | console.log(result);
54 | res.status(201).json({
55 | message: 'User Created'
56 | });
57 | }).catch(err => {
58 | res.status(500).json({
59 | error: err.message,
60 | })
61 | });
62 | }
63 | })
64 |
65 | }
66 | })
67 | });
68 |
69 | router.post('/password', (req, res, next) => {
70 |
71 | if (req.body.new_password != req.body.new_password2) {
72 | res.render('Admin/Login/changepass', {
73 | wrong: 0,
74 | msg: "New password not matching in both case",
75 | })
76 | }
77 | console.log(req.body);
78 | User.find({
79 | email: req.body.email
80 | }).exec().then(user => {
81 | if (user.length < 1) {
82 | res.render('Admin/Login/changepass', {
83 | wrong: 0,
84 | msg: "Entered Password or Email is wrong . Please Try Again!!",
85 | });
86 | } else {
87 | bcrypt.compare(req.body.curr_password, user[0].password, (err, result) => {
88 | if (err) {
89 | res.render('Admin/Login/changepass', {
90 | wrong: 0,
91 | msg: "Entered Password or Email is wrong . Please Try Again!!",
92 | });
93 | } else {
94 | if (result) {
95 | bcrypt.hash(req.body.new_password, 10, (err, hash) => {
96 | if (err) {
97 | res.status(500).json({
98 | error: err.message,
99 | });
100 | } else {
101 |
102 | User.updateOne({
103 | email: req.body.email,
104 | }, {
105 | password: hash
106 | }).then(result => {
107 | res.cookie("token", '');
108 | res.cookie("name", '')
109 | res.cookie("role", '')
110 | console.log(result);
111 | res.render('Admin/Login/login', {
112 | wrong: 0,
113 | msg: "Password Sucessfully Updated .Please Login Again!!"
114 | });
115 |
116 | }).catch(err => {
117 | res.status(500).json({
118 | error: err.message,
119 | })
120 | });
121 | }
122 | })
123 | } else {
124 | res.render('Admin/Login/changepass', {
125 | wrong: 0,
126 | msg: "Entered Password or Email is wrong . Please Try Again!!",
127 | });
128 | }
129 | }
130 | })
131 | }
132 | }).catch(err => {
133 | res.render('Admin/Login/changepass', {
134 | wrong: 0,
135 | msg: "Entered Password or Email is wrong . Please Try Again!!",
136 | });
137 |
138 | })
139 |
140 | });
141 |
142 | router.post('/login', (req, res, next) => {
143 | console.log(req.body);
144 | User.find({
145 | email: req.body.email
146 | }).exec().then(user => {
147 | if (user.length < 1) {
148 | res.render('Admin/Login/login', {
149 | wrong: 0,
150 | msg: "Entered Password or Email is wrong . Please Try Again!!",
151 | });
152 | } else {
153 | bcrypt.compare(req.body.password, user[0].password, (err, result) => {
154 | if (err) {
155 | res.render('Admin/Login/login', {
156 | wrong: 0,
157 | msg: "Entered Password or Email is wrong . Please Try Again!!",
158 | });
159 |
160 | } else {
161 | if (result) {
162 | var token = jwt.sign({
163 | email: user[0].email,
164 | userId: user[0]._id,
165 | }, process.env.JWT_KEY, {
166 | expiresIn: '1h',
167 | });
168 | res.cookie("token", token);
169 | res.cookie("name", user[0].firstname)
170 | res.cookie("role", user[0].role)
171 | res.redirect('/admin');
172 | } else {
173 | res.render('Admin/Login/login', {
174 | wrong: 0,
175 | msg: "Entered Password or Email is wrong . Please Try Again!!",
176 | });
177 |
178 | }
179 | }
180 | })
181 | }
182 | }).catch(err => {
183 | res.render('Admin/Login/login', {
184 | wrong: 0,
185 | msg: "Entered Password or Email is wrong . Please Try Again!!",
186 | });
187 |
188 | })
189 | });
190 |
191 |
192 | //************************ */ Delete Requests******************
193 |
194 |
195 | router.delete('/user/:id', checkAuth, (req, res) => {
196 | User.deleteOne({
197 | _id: req.params.id
198 | }, (err, obj) => {
199 | if (err) {
200 | res.status(500).json({
201 | error: err.message
202 | });
203 | } else {
204 | res.status(200).json({
205 | message: "User Deleted"
206 | });
207 | }
208 | });
209 | });
210 |
211 | module.exports = router
--------------------------------------------------------------------------------
/views/Admin/Blog Page/addBlog.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 | AddBlog
16 |
17 |
18 |
19 |
20 |
21 |
Blogs
22 |
23 |
24 |
25 |
37 |
38 |
39 |
40 |
41 |
42 |
Welcome to CCNITM Blogs
43 |
44 |
49 |
50 |
51 |
Author Name
52 |
53 |
54 |
55 |
Author Email
56 |
57 |
58 |
59 |
Linked Profile Link
60 |
61 |
62 |
63 |
64 | Choose Category
65 | Competitive Programming
66 | Web Development
67 | Machine Learning
68 | Network Security
69 | App Development
70 | Interview Experience
71 | Other
72 |
73 | Write Your Blog Here
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | Short Description of the Blog(less then 200
82 | words)
83 |
84 |
85 |
86 | Related Tags (Please add a # before every
87 | tag)
88 |
89 |
98 |
107 |
108 |
109 |
110 |
111 |
112 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------