-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
218 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,7 @@ body{ | |
width: 100px; | ||
background-size: cover; | ||
} | ||
|
||
#marketplace-map { | ||
height: 400px; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* jshint unused:false, camelcase:false */ | ||
/* global google, cartographer, addMarker */ | ||
|
||
(function(){ | ||
'use strict'; | ||
|
||
var map; | ||
|
||
$(document).ready(function(){ | ||
map = cartographer('marketplace-map', 39.8282, -98.5795, 4); | ||
var rows = $('.item').toArray(); | ||
// console.log(rows); | ||
if(rows.length){ | ||
rows.forEach(function(row){ | ||
// console.log(row); | ||
addMarker(map, parseFloat($(row).attr('data-lat')), parseFloat($(row).attr('data-lng')), $(row).attr('data-loc'), '/img/marker.png'); | ||
}); | ||
} | ||
}); | ||
|
||
})(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
(function(){ | ||
'use strict'; | ||
/* jshint unused:false, camelcase:false */ | ||
/* global google */ | ||
|
||
$(document).ready(function(){ | ||
function geocode(address, cb){ | ||
'use strict'; | ||
var geocoder = new google.maps.Geocoder(); | ||
geocoder.geocode({address:address}, function(results, status){ | ||
//console.log('results', results); | ||
var name = results[0].formatted_address, | ||
lat = results[0].geometry.location.lat(), | ||
lng = results[0].geometry.location.lng(); | ||
cb(name, lat, lng); | ||
}); | ||
} | ||
|
||
})(); | ||
function cartographer(cssId, lat, lng, zoom){ | ||
'use strict'; | ||
var mapOptions = {center: new google.maps.LatLng(lat, lng), zoom: zoom, mapTypeId: google.maps.MapTypeId.ROADMAP}, | ||
map = new google.maps.Map(document.getElementById(cssId), mapOptions); | ||
|
||
return map; | ||
} | ||
|
||
function addMarker(map, lat, lng, name, icon){ | ||
'use strict'; | ||
var latLng = new google.maps.LatLng(lat, lng); | ||
// console.log(latLng); | ||
new google.maps.Marker({map: map, position: latLng, title: name, animation: google.maps.Animation.DROP, icon: icon}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,23 @@ | ||
/* jshint unused:false, camelcase:false */ | ||
/* global google */ | ||
/* global google, geocode */ | ||
|
||
(function(){ | ||
'use strict'; | ||
|
||
$(document).ready(function(){ | ||
$('button[type=submit]').click(geocodeAndSubmit); | ||
$('#submitItem').click(geocodeAndSubmit); | ||
}); | ||
|
||
function geocodeAndSubmit(e){ | ||
var location = $('input[name=location]').val(); | ||
geocode(location, function(name, lat, lng){ | ||
$('input[name=location]').val(name); | ||
$('form').append('<input name="lat" value="'+lat+'" type="hidden">'); | ||
$('form').append('<input name="lng" value="'+lng+'" type="hidden">'); | ||
$('form').submit(); | ||
$('#newItem').append('<input name="lat" value="'+lat+'" type="hidden">'); | ||
$('#newItem').append('<input name="lng" value="'+lng+'" type="hidden">'); | ||
$('#newItem').submit(); | ||
}); | ||
e.preventDefault(); | ||
} | ||
|
||
function geocode(address, cb){ | ||
var geocoder = new google.maps.Geocoder(); | ||
geocoder.geocode({address:address}, function(results, status){ | ||
//console.log('results', results); | ||
var name = results[0].formatted_address, | ||
lat = results[0].geometry.location.lat(), | ||
lng = results[0].geometry.location.lng(); | ||
cb(name, lat, lng); | ||
}); | ||
} | ||
|
||
})(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
extends ../shared/template | ||
block content | ||
h2 Profile | ||
.panel.panel-default | ||
.panel-body | ||
.row | ||
.col-xs-12 | ||
#marketplace-map | ||
.row | ||
.col-xs-12 | ||
table.table | ||
thead | ||
tr | ||
th Photo | ||
th Name | ||
th Location | ||
th Description | ||
tbody | ||
each item in items | ||
tr.item(data-loc='#{item.location}', data-lat='#{item.lat}', data-lng='#{item.lng}') | ||
td.item-photo(style='background-image:url(#{item.photo})') | ||
td: a(href='/items/#{item._id}')= item.name | ||
td= item.location | ||
td= item.description | ||
|
||
block scripts | ||
script(src='/js/user/items-index.js') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* global describe, before, beforeEach, it */ | ||
|
||
'use strict'; | ||
|
||
process.env.DB = 'wine-seller-test'; | ||
|
||
var expect = require('chai').expect, | ||
cp = require('child_process'), | ||
app = require('../../app/index'), | ||
cookie = null, | ||
request = require('supertest'); | ||
|
||
describe('users', function(){ | ||
before(function(done){ | ||
request(app).get('/').end(done); | ||
}); | ||
|
||
beforeEach(function(done){ | ||
cp.execFile(__dirname + '/../scripts/clean-db.sh', [process.env.DB], {cwd:__dirname + '/../scripts'}, function(err, stdout, stderr){ | ||
request(app) | ||
.post('/login') | ||
.send('email=nodeapptest%2Bbob%40gmail.com&password=1234') | ||
.end(function(err, res){ | ||
cookie = res.headers['set-cookie'][0]; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('post /items', function(){ | ||
it('should redirect to the profile page', function(done){ | ||
request(app) | ||
.post('/items') | ||
.set('cookie', cookie) | ||
.send('name=Red+Wine&photo=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fc%2Fcc%2FFrench_beaujolais_red_wine_bottle.jpg&tags=red%2C+wine&location=Nashville%2C+TN%2C+USA&description=Red+Wine') | ||
.end(function(err, res){ | ||
expect(res.status).to.equal(302); | ||
expect(res.headers.location).to.equal('/profile'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('get /marketplace', function(){ | ||
it('should display the marketplace page', function(done){ | ||
request(app) | ||
.get('/marketplace') | ||
.set('cookie', cookie) | ||
.end(function(err, res){ | ||
expect(res.status).to.equal(200); | ||
expect(res.text).to.include('Marketplace'); | ||
expect(res.text).to.include('White Wine'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('put /profile', function(){ | ||
it('should redirect to the profile page after item is put on sale', function(done){ | ||
request(app) | ||
.post('/items/a00000000000000000000001') | ||
.send('_method=put') | ||
.set('cookie', cookie) | ||
.end(function(err, res){ | ||
expect(res.status).to.equal(302); | ||
expect(res.headers.location).to.equal('/profile'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters