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

Contributors Page with Powertag searches #2029

Closed
SidharthBansal opened this issue Jan 17, 2018 · 15 comments · Fixed by #2180
Closed

Contributors Page with Powertag searches #2029

SidharthBansal opened this issue Jan 17, 2018 · 15 comments · Fixed by #2180
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute Ruby

Comments

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 17, 2018

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!
🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

Please describe the problem

Contributors page available at www.publiclab.org/contributors/tagname works fine when tagname is a normal tag like balloon but when it is a powertag having wildcard character asterisk, eg tagname is balloon* then it shows no contributors.
We supply tagname as balloon* to get all the tags starting by balloon eg balloon-mapping ,balloon etc in the url at Public Labs

Solution

A message to indicate the users that for a wildcard search, contributors cannot be listed. So, requesting users to not enter wildcards.
Message like

This is a wildcard tag search.
Wildcard tag searches use the * asterisk in their URLs, and do not show contributor listings.

📋 Step by Step

🙋‍♀️ Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!
Add @wildcard = true if params[:id][-1..-1] == '*' in

def contributors

Also add the custom message in the if-else statement in the view. Make the if @wildcard as the first condition of the if-else loop in
<% if @notes.nil? || @notes.length == 0 %>
<p><%= raw t('tag.contributors.no_contributors', :tag => params[:id]) %>:</p>
<% else %>

💾 Commit your changes

🔀 Start a Pull Request.

🏁 Done Ask in comments for a review :)

🤔❓ Questions?

Leave a comment below!

We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. If someone seem stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!
Thank you!

Your help makes Public Lab better! We deeply appreciate your helping refine and improve this site.

@SidharthBansal SidharthBansal added fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet first-timers-only They need to be well-formatted using the First-timers_Issue_Template. labels Jan 17, 2018
@jywarren jywarren added help wanted requires help by anyone willing to contribute Ruby labels Jan 17, 2018
@kellyjacksonio
Copy link

I'll give it a shot!

@jywarren
Copy link
Member

jywarren commented Jan 18, 2018 via email

@kellyjacksonio
Copy link

one question: are you wanting the code in lines 60-62 to be replaced with the wildcard conditional, or do i create another if / else statement prior to lines 60-62?

@kellyjacksonio
Copy link

Alright, gave it my best shot! Please review and let me know what I could have done better

@SidharthBansal
Copy link
Member Author

@kellyjacksonio You need to create an if statement before lines 60-62.
Thanks for the pr

@ina-mastabba
Copy link
Contributor

Thanks for reaching out to first-timers. I would like to resolve this issue. It's not clear to me whether or not @kellyjacksonio is still working on it. If so maybe I could help?

@jywarren
Copy link
Member

Hi, @ina-mastabba -- maybe you could try picking up where @kellyjacksonio left off, in #2048? Otherwise there are plenty of issues to go around!

https://publiclab.github.io/community-toolbox/#r=all

Thanks!!

@ina-mastabba
Copy link
Contributor

I tried a couple of permutations of the conditional in _contributer.html.erb
e.g.

<% if @wildcard %>
    <p><%= raw t('tag.contributors.wild_card_search_detected', :tag => params[:id]) %></p>
<% elsif @noteCount.nil? || @noteCount == 0 %>
    <p><%= raw t('tag.contributors.no_contributors', :tag => params[:id]) %>:</p>
<% else %>
...

and...

<% if @noteCount.nil? || @noteCount == 0 && !@wildcard %>
    <p><%= raw t('tag.contributors.no_contributors', :tag => params[:id]) %>:</p>
<% elsif @wildcard %>
    <p><%= raw t('tag.contributors.wild_card_search_detected', :tag => params[:id]) %></p>
<% else %>
...

but this test fails:

test 'validate unused tag' do
    UserSession.create(users(:bob))

    get :contributors,
        id: 'question:*'

    assert_template :contributors
    assert_tag tag: 'p',
               child: /No contributors for that tag/
end

test_validate_unused_tag#Minitest::Result (83.86s)
expected tag, but no tag found matching {:tag=>"p", :child=>/No contributors for that tag/}

Otherwise the app seems to work as requested.

Any suggestions?

@ina-mastabba
Copy link
Contributor

Seems like I can either re-write the test or do something like:

<% if @wildcard %>
    <p><%= raw t('tag.contributors.wild_card_search_detected', :tag => params[:id]) %></p>
    <p><%= raw t('tag.contributors.no_contributors', :tag => params[:id]) %>:</p>
<% elsif @noteCount.nil? || @noteCount == 0 %>
    <p><%= raw t('tag.contributors.no_contributors', :tag => params[:id]) %>:</p>
<% else %>

@SidharthBansal
Copy link
Member Author

Try out this

<% if @wildcard %>
<p>This is a wildcard tag search.</p>
<p>Wildcard tag searches use the * asterisk in their URLs, and do not show contributor listings.</p>
<% elsif @notes.nil? || @notes.length == 0 %> 
   <p><%= raw t('tag.contributors.no_contributors', :tag => params[:id]) %>:</p> 
<% else %> 
....

Thanks!!!

@ina-mastabba
Copy link
Contributor

That results in the same failure.

@SidharthBansal
Copy link
Member Author

Oh Sorry I didn't read the test....You need to change the tests too...

@ina-mastabba
Copy link
Contributor

No worries,..will do.

@jywarren
Copy link
Member

jywarren commented Feb 2, 2018

Great, thank you! Indeed, the test formerly "asserted" that there be no contributors listed on this page. Now that test can change!

Thanks!!!

@ina-mastabba
Copy link
Contributor

ina-mastabba commented Feb 2, 2018

I actually ended up not changing the test but changing the wildcard warning message to include the text "No contributors for that tag" so that it also meets the requirement of the assert_tag test. So the message reads: "No contributors for that tag. Wildcard tag search detected. Wildcard tag searches use the * asterisk in their URLs, and will not show contributor listings."
Is that acceptable?
I submitted pull request #2180 on 1/31/18. It's a cross-fork request from a feature branch as I forked the repo initially. Please let me know if that's not acceptable and I can create a feature from the original repo and redo the changes. There weren't many.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute Ruby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants