Fixed pro

master
Keith Irwin 2017-04-25 17:22:23 -04:00
parent 2043599fa2
commit b390bd4a57
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
4 changed files with 104 additions and 87 deletions

View File

@ -6,84 +6,86 @@ const mw = require('../middleware.js'),
xss = require('xss'),
User = require('../models.js').user;
// Index
router.get('/', (req,res,next)=>{
res.render('index');
});
// Help
router.get('/help', mw.ensureAuth, (req,res)=>{
res.render('help');
});
// Terms of Service and Privacy Policy
router.get('/terms', (req,res)=>{
res.render('terms');
})
.get('/privacy', (req,res)=>{
res.render('privacy');
});
// robots.txt
router.get('/robots.txt', (req,res)=>{
res.type('text/plain');
res.send("User-agent: *\n"+
"Disallow: /map/*\n"
);
});
// favicon.ico
router.get('/favicon.ico', (req,res)=>{
res.redirect('/static/img/icon/by/16-32-48.ico');
});
// Endpoint to validate forms
router.get('/validate', (req,res)=>{
module.exports = router
// Validate unique slug
if (req.query.slug) {
User.findOne({ slug: slug(req.query.slug) })
.then( (existingUser)=>{
if (existingUser && existingUser.id!==req.user.id) {
res.sendStatus(400);
}
else { res.sendStatus(200); }
})
.catch( (err)=>{ mw.throwErr(err,req); });
}
// Validate unique email
else if (req.query.email) {
User.findOne({ email: req.query.email })
.then( (existingUser)=>{
if (existingUser && existingUser.id!==req.user.id) {
res.sendStatus(400);
}
else { res.sendStatus(200); }
})
.catch( (err)=>{ mw.throwErr(err,req); });
}
// Create slug
else if (req.query.slugify) {
res.send(slug(xss(req.query.slugify)));
}
else if (req.query.xss) {
res.send(xss(req.query.xss));
}
});
// Index
.get('/', (req,res,next)=>{
res.render('index');
})
// Link to androidapp in play store
router.get('/android', (req,res)=>{
res.redirect('https://play.google.com/store/apps/details?id=us.keithirwin.tracman');
});
// Help
.get('/help', mw.ensureAuth, (req,res)=>{
res.render('help');
})
// Terms of Service and Privacy Policy
.get('/terms', (req,res)=>{
res.render('terms');
})
.get('/privacy', (req,res)=>{
res.render('privacy');
})
// robots.txt
.get('/robots.txt', (req,res)=>{
res.type('text/plain');
res.send("User-agent: *\n"+
"Disallow: /map/*\n"
);
})
// favicon.ico
.get('/favicon.ico', (req,res)=>{
res.redirect('/static/img/icon/by/16-32-48.ico');
})
// Endpoint to validate forms
.get('/validate', (req,res)=>{
// Validate unique slug
if (req.query.slug) {
User.findOne({ slug: slug(req.query.slug) })
.then( (existingUser)=>{
if (existingUser && existingUser.id!==req.user.id) {
res.sendStatus(400);
}
else { res.sendStatus(200); }
})
.catch( (err)=>{ mw.throwErr(err,req); });
}
// Validate unique email
else if (req.query.email) {
User.findOne({ email: req.query.email })
.then( (existingUser)=>{
if (existingUser && existingUser.id!==req.user.id) {
res.sendStatus(400);
}
else { res.sendStatus(200); }
})
.catch( (err)=>{ mw.throwErr(err,req); });
}
// Create slug
else if (req.query.slugify) {
res.send(slug(xss(req.query.slugify)));
}
else if (req.query.xss) {
res.send(xss(req.query.xss));
}
})
// Link to androidapp in play store
.get('/android', (req,res)=>{
res.redirect('https://play.google.com/store/apps/details?id=us.keithirwin.tracman');
})
// Link to iphone app in the apple store
// ... maybe someday
.get('/ios', (req,res)=>{
res.redirect('/help#why-is-there-no-ios-app');
})
// Link to iphone app in the apple store
// ... maybe someday
router.get('/ios', (req,res)=>{
res.redirect('/help#why-is-there-no-ios-app');
});
module.exports = router;
;

