Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: AtulSingh-Emyre/prevelec
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: oss2019/prevelec
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 13 commits
  • 7 files changed
  • 4 contributors

Commits on Oct 31, 2021

  1. Copy the full SHA
    e945e7c View commit details
  2. Copy the full SHA
    0b5909f View commit details
  3. Copy the full SHA
    76093ab View commit details
  4. Merge pull request #12 from arunkone07/master

    Fixed issues in 'Read More' functionality in About page.
    AtulSingh-Emyre authored Oct 31, 2021
    Copy the full SHA
    c98ab1e View commit details
  5. Copy the full SHA
    fe435cd View commit details
  6. Merge pull request #13 from 9I0xDeepankar/master

    made navbar more attractive
    AtulSingh-Emyre authored Oct 31, 2021
    Copy the full SHA
    4e414a8 View commit details
  7. Copy the full SHA
    dee00b3 View commit details
  8. Copy the full SHA
    23439d1 View commit details
  9. Copy the full SHA
    efc5fbd View commit details
  10. Copy the full SHA
    d197bd4 View commit details
  11. Merge pull request #15 from arunkone07/master

    Enhanced contents and styling of home page
    AtulSingh-Emyre authored Oct 31, 2021
    Copy the full SHA
    1fa621e View commit details
  12. Copy the full SHA
    4a6eb48 View commit details
  13. Merge pull request #14 from 9I0xDeepankar/master

    enhanced UI for dashboard,blog,compose,achievements
    AtulSingh-Emyre authored Oct 31, 2021
    Copy the full SHA
    624da6b View commit details
Showing with 384 additions and 367 deletions.
  1. +95 −99 app.js
  2. +70 −64 views/achievements.ejs
  3. +29 −20 views/blog.ejs
  4. +27 −22 views/compose.ejs
  5. +7 −7 views/dash.ejs
  6. +16 −10 views/home.ejs
  7. +140 −145 views/partials/header.ejs
194 changes: 95 additions & 99 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//jshint esversion:6

const express = require('express');
const bodyParser = require('body-parser');
const ejs = require('ejs');
const _ = require('lodash');
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 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.";
@@ -16,152 +16,148 @@ const app = express();

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

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

let posts = [];

app.get('/', function (req, res) {
res.render('login2');

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) {
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("/home",function(req,res){
res.render("home");
});
app.get('/achievements', function (req, res) {
res.render('achievements');

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

});

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

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

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

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

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

posts.push(post);

res.redirect('/');
res.redirect("/");

});

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

let creds = [];

