Created a separate page to which user gets redirected if no token is present (foursquare)
This commit is contained in:
@ -21,6 +21,14 @@ exports.getApi = function(req, res) {
|
|||||||
* GET /api/foursquare
|
* GET /api/foursquare
|
||||||
*/
|
*/
|
||||||
exports.getFoursquare = function(req, res) {
|
exports.getFoursquare = function(req, res) {
|
||||||
|
if (!req.user.tokens.foursquare) {
|
||||||
|
return res.render('api/unauthorized', {
|
||||||
|
title: 'Foursquare API',
|
||||||
|
provider: 'Foursquare',
|
||||||
|
user: req.user
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
trendingVenues: function(callback) {
|
trendingVenues: function(callback) {
|
||||||
var geo = geoip.lookup('4.17.136.0');
|
var geo = geoip.lookup('4.17.136.0');
|
||||||
@ -43,12 +51,8 @@ exports.getFoursquare = function(req, res) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(err, results) {
|
function(err, results) {
|
||||||
if (err) {
|
|
||||||
req.flash('info', err);
|
|
||||||
}
|
|
||||||
res.render('api/foursquare', {
|
res.render('api/foursquare', {
|
||||||
title: 'Foursquare API',
|
title: 'Foursquare API',
|
||||||
message: req.flash('info'),
|
|
||||||
user: req.user,
|
user: req.user,
|
||||||
trendingVenues: results.trendingVenues,
|
trendingVenues: results.trendingVenues,
|
||||||
venueDetail: results.venueDetail,
|
venueDetail: results.venueDetail,
|
||||||
|
@ -1,64 +1,54 @@
|
|||||||
extends ../layout
|
extends ../layout
|
||||||
|
|
||||||
block content
|
block content
|
||||||
if !user.tokens.foursquare
|
.page-header
|
||||||
h3
|
|
||||||
i.fa.fa-shield
|
|
||||||
| Authorization Required
|
|
||||||
a(href='/auth/foursquare')
|
|
||||||
.label.label-primary.label-block
|
|
||||||
h2
|
|
||||||
i.fa.fa-qrcode
|
|
||||||
| Get Foursquare Token
|
|
||||||
else
|
|
||||||
h1
|
h1
|
||||||
i.fa.fa-foursquare
|
i.fa.fa-foursquare
|
||||||
| Foursquare APIs
|
| Foursquare APIs
|
||||||
.btn-group.btn-group-justified
|
.btn-group.btn-group-justified
|
||||||
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/start', target='_blank')
|
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/start', target='_blank')
|
||||||
i.fa.fa-check-square-o
|
i.fa.fa-check-square-o
|
||||||
| Getting Started
|
| Getting Started
|
||||||
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/explore', target='_blank')
|
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/explore', target='_blank')
|
||||||
i.fa.fa-laptop
|
i.fa.fa-laptop
|
||||||
| API Console
|
| API Console
|
||||||
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/', target='_blank')
|
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/', target='_blank')
|
||||||
i.fa.fa-code-fork
|
i.fa.fa-code-fork
|
||||||
| API Endpoints
|
| API Endpoints
|
||||||
|
h3.text-primary Trending Venues
|
||||||
h3.text-primary Trending Venues
|
table.dataTable.table.table-striped.table-bordered
|
||||||
table.dataTable.table.table-striped.table-bordered
|
thead
|
||||||
thead
|
tr
|
||||||
|
th Name
|
||||||
|
th.hidden-xs.hidden-sm Category
|
||||||
|
th.hidden-xs Checkins
|
||||||
|
th Here Now
|
||||||
|
tbody
|
||||||
|
for venue in trendingVenues.venues
|
||||||
tr
|
tr
|
||||||
th Name
|
td= venue.name
|
||||||
th.hidden-xs.hidden-sm Category
|
td.hidden-xs.hidden-sm #{venue.categories[0].name}
|
||||||
th.hidden-xs Checkins
|
td.hidden-xs #{venue.stats.checkinsCount}
|
||||||
th Here Now
|
td= venue.hereNow.count
|
||||||
tbody
|
h3.text-primary Venue Detail
|
||||||
for venue in trendingVenues.venues
|
p
|
||||||
tr
|
img(src='#{venueDetail.venue.photos.groups[0].items[0].prefix}150x150#{venueDetail.venue.photos.groups[0].items[0].suffix}')
|
||||||
td= venue.name
|
.label.label-primary #{venueDetail.venue.name} (#{venueDetail.venue.categories[0].shortName})
|
||||||
td.hidden-xs.hidden-sm #{venue.categories[0].name}
|
.label.label-success #{venueDetail.venue.location.address}, #{venueDetail.venue.location.city}, #{venueDetail.venue.location.state}
|
||||||
td.hidden-xs #{venue.stats.checkinsCount}
|
.label.label-warning #{venueDetail.venue.likes.count} likes, #{venueDetail.venue.rating} rating
|
||||||
td= venue.hereNow.count
|
|
||||||
h3.text-primary Venue Detail
|
|
||||||
p
|
|
||||||
img(src='#{venueDetail.venue.photos.groups[0].items[0].prefix}150x150#{venueDetail.venue.photos.groups[0].items[0].suffix}')
|
|
||||||
.label.label-primary #{venueDetail.venue.name} (#{venueDetail.venue.categories[0].shortName})
|
|
||||||
.label.label-success #{venueDetail.venue.location.address}, #{venueDetail.venue.location.city}, #{venueDetail.venue.location.state}
|
|
||||||
.label.label-warning #{venueDetail.venue.likes.count} likes, #{venueDetail.venue.rating} rating
|
|
||||||
|
|
||||||
h3.text-primary User Checkins
|
h3.text-primary User Checkins
|
||||||
table.dataTable.table.table-bordered.table-hover
|
table.dataTable.table.table-bordered.table-hover
|
||||||
thead
|
thead
|
||||||
|
tr
|
||||||
|
th Name
|
||||||
|
th Location
|
||||||
|
th Category
|
||||||
|
th Checkins
|
||||||
|
tbody
|
||||||
|
for checkin in userCheckins.checkins.items
|
||||||
tr
|
tr
|
||||||
th Name
|
td= checkin.venue.name
|
||||||
th Location
|
td #{checkin.venue.location.address}, #{checkin.venue.location.city}, #{checkin.venue.location.state}
|
||||||
th Category
|
td= checkin.venue.categories[0].shortName
|
||||||
th Checkins
|
td= checkin.venue.stats.checkinsCount
|
||||||
tbody
|
|
||||||
for checkin in userCheckins.checkins.items
|
|
||||||
tr
|
|
||||||
td= checkin.venue.name
|
|
||||||
td #{checkin.venue.location.address}, #{checkin.venue.location.city}, #{checkin.venue.location.state}
|
|
||||||
td= checkin.venue.categories[0].shortName
|
|
||||||
td= checkin.venue.stats.checkinsCount
|
|
||||||
|
9
views/api/unauthorized.jade
Normal file
9
views/api/unauthorized.jade
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
extends ../layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
h3
|
||||||
|
i.fa.fa-lock
|
||||||
|
| Authorization Required
|
||||||
|
a.btn.btn-lg.btn-primary(href='/auth/foursquare')
|
||||||
|
i.fa.fa-qrcode
|
||||||
|
| Get #{provider} Token
|
Reference in New Issue
Block a user