View File

@ -66,6 +66,7 @@ router.route('/')
req.flash('warning', `<u>${req.body.email}</u> is not a valid email address. `);
res.redirect('/settings');
}
else {
// Email changed
@ -231,6 +232,7 @@ router.route('/password/:token')
mw.throwErr(new Error(`That password could be cracked in ${daysToCrack} days! Come up with a more complex password that would take at least 10 days to crack. `));
res.redirect(`/settings/password/${req.params.token}`);
}
else {
// Delete token
@ -282,7 +284,7 @@ router.route('/pro')
{$set:{ isPro:true }})
.then( (user)=>{
req.flash('success','You have been signed up for pro. ');
res.redirect('/map');
res.redirect(req.session.next||'/settings');
})
.catch( (err)=>{
mw.throwErr(err,req);

View File

@ -113,6 +113,8 @@ section {
.red, .red:hover { color: #fb6e3d !important; }
.yellow, .yellow:hover { color: #fbc93d !important; }
.green, .green:hover { color: #8ae137 !important; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.shadow {
-moz-box-shadow: .18vw .18vw .36vw #000;

View File

@ -1,5 +1,13 @@
{% extends 'templates/base.html' %}
{% block title %}{{ super() }} | Pro{% endblock %}
{% block title %}{{super()}} | Pro{% endblock %}
{% block head %}{{super()}}
<style>
p { margin-bottom: 18px; }
.main.btn, #already-pro
{ width: 40vw; }
</style>
{% endblock %}
{% block main %}
<section class='dark'>
@ -12,20 +20,23 @@
<p>Glad you're enjoying my website and app. I made the whole thing, from front to backend, and I'm really proud of it! However, I'm a long-haul trucker by day and coding is just a hobby. I don't make any money off this website, and I pay the server fees out of my own pocket. Do you pity me enough to donate some <a href="https://cash.me/$KeithIrwin">money</a> or <a href="bitcoin:16KY9k6qdXqDD3mWwr8hrD7ky18AqYSJDo?label=tracman">bitcoin</a>? </p>
<p>To make a little money off this service, I'm going to be offering a pro version with more features. It'll be cheap, probably $1 or $2 per month. However, while Tracman is in beta, you can beta test the pro version too. Be sure to <a href="https://github.com/Tracman-org/Server/issues/new">inform me about any bugs</a> you encounter. And keep in mind that at some point, when we launch out of beta, Tracman Pro will <em>not</em> be free and <strong>you will lose your pro membership</strong> unless start paying for it.
<p>To make a little money off this service, I'm going to be offering a pro version with more features. It'll be cheap, probably $1 or $2 per month. While Tracman is in beta, you can test the pro version for free. Be sure to <a href="https://github.com/Tracman-org/Server/issues/new">inform me about any bugs</a> you encounter. And keep in mind that at some point, when we launch out of beta, Tracman Pro will <i>not</i> be free and you will <b>lose</b> your pro membership unless start paying for it. </p>
<p>That said, just click the button below to test out the pro features. Keep in mind, they are as <a href="/#disclaimer">unstable</a> as the rest of this product.
<p>That said, just click the button below to try pro out. </p>
<p>Cheers, <br>
<a href="https://keithirwin.us/">Keith Irwin</a></p>
<form class='row flexbox' action="#" method="POST">
<form class='flex' action="#" method="POST">
{% if user.isPro %}
<div class='alert alert-success'><i class="fa fa-check-circle"></i> You are already pro! </div>
<a class='btn' href="/map">go to map</a>
<div id='already-pro' class='inline-block alert alert-success'>
<i class="fa fa-check-circle"></i>
<span class='text'>You are already pro! </span>
</div>
<a class='btn' href="javascript:history.go(-1)">go back</a>
{% else %}
<button type="submit" class='btn yellow'>GO PRO</button>
<a class='btn' href="/map">go home</a>
<input type="submit" class='btn main' value="Go Pro"></input>
<a class='btn' href="javascript:history.go(-1)">go home</a>
{% endif %}
</form>