Skip to content

Commit

Permalink
clean up, start admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkahn authored and samc1213 committed Aug 31, 2023
1 parent 97dda32 commit 3f6f094
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = function (grunt) {
});

grunt.config.requires('watch.js.files');
var files = grunt.config('watch.js.files');
let files = grunt.config('watch.js.files');
files = grunt.file.expand(files);

grunt.registerTask('test', ['mochaTest']);
Expand Down
4 changes: 2 additions & 2 deletions lib/transporter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var env = process.env.NODE_ENV || 'development'
const env = process.env.NODE_ENV || 'development'
, config = require('../config/config')[env]
, nodemailer = require('nodemailer')
;

var transporter = nodemailer.createTransport({
const transporter = nodemailer.createTransport({
host: process.env.EMAIL_HOST || config.EMAIL_HOST,
port: process.env.EMAIL_PORT || config.EMAIL_PORT,
auth: {
Expand Down
7 changes: 3 additions & 4 deletions middleware/staging-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
*/


var auth = require('basic-auth');
const auth = require('basic-auth');

module.exports = function(req, res, next) {
var creds = auth(req);
let creds = auth(req);
if (!creds || creds.name !== 'recycling' || creds.pass !== 'recycling') {
res.writeHead(401, {"WWW-Authenticate": 'Basic realm="Recycling Staging Site"'});
res.end();
} else {
next();
}

}
};
1 change: 0 additions & 1 deletion models/Ward.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ WardSchema.virtual('locationCount').get(function() {


WardSchema.post('save', function(ward){

var cacheIdx = 'wards.' + ward.number;
async.series([
function(cb) { cache.delete('wards.all', cb); },
Expand Down
13 changes: 13 additions & 0 deletions routes/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const express = require('express')
, router = express.Router()
, Reports = require('../models/Report')
;

router.get('/', function(req, res, next) {
let reports = Reports.find();
res.render('admin', {reports: reports});
});

module.exports = function(app) {
app.use('/admin', router);
};
4 changes: 2 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ router.get('/press', function (req, res) {
});

// Loader.io verification page. Do not delete.
router.get('/loaderio-f6c2b68c741ca5d56479042a794cf7da', function(req, res){
router.get('/loaderio-f6c2b68c741ca5d56479042a794cf7da', function(req, res) {
res.send('loaderio-f6c2b68c741ca5d56479042a794cf7da')
})
});

module.exports = router;
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app.post('/reports.json', reports.create);
app.get('/locations.json', locations.index);
app.get('/locations/count.json', locations.count);
app.use(require('./routes/wards.js'));
require('./routes/admin.js')(app);


if (env != 'development' && cluster.isMaster) {
Expand Down
54 changes: 54 additions & 0 deletions views/admin.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Teko' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Crowdsourcing data about which residential buildings do not have recycling in Chicago">
<title>My Building Doesn&#039;t Recycle!</title>
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link href="/css/recycling.css" rel="stylesheet">
</head>
<body>
<nav id='main_nav' class="navbar navbar-default navbar-style" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-type navbar-brand" href="/">My Building Doesn&#039;t Recycle!</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a class='<%= navActive.getinvolved %>' href="/get-involved">Get Involved</a></li>
<li><a class='<%= navActive.wards %>' href="/wards">Wards</a></li>
<li><a class='<%= navActive.about %>' href="/about">About</a></li>
<li><a class='<%= navActive.press %>'href="/press">Press</a></li>
<li><a class='<%= navActive.contact %>' href="/contact">Contact</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1>Admin</h1>
<ul>
<% for(var i = 0; i < reports.length; i++) { %>
<% var report = reports[i]; %>
<li><%= report.comment %></li>
<% } %>
</ul>
</div>
</div>
</div>
</body>
</html>

0 comments on commit 3f6f094

Please sign in to comment.