Skip to content

Commit

Permalink
Fixed error in 'Read more' functionality in About page.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkone07 committed Oct 31, 2021
2 parents e945e7c + c40ac94 commit 0b5909f
Show file tree
Hide file tree
Showing 8 changed files with 1,151 additions and 280 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Prevelec

[![forthebadge](https://forthebadge.com/images/badges/uses-html.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/contains-tasty-spaghetti-code.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/open-source.svg)](https://forthebadge.com)
- This website aims to reduce the amount of electricity used by people in their daily lives
by providing them a report on their usage and providing bonusses on consuming lesser energy.

- This website aims to reduce the amount of electricity used by people in their daily lives
by providing them a report on their usage and providing bonusses on consuming lesser energy.

<h2> Instructions for execution of the code </h2>

Expand All @@ -21,12 +23,12 @@ by providing them a report on their usage and providing bonusses on consuming le
<li>Replace the XXXXXXXXXXXXXXX in DB_URL with the link obtained in step 1. Now, follow the below steps to run it.</li>
</ol>


<h3>Running the application: </h3>
The website server is initiated by - <br>
<pre>
npm i<br>
node app.js<br>
npm i
npm run start

</pre>
~command on git bash.<br>
<h2>About the website</h2>
Expand Down Expand Up @@ -70,22 +72,23 @@ Signout: Signs a user out of the active session.
</ul>

### Enhancements available to do
(difficulty mentioned out of 5 and graded relatively) <br />
- [ ] In dashboard overall rank, rename the heading as leaderboard and pull the list of users from the database. use random values generated by the random function for the number of units used. ![leaderboard image](https://user-images.githubusercontent.com/59884618/138979430-d19423be-8683-4296-a387-a210199c89f2.png)

(difficulty mentioned out of 5 and graded relatively) <br />

- [ ] In dashboard overall rank, rename the heading as leaderboard and pull the list of users from the database. use random values generated by the random function for the number of units used. ![leaderboard image](https://user-images.githubusercontent.com/59884618/138979430-d19423be-8683-4296-a387-a210199c89f2.png)

<!-- <img src="" height="200px" /> -->
<!-- <br/> -->

- [ ] Add a form page to upload the units used per month in an year. It should have the fields: 'units used' (text) , 'month' (drop down). Upon submitting, the data needs to be persisted to database connected along with a **reference field** of userId. (This PR will be counted as 2 PRs). <br />
- [ ] Add option to add images in compose page. Make sure the image is visible along with title and post once published in the blog page. (will be counted as 2 PRs) <br />
- [ ] The components in dashboard are shifted to left align. Fix it to make it center aligned. <br /><br /><img src="https://user-images.githubusercontent.com/59884618/138979928-04320506-17bd-465b-8f5b-d4f5bb52c8a3.png" height="200px" />
- [ ] Remake the landing page - it should have the following things (Each of the following count as a separate PR). <br />
- [ ] use particle js to make a jumbotron with heading as PREVELEC and a short description of the website (20-30 words from lorem ipsum).
- [ ] List of contributors to the project (use format as shown below) ![image](https://user-images.githubusercontent.com/59884618/138980293-14aef481-aac5-4d65-8c02-ec969e2130cb.png)
- [ ] Nav bar should have only signin option if user is not signed in.
- [ ] Footer with contact info (phone number, email and github repo would be fine)
- [ ] use particle js to make a jumbotron with heading as PREVELEC and a short description of the website (20-30 words from lorem ipsum).
- [ ] List of contributors to the project (use format as shown below) ![image](https://user-images.githubusercontent.com/59884618/138980293-14aef481-aac5-4d65-8c02-ec969e2130cb.png)
- [ ] Nav bar should have only signin option if user is not signed in.
- [ ] Footer with contact info (phone number, email and github repo would be fine)
- [ ] Making the webpage responsive (one page per PR)(2)
- [ ] Making server side code more modular (separating out the routes and controllers) (counts as 3 PRs).
- [ ] Making server side code more modular (separating out the routes and controllers) (counts as 3 PRs).
<p> PS: For the issues that I have opened already, comment in the issue to let me know if you are taking it up. (like by commenting 'I would like to take this up')</p>
<p> For any queries, contact me at [email protected] </p>
326 changes: 163 additions & 163 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,163 +1,163 @@
//jshint esversion:6

const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");
const _ = require("lodash");

const User = require("./models/user");
const connectDB = require("./config/connectDb");

const homeStartingContent = "In this modern era, sources of non-renewable energy are depleting rapidly due to excess use. Hence, Energy conservation has become prominent. To create awareness about this, we created this website. This page is for sharing various techniques and updates related to energy conservation. It is public and hence visible to every registered user. Go green... Happy conserving!";
const aboutContent = "Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Dictumst vestibulum rhoncus est pellentesque elit ullamcorper. Non diam phasellus vestibulum lorem sed. Platea dictumst quisque sagittis purus sit. Egestas sed sed risus pretium quam vulputate dignissim suspendisse. Mauris in aliquam sem fringilla. Semper risus in hendrerit gravida rutrum quisque non tellus orci. Amet massa vitae tortor condimentum lacinia quis vel eros. Enim ut tellus elementum sagittis vitae. Mauris ultrices eros in cursus turpis massa tincidunt dui.";
const contactContent = "Scelerisque eleifend donec pretium vulputate sapien. Rhoncus urna neque viverra justo nec ultrices. Arcu dui vivamus arcu felis bibendum. Consectetur adipiscing elit duis tristique. Risus viverra adipiscing at in tellus integer feugiat. Sapien nec sagittis aliquam malesuada bibendum arcu vitae. Consequat interdum varius sit amet mattis. Iaculis nunc sed augue lacus. Interdum posuere lorem ipsum dolor sit amet consectetur adipiscing elit. Pulvinar elementum integer enim neque. Ultrices gravida dictum fusce ut placerat orci nulla. Mauris in aliquam sem fringilla ut morbi tincidunt. Tortor posuere ac ut consequat semper viverra nam libero.";

const app = express();

app.set('view engine', 'ejs');

app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));
connectDB();

let posts = [];


app.get("/",function(req,res){
res.render("login2");
});
app.post("/",async function(req,res){
try{
var result = await User.find({email:req.body.em, password:req.body.pass});
if(!result) res.send('Try again!');
res.render("dash");
}
catch(err) {
console.log(err);
}
});

app.get("/home",function(req,res){
res.render("home");
});

app.get("/achievements",function(req,res){
res.render("achievements");

});

app.get("/blog", function(req, res){
res.render("blog", {
startingContent: homeStartingContent,
posts: posts
});
});

app.get("/about", function(req, res){
res.render("about", {aboutContent: aboutContent});
});

app.get("/contact", function(req, res){
res.render("contact", {contactContent: contactContent});
});

app.get("/compose", function(req, res){
res.render("compose");
});

app.post("/compose", function(req, res){
const post = {
title: req.body.postTitle,
content: req.body.postBody
};

posts.push(post);

res.redirect("/");

});

app.get("/login",function(req,res){
res.render("login2");
});

let creds = [];

var count=0;
app.post("/login", function(req, res){
const cred = {
uid: req.body.em,
content: req.body.pass
};
console.log(req.body.em);
creds.forEach(function(pred){
if(pred.uid==cred.uid && pred.content==cred.content)
{ res.render("dash");
count++;
}
});
if(count==0)
res.send("/");


});

app.get("/register",function(req,res){
res.render("register");
});
app.post("/register",function(req,res){
var cred = {
name: req.body.name,
uid: req.body.email,
content: req.body.password
};
const newUser = new User({
name: cred.name,
email: cred.uid,
password: cred.content
});
newUser.save().then(() => {
res.render("login2");
}).catch((err) => {
console.log(err);
});
});

var img=0;
var year=["January","February","March","April","May","June","July","August","September","October","November","December"];

app.get("/dash",function(req,res){
res.render("dash");
});
app.get("/posts",function(req,res){
res.render("blog", {
startingContent: homeStartingContent,
posts: posts
});

});
app.get("/posts/:postName", function(req, res){
const requestedTitle = _.lowerCase(req.params.postName);

posts.forEach(function(post){
const storedTitle = _.lowerCase(post.title);

if (storedTitle === requestedTitle) {
res.render("post", {
title: post.title,
content: post.content
});
}
});

});

var i=6;
app.post("/dash",function(req,res){
res.render("dash");
});


app.listen(3000, function() {
console.log("Server started on port 3000");
});
//jshint esversion:6

const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");
const _ = require("lodash");

const User = require("./models/user");
const connectDB = require("./config/connectDb");

const homeStartingContent = "In this modern era, sources of non-renewable energy are depleting rapidly due to excess use. Hence, Energy conservation has become prominent. To create awareness about this, we created this website. This page is for sharing various techniques and updates related to energy conservation. It is public and hence visible to every registered user. Go green... Happy conserving!";
const aboutContent = "Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Dictumst vestibulum rhoncus est pellentesque elit ullamcorper. Non diam phasellus vestibulum lorem sed. Platea dictumst quisque sagittis purus sit. Egestas sed sed risus pretium quam vulputate dignissim suspendisse. Mauris in aliquam sem fringilla. Semper risus in hendrerit gravida rutrum quisque non tellus orci. Amet massa vitae tortor condimentum lacinia quis vel eros. Enim ut tellus elementum sagittis vitae. Mauris ultrices eros in cursus turpis massa tincidunt dui.";
const contactContent = "Scelerisque eleifend donec pretium vulputate sapien. Rhoncus urna neque viverra justo nec ultrices. Arcu dui vivamus arcu felis bibendum. Consectetur adipiscing elit duis tristique. Risus viverra adipiscing at in tellus integer feugiat. Sapien nec sagittis aliquam malesuada bibendum arcu vitae. Consequat interdum varius sit amet mattis. Iaculis nunc sed augue lacus. Interdum posuere lorem ipsum dolor sit amet consectetur adipiscing elit. Pulvinar elementum integer enim neque. Ultrices gravida dictum fusce ut placerat orci nulla. Mauris in aliquam sem fringilla ut morbi tincidunt. Tortor posuere ac ut consequat semper viverra nam libero.";

const app = express();

app.set('view engine', 'ejs');

app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));
connectDB();

let posts = [];


app.get("/",function(req,res){
res.render("login2");
});
app.post("/",async function(req,res){
try{
var result = await User.find({email:req.body.em, password:req.body.pass});
if(!result) res.send('Try again!');
res.render("dash");
}
catch(err) {
console.log(err);
}
});

app.get("/home",function(req,res){
res.render("home");
});

app.get("/achievements",function(req,res){
res.render("achievements");

});

app.get("/blog", function(req, res){
res.render("blog", {
startingContent: homeStartingContent,
posts: posts
});
});

app.get("/about", function(req, res){
res.render("about", {aboutContent: aboutContent});
});

app.get("/contact", function(req, res){
res.render("contact", {contactContent: contactContent});
});

app.get("/compose", function(req, res){
res.render("compose");
});

app.post("/compose", function(req, res){
const post = {
title: req.body.postTitle,
content: req.body.postBody
};

posts.push(post);

res.redirect("/");

});

app.get("/login",function(req,res){
res.render("login2");
});

let creds = [];

var count=0;
app.post("/login", function(req, res){
const cred = {
uid: req.body.em,
content: req.body.pass
};
console.log(req.body.em);
creds.forEach(function(pred){
if(pred.uid==cred.uid && pred.content==cred.content)
{ res.render("dash");
count++;
}
});
if(count==0)
res.send("/");


});

app.get("/register",function(req,res){
res.render("register");
});
app.post("/register",function(req,res){
var cred = {
name: req.body.name,
uid: req.body.email,
content: req.body.password
};
const newUser = new User({
name: cred.name,
email: cred.uid,
password: cred.content
});
newUser.save().then(() => {
res.render("login2");
}).catch((err) => {
console.log(err);
});
});

var img=0;
var year=["January","February","March","April","May","June","July","August","September","October","November","December"];

app.get("/dash",function(req,res){
res.render("dash");
});
app.get("/posts",function(req,res){
res.render("blog", {
startingContent: homeStartingContent,
posts: posts
});

});
app.get("/posts/:postName", function(req, res){
const requestedTitle = _.lowerCase(req.params.postName);

posts.forEach(function(post){
const storedTitle = _.lowerCase(post.title);

if (storedTitle === requestedTitle) {
res.render("post", {
title: post.title,
content: post.content
});
}
});

});

var i=6;
app.post("/dash",function(req,res){
res.render("dash");
});


app.listen(3000, function() {
console.log("Server started on port 3000");
});
Loading

0 comments on commit 0b5909f

Please sign in to comment.