var count = 0;
app.post('/login', function (req, res) {
var count=0;
app.post("/login", function(req, res){
const cred = {
uid: req.body.em,
content: req.body.pass,
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++;
creds.forEach(function(pred){
if(pred.uid==cred.uid && pred.content==cred.content)
{ res.render("dash");
count++;
}
});
if (count == 0) res.send('/');
});
if(count==0)
res.send("/");


});

app.get('/register', function (req, res) {
res.render('register');
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);
});
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"];

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');
});
app.get('/posts/:postName', function (req, res) {
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) {
posts.forEach(function(post){
const storedTitle = _.lowerCase(post.title);

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

});

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

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

app.listen(3000, function() {
console.log("Server started on port 3000");
});
134 changes: 70 additions & 64 deletions views/achievements.ejs
Original file line number Diff line number Diff line change
@@ -1,64 +1,70 @@
<%- include("partials/header")-%>

<main role="main">

<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>

</div>
<script>
jQuery(function () {
jQuery(".jtable-command-button.jtable-edit-command-button").click(function () {
alert("Points collected!");
});
});
</script>

<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->

<div class="container marketing">

<!-- Three columns of text below the carousel -->
<div class="row">
<div class="col-lg-4">
<svg class="bd-placeholder-img rounded-circle" width="140" height="140" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 140x140"><title>Placeholder</title><rect width="100%" height="100%" fill="#777"/><text x="50%" y="50%" fill="#777" dy=".3em">140x140</text></svg>
<h2>GOLD</h2>
<p>Congratulations... <br> You've done a great job! <br> you have been placed among 20 least electricity consumers.</p>
<p>Points:50</p>
<p><a class="btn btn-secondary" href="#" role="button" class=".jtable-command-button.jtable-edit-command-button">Collect Points &raquo;</a></p>
</div><!-- /.col-lg-4 -->

<div class="col-lg-4">
<svg class="bd-placeholder-img rounded-circle" width="140" height="140" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 140x140"><title>Placeholder</title><rect width="100%" height="100%" fill="#777"/><text x="50%" y="50%" fill="#777" dy=".3em">140x140</text></svg>
<h2>SILVER</h2>
<p>Congratulations... <br> You've done a great job! <br> your current month electricity consumption is less than the average of all previous month's electricity consumption.</p>
<p>Points:50</p>
<p class=".jtable-command-button.jtable-edit-command-button"><a class="btn btn-secondary" href="#" role="button" >Collect Points &raquo;</a></p>
</div><!-- /.col-lg-4 -->

<div class="col-lg-4">
<svg class="bd-placeholder-img rounded-circle" width="140" height="140" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 140x140"><title>Placeholder</title><rect width="100%" height="100%" fill="#777"/><text x="50%" y="50%" fill="#777" dy=".3em">140x140</text></svg>
<h2>BRONZE</h2>
<p>Congratulations...<br> You've done a great job! <br> your current month electricity consumption is less than the previous month's electricity consumption. </p>
<p> Points:50 </p>
<p><a class="btn btn-secondary" class=".jtable-command-button.jtable-edit-command-button" href="#" role="button">Collect Points &raquo;</a></p>
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->



<footer class="container">
<p class="float-right"><a href="#">Back to top</a></p>
<p>&copy; 2017-2019 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
</main>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="/docs/4.4/assets/js/vendor/jquery.slim.min.js"><\/script>')</script><script src="/docs/4.4/dist/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script></body>
</html>
<%- include("partials/header")-%>

<main role="main">

<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>

</div>
<style type="text/css">
body {
background-color: rgba(233, 215, 112, 0.219);
margin-top: 100px;
}
</style>
<script>
jQuery(function() {
jQuery(".jtable-command-button.jtable-edit-command-button").click(function() {
alert("Points collected!");
});
});
</script>

<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->

<div class="container marketing">

<!-- Three columns of text below the carousel -->
<div class="row">
<div class="col-lg-4">
<svg class="bd-placeholder-img rounded-circle" width="140" height="140" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 140x140"><title>Placeholder</title><rect width="100%" height="100%" fill="#777"/><text x="50%" y="50%" fill="#777" dy=".3em">140x140</text></svg>
<img class="gold-image"></div>img>
<h2>GOLD</h2>
<p>Congratulations... <br> You've done a great job! <br> you have been placed among 20 least electricity consumers.</p>
<p>Points:50</p>
<p><a class="btn btn-secondary" href="#" role="button" class=".jtable-command-button.jtable-edit-command-button">Collect Points &raquo;</a></p>
</div><!-- /.col-lg-4 -->

<div class="col-lg-4">
<svg class="bd-placeholder-img rounded-circle" width="140" height="140" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 140x140"><title>Placeholder</title><rect width="100%" height="100%" fill="#777"/><text x="50%" y="50%" fill="#777" dy=".3em">140x140</text></svg>
<h2>SILVER</h2>
<p>Congratulations... <br> You've done a great job! <br> your current month electricity consumption is less than the average of all previous month's electricity consumption.</p>
<p>Points:50</p>
<p class=".jtable-command-button.jtable-edit-command-button"><a class="btn btn-secondary" href="#" role="button" >Collect Points &raquo;</a></p>
</div><!-- /.col-lg-4 -->

<div class="col-lg-4">
<svg class="bd-placeholder-img rounded-circle" width="140" height="140" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: 140x140"><title>Placeholder</title><rect width="100%" height="100%" fill="#777"/><text x="50%" y="50%" fill="#777" dy=".3em">140x140</text></svg>
<h2>BRONZE</h2>
<p>Congratulations...<br> You've done a great job! <br> your current month electricity consumption is less than the previous month's electricity consumption. </p>
<p> Points:50 </p>
<p><a class="btn btn-secondary" class=".jtable-command-button.jtable-edit-command-button" href="#" role="button">Collect Points &raquo;</a></p>
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->



<footer class="container">
<p class="float-right"><a href="#">Back to top</a></p>
<p>&copy; 2017-2019 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
</main>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="/docs/4.4/assets/js/vendor/jquery.slim.min.js"><\/script>')</script><script src="/docs/4.4/dist/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script></body>
</html>
Loading