Finally remembered how to use Bootstrap grid to make home.hbs look right; use it as landing page for root URL.

This commit is contained in:
jkaplon 2016-07-03 11:37:29 -04:00
parent 9cb8094694
commit 0dfb9b300f
2 changed files with 15 additions and 51 deletions

View File

@ -48,9 +48,8 @@ But, for now, order routes like this:
- static routes, ordered more specific to less specific - static routes, ordered more specific to less specific
- dynamic routes, ordered more specific to less specific - dynamic routes, ordered more specific to less specific
********************************************************************************************************/ ********************************************************************************************************/
// temp testing for static home page. app.get('/', function(req, res){
app.get('/home', function(req, res) { winston.info("GET /");
winston.info('GET /home');
res.render('home', {}, function(err, html) { res.render('home', {}, function(err, html) {
if(err !== null) { if(err !== null) {
winston.error(err); winston.error(err);
@ -60,43 +59,6 @@ app.get('/home', function(req, res) {
}); });
}); });
app.get('/', function(req, res){
winston.info("GET /");
pg.connect(conString, function(err, client, done) {
if(err) {
return winston.error('error fetching client from pool', err);
}
var devIndexQry =
"select status, published_at " +
"from alerts " +
"where status in ('Open', 'Closed') " +
"order by published_at desc " +
"limit 2"
client.query(devIndexQry, function(err, result) {
//call `done()` to release the client back to the pool
done();
if(err) {
return winston.error('error running query', err);
}
// Loop over elements in rows array, convert ugly UTC times to pretty local times.
result.rows.forEach(function(row){
row.pubdate = courtsopenUtils.getLocDateFromUTC(row.published_at);
row.pubtime = courtsopenUtils.getLocTimeFromUTC(row.published_at);
if(row.status.toLowerCase().indexOf('closed') > -1){
row.statusclass = 'closed';
} else { row.statusclass = 'open'; }
});
res.render('index', {values: result.rows}, function(err, html) {
if(err !== null) {
winston.error(err);
} else {
res.send(html);
}
});
});
});
});
app.post('/', function(req, res){ app.post('/', function(req, res){
var postEvent = req.body.postEvent; var postEvent = req.body.postEvent;
var source = req.body.source; var source = req.body.source;
@ -148,8 +110,6 @@ app.get('/:loc', function(req, res) {
if (loc !== 'tt') { if (loc !== 'tt') {
res.status(404).send('Not found'); res.status(404).send('Not found');
} else { } else {
// This is repeated code from app.get('/') handler.
// TODO, refactor as exported function in courtsopenUtils.js.
winston.info("GET /tt"); winston.info("GET /tt");
pg.connect(conString, function(err, client, done) { pg.connect(conString, function(err, client, done) {
if(err) { if(err) {

View File

@ -6,13 +6,17 @@
<hr></hr> <hr></hr>
<h2 class="text-center">What's the <em>QUICKEST</em> way to know if the courts are open?:</br><strong>TennisCourtsOpen.com</strong></h2> <h2 class="text-center">What's the <em>QUICKEST</em> way to know if the courts are open?:</br><strong>TennisCourtsOpen.com</strong></h2>
<hr></hr> <hr></hr>
<div> <div class="row">
<img src="pro-shop-device.jpg" alt="TennisCourtsOpen.com internet-enabled hardware device" class="img-thumbnail pull-left" style="margin-right: 10px"> <div class="col-md-2">
<p class="lead">At each location, we supply an internet-enabled physical switch to update status pages here at TennisCourtsOpen.com.</p> <img src="pro-shop-device.jpg" alt="TennisCourtsOpen.com internet-enabled hardware device" class="img-thumbnail">
<p class="lead">Want to sign on as another TennisCourtsOpen.com location? <a href="mailto:info@tenniscourtsopen.com">Email us.</a></p> </div>
<table class="table"> <div class="col-md-10">
{{! Make this table dynamic later when DB supports multiple locations. }} <p class="lead">At each location, we supply an internet-enabled physical switch to update status pages here at TennisCourtsOpen.com.</p>
<th>Here are the currently supported locations:</th> <p class="lead">Want to sign on as another TennisCourtsOpen.com location? <a href="mailto:info@tenniscourtsopen.com">Email us.</a></p>
<tr><td><a href="https://tenniscourtsopen.com/tt">Temple Terrace Recreation Center, clay courts</a></td></tr> <table class="table lead">
</table> {{! Make this table dynamic later when DB supports multiple locations. }}
<th>Here are the currently supported locations:</th>
<tr><td><a href="https://tenniscourtsopen.com/tt">Temple Terrace Recreation Center, clay courts</a></td></tr>
</table>
</div>
</div> </div>