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

Create /map/ route for wiki pages #7061

Merged
merged 25 commits into from
Jan 10, 2020
Merged

Conversation

nstjean
Copy link
Contributor

@nstjean nstjean commented Dec 30, 2019

Fixes #7060 (<=== Add issue number here)

  • Created a route /map/wiki/:wikislug - I couldn't use /map/:wikislug because we already had a route with that pattern.

  • If Wiki exists then it is checking for location info to display:

🎈 Public Lab: Wiki - Google Chrome_007

  • If the map is panned while looking at a wiki page map then it displays the current location in the hash so it can be copied and pasted. If there is location info in the URL hash it will override the display of the wiki's saved location.

🎈 Public Lab: Wiki - Google Chrome_010

  • If Wiki exists but does not have location information this is displayed:

🎈 Public Lab: Wiki - Google Chrome_008

  • If wiki does not exist user is redirected to the standard /map/ and a "not found" message is shown:

🎈 Public Lab: Map - Google Chrome_009

@nstjean
Copy link
Contributor Author

nstjean commented Dec 31, 2019

Here is a wiki page that has a location:

🎈 Public Lab: Events - Google Chrome_011

This is the map when the button is clicked on:

🎈 Public Lab: Wiki - Google Chrome_017

This is a note that has a location with a top map:

🎈 Public Lab: This is a post testing location - Google Chrome_012

This is the map when the button has been clicked on:

🎈 Public Lab: Map - Google Chrome_013

And this is how the url updates while you are panning and zooming!

Peek 2019-12-31 14-11

@nstjean
Copy link
Contributor Author

nstjean commented Dec 31, 2019

Based on feedback in #6993 I've changed the routes and URL hash pattern
Wiki route is now /map/:wikislug
And general route is /map#zoom/lat/lon

Currently there is no way to specify active layers, that can be added on to the hash if it is needed!

@sagarpreet-chadha
Copy link
Contributor

Looks great!!!

@sagarpreet-chadha
Copy link
Contributor

sagarpreet-chadha commented Jan 1, 2020

  • Make a “/map/wiki_slug” route that sources lat/lon/zoom from the matching wiki page
  • Generate/update URL hashes on /map/wiki_slug#zoom/lat/lon pages as you drag the
    map
  • Display notes, wikis, and people on “/map/slug” pages
  • Display popups showing title, link for each wiki, note, and question
  • Make a “#” permalink (in grey) appear in wiki page popups that show “/map/slug
    permalinks for sharing
  • Add a “View map” button to geotagged page sidebars, opening “/map/slug” style URLs
    for wikis, and “/map#zoom/lat/lon” URL hashes for notes
  • Add a “Add to map +” prompt button on any “/map/...” pages to add a note, question or
    wiki at that location
  • Direct users to a post type selection page from the above prompt button, at
    “/post/choose?tags=lat:10,lon:10 -- preserving params!)

@sagarpreet-chadha
Copy link
Contributor

Hey @nstjean , i think we will be solving all these things here, right?

@nstjean
Copy link
Contributor Author

nstjean commented Jan 1, 2020

@sagarpreet-chadha I've marked off the 3 that are taken care of with my current PRs!

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really awesome. Ready to merge?!!?

@nstjean
Copy link
Contributor Author

nstjean commented Jan 1, 2020

@jywarren I created this branch from the #7046 branch, so I think that needs to be merged first, then this rebased to master.

@nstjean nstjean changed the title [WIP] Create /map/ route for wiki pages Create /map/ route for wiki pages Jan 2, 2020
@codecov
Copy link

codecov bot commented Jan 2, 2020

Codecov Report

Merging #7061 into master will increase coverage by 0.15%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7061      +/-   ##
==========================================
+ Coverage   80.83%   80.98%   +0.15%     
==========================================
  Files          97       97              
  Lines        5572     5585      +13     
==========================================
+ Hits         4504     4523      +19     
+ Misses       1068     1062       -6
Impacted Files Coverage Δ
app/controllers/map_controller.rb 50% <100%> (+7.55%) ⬆️
app/models/node.rb 90.85% <0%> (+0.18%) ⬆️
app/controllers/editor_controller.rb 76.74% <0%> (+2.32%) ⬆️

@nstjean
Copy link
Contributor Author

nstjean commented Jan 2, 2020

@jywarren This is all set now!

@jywarren
Copy link
Member

jywarren commented Jan 2, 2020

Ah, i'm sorry, i wanted to add one more small request - could we left-align the button? Apologies! Then this is perfect!

@nstjean
Copy link
Contributor Author

nstjean commented Jan 3, 2020

Yes of course! I'll get that moved.

@nstjean
Copy link
Contributor Author

nstjean commented Jan 3, 2020

Here you go, it's all set!

FireShot Capture 165 - 🎈 Public Lab_ Software Outreach - localhost

@nstjean
Copy link
Contributor Author

nstjean commented Jan 3, 2020

Now the codecov test is failing. Do I need to do something different?

@jywarren
Copy link
Member

jywarren commented Jan 3, 2020

Hmm, I don't think so - i want to see if we can modify the thresholds; i think it's saying that it doesn't like that the new code is not tested to at least the percentage coverage of the overall repository. We could add a functional test or a system test to address this, maybe? We're just getting used to the new CodeCov checks, sorry!

@nstjean
Copy link
Contributor Author

nstjean commented Jan 3, 2020

Hmmm ok. I was going to add some tests for this anyways!

@nstjean
Copy link
Contributor Author

nstjean commented Jan 3, 2020

Ok I added map_test.rb to system tests to test out various map options and display. It should cover the map#wiki controller.

Copy link
Contributor

@sagarpreet-chadha sagarpreet-chadha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are awesome!!!

const bounds = new L.LatLngBounds(
new L.LatLng(84.67351257, -172.96875),
new L.LatLng(-54.36775852, 178.59375)
);

var user_lat = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes awesome i wanted this to be removed from here and not the URLHash logic! Thanks!

@@ -0,0 +1,53 @@
function urlMapHash() {
// This is based off of jywarren's urlhash, made specific to our map hash needs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey this is cool, can you tell what specific changes you did to match plots2? Is the URL different now? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the format to be #zoom/lat/lon. I really like having a hash function available to get and set the values!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question, have the layer names been removed from the hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently yes they aren't in the hash. It had been set up to use the route for the layer names, which had to be changed. Do you need them added back in? It's easy enough to add them at the end of the hash, if that works for @jywarren ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's fine for now. I was trying to figure out an issue when I noticed we don't have them anymore. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had them to track active layers. In LEL it is used in the embed to preserve the state of the layers. I don't remember if this was the case in plots2? @sagarpreet-chadha, could you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,
So i made embed feature to take array of layers as input, and show them on map by default (@nstjean ...we will use this in /people map in plots2). This feature is unrelated to url hash AFAIK.

If we will require layer names in future, it should be pretty easy, right? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Got it. To correct what I said earlier, it wasn't in the hash but before it. Thanks, @sagarpreet-chadha!

@nstjean
Copy link
Contributor Author

nstjean commented Jan 6, 2020

Wow, I don't know what was changed with the codecov, but now my patch went from 70% before to 15% now!

@jywarren
Copy link
Member

jywarren commented Jan 6, 2020

Ah, i think it gets logged gradually, so by the time the Travis run finishes it may be much higher. I wish it notified about that! Let's see!

@nstjean
Copy link
Contributor Author

nstjean commented Jan 6, 2020

It did go back up! Interesting.

This is the test failure, which doesn't make sense to me. Unless me adding the new tags broke this somehow? I didn't change anything that existed, just added.
FireShot Capture 168 - Job #15870 3 - publiclab_plots2 - Travis CI - travis-ci org

And then every one of my map tests is timing out and erroring. 😒

@nstjean
Copy link
Contributor Author

nstjean commented Jan 6, 2020

I took a look and ran it in my local dev to try out some different numbers.

I believe that page may be broken. Take a look: https://publiclab.org/contributors/general
How can we have 61 contributors making 32 posts? I think me adding some new tags in the test fixtures caused this to be visible. The test is supposed to count the number of users in the controller vs. the number of rows on the page, and it's not equal: it's coming back with 0 rows but 1 user in the controller.

test 'tag contributors' do
get :show,
params: {
node_type: 'contributors',
id: Tag.last.name
}
assert :success
assert_not_nil :notes
assert_not_nil :users
assert_not_nil :tag
selector = css_select ".users-row"
assert_equal selector.size, assigns(:users).length
end

What do you want me to do? Fixing this page could take a while.

@nstjean
Copy link
Contributor Author

nstjean commented Jan 10, 2020

Hooray!! @jywarren this passed the tests! I think it's ready for merge!

@jywarren jywarren merged commit 9fe2504 into publiclab:master Jan 10, 2020
@jywarren
Copy link
Member

Awesome!! we can test it at stable.publiclab.org now.

@nstjean
Copy link
Contributor Author

nstjean commented Jan 13, 2020

Yay!!! Oh this is exciting to see, haha.

Tlazypanda pushed a commit to Tlazypanda/plots2 that referenced this pull request Jan 14, 2020
* add route for map/wiki/:id and display wiki location

* add error messages for no location, no wiki

* fix codeclimate error

* display url hash on page load

* Add buttons on wiki pages to link to map or prompt location entry

* add redirect from /maps/ to /map/

* change url hash format to #zoom/lat/lon

* fix codeclimate error

* change button on wiki and page to new hash format

* change PublicPagesTest test from /maps to /map

* clean up code

* remove center tag and unnecessary javascript

* add map tests to system tests

* include 0 in testing numbers

* increase capybara default max wait time

* change test tag contributors to a fixed tag name to stop error

* remove two tests to check if it passes on server

* add map controller tests

* attempt to fix travis error

* comment out all system map tests

* format assertion in show map by hash location in a different way

* hide show map by hash location, show correct url for wiki map

* Increase wait time for map system tests

* update yarn.lock

* set max wait time to 90
vinitshahdeo pushed a commit to vinitshahdeo/plots2 that referenced this pull request Feb 1, 2020
* add route for map/wiki/:id and display wiki location

* add error messages for no location, no wiki

* fix codeclimate error

* display url hash on page load

* Add buttons on wiki pages to link to map or prompt location entry

* add redirect from /maps/ to /map/

* change url hash format to #zoom/lat/lon

* fix codeclimate error

* change button on wiki and page to new hash format

* change PublicPagesTest test from /maps to /map

* clean up code

* remove center tag and unnecessary javascript

* add map tests to system tests

* include 0 in testing numbers

* increase capybara default max wait time

* change test tag contributors to a fixed tag name to stop error

* remove two tests to check if it passes on server

* add map controller tests

* attempt to fix travis error

* comment out all system map tests

* format assertion in show map by hash location in a different way

* hide show map by hash location, show correct url for wiki map

* Increase wait time for map system tests

* update yarn.lock

* set max wait time to 90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make /map/_wiki_slug_ routes that source lat/lon/zoom from matching wiki page
6 participants