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-03-18 13:40:03 -06:00
|
|
|
router.get('/', function(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-01 11:03:05 -06:00
|
|
|
router.get('/help', mw.ensureAuth, function(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-03-18 11:21:48 -06:00
|
|
|
router.get('/terms', function(req,res){
|
2017-04-01 11:03:05 -06:00
|
|
|
res.render('terms');
|
|
|
|
}).get('/privacy', function(req,res){
|
|
|
|
res.render('privacy');
|
2017-03-18 11:21:48 -06:00
|
|
|
});
|
|
|
|
|
2017-04-10 01:00:56 -06:00
|
|
|
// robots.txt
|
|
|
|
router.get('/robots.txt', function(req,res){
|
|
|
|
res.type('text/plain');
|
|
|
|
res.send("User-agent: *\n"+
|
|
|
|
"Disallow: /map/*\n"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
// favicon.ico
|
|
|
|
router.get('/favicon.ico', function(req,res){
|
|
|
|
res.redirect('/static/img/icon/by/16-32-48.ico');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Endpoint to validate forms
|
|
|
|
router.get('/validate', function(req,res){
|
|
|
|
if (req.query.slug) { // validate unique slug
|
|
|
|
User.findOne({slug:slug(req.query.slug)}, function(err, existingUser){
|
|
|
|
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); }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Link to androidapp in play store
|
|
|
|
router.get('/android', function(req,res){
|
|
|
|
res.redirect('https://play.google.com/store/apps/details?id=us.keithirwin.tracman');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Link to iphone app in the apple store
|
|
|
|
router.get('/ios', function(req,res){
|
|
|
|
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;
|