Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort by Location of User #60

Closed
andyparkerson opened this issue Nov 18, 2019 · 2 comments
Closed

Sort by Location of User #60

andyparkerson opened this issue Nov 18, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@andyparkerson
Copy link

grab the visitor's IP address and have it automatically sort by the city they're in.

@andyparkerson andyparkerson changed the title Sort by Location Sort by Location of User Nov 18, 2019
@adamculpepper adamculpepper added the enhancement New feature or request label Nov 18, 2019
@adamculpepper
Copy link
Member

adamculpepper commented Nov 21, 2019

Thanks for the suggestion @andyparkerson! I started working on the first steps of this as you can see inside the on.('change') of the scripts.js file. I was planning on using history.pushState to update the URL address when the location was changed, but ran into some issues with loading that address when you first go to that url, for example http://louisianagroups.com/baton-rouge. I wasn't happy with the site fully loading and then the locations dropdown kicking in to filter them. I want them to load like normal, already filtered. I needed to refactor the ES6 promises (which I ended up using Knockout subscriptions instead) and needed to move on to more core functionality.

But this update is very high on my mental todo list and thank you for documenting it. :)

@adamculpepper
Copy link
Member

adamculpepper commented Dec 17, 2019

@andyparkerson this is pushed to the live site. It took quite a bit of doing!

I ended up writing a custom jQuery plugin (Stylish Select) in the process because I kept fighting with Select2's dropdown position (when the select2 element was hidden).

I started off using http://ip-api.com/json for user location detection but found out that they don't allow HTTPS for free, so I went down the route of using Google's Geocoding Location API but there were too many hurtles to jump over and the looming monthly API charge based on calls, so I ended up going with https://extreme-ip-lookup.com/json since it's free up to 50,000/month and gives HTTPS access. If we ever end up getting over 50,000 unique visits to the site, we'll have to refactor this piece, but I HIGHLY doubt that'll ever happen, but a girl can dream!

I added issue #67 as a measure to make sure we aren't doing needless location detection API calls in the future.

I added issue #68 as a reminder that the website URL needs to change when the location dropdown is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants