From 3b829d55e1485269da7514d29f65b52bc4c2efa7 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sun, 2 Apr 2017 13:41:52 -0500 Subject: [PATCH 01/21] add ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file From c260737a00fad7dd54e39a8494a97be3c56037f9 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sun, 2 Apr 2017 13:42:35 -0500 Subject: [PATCH 02/21] init commit --- app.js | 46 ++++++++++++++++++ bin/www | 90 ++++++++++++++++++++++++++++++++++++ package.json | 30 ++++++++++++ public/stylesheets/style.css | 8 ++++ routes/index.js | 9 ++++ routes/users.js | 9 ++++ views/error.hbs | 3 ++ views/index.hbs | 2 + views/layout.hbs | 10 ++++ 9 files changed, 207 insertions(+) create mode 100644 app.js create mode 100755 bin/www create mode 100644 package.json create mode 100644 public/stylesheets/style.css create mode 100644 routes/index.js create mode 100644 routes/users.js create mode 100644 views/error.hbs create mode 100644 views/index.hbs create mode 100644 views/layout.hbs diff --git a/app.js b/app.js new file mode 100644 index 0000000..94a75a6 --- /dev/null +++ b/app.js @@ -0,0 +1,46 @@ +var express = require('express'); +var path = require('path'); +var favicon = require('serve-favicon'); +var logger = require('morgan'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); + +var index = require('./routes/index'); +var users = require('./routes/users'); + +var app = express(); + +// view engine setup +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'hbs'); + +// uncomment after placing your favicon in /public +//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); +app.use(logger('dev')); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: false })); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, 'public'))); + +app.use('/', index); +app.use('/users', users); + +// catch 404 and forward to error handler +app.use(function(req, res, next) { + var err = new Error('Not Found'); + err.status = 404; + next(err); +}); + +// error handler +app.use(function(err, req, res, next) { + // set locals, only providing error in development + res.locals.message = err.message; + res.locals.error = req.app.get('env') === 'development' ? err : {}; + + // render the error page + res.status(err.status || 500); + res.render('error'); +}); + +module.exports = app; diff --git a/bin/www b/bin/www new file mode 100755 index 0000000..22f988a --- /dev/null +++ b/bin/www @@ -0,0 +1,90 @@ +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var app = require('../app'); +var debug = require('debug')('project-what-have-you-done:server'); +var http = require('http'); + +/** + * Get port from environment and store in Express. + */ + +var port = normalizePort(process.env.PORT || '3000'); +app.set('port', port); + +/** + * Create HTTP server. + */ + +var server = http.createServer(app); + +/** + * Listen on provided port, on all network interfaces. + */ + +server.listen(port); +server.on('error', onError); +server.on('listening', onListening); + +/** + * Normalize a port into a number, string, or false. + */ + +function normalizePort(val) { + var port = parseInt(val, 10); + + if (isNaN(port)) { + // named pipe + return val; + } + + if (port >= 0) { + // port number + return port; + } + + return false; +} + +/** + * Event listener for HTTP server "error" event. + */ + +function onError(error) { + if (error.syscall !== 'listen') { + throw error; + } + + var bind = typeof port === 'string' + ? 'Pipe ' + port + : 'Port ' + port; + + // handle specific listen errors with friendly messages + switch (error.code) { + case 'EACCES': + console.error(bind + ' requires elevated privileges'); + process.exit(1); + break; + case 'EADDRINUSE': + console.error(bind + ' is already in use'); + process.exit(1); + break; + default: + throw error; + } +} + +/** + * Event listener for HTTP server "listening" event. + */ + +function onListening() { + var addr = server.address(); + var bind = typeof addr === 'string' + ? 'pipe ' + addr + : 'port ' + addr.port; + debug('Listening on ' + bind); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..4ce291e --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "project-what-have-you-done", + "version": "0.0.0", + "private": true, + "scripts": { + "start": "node ./bin/www" + }, + "dependencies": { + "body-parser": "~1.17.1", + "cookie-parser": "~1.4.3", + "debug": "~2.6.3", + "express": "~4.15.2", + "hbs": "~4.0.1", + "morgan": "~1.8.1", + "serve-favicon": "~2.4.2" + }, + "description": "Build an application to help track the legislative activities of your local representatives.", + "main": "app.js", + "repository": { + "type": "git", + "url": "git+https://github.com/bhefty/project_what_have_you_done.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/bhefty/project_what_have_you_done/issues" + }, + "homepage": "https://github.com/bhefty/project_what_have_you_done#readme" +} diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css new file mode 100644 index 0000000..9453385 --- /dev/null +++ b/public/stylesheets/style.css @@ -0,0 +1,8 @@ +body { + padding: 50px; + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; +} + +a { + color: #00B7FF; +} diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..ecca96a --- /dev/null +++ b/routes/index.js @@ -0,0 +1,9 @@ +var express = require('express'); +var router = express.Router(); + +/* GET home page. */ +router.get('/', function(req, res, next) { + res.render('index', { title: 'Express' }); +}); + +module.exports = router; diff --git a/routes/users.js b/routes/users.js new file mode 100644 index 0000000..623e430 --- /dev/null +++ b/routes/users.js @@ -0,0 +1,9 @@ +var express = require('express'); +var router = express.Router(); + +/* GET users listing. */ +router.get('/', function(req, res, next) { + res.send('respond with a resource'); +}); + +module.exports = router; diff --git a/views/error.hbs b/views/error.hbs new file mode 100644 index 0000000..0659765 --- /dev/null +++ b/views/error.hbs @@ -0,0 +1,3 @@ +

{{message}}

+

{{error.status}}

+
{{error.stack}}
diff --git a/views/index.hbs b/views/index.hbs new file mode 100644 index 0000000..1f308fd --- /dev/null +++ b/views/index.hbs @@ -0,0 +1,2 @@ +

{{title}}

+

Welcome to {{title}}

diff --git a/views/layout.hbs b/views/layout.hbs new file mode 100644 index 0000000..068eb6b --- /dev/null +++ b/views/layout.hbs @@ -0,0 +1,10 @@ + + + + {{title}} + + + + {{{body}}} + + From 2d5b3bc7698f043fe51efd66d3cc2ab4c1b9982c Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Tue, 4 Apr 2017 06:42:59 -0500 Subject: [PATCH 03/21] add data structure --- models/legislators.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 models/legislators.js diff --git a/models/legislators.js b/models/legislators.js new file mode 100644 index 0000000..64db97a --- /dev/null +++ b/models/legislators.js @@ -0,0 +1,11 @@ +class Legistlator { + constructor(img, name, chamber, party, votes) { + this.img = img + this.name = name + this.chamber = chamber + this.party = party + this.votes = votes + } +} + +module.exports = Legistlator \ No newline at end of file From bd6a728bebd17eb3fb95b8af25202213d8d7d784 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Tue, 4 Apr 2017 06:43:15 -0500 Subject: [PATCH 04/21] add legislator route --- routes/legislators.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 routes/legislators.js diff --git a/routes/legislators.js b/routes/legislators.js new file mode 100644 index 0000000..172530f --- /dev/null +++ b/routes/legislators.js @@ -0,0 +1,22 @@ +var express = require('express'); +var router = express.Router(); + +const sunlightAPI = require('../utils/api') + +/* GET legislator info by id */ +router.get('/:id', function(req, res, next) { + const id = req.params.id + let data = [] + + let legislator = sunlightAPI.getLegislatorByID(id) + let votes = sunlightAPI.getRecentVotesByID(id) + + Promise.all([legislator, votes]) + .then(results => res.send(results)) + .catch((err) => { + console.error(err) + }) + +}); + +module.exports = router; From 85988d3ae555ee95ea42b7985452d591cd99cbf7 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Tue, 4 Apr 2017 06:43:33 -0500 Subject: [PATCH 05/21] api logic --- utils/api.js | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 utils/api.js diff --git a/utils/api.js b/utils/api.js new file mode 100644 index 0000000..2d9a547 --- /dev/null +++ b/utils/api.js @@ -0,0 +1,186 @@ +const request = require('request') + +const Legislator = require('../models/legislators') + +const URI = 'https://congress.api.sunlightfoundation.com' + +const capitalize = (text) => { + return text.charAt(0).toUpperCase() + text.slice(1) +} + +const formatParty = (party) => { + switch (party) { + case 'R': + return 'Republican' + break + case 'D': + return 'Democrat' + break + case 'I': + return 'Independent' + break + default: + return 'No associated party' + } +} + +const getRecentVotes = (id) => { + return new Promise((resolve, reject) => { + let options = { + url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, + headers: { + 'User-Agent': 'request' + } + } + class Vote { + constructor(bill_id, official_title, url, question, vote){ + this.bill_id = bill_id + this.official_title = official_title + this.url = url + this.question = question + this.vote = vote + } + } + let voteInfo = [] + + request(options, (error, response, body) => { + if (!error && response.statusCode == 200) { + let results = JSON.parse(body) + results.results.map((voteData) => { + voteInfo.push( + new Vote( + voteData.bill.bill_id, + voteData.bill.official_title, + voteData.bill.urls.congress, + voteData.question, + voteData.voter_ids[id] + ) + ) + }) + resolve(voteInfo) + } else { + reject(error) + } + }) + }) +} + +const mapLegislators = (legislator) => { + return new Promise((resolve, reject) => { + // results.results.map((legislators) => { + getRecentVotes(legislator.bioguide_id) + .then((voteResults) => { + return new Legislator( + `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, + `${legislator.first_name} ${legislator.last_name}`, + capitalize(legislator.chamber), + formatParty(legislator.party), + voteResults + ) + }) + .then((mappedLegislator) => resolve(mappedLegislator)) + // }) + }) +} + +const sunlightAPI = { + getLegistlatorByZip: (zip) => { + return new Promise((resolve, reject) => { + if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(zip))) { + reject('Not a valid zip!') + } else { + let options = { + url: `${URI}/legislators/locate?zip=${zip}`, + headers: { + 'User-Agent': 'request' + } + } + + request(options, (error, response, body) => { + if (!error && response.statusCode == 200) { + let results = JSON.parse(body) + let legislatorList = [] + + results.results.map((legislator) => { + getRecentVotes(legislator.bioguide_id) + .then((votes) => { + legislatorList.push( + legislator, + votes + ) + }) + .then(() => resolve(legislatorList)) + // legislatorList.push( + // legislator, + // getRecentVotes(legislator.bioguide_id) + // ) + // mapLegislators(legislator) + // .then((result) => { + // resolve(result) + // }) + }) + // resolve(legislatorList) + + // results.results.map((legislatorResult) => { + // getRecentVotes(legislatorResult.bioguide_id) + // .then((voteResults) => { + // legislatorList.push( + // new Legislator( + // `https://theunitedstates.io/images/congress/original/${legislatorResult.bioguide_id}.jpg`, + // `${legislatorResult.first_name} ${legislatorResult.last_name}`, + // capitalize(legislatorResult.chamber), + // formatParty(legislatorResult.party), + // voteResults + // ) + // ) + // console.log(legislatorList.length) + // }) + // }) + } else { + reject(error) + } + }) + } + }) + }, + getLegislatorByID: (id) => { + return new Promise((resolve, reject) => { + let options = { + url: `${URI}/legislators?bioguide_id=${id}`, + headers: { + 'User-Agent': 'request' + } + } + + request(options, (error, response, body) => { + if (!error && response.statusCode == 200) { + let results = JSON.parse(body) + resolve(results) + } else { + reject(error) + } + }) + }) + }, + getRecentVotesByID: (id) => { + return new Promise((resolve, reject) => { + let options = { + url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, + headers: { + 'User-Agent': 'request' + } + } + + request(options, (error, response, body) => { + if (!error && response.statusCode == 200) { + let results = JSON.parse(body) + resolve(results) + } else { + reject(error) + } + }) + }) + } +} + +module.exports = sunlightAPI \ No newline at end of file From 12409a7fe3ca40fe35577116415186cfaf0e4b1f Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Tue, 4 Apr 2017 06:43:52 -0500 Subject: [PATCH 06/21] test api logic --- app.js | 4 ++-- npm-debug.log | 47 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 15 +-------------- routes/index.js | 21 +++++++++++++++++++++ routes/users.js | 9 --------- 5 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 npm-debug.log delete mode 100644 routes/users.js diff --git a/app.js b/app.js index 94a75a6..c317392 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var index = require('./routes/index'); -var users = require('./routes/users'); +let legislators = require('./routes/legislators') var app = express(); @@ -23,7 +23,7 @@ app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', index); -app.use('/users', users); +app.use('/legislators', legislators) // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..e29ebea --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,47 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/Users/billhefty/.nvm/versions/node/v7.7.4/bin/node', +1 verbose cli '/Users/billhefty/.nvm/versions/node/v7.7.4/bin/npm', +1 verbose cli 'start' ] +2 info using npm@4.1.2 +3 info using node@v7.7.4 +4 verbose run-script [ 'prestart', 'start', 'poststart' ] +5 info lifecycle project-what-have-you-done@0.0.0~prestart: project-what-have-you-done@0.0.0 +6 silly lifecycle project-what-have-you-done@0.0.0~prestart: no script for prestart, continuing +7 info lifecycle project-what-have-you-done@0.0.0~start: project-what-have-you-done@0.0.0 +8 verbose lifecycle project-what-have-you-done@0.0.0~start: unsafe-perm in lifecycle true +9 verbose lifecycle project-what-have-you-done@0.0.0~start: PATH: /Users/billhefty/.nvm/versions/node/v7.7.4/lib/node_modules/npm/bin/node-gyp-bin:/Users/billhefty/viking-projects/project_what_have_you_done/node_modules/.bin:/Users/billhefty/.nvm/versions/node/v7.7.4/bin:/Users/billhefty/mongodb/bin:/Users/billhefty/.rvm/gems/ruby-2.3.0/bin:/Users/billhefty/.rvm/gems/ruby-2.3.0@global/bin:/Users/billhefty/.rvm/rubies/ruby-2.3.0/bin:/Users/billhefty/mongodb/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/billhefty/.rvm/bin:/Users/billhefty/.rvm/bin:/Applications/Postgres.app/Contents/Versions/latest/bin +10 verbose lifecycle project-what-have-you-done@0.0.0~start: CWD: /Users/billhefty/viking-projects/project_what_have_you_done +11 silly lifecycle project-what-have-you-done@0.0.0~start: Args: [ '-c', 'node ./bin/www' ] +12 silly lifecycle project-what-have-you-done@0.0.0~start: Returned: code: 1 signal: null +13 info lifecycle project-what-have-you-done@0.0.0~start: Failed to exec start script +14 verbose stack Error: project-what-have-you-done@0.0.0 start: `node ./bin/www` +14 verbose stack Exit status 1 +14 verbose stack at EventEmitter. (/Users/billhefty/.nvm/versions/node/v7.7.4/lib/node_modules/npm/lib/utils/lifecycle.js:279:16) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at EventEmitter.emit (events.js:194:7) +14 verbose stack at ChildProcess. (/Users/billhefty/.nvm/versions/node/v7.7.4/lib/node_modules/npm/lib/utils/spawn.js:40:14) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at ChildProcess.emit (events.js:194:7) +14 verbose stack at maybeClose (internal/child_process.js:899:16) +14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) +15 verbose pkgid project-what-have-you-done@0.0.0 +16 verbose cwd /Users/billhefty/viking-projects/project_what_have_you_done +17 error Darwin 16.5.0 +18 error argv "/Users/billhefty/.nvm/versions/node/v7.7.4/bin/node" "/Users/billhefty/.nvm/versions/node/v7.7.4/bin/npm" "start" +19 error node v7.7.4 +20 error npm v4.1.2 +21 error code ELIFECYCLE +22 error project-what-have-you-done@0.0.0 start: `node ./bin/www` +22 error Exit status 1 +23 error Failed at the project-what-have-you-done@0.0.0 start script 'node ./bin/www'. +23 error Make sure you have the latest version of node.js and npm installed. +23 error If you do, this is most likely a problem with the project-what-have-you-done package, +23 error not with npm itself. +23 error Tell the author that this fails on your system: +23 error node ./bin/www +23 error You can get information on how to open an issue for this project with: +23 error npm bugs project-what-have-you-done +23 error Or if that isn't available, you can get their info via: +23 error npm owner ls project-what-have-you-done +23 error There is likely additional logging output above. +24 verbose exit [ 1, true ] diff --git a/package.json b/package.json index 4ce291e..b61fd62 100644 --- a/package.json +++ b/package.json @@ -13,18 +13,5 @@ "hbs": "~4.0.1", "morgan": "~1.8.1", "serve-favicon": "~2.4.2" - }, - "description": "Build an application to help track the legislative activities of your local representatives.", - "main": "app.js", - "repository": { - "type": "git", - "url": "git+https://github.com/bhefty/project_what_have_you_done.git" - }, - "keywords": [], - "author": "", - "license": "ISC", - "bugs": { - "url": "https://github.com/bhefty/project_what_have_you_done/issues" - }, - "homepage": "https://github.com/bhefty/project_what_have_you_done#readme" + } } diff --git a/routes/index.js b/routes/index.js index ecca96a..d21a382 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,6 +1,27 @@ var express = require('express'); var router = express.Router(); +const sunlightAPI = require('../utils/api') +const Legistlator = require('../models/legislators') + +/* GET legislator by zip */ +router.get('/:zip?', function(req, res, next) { + if (!req.query.zip) { + next() + } else { + const zip = req.query.zip + + let legislatorList = [] + + sunlightAPI.getLegistlatorByZip(zip) + .then((results) => res.send(results)) + .catch((err) => { + console.error(err) + res.send(err) + }) + } +}); + /* GET home page. */ router.get('/', function(req, res, next) { res.render('index', { title: 'Express' }); diff --git a/routes/users.js b/routes/users.js deleted file mode 100644 index 623e430..0000000 --- a/routes/users.js +++ /dev/null @@ -1,9 +0,0 @@ -var express = require('express'); -var router = express.Router(); - -/* GET users listing. */ -router.get('/', function(req, res, next) { - res.send('respond with a resource'); -}); - -module.exports = router; From 9352605e5c282cc9623445a63bee5ed08b9c3db9 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 20:15:00 -0500 Subject: [PATCH 07/21] refactor getLegislatorByZip --- models/legislators.js | 3 +- npm-debug.log | 47 ------- utils/api.js | 311 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 258 insertions(+), 103 deletions(-) delete mode 100644 npm-debug.log diff --git a/models/legislators.js b/models/legislators.js index 64db97a..cc13b05 100644 --- a/models/legislators.js +++ b/models/legislators.js @@ -1,5 +1,6 @@ class Legistlator { - constructor(img, name, chamber, party, votes) { + constructor(id, img, name, chamber, party, votes) { + this.id = id this.img = img this.name = name this.chamber = chamber diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index e29ebea..0000000 --- a/npm-debug.log +++ /dev/null @@ -1,47 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/Users/billhefty/.nvm/versions/node/v7.7.4/bin/node', -1 verbose cli '/Users/billhefty/.nvm/versions/node/v7.7.4/bin/npm', -1 verbose cli 'start' ] -2 info using npm@4.1.2 -3 info using node@v7.7.4 -4 verbose run-script [ 'prestart', 'start', 'poststart' ] -5 info lifecycle project-what-have-you-done@0.0.0~prestart: project-what-have-you-done@0.0.0 -6 silly lifecycle project-what-have-you-done@0.0.0~prestart: no script for prestart, continuing -7 info lifecycle project-what-have-you-done@0.0.0~start: project-what-have-you-done@0.0.0 -8 verbose lifecycle project-what-have-you-done@0.0.0~start: unsafe-perm in lifecycle true -9 verbose lifecycle project-what-have-you-done@0.0.0~start: PATH: /Users/billhefty/.nvm/versions/node/v7.7.4/lib/node_modules/npm/bin/node-gyp-bin:/Users/billhefty/viking-projects/project_what_have_you_done/node_modules/.bin:/Users/billhefty/.nvm/versions/node/v7.7.4/bin:/Users/billhefty/mongodb/bin:/Users/billhefty/.rvm/gems/ruby-2.3.0/bin:/Users/billhefty/.rvm/gems/ruby-2.3.0@global/bin:/Users/billhefty/.rvm/rubies/ruby-2.3.0/bin:/Users/billhefty/mongodb/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/billhefty/.rvm/bin:/Users/billhefty/.rvm/bin:/Applications/Postgres.app/Contents/Versions/latest/bin -10 verbose lifecycle project-what-have-you-done@0.0.0~start: CWD: /Users/billhefty/viking-projects/project_what_have_you_done -11 silly lifecycle project-what-have-you-done@0.0.0~start: Args: [ '-c', 'node ./bin/www' ] -12 silly lifecycle project-what-have-you-done@0.0.0~start: Returned: code: 1 signal: null -13 info lifecycle project-what-have-you-done@0.0.0~start: Failed to exec start script -14 verbose stack Error: project-what-have-you-done@0.0.0 start: `node ./bin/www` -14 verbose stack Exit status 1 -14 verbose stack at EventEmitter. (/Users/billhefty/.nvm/versions/node/v7.7.4/lib/node_modules/npm/lib/utils/lifecycle.js:279:16) -14 verbose stack at emitTwo (events.js:106:13) -14 verbose stack at EventEmitter.emit (events.js:194:7) -14 verbose stack at ChildProcess. (/Users/billhefty/.nvm/versions/node/v7.7.4/lib/node_modules/npm/lib/utils/spawn.js:40:14) -14 verbose stack at emitTwo (events.js:106:13) -14 verbose stack at ChildProcess.emit (events.js:194:7) -14 verbose stack at maybeClose (internal/child_process.js:899:16) -14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) -15 verbose pkgid project-what-have-you-done@0.0.0 -16 verbose cwd /Users/billhefty/viking-projects/project_what_have_you_done -17 error Darwin 16.5.0 -18 error argv "/Users/billhefty/.nvm/versions/node/v7.7.4/bin/node" "/Users/billhefty/.nvm/versions/node/v7.7.4/bin/npm" "start" -19 error node v7.7.4 -20 error npm v4.1.2 -21 error code ELIFECYCLE -22 error project-what-have-you-done@0.0.0 start: `node ./bin/www` -22 error Exit status 1 -23 error Failed at the project-what-have-you-done@0.0.0 start script 'node ./bin/www'. -23 error Make sure you have the latest version of node.js and npm installed. -23 error If you do, this is most likely a problem with the project-what-have-you-done package, -23 error not with npm itself. -23 error Tell the author that this fails on your system: -23 error node ./bin/www -23 error You can get information on how to open an issue for this project with: -23 error npm bugs project-what-have-you-done -23 error Or if that isn't available, you can get their info via: -23 error npm owner ls project-what-have-you-done -23 error There is likely additional logging output above. -24 verbose exit [ 1, true ] diff --git a/utils/api.js b/utils/api.js index 2d9a547..7bb6d20 100644 --- a/utils/api.js +++ b/utils/api.js @@ -83,65 +83,225 @@ const mapLegislators = (legislator) => { }) } +const formatLegislator = (legislator) => { + return new Promise((resolve, reject) => { + // results.results.map((legislators) => { + getRecentVotes(legislator.bioguide_id) + .then((voteResults) => { + return new Legislator( + `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, + `${legislator.first_name} ${legislator.last_name}`, + capitalize(legislator.chamber), + formatParty(legislator.party), + voteResults + ) + }) + .then((mappedLegislator) => resolve(mappedLegislator)) + // }) + }) +} + +const applyVotes = (legislator) => { + return new Promise((resolve) => { + resolve(legislator.vote_info = 'none now') + }) +} + const sunlightAPI = { getLegistlatorByZip: (zip) => { return new Promise((resolve, reject) => { - if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(zip))) { - reject('Not a valid zip!') - } else { - let options = { - url: `${URI}/legislators/locate?zip=${zip}`, - headers: { - 'User-Agent': 'request' - } - } - - request(options, (error, response, body) => { - if (!error && response.statusCode == 200) { - let results = JSON.parse(body) - let legislatorList = [] - - results.results.map((legislator) => { - getRecentVotes(legislator.bioguide_id) - .then((votes) => { - legislatorList.push( - legislator, - votes - ) - }) - .then(() => resolve(legislatorList)) - // legislatorList.push( - // legislator, - // getRecentVotes(legislator.bioguide_id) - // ) - // mapLegislators(legislator) - // .then((result) => { - // resolve(result) - // }) - }) - // resolve(legislatorList) - - // results.results.map((legislatorResult) => { - // getRecentVotes(legislatorResult.bioguide_id) - // .then((voteResults) => { - // legislatorList.push( - // new Legislator( - // `https://theunitedstates.io/images/congress/original/${legislatorResult.bioguide_id}.jpg`, - // `${legislatorResult.first_name} ${legislatorResult.last_name}`, - // capitalize(legislatorResult.chamber), - // formatParty(legislatorResult.party), - // voteResults - // ) - // ) - // console.log(legislatorList.length) - // }) - // }) - } else { - reject(error) - } - }) + let options = { + url: `${URI}/legislators/locate?zip=${zip}`, + headers: { + 'User-Agent': 'request' + } } + request(options, (error, response, body) => { + if (!error && response.statusCode == 200) { + let results = JSON.parse(body) + let legislatorList = [] + + // Format the results + results.results.map((legislator) => { + legislatorList.push( + new Legislator( + legislator.bioguide_id, + `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, + `${legislator.first_name} ${legislator.last_name}`, + capitalize(legislator.chamber), + formatParty(legislator.party) + )) + }) + + resolve(legislatorList) + } else { + reject(error) + } + }) }) + + // let requestLegislators = (zip) => new Promise((resolve, reject) => { + // let options = { + // url: `${URI}/legislators/locate?zip=${zip}`, + // headers: { + // 'User-Agent': 'request' + // } + // } + // request(options, (error, response, body) => { + // if (!error && response.statusCode == 200) { + // let results = JSON.parse(body) + // resolve(results) + // } else { + // reject(error) + // } + // }) + // }) + + // let requestVoteInfo = (id) => new Promise((resolve, reject) => { + // let options = { + // url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, + // headers: { + // 'User-Agent': 'request' + // } + // } + // class Vote { + // constructor(bill_id, official_title, url, question, vote){ + // this.bill_id = bill_id + // this.official_title = official_title + // this.url = url + // this.question = question + // this.vote = vote + // } + // } + // let voteInfo = [] + + // request(options, (error, response, body) => { + // if (!error && response.statusCode == 200) { + // let results = JSON.parse(body) + // results.results.map((voteData) => { + // voteInfo.push( + // new Vote( + // voteData.bill.bill_id, + // voteData.bill.official_title, + // voteData.bill.urls.congress, + // voteData.question, + // voteData.voter_ids[id] + // ) + // ) + // }) + // resolve(voteInfo) + // } else { + // reject(error) + // } + // }) + // }) + + // let mapVotesToLegislator = (legislator) => new Promise((resolve, reject) => { + // requestVoteInfo(legislator.bioguide_id) + // .then((voteResults) => { + // return new Legislator( + // `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, + // `${legislator.first_name} ${legislator.last_name}`, + // capitalize(legislator.chamber), + // formatParty(legislator.party), + // voteResults + // ) + // }) + // .then((mappedLegislator) => resolve(mappedLegislator)) + // }) + + // let listOfLegislators = [] + + // let fn = function applyVotesToLegislator(legislator) { + // return new Promise(resolve => legislator.vote_info = 'none') + // } + // let legislatorList = [] + // let resultPromise + // requestLegislators(zipcode) + // .then(results => results) + + + + // }) + + + + // return new Promise((resolve, reject) => { + // if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(zip))) { + // reject('Not a valid zip!') + // } else { + // let options = { + // url: `${URI}/legislators/locate?zip=${zip}`, + // headers: { + // 'User-Agent': 'request' + // } + // } + + // request(options, (error, response, body) => { + // if (!error && response.statusCode == 200) { + // let results = JSON.parse(body) + // let legislatorList = [] + + // // getRecentVotes(results.results[0].bioguide_id) + // // .then((votes) => { + // // results.results[0].vote_info = votes + // // resolve(results.results[0]) + // // }) + + // let legislatorResults = results.results.map((legislator) => { + // getRecentVotes(legislator.bioguide_id) + // .then((votes) => { + // legislator.vote_info = votes + // return legislator + // }) + // }) + // resolve(legislatorResults) + + // // resolve(results.results[0]) + + // // getRecentVotes(results.results[0]) + + // // results.results.map((legislator) => { + // // getRecentVotes(legislator.bioguide_id) + // // .then((votes) => { + // // legislatorList.push( + // // legislator, + // // votes + // // ) + // // }) + // // .then(() => resolve(legislatorList)) + // // // legislatorList.push( + // // // legislator, + // // // getRecentVotes(legislator.bioguide_id) + // // // ) + // // // mapLegislators(legislator) + // // // .then((result) => { + // // // resolve(result) + // // // }) + // // }) + // // resolve(legislatorList) + + // // results.results.map((legislatorResult) => { + // // getRecentVotes(legislatorResult.bioguide_id) + // // .then((voteResults) => { + // // legislatorList.push( + // // new Legislator( + // // `https://theunitedstates.io/images/congress/original/${legislatorResult.bioguide_id}.jpg`, + // // `${legislatorResult.first_name} ${legislatorResult.last_name}`, + // // capitalize(legislatorResult.chamber), + // // formatParty(legislatorResult.party), + // // voteResults + // // ) + // // ) + // // console.log(legislatorList.length) + // // }) + // // }) + // } else { + // reject(error) + // } + // }) + // } + // }) }, getLegislatorByID: (id) => { return new Promise((resolve, reject) => { @@ -155,6 +315,7 @@ const sunlightAPI = { request(options, (error, response, body) => { if (!error && response.statusCode == 200) { let results = JSON.parse(body) + resolve(results) } else { reject(error) @@ -170,17 +331,57 @@ const sunlightAPI = { 'User-Agent': 'request' } } + class Vote { + constructor(bill_id, official_title, url, question, vote){ + this.bill_id = bill_id + this.official_title = official_title + this.url = url + this.question = question + this.vote = vote + } + } + let voteInfo = [] request(options, (error, response, body) => { if (!error && response.statusCode == 200) { let results = JSON.parse(body) - resolve(results) + results.results.map((voteData) => { + voteInfo.push( + new Vote( + voteData.bill.bill_id, + voteData.bill.official_title, + voteData.bill.urls.congress, + voteData.question, + voteData.voter_ids[id] + ) + ) + }) + resolve(voteInfo) } else { reject(error) } }) }) } + // getRecentVotesByID: (id) => { + // return new Promise((resolve, reject) => { + // let options = { + // url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, + // headers: { + // 'User-Agent': 'request' + // } + // } + + // request(options, (error, response, body) => { + // if (!error && response.statusCode == 200) { + // let results = JSON.parse(body) + // resolve(results) + // } else { + // reject(error) + // } + // }) + // }) + // } } module.exports = sunlightAPI \ No newline at end of file From 2fdb64c150032edbe765c8a2d0ae161a1c8e9a86 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:02:19 -0500 Subject: [PATCH 08/21] add npm-debug.log --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 40b878d..9303c34 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +node_modules/ +npm-debug.log \ No newline at end of file From aebfa05c49f42bf725e74c85141ddc53e2bb112f Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:02:47 -0500 Subject: [PATCH 09/21] add Votes class --- models/votes.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 models/votes.js diff --git a/models/votes.js b/models/votes.js new file mode 100644 index 0000000..4ce3116 --- /dev/null +++ b/models/votes.js @@ -0,0 +1,11 @@ +class Vote { + constructor(bill_id, official_title, url, question, vote){ + this.bill_id = bill_id + this.official_title = official_title + this.url = url + this.question = question + this.vote = vote + } +} + +module.exports = Vote \ No newline at end of file From f5fb09606532727ca6f500d5f28898721ab0030c Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:03:07 -0500 Subject: [PATCH 10/21] refactor routes --- routes/legislators.js | 7 + utils/api.js | 303 +++--------------------------------------- 2 files changed, 27 insertions(+), 283 deletions(-) diff --git a/routes/legislators.js b/routes/legislators.js index 172530f..16c3439 100644 --- a/routes/legislators.js +++ b/routes/legislators.js @@ -12,6 +12,13 @@ router.get('/:id', function(req, res, next) { let votes = sunlightAPI.getRecentVotesByID(id) Promise.all([legislator, votes]) + .then((results) => { + let legislatorObj = { + legislator: results[0], + votes: results[1] + } + return legislatorObj + }) .then(results => res.send(results)) .catch((err) => { console.error(err) diff --git a/utils/api.js b/utils/api.js index 7bb6d20..2b6ffaf 100644 --- a/utils/api.js +++ b/utils/api.js @@ -1,6 +1,7 @@ const request = require('request') const Legislator = require('../models/legislators') +const Vote = require('../models/votes') const URI = 'https://congress.api.sunlightfoundation.com' @@ -24,87 +25,14 @@ const formatParty = (party) => { } } -const getRecentVotes = (id) => { - return new Promise((resolve, reject) => { - let options = { - url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, - headers: { - 'User-Agent': 'request' - } - } - class Vote { - constructor(bill_id, official_title, url, question, vote){ - this.bill_id = bill_id - this.official_title = official_title - this.url = url - this.question = question - this.vote = vote - } - } - let voteInfo = [] - - request(options, (error, response, body) => { - if (!error && response.statusCode == 200) { - let results = JSON.parse(body) - results.results.map((voteData) => { - voteInfo.push( - new Vote( - voteData.bill.bill_id, - voteData.bill.official_title, - voteData.bill.urls.congress, - voteData.question, - voteData.voter_ids[id] - ) - ) - }) - resolve(voteInfo) - } else { - reject(error) - } - }) - }) -} - -const mapLegislators = (legislator) => { - return new Promise((resolve, reject) => { - // results.results.map((legislators) => { - getRecentVotes(legislator.bioguide_id) - .then((voteResults) => { - return new Legislator( - `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, - `${legislator.first_name} ${legislator.last_name}`, - capitalize(legislator.chamber), - formatParty(legislator.party), - voteResults - ) - }) - .then((mappedLegislator) => resolve(mappedLegislator)) - // }) - }) -} - -const formatLegislator = (legislator) => { - return new Promise((resolve, reject) => { - // results.results.map((legislators) => { - getRecentVotes(legislator.bioguide_id) - .then((voteResults) => { - return new Legislator( - `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, - `${legislator.first_name} ${legislator.last_name}`, - capitalize(legislator.chamber), - formatParty(legislator.party), - voteResults - ) - }) - .then((mappedLegislator) => resolve(mappedLegislator)) - // }) - }) -} - -const applyVotes = (legislator) => { - return new Promise((resolve) => { - resolve(legislator.vote_info = 'none now') - }) +const addLegislator = (legislator) => { + return new Legislator( + legislator.bioguide_id, + `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, + `${legislator.first_name} ${legislator.last_name}`, + capitalize(legislator.chamber), + formatParty(legislator.party) + ) } const sunlightAPI = { @@ -121,187 +49,19 @@ const sunlightAPI = { let results = JSON.parse(body) let legislatorList = [] - // Format the results + // Format the fields results.results.map((legislator) => { legislatorList.push( - new Legislator( - legislator.bioguide_id, - `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, - `${legislator.first_name} ${legislator.last_name}`, - capitalize(legislator.chamber), - formatParty(legislator.party) - )) + addLegislator(legislator) + ) }) - + resolve(legislatorList) } else { reject(error) } }) }) - - // let requestLegislators = (zip) => new Promise((resolve, reject) => { - // let options = { - // url: `${URI}/legislators/locate?zip=${zip}`, - // headers: { - // 'User-Agent': 'request' - // } - // } - // request(options, (error, response, body) => { - // if (!error && response.statusCode == 200) { - // let results = JSON.parse(body) - // resolve(results) - // } else { - // reject(error) - // } - // }) - // }) - - // let requestVoteInfo = (id) => new Promise((resolve, reject) => { - // let options = { - // url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, - // headers: { - // 'User-Agent': 'request' - // } - // } - // class Vote { - // constructor(bill_id, official_title, url, question, vote){ - // this.bill_id = bill_id - // this.official_title = official_title - // this.url = url - // this.question = question - // this.vote = vote - // } - // } - // let voteInfo = [] - - // request(options, (error, response, body) => { - // if (!error && response.statusCode == 200) { - // let results = JSON.parse(body) - // results.results.map((voteData) => { - // voteInfo.push( - // new Vote( - // voteData.bill.bill_id, - // voteData.bill.official_title, - // voteData.bill.urls.congress, - // voteData.question, - // voteData.voter_ids[id] - // ) - // ) - // }) - // resolve(voteInfo) - // } else { - // reject(error) - // } - // }) - // }) - - // let mapVotesToLegislator = (legislator) => new Promise((resolve, reject) => { - // requestVoteInfo(legislator.bioguide_id) - // .then((voteResults) => { - // return new Legislator( - // `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, - // `${legislator.first_name} ${legislator.last_name}`, - // capitalize(legislator.chamber), - // formatParty(legislator.party), - // voteResults - // ) - // }) - // .then((mappedLegislator) => resolve(mappedLegislator)) - // }) - - // let listOfLegislators = [] - - // let fn = function applyVotesToLegislator(legislator) { - // return new Promise(resolve => legislator.vote_info = 'none') - // } - // let legislatorList = [] - // let resultPromise - // requestLegislators(zipcode) - // .then(results => results) - - - - // }) - - - - // return new Promise((resolve, reject) => { - // if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(zip))) { - // reject('Not a valid zip!') - // } else { - // let options = { - // url: `${URI}/legislators/locate?zip=${zip}`, - // headers: { - // 'User-Agent': 'request' - // } - // } - - // request(options, (error, response, body) => { - // if (!error && response.statusCode == 200) { - // let results = JSON.parse(body) - // let legislatorList = [] - - // // getRecentVotes(results.results[0].bioguide_id) - // // .then((votes) => { - // // results.results[0].vote_info = votes - // // resolve(results.results[0]) - // // }) - - // let legislatorResults = results.results.map((legislator) => { - // getRecentVotes(legislator.bioguide_id) - // .then((votes) => { - // legislator.vote_info = votes - // return legislator - // }) - // }) - // resolve(legislatorResults) - - // // resolve(results.results[0]) - - // // getRecentVotes(results.results[0]) - - // // results.results.map((legislator) => { - // // getRecentVotes(legislator.bioguide_id) - // // .then((votes) => { - // // legislatorList.push( - // // legislator, - // // votes - // // ) - // // }) - // // .then(() => resolve(legislatorList)) - // // // legislatorList.push( - // // // legislator, - // // // getRecentVotes(legislator.bioguide_id) - // // // ) - // // // mapLegislators(legislator) - // // // .then((result) => { - // // // resolve(result) - // // // }) - // // }) - // // resolve(legislatorList) - - // // results.results.map((legislatorResult) => { - // // getRecentVotes(legislatorResult.bioguide_id) - // // .then((voteResults) => { - // // legislatorList.push( - // // new Legislator( - // // `https://theunitedstates.io/images/congress/original/${legislatorResult.bioguide_id}.jpg`, - // // `${legislatorResult.first_name} ${legislatorResult.last_name}`, - // // capitalize(legislatorResult.chamber), - // // formatParty(legislatorResult.party), - // // voteResults - // // ) - // // ) - // // console.log(legislatorList.length) - // // }) - // // }) - // } else { - // reject(error) - // } - // }) - // } - // }) }, getLegislatorByID: (id) => { return new Promise((resolve, reject) => { @@ -316,7 +76,10 @@ const sunlightAPI = { if (!error && response.statusCode == 200) { let results = JSON.parse(body) - resolve(results) + // Format the fields + let legislator = addLegislator(results.results[0]) + + resolve(legislator) } else { reject(error) } @@ -331,20 +94,13 @@ const sunlightAPI = { 'User-Agent': 'request' } } - class Vote { - constructor(bill_id, official_title, url, question, vote){ - this.bill_id = bill_id - this.official_title = official_title - this.url = url - this.question = question - this.vote = vote - } - } - let voteInfo = [] request(options, (error, response, body) => { if (!error && response.statusCode == 200) { let results = JSON.parse(body) + + let voteInfo = [] + results.results.map((voteData) => { voteInfo.push( new Vote( @@ -363,25 +119,6 @@ const sunlightAPI = { }) }) } - // getRecentVotesByID: (id) => { - // return new Promise((resolve, reject) => { - // let options = { - // url: `${URI}/votes?fields=voter_ids,question,bill&voter_ids.${id}__exists=true&bill_id__exists=true`, - // headers: { - // 'User-Agent': 'request' - // } - // } - - // request(options, (error, response, body) => { - // if (!error && response.statusCode == 200) { - // let results = JSON.parse(body) - // resolve(results) - // } else { - // reject(error) - // } - // }) - // }) - // } } module.exports = sunlightAPI \ No newline at end of file From 0b44a4cb07ba97909c9b5110b732415af4e5c477 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:06:48 -0500 Subject: [PATCH 11/21] check for valid zipcodef --- utils/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/api.js b/utils/api.js index 2b6ffaf..a712421 100644 --- a/utils/api.js +++ b/utils/api.js @@ -38,6 +38,9 @@ const addLegislator = (legislator) => { const sunlightAPI = { getLegistlatorByZip: (zip) => { return new Promise((resolve, reject) => { + if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(zip))) { ++ reject('Not a valid zip!') ++ } let options = { url: `${URI}/legislators/locate?zip=${zip}`, headers: { From d280f2930567e26181ddbb2e119bdef44f0c0546 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:08:05 -0500 Subject: [PATCH 12/21] check for valid zipcodef --- routes/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/routes/index.js b/routes/index.js index d21a382..2e923de 100644 --- a/routes/index.js +++ b/routes/index.js @@ -11,10 +11,8 @@ router.get('/:zip?', function(req, res, next) { } else { const zip = req.query.zip - let legislatorList = [] - sunlightAPI.getLegistlatorByZip(zip) - .then((results) => res.send(results)) + .then((legislators) => res.send(legislators)) .catch((err) => { console.error(err) res.send(err) From f85b9f5b8829b7091d241d2f5dd0d92de9f1168f Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:09:25 -0500 Subject: [PATCH 13/21] remove formatting --- utils/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/api.js b/utils/api.js index a712421..92164f3 100644 --- a/utils/api.js +++ b/utils/api.js @@ -39,8 +39,8 @@ const sunlightAPI = { getLegistlatorByZip: (zip) => { return new Promise((resolve, reject) => { if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(zip))) { -+ reject('Not a valid zip!') -+ } + reject('Not a valid zip!') + } let options = { url: `${URI}/legislators/locate?zip=${zip}`, headers: { From 5d0db50b052e508922722be1237776250981a5e0 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:34:37 -0500 Subject: [PATCH 14/21] add single person page view --- views/legislator.hbs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 views/legislator.hbs diff --git a/views/legislator.hbs b/views/legislator.hbs new file mode 100644 index 0000000..59f3d41 --- /dev/null +++ b/views/legislator.hbs @@ -0,0 +1,13 @@ +{{legislator.name}} +
{{legislator.chamber}}
+

{{legislator.name}}

+

{{legislator.party}}

+ +

Phone Number: {{legislator.phone}}

+

Website: {{legislator.website}}

+ +

Recent Votes

+{{#each votes as |bill|}} +

{{bill.bill_id}}

+

{{bill.official_title}}

+{{/each}} \ No newline at end of file From db8959c8e06b85f673764240aa651d27a8d7113d Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:34:55 -0500 Subject: [PATCH 15/21] add legislator list by zipcode view --- views/legislatorList.hbs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 views/legislatorList.hbs diff --git a/views/legislatorList.hbs b/views/legislatorList.hbs new file mode 100644 index 0000000..4af1433 --- /dev/null +++ b/views/legislatorList.hbs @@ -0,0 +1,8 @@ +

Zipcode: {{zip}}

+ +{{#each legislators as |legislator|}} +
{{legislator.chamber}}
+ {{legislator.name}} +

{{legislator.name}}

+

{{legislator.party}}

+{{/each}} \ No newline at end of file From fbd36639a36eff86aacddb2a79f27ca20593e60e Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:35:07 -0500 Subject: [PATCH 16/21] adjust route views --- routes/index.js | 6 ++++-- routes/legislators.js | 4 +++- views/index.hbs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/routes/index.js b/routes/index.js index 2e923de..dde5d0d 100644 --- a/routes/index.js +++ b/routes/index.js @@ -12,7 +12,9 @@ router.get('/:zip?', function(req, res, next) { const zip = req.query.zip sunlightAPI.getLegistlatorByZip(zip) - .then((legislators) => res.send(legislators)) + .then((legislators) => { + res.render('legislatorList', {legislators: legislators, zip: zip}); + }) .catch((err) => { console.error(err) res.send(err) @@ -22,7 +24,7 @@ router.get('/:zip?', function(req, res, next) { /* GET home page. */ router.get('/', function(req, res, next) { - res.render('index', { title: 'Express' }); + res.render('index', {title: 'Express'}); }); module.exports = router; diff --git a/routes/legislators.js b/routes/legislators.js index 16c3439..6dd6b7f 100644 --- a/routes/legislators.js +++ b/routes/legislators.js @@ -19,7 +19,9 @@ router.get('/:id', function(req, res, next) { } return legislatorObj }) - .then(results => res.send(results)) + .then((results) => { + res.render('legislator', {legislator: results.legislator, votes: results.votes}) + }) .catch((err) => { console.error(err) }) diff --git a/views/index.hbs b/views/index.hbs index 1f308fd..e64a04d 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,2 +1,2 @@

{{title}}

-

Welcome to {{title}}

+

Welcome to {{title}}

\ No newline at end of file From f89b01201f168e75ce0ff7e85252da34b7fa11f7 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sat, 8 Apr 2017 21:37:31 -0500 Subject: [PATCH 17/21] add phone number and website for legislators --- models/legislators.js | 4 +++- utils/api.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/legislators.js b/models/legislators.js index cc13b05..0282d95 100644 --- a/models/legislators.js +++ b/models/legislators.js @@ -1,10 +1,12 @@ class Legistlator { - constructor(id, img, name, chamber, party, votes) { + constructor(id, img, name, chamber, party, phone, website, votes) { this.id = id this.img = img this.name = name this.chamber = chamber this.party = party + this.phone = phone + this.website = website this.votes = votes } } diff --git a/utils/api.js b/utils/api.js index 92164f3..57f8ef8 100644 --- a/utils/api.js +++ b/utils/api.js @@ -31,7 +31,9 @@ const addLegislator = (legislator) => { `https://theunitedstates.io/images/congress/original/${legislator.bioguide_id}.jpg`, `${legislator.first_name} ${legislator.last_name}`, capitalize(legislator.chamber), - formatParty(legislator.party) + formatParty(legislator.party), + legislator.phone, + legislator.website ) } From ad84e57e80da80aea3df2f2e543328fc2f100dfe Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sun, 9 Apr 2017 00:31:01 -0500 Subject: [PATCH 18/21] add styling to page views --- .../style.scssc | Bin 0 -> 11838 bytes public/stylesheets/style.css | 42 +++++++++++++-- public/stylesheets/style.css.map | 7 +++ routes/index.js | 12 ++--- styles_sass/style.scss | 50 ++++++++++++++++++ views/index.hbs | 15 +++++- views/layout.hbs | 30 ++++++++++- views/legislator.hbs | 9 +++- views/legislatorList.hbs | 22 +++++--- 9 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 .sass-cache/044ac856268bb8c1ecdb415330e4a633469d4cdb/style.scssc create mode 100644 public/stylesheets/style.css.map create mode 100644 styles_sass/style.scss diff --git a/.sass-cache/044ac856268bb8c1ecdb415330e4a633469d4cdb/style.scssc b/.sass-cache/044ac856268bb8c1ecdb415330e4a633469d4cdb/style.scssc new file mode 100644 index 0000000000000000000000000000000000000000..1d787fe3a0f82a622f1706a5f5eec07a60077d62 GIT binary patch literal 11838 zcmb_i&2uA16<;YSSs%7#d)K>O+q<54znqO_k8RoBOb60Qh+(Ue)Pgr$45-G^$Q~kT z#LUQRlUj~&gFk^IC%C~8Zg7AqxWOMlQE=ts04Lt->5u7A%SIu!)UqyNwfTFF>r1lx>4jf&qL31oUa8z{87;ICY@>8JoP)R(CZylvOmGXF8F;;>S9GRm z*Xtg8VRTdooI6=zAvZxL@%MW}zx&;O#}iVOL~1!J^?t|edcC*=7Wdq)C+sDq=T4P< z6ZPGuXT#4OzvuY{px^d89?IHaU^F=XHn^C53xBwGQ-RSh?wF96Xv7Z{D z+dJ_BXMx+mz68(Ww*+mRQ;$0_RdT5Jkg zVn32)zYMC;L>o*67X)GKg*Hwk*OUK}kIoW}Sb79uL$i>0oW5=M6uT`f^{L}($iJC`EdlX-8}X? zol~zJUu>TFpZL9#T0acXr_m<=(0Fm`#*I_=%xhc(gGMXpd8i3I7J6={@j0O_&(Ks19shB^B58pLaYEClITOh9Z^EO2z2 z+@*_Tg)U{5;j=L4qd7BVhONMM(2H4Y9?94oHbcK3i^ctc4>{s?iey;e>qy6O4&xA5 zl*pr}tNUB^{<*dK!Jz54T~H3+faX38Ja z2V~8u`YmAWw|y^kR%y%YhhEc-p(gk}u%X|8#qWa)K?akxnDIdoSWnA*#1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hnwY2=45B~=Ri7V6YFjndJQILos{=^3zf^2dVpOA_8$j0AR?-gT|7`1B_wN**rO;-GJ;za{en#@$TBc0q|c zUE=79N2w+NwJ+-cGGhN!5km>J4D{N|jiLE}$%v_awk|BE`M)SQ-AUmC* z+hlg~*weAtGtT5I^?1;+YzyD)g9ldd37`F}+3W1z#`f!puY5?gs5;9_zc#%M_kgiXoLl;|170TEMFRTW9c c|7H0lD=PTDul_1&0oJcNH6$Z(lBz%dFKg;m7ytkO literal 0 HcmV?d00001 diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 9453385..d172e5a 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -1,8 +1,40 @@ body { - padding: 50px; - font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; -} + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { - color: #00B7FF; -} + color: #00B7FF; } + +.results { + display: inline-flex; + width: 100%; } + +.card { + background-color: #fff; + display: inline-flex; + margin: 50px; + width: 300px; + height: 480px; + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); + transition: 0.3s; } + .card:hover { + box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2); } + .card img { + width: 300px; + height: 365px; } + .card .chamber { + text-align: center; + margin: 10px; + color: #aaa; + font-size: 16px; } + +.inner-card { + padding: 2px 16px; } + +.form-card { + max-width: 500px; + margin: 0 auto; + text-align: center; } + .form-card form { + margin-top: 50px; } + +/*# sourceMappingURL=style.css.map */ diff --git a/public/stylesheets/style.css.map b/public/stylesheets/style.css.map new file mode 100644 index 0000000..0837cea --- /dev/null +++ b/public/stylesheets/style.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,IAAK;EAEH,IAAI,EAAE,kDAAkD;;AAG1D,CAAE;EACA,KAAK,EAAE,OAAO;;AAGhB,QAAS;EACL,OAAO,EAAE,WAAW;EACpB,KAAK,EAAE,IAAI;;AAGf,KAAM;EACF,gBAAgB,EAAE,IAAI;EACtB,OAAO,EAAE,WAAW;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,KAAK;EACb,UAAU,EAAE,8BAA2B;EACvC,UAAU,EAAE,IAAI;EAChB,WAAQ;IACJ,UAAU,EAAE,+BAA4B;EAE5C,SAAI;IACA,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;EAGjB,cAAS;IACL,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;;AAIvB,WAAY;EACR,OAAO,EAAE,QAAQ;;AAGrB,UAAW;EACP,SAAS,EAAE,KAAK;EAChB,MAAM,EAAE,MAAM;EACd,UAAU,EAAE,MAAM;EAClB,eAAK;IACD,UAAU,EAAE,IAAI", +"sources": ["../../styles_sass/style.scss"], +"names": [], +"file": "style.css" +} \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index dde5d0d..c321e60 100644 --- a/routes/index.js +++ b/routes/index.js @@ -4,12 +4,12 @@ var router = express.Router(); const sunlightAPI = require('../utils/api') const Legistlator = require('../models/legislators') -/* GET legislator by zip */ -router.get('/:zip?', function(req, res, next) { - if (!req.query.zip) { - next() +router.post('/', function(req, res, next) { + if (!(/^\d{5}(?:[-\s]\d{4})?$/.test(req.body.zip))) { + console.log('error out') + res.render('index') } else { - const zip = req.query.zip + const zip = req.body.zip sunlightAPI.getLegistlatorByZip(zip) .then((legislators) => { @@ -22,8 +22,8 @@ router.get('/:zip?', function(req, res, next) { } }); -/* GET home page. */ router.get('/', function(req, res, next) { + console.log('error?') res.render('index', {title: 'Express'}); }); diff --git a/styles_sass/style.scss b/styles_sass/style.scss new file mode 100644 index 0000000..7f78ff7 --- /dev/null +++ b/styles_sass/style.scss @@ -0,0 +1,50 @@ +body { +// padding: 50px; + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; +} + +a { + color: #00B7FF; +} + +.results { + display: inline-flex; + width: 100%; +} + +.card { + background-color: #fff; + display: inline-flex; + margin: 50px; + width: 300px; + height: 480px; + box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); + transition: 0.3s; + &:hover { + box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); + } + img { + width: 300px; + height: 365px; + } + + .chamber { + text-align: center; + margin: 10px; + color: #aaa; + font-size: 16px; + } +} + +.inner-card { + padding: 2px 16px; +} + +.form-card { + max-width: 500px; + margin: 0 auto; + text-align: center; + form { + margin-top: 50px; + } +} \ No newline at end of file diff --git a/views/index.hbs b/views/index.hbs index e64a04d..6826c47 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,2 +1,13 @@ -

{{title}}

-

Welcome to {{title}}

\ No newline at end of file +
+
+
+

Find-My-Rep

+
+
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/views/layout.hbs b/views/layout.hbs index 068eb6b..a7a8620 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -1,10 +1,38 @@ - {{title}} + + + + Find-My-Rep + + {{{body}}} + + diff --git a/views/legislator.hbs b/views/legislator.hbs index 59f3d41..db2c239 100644 --- a/views/legislator.hbs +++ b/views/legislator.hbs @@ -1,4 +1,11 @@ -{{legislator.name}} +
+
+
+ {{legislator.name}} +
+
+
+
{{legislator.chamber}}

{{legislator.name}}

{{legislator.party}}

diff --git a/views/legislatorList.hbs b/views/legislatorList.hbs index 4af1433..de6807f 100644 --- a/views/legislatorList.hbs +++ b/views/legislatorList.hbs @@ -1,8 +1,14 @@ -

Zipcode: {{zip}}

- -{{#each legislators as |legislator|}} -
{{legislator.chamber}}
- {{legislator.name}} -

{{legislator.name}}

-

{{legislator.party}}

-{{/each}} \ No newline at end of file +
+ {{#each legislators as |legislator|}} +
+
+

{{legislator.chamber}}

+ {{legislator.name}} +
+

{{legislator.name}}

+

{{legislator.party}}

+
+
+
+ {{/each}} +
\ No newline at end of file From 43d4b4f3d63aefec902d1aa4e48d23363f6aaebb Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sun, 9 Apr 2017 01:06:17 -0500 Subject: [PATCH 19/21] add styling --- .../style.scssc | Bin 11838 -> 15829 bytes public/stylesheets/style.css | 21 ++++++++- public/stylesheets/style.css.map | 2 +- styles_sass/style.scss | 28 ++++++++++- views/legislator.hbs | 44 +++++++++++------- views/legislatorList.hbs | 16 ++++--- 6 files changed, 85 insertions(+), 26 deletions(-) diff --git a/.sass-cache/044ac856268bb8c1ecdb415330e4a633469d4cdb/style.scssc b/.sass-cache/044ac856268bb8c1ecdb415330e4a633469d4cdb/style.scssc index 1d787fe3a0f82a622f1706a5f5eec07a60077d62..a131adb71fd4dc53e12b3edf8bba857d55309bd3 100644 GIT binary patch literal 15829 zcmb_j&669)b?1&)y8!l+;4Z}vksK{WilhlFmRxd|)27^%LW(O(G|Qx1mC$9>EHKy| z3&6mb!E)CwRZclNm-uFvbBS+ul`nQx4oOvVNe-!`D!Ih=AK)tAa&WHpdp+I#rUwl` zkR+8#+raDJ`+nX1x^btvRlR-3z5YCC2aO~=4BY2Qa2VVuHClHzH#eL2wzv0ct(_hJ z-riO#xPN<8VK%Xy+fJ3yjkuf+TC_siMc_2ORCJf8JtAHDF(yyy4hpjpT7;>cT18KhE1eb0L@ z>U8|)!S@D1w-FS)McxTIdqF>bIU9Kw^Tdj7jxFH#SBAb1JH2+GsOD3uH}X`E+CeAi zCPk3A>vsYrFDt(Amc=J=&u;`Z__`f-gK!qqZ-wmuX=@;0JlOj#m{|N74f+jKtMEKX zW?{mCA0K>r;xVWli?8Z^zq=nq-dQPw_z*0MpB8~zocR5u-irX@f=Ti$io+y~x^t`y z5-jkj)rx}z{#@iiw<)Hu3*t-mMpy#YC}Isn1rtR5Bq9K+C`vN} zgBBtvO^$hf=(h(V@GorKbX~XSH=6+Exp!;5Bj(=R5TXOzaWC-ZV+^GPKu>^kz?)GI z-5mem1o&%?osF`-m;>LEFK~2@UE=52Wqu)-hR^y@55-wwDWIv#Pvl?~X{@Pv1YL(KH*@o_itkGw)RcqMJik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0{vFa19^zZ31q$Y6 zjB#|u25JIOvDE=&Z2zu;ffCmxBR#g<7@GfwjIBB_Ty~4x+1usiQadfYmLdBZ=vJpB z9H}k9n8+poMOFupWM9ckf1<>w(*ie!=3mWAcgRFu5th^ZpOx?QY)B{a)JF5v#k=8E z*_`zECezY$uz!H!@g7g8UNxJH7#v4W=lkFRmCiU)!AF-DaQ6_8C#tb`9@pTUePV0? zRhn=R;uN(wKM>yHN&NuSsKSM#E82S|02OB)K*ss8iZe=#Dp=eYntwyaSuwt>-L+-x zj6BS6eF&;mPUGl`1#ALPTy+4+l_;(#F)F9IF*N^{f$QjpPo;aVn>f;5PLX14ozK zYbN;{3Z}f6+J-0n=G>?WkMRmu11+kZkE1JgG82HR%Q}F}jqj^qq69dEA4K$}z>T5# z9~g3DU06=@=L$~uQaaexjW+aJ#)vhnwY2=45B~=Ri7V6YFjndJQILos{=^3zf^2dVpOA_8$j0AR?-gT|7`1B_wN**rO;-GJ;za{en#@$TBc0q|c zUE=79N2w+NwJ+-cGGhN!5km>J4D{N|jiLE}$%v_awk|BE`M)SQ-AUmC* z+hlg~*weAtGtT5I^?1;+YzyD)g9ldd37`F}+3W1z#`f!puY5?gs5;9_zc#%M_kgiXoLl;|170TEMFRTW9c c|7H0lD=PTDul_1&0oJcNH6$Z(lBz%dFKg;m7ytkO diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index d172e5a..0431468 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -2,12 +2,19 @@ body { font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { - color: #00B7FF; } + color: #000; + text-decoration: none; } + a:hover { + color: #000; + text-decoration: none; } .results { display: inline-flex; width: 100%; } +.card-container { + text-align: center; } + .card { background-color: #fff; display: inline-flex; @@ -26,6 +33,14 @@ a { margin: 10px; color: #aaa; font-size: 16px; } + .card .website { + color: #8aacb8; } + +.single { + display: inline; } + +.recent-votes { + margin-top: 50px; } .inner-card { padding: 2px 16px; } @@ -37,4 +52,8 @@ a { .form-card form { margin-top: 50px; } +.vote-result { + color: #aaa; + font-size: 18px; } + /*# sourceMappingURL=style.css.map */ diff --git a/public/stylesheets/style.css.map b/public/stylesheets/style.css.map index 0837cea..34d267f 100644 --- a/public/stylesheets/style.css.map +++ b/public/stylesheets/style.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,IAAK;EAEH,IAAI,EAAE,kDAAkD;;AAG1D,CAAE;EACA,KAAK,EAAE,OAAO;;AAGhB,QAAS;EACL,OAAO,EAAE,WAAW;EACpB,KAAK,EAAE,IAAI;;AAGf,KAAM;EACF,gBAAgB,EAAE,IAAI;EACtB,OAAO,EAAE,WAAW;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,KAAK;EACb,UAAU,EAAE,8BAA2B;EACvC,UAAU,EAAE,IAAI;EAChB,WAAQ;IACJ,UAAU,EAAE,+BAA4B;EAE5C,SAAI;IACA,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;EAGjB,cAAS;IACL,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;;AAIvB,WAAY;EACR,OAAO,EAAE,QAAQ;;AAGrB,UAAW;EACP,SAAS,EAAE,KAAK;EAChB,MAAM,EAAE,MAAM;EACd,UAAU,EAAE,MAAM;EAClB,eAAK;IACD,UAAU,EAAE,IAAI", +"mappings": "AAAA,IAAK;EAEH,IAAI,EAAE,kDAAkD;;AAG1D,CAAE;EACA,KAAK,EAAE,IAAI;EACX,eAAe,EAAE,IAAI;EACrB,OAAQ;IACN,KAAK,EAAE,IAAI;IACX,eAAe,EAAE,IAAI;;AAIzB,QAAS;EACL,OAAO,EAAE,WAAW;EACpB,KAAK,EAAE,IAAI;;AAGf,eAAgB;EACZ,UAAU,EAAE,MAAM;;AAGtB,KAAM;EACF,gBAAgB,EAAE,IAAI;EACtB,OAAO,EAAE,WAAW;EACpB,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,KAAK;EACb,UAAU,EAAE,8BAA2B;EACvC,UAAU,EAAE,IAAI;EAChB,WAAQ;IACJ,UAAU,EAAE,+BAA4B;EAE5C,SAAI;IACA,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;EAGjB,cAAS;IACL,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;EAGnB,cAAS;IACL,KAAK,EAAE,OAAO;;AAItB,OAAQ;EACJ,OAAO,EAAE,MAAM;;AAGnB,aAAc;EACV,UAAU,EAAE,IAAI;;AAGpB,WAAY;EACR,OAAO,EAAE,QAAQ;;AAGrB,UAAW;EACP,SAAS,EAAE,KAAK;EAChB,MAAM,EAAE,MAAM;EACd,UAAU,EAAE,MAAM;EAClB,eAAK;IACD,UAAU,EAAE,IAAI;;AAIxB,YAAa;EACT,KAAK,EAAE,IAAI;EACX,SAAS,EAAE,IAAI", "sources": ["../../styles_sass/style.scss"], "names": [], "file": "style.css" diff --git a/styles_sass/style.scss b/styles_sass/style.scss index 7f78ff7..ed6da18 100644 --- a/styles_sass/style.scss +++ b/styles_sass/style.scss @@ -4,7 +4,12 @@ body { } a { - color: #00B7FF; + color: #000; + text-decoration: none; + &:hover { + color: #000; + text-decoration: none; + } } .results { @@ -12,6 +17,10 @@ a { width: 100%; } +.card-container { + text-align: center; +} + .card { background-color: #fff; display: inline-flex; @@ -34,6 +43,18 @@ a { color: #aaa; font-size: 16px; } + + .website { + color: #8aacb8; + } +} + +.single { + display: inline; +} + +.recent-votes { + margin-top: 50px; } .inner-card { @@ -47,4 +68,9 @@ a { form { margin-top: 50px; } +} + +.vote-result { + color: #aaa; + font-size: 18px; } \ No newline at end of file diff --git a/views/legislator.hbs b/views/legislator.hbs index db2c239..717444d 100644 --- a/views/legislator.hbs +++ b/views/legislator.hbs @@ -1,20 +1,32 @@ -
-
-
- {{legislator.name}} +
+
+
+

{{legislator.chamber}}

+ {{legislator.name}} +
+

{{legislator.name}}

+

{{legislator.party}}

+
+

Phone Number: {{legislator.phone}}

+

Website: {{legislator.website}}

+
-
- -
{{legislator.chamber}}
-

{{legislator.name}}

-

{{legislator.party}}

-

Phone Number: {{legislator.phone}}

-

Website: {{legislator.website}}

+
+

Recent Votes

+
+ {{#each votes as |bill|}} + +
+

{{bill.bill_id}}

+

{{bill.official_title}}

+
+

Vote: {{bill.vote}}

+
+
+
+ {{/each}} + -

Recent Votes

-{{#each votes as |bill|}} -

{{bill.bill_id}}

-

{{bill.official_title}}

-{{/each}} \ No newline at end of file +
\ No newline at end of file diff --git a/views/legislatorList.hbs b/views/legislatorList.hbs index de6807f..2d1bd4f 100644 --- a/views/legislatorList.hbs +++ b/views/legislatorList.hbs @@ -1,14 +1,16 @@
{{#each legislators as |legislator|}}
-
-

{{legislator.chamber}}

- {{legislator.name}} - +
{{/each}}
\ No newline at end of file From b50f9f3101873bc39224f56bf8caa9f3353c10a2 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sun, 9 Apr 2017 01:10:37 -0500 Subject: [PATCH 20/21] save request --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b61fd62..f9cf5cd 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "express": "~4.15.2", "hbs": "~4.0.1", "morgan": "~1.8.1", + "request": "^2.81.0", "serve-favicon": "~2.4.2" } } From 85015d3621e0a517d307493eccc3ae51033dd905 Mon Sep 17 00:00:00 2001 From: Bill Hefty Date: Sun, 9 Apr 2017 01:14:57 -0500 Subject: [PATCH 21/21] add heroku link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cb007d2..e8a0ef8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # project_what_have_you_done Build an application to help track the legislative activities of your local representatives. + +## [View App Here](http://find-my-rep.herokuapp.com/) \ No newline at end of file