diff --git a/app.js b/app.js index 5a79fd21da..35b42fbe91 100755 --- a/app.js +++ b/app.js @@ -65,12 +65,12 @@ app.get('/api/foursquare', passportConf.ensureAuthenticated, api.getFoursquare); app.get('/api/tumblr', passportConf.ensureAuthenticated, api.getTumblr); app.get('/api/facebook', passportConf.ensureAuthenticated, api.getFacebook); app.get('/api/scraping', api.getScraping); -app.get('/api/github', api.getGithub); +app.get('/api/github', passportConf.ensureAuthenticated, api.getGithub); app.get('/api/lastfm', api.getLastfm); app.get('/api/nyt', api.getNewYorkTimes); app.get('/api/twilio', api.getTwilio); app.get('/api/etsy', api.getEtsy); -app.get('/api/twitter', api.getTwitter); +app.get('/api/twitter', passportConf.ensureAuthenticated, api.getTwitter); app.get('/contact', contact.getContact); app.post('/contact', contact.postContact); diff --git a/controllers/api.js b/controllers/api.js index 16357e8943..f6827bab5f 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -8,7 +8,7 @@ var geoip = require('geoip-lite'); var FB = require('fb'); var tumblr = require('tumblr.js'); var foursquare = require('node-foursquare')({ secrets: config.foursquare }); - +var Github = require('github-api'); /** * GET /api @@ -118,4 +118,47 @@ exports.getScraping = function(req, res) { user: req.user }); }); -}; \ No newline at end of file +}; + +exports.getGithub = function(req, res) { + var token = _.findWhere(req.user.tokens, { kind: 'github' }); + if (!token) { + return res.render('api/unauthorized', { + title: 'GitHub API', + provider: 'GitHub', + user: req.user + }); + } + // TODO: Fix rate limit on passport-github token + var github = new Github({ token: token.token }); + var repo = github.getRepo('sahat', 'cloudbucket'); + repo.show(function(err, repo) { + res.render('api/github', { + title: 'GitHub API', + repo: repo, + user: req.user + }); + }); + +}; + +exports.getTwilio = function(req, res) { + +}; + +exports.getEtsy = function(req, res) { + +}; + +exports.getNewYorkTimes = function(req, res) { + +}; + +exports.getLastfm = function(req, res) { + +}; + +exports.getTwitter = function(req, res) { + +}; + diff --git a/package.json b/package.json index 5690e404c8..44637ce14d 100755 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "connect-flash": "*", "express": "*", "forever": "*", + "github-api": "*", "request": "*", "geoip-lite": "*", "jade": "*", diff --git a/public/css/ios7.less b/public/css/ios7.less index e649546ab2..0fdc3475ab 100644 --- a/public/css/ios7.less +++ b/public/css/ios7.less @@ -497,14 +497,12 @@ label-info { .panel { background-color: #fff; border-radius: 0; - border: 0; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); } .panel-default { > .panel-heading { background-color: #fff; - border: 0; color: #007aff; font-size: 15px; font-weight: 400; @@ -518,6 +516,27 @@ label-info { } + + +// Wells ================================================================= +.well { + padding: 15px 15px 5px; + border: 0; + background-color: rgba(0, 0, 0, 0.08); + margin-bottom: 0; + color: #555; + + strong { + font-size: 85%; + color: #888; + border-bottom: 1px solid #c6c6c6; + display: block; + padding-bottom: 8px; + margin-bottom: 10px; + } +} + + // Typography ================================================================= .page-header { diff --git a/views/api.jade b/views/api.jade index a77fe2cfb3..5654cba464 100644 --- a/views/api.jade +++ b/views/api.jade @@ -5,24 +5,24 @@ block content ul.list-unstyled.lead li - a(href='/api/foursquare') Foursquare - li - a(href='/api/tumblr') Tumblr + a(href='/api/etsy') Etsy li a(href='/api/facebook') Facebook + li + a(href='/api/foursquare') Foursquare + li + a(href='/api/github') GitHub li a(href='/api/lastfm') Last.fm li - a(href='/api/tokbox') Tokbox + a(href='/api/nyt') New York Times li - a(href='/api/scraping') Web Scraping + a(href='/api/tumblr') Tumblr li a(href='/api/twitter') Twitter li a(href='/api/twilio') Twilio li - a(href='/api/etsy') Etsy - li - a(href='/api/nyt') New York Times - li - a(href='/api/github') GitHub + a(href='/api/scraping') Web Scraping + + diff --git a/views/api/github.jade b/views/api/github.jade new file mode 100644 index 0000000000..c9b4b56331 --- /dev/null +++ b/views/api/github.jade @@ -0,0 +1,44 @@ +extends ../layout + +block content + .page-header + h1 + i.fa.fa-github + | GitHub API + .btn-group.btn-group-justified + a.btn.btn-lg.btn-primary(href='http://developer.github.com/guides/getting-started/', target='_blank') + i.fa.fa-check-square-o + | Getting Started + a.btn.btn-lg.btn-primary(href='https://apigee.com/console/github', target='_blank') + i.fa.fa-laptop + | API Console + a.btn.btn-lg.btn-primary(href='http://developer.github.com/v3/', target='_blank') + i.fa.fa-code-fork + | Documentation + + .panel.panel-default + .panel-heading + h3.panel-title Repository Information + .panel-body + .row + .col-xs-4 + img.img-rounded.img-responsive(src='https://github.global.ssl.fastly.net/images/modules/logos_page/Octocat.png') + .col-sm-6.col-md-8 + h4 + a(href='#{repo.html_url}') #{repo.name} + p + .btn.btn-sm.btn-primary-outline + i.fa.fa-eye-slash + | Watchers: #{repo.watchers_count} + .btn.btn-sm.btn-primary-outline + i.fa.fa-star + | Starred: #{repo.stargazers_count} + .btn.btn-sm.btn-primary-outline + i.fa.fa-code-fork + | Forks: #{repo.forks_count} + .btn.btn-sm.btn-primary-outline + i.fa.fa-code + | #{repo.language} + .well + strong DESCRIPTION + p= repo.description \ No newline at end of file diff --git a/views/api/scraping.jade b/views/api/scraping.jade index b5fe809563..f12bb1b2b9 100644 --- a/views/api/scraping.jade +++ b/views/api/scraping.jade @@ -17,7 +17,7 @@ block content img(src='/img/hacker_news.png', width=50, height=50) span Hacker News Frontpage - table.table.table-condensed.table-hover + table.table.table-condensed thead tr th №