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

Add "lock" icon and de-linkify Edit tab of "locked" wiki pages #1099

Closed
4 of 5 tasks
jywarren opened this issue Dec 14, 2016 · 32 comments
Closed
4 of 5 tasks

Add "lock" icon and de-linkify Edit tab of "locked" wiki pages #1099

jywarren opened this issue Dec 14, 2016 · 32 comments
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute HTML Ruby
Milestone

Comments

@jywarren
Copy link
Member

jywarren commented Dec 14, 2016

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!

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

The problem

We have wiki page "locking" coming up as a feature -- it'll only be allowed by admins and moderators -- in #397.

There are several steps to completely implement this, but one easy first task is to display a "lock" icon instead of the Edit tab on pages that are locked.

A page that'll be locked, for example, is https://publiclab.org/about -- a very high-traffic page that gets vandalized a lot.

Solution

We'll be locking by using a locked tag, and so we can check for that tag in the template:

https://github.com/publiclab/plots2/blob/master/app/views/wiki/show.html.erb#L45

I think it makes sense to break this up over multiple lines, and instead of linking to the edit page, we can link to a wiki page explaining what locking is:

        <% if @node.has_tag('locked') %>
          <li><a href="<%= @node.edit_path %>?t=<%= Time.now.to_i %>"><i class="fa fa-pencil"></i><span class="hidden-xs hidden-sm"> <%= t('wiki.show.edit') %></span></a></li>
        <% else %>
          <li><a href="/wiki/locked"><i class="fa fa-lock"></i></a></li>
        <% end %>

Note that this is not actually preventing people from going directly to the editing URL -- that'll happen in another section of the original #397 issue. But this is a good start and an easy addition!

Steps to Fix

  • claim this issue with a comment here, below, and ask any clarifying questions you need
  • set up a repository locally following the README instructions, and make sure that all tests pass
  • try to fix the issue following the steps above, but even before you're done, you can:
  • commit your changes and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
  • alert someone via the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!

Please email the developers list (see https://publiclab.org/developers) if you have questions, and take a look at our first-timers landing page for more information!

@jywarren jywarren added first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute HTML Ruby labels Dec 14, 2016
@jywarren jywarren added this to the Rich Wikis milestone Dec 14, 2016
@jywarren jywarren mentioned this issue Dec 14, 2016
8 tasks
@pycarlson
Copy link
Contributor

pycarlson commented Dec 15, 2016

Hi! I would love to claim this issue. This will be the first time I've ever contributed to open source.

@ryzokuken
Copy link
Member

Sure, @pyluftig! If you need help with this issue or setting up the project locally, please feel free to ask here or on our Gitter channel.

@pycarlson
Copy link
Contributor

Hi @ryzokuken I already have a question. I am trying to create and run the database, and am having some trouble. Is there anyone who could walk me through the process?

@ryzokuken
Copy link
Member

Definitely, @pyluftig. Either explain what's exactly wrong over here or on our Gitter Channel.

@pycarlson
Copy link
Contributor

pycarlson commented Dec 15, 2016

I have forked and cloned the repo, and installed mysql. When I run rake db:create I get this error: Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES). I know this has to do with the db but I am uncertain how to correct it. Thanks!

@ryzokuken
Copy link
Member

Actually, mysql2 is used only in production and I would suggest you to use sqlite3 for development instead. Install the gems using bundle install --without production mysql and try running rake db:setup.

@pycarlson
Copy link
Contributor

pycarlson commented Dec 15, 2016

Okay so this is the error I am getting with just trying to use sqlite3:

Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/pauletteluftig1/Desktop/open_source/plots2/config/database.yml.

There must be something obvious that I am missing - I just need to add the config info, right?

@ryzokuken
Copy link
Member

Well, it seems you started using sqlite3, and then tried running rake db:setup without doing:

$ cp db/schema.rb.example db/schema.rb.
$ cp config/database.yml.sqlite.example config/database.yml

This should do the trick. Run rake db:setup after you execute these two.

@pycarlson
Copy link
Contributor

okay - thank you! was this listed somewhere? I was able to migrate and when trying to run locally I get an error saying couldn't find file 'bootstrap/dist/css/bootstrap.min.css'. I have to head to bed. I assume this app uses bootstrap and that we need that?

@ryzokuken
Copy link
Member

ryzokuken commented Dec 15, 2016

Yes. For frontend dependencies, you'll need to run bower install.

BTW, All of this stuff is listed in the installation section of our README.

@pycarlson
Copy link
Contributor

My apologies! I was looking at a different getting started view. I will use the read me!! Thank you.

@pycarlson
Copy link
Contributor

Up and running - thanks so much for the help @ryzokuken!

@jywarren
Copy link
Member Author

Just wanted to say we're pleased and excited to receive your first open source contribution. Happy to help with anything else! Also glad that due to timezones we seem to have a 24-hour team 🕐 🕢 thanks @ryzokuken 👍

@rafeeq-123
Copy link

Hello,
Would there be a way for me to also contribute here as well? Seems like an interesting add!
Thank you!

@jywarren
Copy link
Member Author

Hi, @rafeeq-123 -- have you had a look at some of our other issues? For first-time contributors, here:

https://github.com/publiclab/plots2/projects/2

And more generally there are a lot of good ones here:

fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet

There are a lot to choose from!

@pycarlson
Copy link
Contributor

pycarlson commented Dec 16, 2016

