2017-03-15 02:01:55 -06:00
|
|
|
'use strict';
|
|
|
|
|
2017-04-10 01:00:56 -06:00
|
|
|
const mw = require('../middleware.js'),
|
|
|
|
router = require('express').Router(),
|
|
|
|
slug = require('slug'),
|
|
|
|
User = require('../models.js').user;
|
2017-03-14 22:05:03 -06:00
|
|
|
|
2017-03-18 12:46:02 -06:00
|
|
|
// Index
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/', (req,res,next)=>{
|
2017-04-01 11:03:05 -06:00
|
|
|
res.render('index');
|
2017-03-18 12:46:02 -06:00
|
|
|
});
|
2016-03-31 15:57:34 -06:00
|
|
|
|
2017-03-18 11:21:48 -06:00
|
|
|
// Help
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/help', mw.ensureAuth, (req,res)=>{
|
|
|
|
res.render('help');
|
|
|
|
});
|
2017-03-15 01:33:02 -06:00
|
|
|
|
2017-04-01 11:03:05 -06:00
|
|
|
// Terms of Service and Privacy Policy
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/terms', (req,res)=>{
|
2017-04-01 11:03:05 -06:00
|
|
|
res.render('terms');
|
2017-04-13 16:53:18 -06:00
|
|
|
})
|
|
|
|
.get('/privacy', (req,res)=>{
|
2017-04-01 11:03:05 -06:00
|
|
|
res.render('privacy');
|
2017-03-18 11:21:48 -06:00
|
|
|
});
|
|
|
|
|
2017-04-10 01:00:56 -06:00
|
|
|
// robots.txt
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/robots.txt', (req,res)=>{
|
2017-04-10 01:00:56 -06:00
|
|
|
res.type('text/plain');
|
|
|
|
res.send("User-agent: *\n"+
|
|
|
|
"Disallow: /map/*\n"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
// favicon.ico
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/favicon.ico', (req,res)=>{
|
2017-04-10 01:00:56 -06:00
|
|
|
res.redirect('/static/img/icon/by/16-32-48.ico');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Endpoint to validate forms
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/validate', (req,res)=>{
|
2017-04-10 01:00:56 -06:00
|
|
|
if (req.query.slug) { // validate unique slug
|
2017-04-13 16:53:18 -06:00
|
|
|
User.findOne( {slug:slug(req.query.slug)}, (err,existingUser)=>{
|
2017-04-10 01:00:56 -06:00
|
|
|
if (err) { console.log('/validate error:',err); }
|
2017-04-12 11:41:27 -06:00
|
|
|
if (existingUser && existingUser.id!==req.user) { res.sendStatus(400); }
|
2017-04-10 01:00:56 -06:00
|
|
|
else { res.sendStatus(200); }
|
2017-04-13 16:53:18 -06:00
|
|
|
} );
|
2017-04-10 01:00:56 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Link to androidapp in play store
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/android', (req,res)=>{
|
2017-04-10 01:00:56 -06:00
|
|
|
res.redirect('https://play.google.com/store/apps/details?id=us.keithirwin.tracman');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Link to iphone app in the apple store
|
2017-04-13 16:53:18 -06:00
|
|
|
router.get('/ios', (req,res)=>{
|
2017-04-10 01:00:56 -06:00
|
|
|
res.sendStatus(404);
|
|
|
|
//TODO: Add link to info about why there's no ios app
|
|
|
|
});
|
|
|
|
|
2016-03-31 15:57:34 -06:00
|
|
|
module.exports = router;
|