Hi @jywarren or @ryzokuken - When I try to log in I get this error: RSolr::Error::ConnectionRefused in UserSessionsController#create. I have not been able to successfully run the bundle exec rake sunspot:reindex command. I really want to get started! I've been googling trying to figure out what's wrong.

This is blocking me from signing in, I believe. Once I can log in and add to the wiki page I should be able to see that view locally, correct?

@pycarlson
Copy link
Contributor

@jywarren when trying to run either bundle exec rake db:setup or bundle exec rake sunspot:reindex I am getting:

RSolr::Error::ConnectionRefused: Connection refused - {:data=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:User</query></delete>", :headers=>{"Content-Type"=>"text/xml"}, :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :path=>"update", :uri=>#<URI::HTTP:0x007fbbd7d0be08 URL:http://localhost:8982/solr/development/update?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}

Doing some searching, it seems like this has been encountered before (in #708 and #854, at least) but I could not find any instructions to resolve this error. Any help would be appreciated!

@pycarlson
Copy link
Contributor

@jywarren and @ryzokuken the link above to the developers page is incorrect and broken: https://publiclab.org/developers. I think you meant https://publiclab.org/wiki/developers and wanted to mention it in case first timers are look at a template you're using for issues, you might want to update it so the url is correct. Thanks!

@jywarren
Copy link
Member Author

Hi, oh thank you so much -- we'd known there was a bad URL somewhere but couldn't find it... it's actually in my "saved replies" template. Just fixed it.

For the RSolr issue - we are working to remove the optional Solr items from the install steps, or at least make them "discouraged" as they're not necessary for a development environment, and they can cause some serious trouble like you're seeing.

But what I believe happened is that rails generate sunspot_rails:install generated a file at config/sunspot.yml -- enabling Solr for development mode. So I believe one of thes two steps will fix it:

These should both do the same thing -- just in case one doesn't work, i listed two.

I hope that's helpful, thank you for your patience and again for finding that bad URL!

@pycarlson
Copy link
Contributor

@jywarren and @ryzokuken Dev Environment is Working!!! Yay!

@ryzokuken
Copy link
Member

Way to go, @pyluftig!

@jywarren
Copy link
Member Author

Awesome!!!

@pycarlson
Copy link
Contributor

@jywarren and @ryzokuken Are there any docs describing the app data model? What type of tag do I need to create? I thought I needed to create a DrupalTag but now realize that isn't likely. Can you describe how tagging works or point me to some docs? Thanks!

@ryzokuken
Copy link
Member

@pyluftig: @jywarren could help you better with the specifics of this issue, but as far as I could comprehend this issue, I don't really believe you need to actually create and/or manipulate tags.

Rather, for this issue, you need to just check if the current wiki in consideration has the locked tag or not. If it is locked, you don't display the Edit button but show a lock icon instead. Afterwards you could work towards blocking users from manually visiting the respective URL and editing the wiki.

Hope it helps

@jywarren
Copy link
Member Author

Yes, the assumption is that people will add tags using the tagging interfaces on each page, so we don't need to worry about that here; though to test, you can just manually enter a tag in the HTML form at the bottom of a wiki or research note (in your development setup).

So this line checks to see if that page (node) has a tag:

        <% if @node.has_tag('locked') %>

As to the app data model, we should make such docs, and I'm hopeful that we can do that in relation to our model cleanup efforts (we're deprecating all the Drupal naming conventions, but slowly!). Thanks!

@pycarlson
Copy link
Contributor

pycarlson commented Dec 18, 2016

@jywarren So do you want to limit who can add and remove the locked tag? Doesn't everyone then have access to adding/removing locks through the UI? Does that defeat the purpose? Maybe it would make more sense to show the lock icon when the current_user is not an admin or a moderator?

UPDATE - now I see that only admins can lock pages! Cool.

@pycarlson
Copy link
Contributor

pycarlson commented Dec 18, 2016

@jywarren Do you want a controller test to show this working? If so, can you guide me on how to create a tag correctly in spec land? Also, was spec was broken on the branch when I pulled it down. Are you aware of this?

@jywarren
Copy link
Member Author

Hi -- great, and apologies that I'm not able to respond quickly on this at the moment.

Here's an example controller test where a tag is added using node.add_tag():

https://github.com/publiclab/plots2/blob/master/test/functional/tag_controller_test.rb#L297-L316

Hope that's helpful and now I realize you were probably asking to add a tag for the purposes of testing, which makes a lot of sense and is a great idea.

I do think we need a diagram of our models, and started working on one -- here's a draft:

screenshot 2016-12-18 at 2 14 43 pm

@pycarlson
Copy link
Contributor

Hi @jywarren - wow! You sure get on top of things fast! Thanks for the info about how to add a tag in a spec. I will add specs on my branch.

I am just curious, but have you considered limiting editing abilities through the back end and just based on whether the viewing user is an admin or a moderator? This way no one would have to worry about locking anything? And a lot could be done just based on the user's role?

@jywarren
Copy link
Member Author

jywarren commented Dec 18, 2016 via email

@pycarlson
Copy link
Contributor

pycarlson commented Dec 18, 2016

Hello again @jywarren - here is the pr for this story 1124

I didn't get specs working for this - are they required to complete the feature?

@jywarren
Copy link
Member Author

Hi, @pyluftig - just wanted to say thanks again and this is now working:

https://publiclab.org/about (click the caret next to the page title to expose the tabs)
https://publiclab.org/wiki/tag/locked (screenshot included)

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. help wanted requires help by anyone willing to contribute HTML Ruby
Projects
None yet
Development

No branches or pull requests

5 participants